LaTeX

General

LyX sources

Other LaTeX editors

Instal·lació / Installation

  • Mageia
    • sudo dnf install latex texlive-dist

Ús / Usage

  • Create div
    • latex toto.tex
  • Create pdf
    • pdflatex toto.tex
  • when prompting an error:
    • ? \help
      Type <return> to proceed, S to scroll future error messages,
      R to run without stopping, Q to run quietly,
      I to insert something, E to edit your file,
      1 or ... or 9 to ignore the next 1 to 9 tokens of input,
      H for help, X to quit.
  • Standalone

Trucs / Tips

  • Document
    • \documentclass[a4paper,10pt]{article}
    • \documentclass[9pt,oneside]{article}
  • Codificació de fitxers de text / Text file coding
    • UTF-8
      • \usepackage[utf8]{inputenc}
    • Latin-1
      • \usepackage[latin1]{inputenc}
  • Sense numeració de pàgina:
    • \pagestyle{empty}
  • Llengua / Language (servirà, entre altres coses, perquè posi «Figura» i no «Figure» al peu de les figures)
    • \usepackage[catalan]{babel}
  • Marges / Margins
    • \addtolength{\textwidth}{3cm}
      \addtolength{\hoffset}{-2.5cm}
      \addtolength{\voffset}{-3cm}
      \addtolength{\textheight}{4cm}
  • Euro
    • \usepackage{eurosym}

      10\euro
  • Errors:
    • Missing $ inserted
      • pot provenir dels accents. Comproveu la codificació del fitxer i que hi hagi només un \usepackage[xxx]{inputenc}.
  • Gràfics / Graphics
  • Circuits
    • CircuiTikz (based on TikZ)
      • CircuiTikz package (overleaf)
      • CircuTikZ manual (pdf)
      • Exemples / Examples
        • Circuit with resistors & Kirchhoff’s laws

        • \documentclass{standalone}
          \usepackage[
          options]{circuitikz}
          \begin{document}
          ...
          \end{document}
          • options:
            • european
            • siunitx
            • ...
          ...

          \begin{tikzpicture}[same_options_as_in_usepackage]
          ...
          \end{tikzpicture}


          \begin{circuitikz}[same_options_as_in_usepackage]
          ...
          \end{circuitikz}

          path-style component \draw (0,0) to[component_name=optional_component_label, options] (2,0);
          • options:
            • invert
            • labels, voltages, annotations, flows and currents
              • label: l=$R_1$ (by default: above)
              • voltage: v=$v_1$
              • current: i=$i_1$
              • annotation: a=1<\kilo\ohm> (by default: below)
              • flow: f=... ()
              • two lines: l2=line1 and line2 ()
              • modifiers:
                • ^ (above)
                • _ (below)
              • current and flow modifiers:
                • < ()
                • > ()
              • units (requires option siunitx)
                • a=$\SI{1}{\kilo\ohm}$
                • a=1<\kilo\ohm>
          • paths
            • to[short]
              • to[short, -*]
            • to[open]
          • batteries
            • to[battery]
            • to[battery1]
            • to[battery2]
          • resistor
            • to[R]
          • capacitor
            • to[capacitor]
          • inductor
            • to[L]
          • diode
            • to[empty diode]
            • to[full diode]
          • ...
          node-style component \draw (0,0) node[component_name,optional_options] (anchor) {text};
          • node[ground]
          • ...
    • ...
  • Química / Chemistry
  • Matemàtiques
    • Mathematical expressions
      • The Comprehensive LATEX Symbol List (pdf)
      • Símbols
      • Operators
      • Brackets and parenthesis
        • Brackets and Parentheses



        • to be used around:
          • \begin{array}...\end{array}
          they have to be in pairs (but can be mixed)
          empty
          a + b a + b \left. a + b \right. \left. a + b \right.
          parentheses ( a + b ) ( a + b ) \left( a + b \right) \left( a + b \right)
          brackets; square brackets [ a + b ] [ a + b ] \left[ a + b \right] \left[ a + b \right]
          braces; curly brackets \{ a + b \} \{ a + b \} \left\{ a + b \right\} \left\{ a + b \right\}
          angle brackets

          \langle a + b \rangle \langle a + b \rangle
          pipes; vertical bars | a + b | | a + b | \left| a + b \right| \left| a + b \right|
          double pipes; double vertical bars \| a + b \| \| a + b \| \left\| a + b \right\| \left\| a + b \right\|
      • Arrays



        • examples combined with brackets/parenthesis
          array (centred) \begin{array}{c}
          a + b + c = d \\
          e = f + g
          \end{array}
          \begin{array}{c} a + b + c = d \\ e = f + g \end{array} \left(
          \begin{array}{c}
          a + b + c = d \\
          e = f + g
          \end{array}
          \right\}
          \left( \begin{array}{c} a + b + c = d \\ e = f + g \end{array} \right\}
          array (left) \begin{array}{l}
          a + b + c = d \\
          e = f + g
          \end{array}
          \begin{array}{l} a + b + c = d \\ e = f + g \end{array}

          array (right) \begin{array}{r}
          a + b + c = d \\
          e = f + g
          \end{array}
          \begin{array}{r} a + b + c = d \\ e = f + g \end{array} \left.
          \begin{array}{r}
          a + b + c = d \\
          e = f + g
          \end{array}
          \right\}
          \left. \begin{array}{r} a + b + c = d \\ e = f + g \end{array} \right\}
          aligned
          (& is the reference)
          \begin{aligned}
          a + b + c &= d \\
          e &= f + g
          \end{aligned}
          \begin{aligned} a + b + c &= d \\ e &= f + g\end{aligned} \left[
          \begin{aligned}
          a + b + c &= d \\
          e &= f + g
          \end{aligned}
          \right]
          \left[ \begin{aligned} a + b + c &= d \\ e &= f + g\end{aligned} \right]
          aligned
          (& is the reference)
          \begin{aligned}
          a &+ b + c = d \\
          e = f &+ g
          \end{aligned}
          \begin{aligned} a &+ b + c = d \\ e = f &+ g\end{aligned}

          cases \begin{cases}
          a + b + c =d \\
          e = f + g
          \end{cases}
          \begin{cases} a + b + c =d \\ e = f + g \end{cases}

      • Matrius / Matrices
        • How to write matrices in Latex ? matrix, pmatrix, bmatrix, vmatrix, Vmatrix
        • ...



        • parenthesis \begin{pmatrix} a & b \\ c & d \end{pmatrix} \begin{pmatrix} a & b \\ c & d \end{pmatrix}
          brackets \begin{bmatrix} a & b \\ c & d \end{bmatrix} \begin{bmatrix} a & b \\ c & d \end{bmatrix}
          Braces \begin{Bmatrix} a & b \\ c & d \end{Bmatrix} \begin{Bmatrix} a & b \\ c & d \end{Bmatrix}
          verts \begin{vmatrix} a & b \\ c & d \end{vmatrix} \begin{vmatrix} a & b \\ c & d \end{vmatrix}
          double Verts \begin{Vmatrix} a & b \\ c & d \end{Vmatrix} \begin{Vmatrix} a & b \\ c & d \end{Vmatrix}
      • Integrals, sums and limits
      • Fractions and Binomials
      • Subscripts and superscripts
      • Spacing

        mu (math unit) = 1/18 em
        \! -3

        1
        \, 3
        \: 4
        \; 5
        \ (space) space in normal text
        \quad 18 (current font size)
        \qquad 36
      • Transformades / Transforms


        • rendered
          Laplace \mathcal{L}\{f\} \mathcal{L}\{f\}
          Fourier \mathcal{L}\{f\} \mathcal{F}\{f\}
          Z-transform \mathcal{Z}\{f\} \mathcal{Z}\{f\}

      • rendered (MathML/TexZilla/x-tex)
        a^2+b^2=c^2 a^2+b^2=c^2
        \sqrt{x^5}
        \sqrt{x^5}
        \frac{a}{b}
        \frac{a}{b}
        \sin x \sin x
        \vec{a} \vec{a}
        \hat(A) \hat{A}
        \int_{0}^{+\infty} x^{t-1} e^{-x} dx \int_{0}^{+\infty} x^{t-1} e^{-x} dx
        \iint_D {dx dy} \iint_D {dx dy}
        A \in B A \in B
        \sum_{n=1}^{+\infty} \sum_{n=1}^{+\infty}
        \prod_{n=1}^\infty \prod_{n=1}^\infty
        \lim_{n \to \infty} \lim_{n \to \infty}
        x = \frac{-b\pm\sqrt{b^2-4ac}}{2a} x = \frac{-b\pm\sqrt{b^2-4ac}}{2a}
        e^{i\pi}+1=0 e^{i\pi}+1=0
        \multiscripts{_2}{F}{_3} \multiscripts{_2}{F}{_3}
        \binom{n}{k/2} \binom{n}{k/2}
        a_{i j} a_{i j}
        \frac{\partial^2}{\partial x^2} \frac{\partial^2}{\partial x^2}
        f(x) = \begin{cases}
        1/3 & \text{if} \quad 0 \leq x \leq 1; \\
        2/3 & \text{if} \quad 3 \leq x \leq 4; \\
        0 & \text{elsewhere}.
        \end{cases}
        f(x) = \begin{cases} 1/3 & \text{if} \quad 0 \leq x \leq 1; \\ 2/3 & \text{if} \quad 3 \leq x \leq 4; \\ 0 & \text{elsewhere}. \end{cases}
        \overset{k \, \text{times}}
        {\overbrace{x+\dots+x}}
        \overset{k \, \text{times}}{\overbrace{x+\dots+x}}
        \begin{pmatrix}
        a & b \\
        c & d
        \end{pmatrix}
        \begin{pmatrix} a & b \\ c & d \end{pmatrix}
        \begin{pmatrix}
        \begin{pmatrix} a & b \\ c & d \end{pmatrix} &
        \begin{pmatrix} e & f \\ g & h \end{pmatrix} \\
        0 &
        \begin{pmatrix} i & j \\ k & l \end{pmatrix}
        \end{pmatrix}
        \begin{pmatrix} \begin{pmatrix} a & b \\ c & d \end{pmatrix} & \begin{pmatrix} e & f \\ g & h \end{pmatrix} \\ 0 & \begin{pmatrix} i & j \\ k & l \end{pmatrix} \end{pmatrix}
        \begin{vmatrix}
        c_0 & c_1\\
        c_2 & c_3\\
        \end{vmatrix}
        \begin{vmatrix} c_0 & c_1\\ c_2 & c_3\\ \end{vmatrix}
        \det
        \begin{vmatrix}
        c_0 & c_1 & c_2 & \dots & c_n \\
        c_1 & c_2 & c_3 & \dots & c_{n+1} \\
        c_2 & c_3 & c_4 & \dots & c_{n+2} \\
        \vdots & \vdots & \vdots & & \vdots \\
        c_n & c_{n+1} & c_{n+2} & \dots & c_{2n}
        \end{vmatrix} > 0
        \det \begin{vmatrix} c_0 & c_1 & c_2 & \dots & c_n \\ c_1 & c_2 & c_3 & \dots & c_{n+1} \\ c_2 & c_3 & c_4 & \dots & c_{n+2} \\ \vdots & \vdots & \vdots & & \vdots \\ c_n & c_{n+1} & c_{n+2} & \dots & c_{2n} \end{vmatrix} > 0
        \mathbf{V}_1 \times \mathbf{V}_2 \mathbf{V}_1 \times \mathbf{V}_2
        {n \choose k} {n \choose k}
    • Equacions amb numeració:
      • \begin{equation}
        ...
        \end{equation}
    • Sense numeració (dins del text):
      • $x=y$
    • Sense numeració (amsmath):
      • \usepackage{amsmath}

        \begin{equation*}
        ...
        \end{equation*}
      • \begin{eqnarray*}
        x=y \\
        y=z
        \end{eqnarray*}
    • Dins de "equation" no hi pot haver cap línia en blanc. Si hi és, donarà un error de tipus: "Underfull \hbox (badness 10000) in paragraph"
    • Diverses equacions / Several equations:
      • \usepackage{amsmath}
        \begin{eqnarray*}
          x = 3 \\
          y = x/2 = 1,5
        \end{eqnarray*}
      • Alineades / Aligned (*)
        • \usepackage{amsmath}
          \begin{align*}
            x &= 3 \\
            y &= x/2 = 1,5
          \end{align*}
      • Centrades / Centred
        • \usepackage{amsmath}
          \begin{gather*}
            x = 3 \\
            y = x/2 = 1,5
          \end{align*}
    • Funció definida per parts:
      • ...
    • Funció definida per parts (amsmath)
      • \usepackage{amsmath}
        \begin{equation*}
          |x| =
          \begin{cases}
          -x & \text{if } x < 0,\\
          0 & \text{if } x = 0,\\
          x & \text{if } x > 0.
          \end{cases}
        \end{equation*}
    • Claus només al final:
      • \left.
        \begin{array}{r}
          z=x^2+y^2 \\
          6=x^2+y^2+z^2
        \end{array}
        \right\}
  • Figures:
    • \usepackage{graphicx} farà que els següents formats de figures siguin suportats:
      • compilació amb pdflatex: .pdf, .png, .jpg
      • compilació amb latex: .eps
    • es poden convertir amb:
      • EPS->PDF: epstopdf
      • PDF->EPS: pdftops; ps2epsi; eps2eps (pdf2ps crea un fitxer ps molt gros)
  • Capçalera / Header:
    • Creeu un fitxer odg de mides: 18,5 x 3,5 (capcalera.odg)
    • Afegiu-hi algun logotip EPS o bé un PDF
    • Exporteu-lo com a PDF: capcalera.pdf
    • Incloeu-lo al vostre tex:
      • \usepackage{graphicx}

        \begin{figure}
          \begin{center}
            \includegraphics[width=18.5cm]{capcalera.pdf}
          \end{center}
        \end{figure}
  • Capses / Boxes
    • Dins d'un text / Inside a text:
      • \framebox{contingut}
    • Paràgraf / Paragraph
      • \parbox[position]{width}{contingut}
    • Dins d'una equació / Inside an equation:
      • \begin{eqnarray*}
        x=2/4\\
        \boxed{
        x=1/2
        }
        \end{eqnarray*}

BibTeX

LaTeX binaries

LaTeX styles

LaTeX utilities

Darrera modificació: 4 de juny de 2022 / Last update: 4th June 2022

Cap a casa / Back home.