LaTeX Cheat Sheet

The LaTeX you look up most often, on one page: document structure, text formatting, maths, tables, figures and citations, each with its rendered result.

Download PDF (2 pages)

Document structure

  • \documentclass{article}
    \usepackage{amsmath}
    
    \begin{document}
    Hello, world!
    \end{document}

    The smallest complete document. The preamble (before \begin{document}) loads packages.

  • \title{My paper}
    \author{Ada Lovelace}
    \maketitle

    Title block; \maketitle goes after \begin{document}

  • \section{Introduction}

    Numbered section (also \subsection, \subsubsection)

  • \section*{Acknowledgements}

    Starred: no number, not in the contents

  • \tableofcontents

    Table of contents (compile twice)

  • % a comment

    Everything after % on a line is ignored

  • \newpage

    Start a new page

Text formatting

  • \textbf{bold}
    bold
  • \textit{italic}
    italic
  • \emph{emphasis}
    emphasis

    Italic, or upright inside italics

  • \underline{underlined}
    underlined
  • \texttt{monospace}
    monospace
  • \textsc{Small Caps}
    Small Caps
  • ``quoted''
    “quoted”

    Two backticks, two apostrophes

  • pages 10--12
    pages 10–12

    En dash for ranges

  • wait---what?
    wait—what?

    Em dash

  • \% \& \$ \# \_ \{ \}
    % & $ # _ { }

    Characters that need a backslash

  • Dr.~Smith
    Dr. Smith

    ~ is a space that never breaks a line

  • \footnote{A note.}

    Numbered footnote at the bottom of the page

  • \href{https://samskrift.com}{a link}

    Clickable link (hyperref package)

Lists

  • \begin{itemize}
      \item First
      \item Second
    \end{itemize}

    Bullet points

  • \begin{enumerate}
      \item First
      \item Second
    \end{enumerate}

    Numbered list

  • \begin{description}
      \item[Term] Its meaning
    \end{description}

    Terms and definitions

Math mode

  • $E = mc^2$
    \displaystyle E = mc^2

    Inline math, inside a sentence

  • \[ a^2 + b^2 = c^2 \]
    a^2 + b^2 = c^2

    Displayed on its own line

  • \begin{equation}
      e^{i\pi} + 1 = 0
      \label{eq:euler}
    \end{equation}
    e^{i\pi} + 1 = 0 \tag{1}

    Numbered; refer to it with \eqref{eq:euler}

  • x^{2}  x_{i}  x_{i}^{2}
    \displaystyle x^{2} \quad x_{i} \quad x_{i}^{2}

    Superscripts and subscripts; braces for more than one character

  • \frac{a}{b}
    \displaystyle \frac{a}{b}

    Fraction

  • \sqrt{x}  \sqrt[3]{x}
    \displaystyle \sqrt{x} \quad \sqrt[3]{x}

    Roots

  • \pm \times \cdot \div
    \displaystyle \pm \quad \times \quad \cdot \quad \div

    Operators

  • \leq \geq \neq \approx \equiv
    \displaystyle \leq \quad \geq \quad \neq \quad \approx \quad \equiv

    Relations

  • \infty \partial \nabla \forall \exists
    \displaystyle \infty \quad \partial \quad \nabla \quad \forall \quad \exists

    Infinity, partial, nabla, for all, exists

  • \to \Rightarrow \iff \mapsto
    \displaystyle \to \quad \Rightarrow \quad \iff \quad \mapsto

    Arrows

  • \text{if } x > 0
    \displaystyle \text{if } x > 0

    Upright words inside math

  • a\,b \; c \quad d \qquad e
    \displaystyle a\,b \; c \quad d \qquad e

    Spaces: thin, medium, quad, double quad

Try formulas in the equation editor

Greek letters

  • \alpha \beta \gamma \delta \epsilon
    \displaystyle \alpha \quad \beta \quad \gamma \quad \delta \quad \epsilon
  • \zeta \eta \theta \lambda \mu
    \displaystyle \zeta \quad \eta \quad \theta \quad \lambda \quad \mu
  • \pi \rho \sigma \tau \phi
    \displaystyle \pi \quad \rho \quad \sigma \quad \tau \quad \phi
  • \chi \psi \omega \varepsilon \varphi
    \displaystyle \chi \quad \psi \quad \omega \quad \varepsilon \quad \varphi

    var- forms are the alternative shapes

  • \Gamma \Delta \Theta \Sigma \Omega
    \displaystyle \Gamma \quad \Delta \quad \Theta \quad \Sigma \quad \Omega

    Capitals: capitalise the command

Find any symbol by name or by drawing it

Sums, integrals and limits

  • \sum_{i=1}^{n} i
    \sum_{i=1}^{n} i

    Sum (bounds go above and below when displayed)

  • \prod_{k=1}^{n} k
    \prod_{k=1}^{n} k

    Product

  • \int_{0}^{1} x^2 \, dx
    \int_{0}^{1} x^2 \, dx

    Integral; \, adds the thin space before dx

  • \iint_{D} f \, dA  \oint_{C} F \cdot dr
    \iint_{D} f \, dA \qquad \oint_{C} F \cdot dr

    Double and contour integrals

  • \lim_{x \to 0} \frac{\sin x}{x}
    \lim_{x \to 0} \frac{\sin x}{x}

    Limit

  • \frac{d}{dx}  \frac{\partial f}{\partial x}
    \displaystyle \frac{d}{dx} \quad \frac{\partial f}{\partial x}

    Derivatives

Brackets

  • \left( \frac{a}{b} \right)
    \displaystyle \left( \frac{a}{b} \right)

    \left and \right grow to fit

  • \{ x \mid x > 0 \}
    \displaystyle \{ x \mid x > 0 \}

    Braces need a backslash

  • \langle x, y \rangle
    \displaystyle \langle x, y \rangle

    Angle brackets

  • |x|  \lVert v \rVert
    \displaystyle |x| \quad \lVert v \rVert

    Absolute value, norm

  • \lfloor x \rfloor  \lceil x \rceil
    \displaystyle \lfloor x \rfloor \quad \lceil x \rceil

    Floor, ceiling

Matrices and cases

  • \begin{pmatrix}
      a & b \\
      c & d
    \end{pmatrix}
    \begin{pmatrix} a & b \\ c & d \end{pmatrix}

    Parentheses (bmatrix: brackets, vmatrix: determinant)

  • |x| = \begin{cases}
      x  & x \geq 0 \\
      -x & x < 0
    \end{cases}
    |x| = \begin{cases} x & x \geq 0 \\ -x & x < 0 \end{cases}

    Piecewise definition

Aligned equations

  • \begin{align}
      f(x) &= (x + 1)^2 \\
           &= x^2 + 2x + 1
    \end{align}
    \begin{aligned} f(x) &= (x + 1)^2 && (1) \\ &= x^2 + 2x + 1 && (2) \end{aligned}

    & marks where lines line up; \\ ends a line; align* has no numbers

Fonts and accents in math

  • \mathbb{R} \mathbb{N} \mathbb{Z}
    \displaystyle \mathbb{R} \quad \mathbb{N} \quad \mathbb{Z}

    Blackboard bold (amssymb)

  • \mathbf{v} \mathcal{L} \mathrm{d}x
    \displaystyle \mathbf{v} \quad \mathcal{L} \quad \mathrm{d}x

    Bold, calligraphic, upright

  • \vec{v} \hat{x} \bar{x} \dot{x} \tilde{x}
    \displaystyle \vec{v} \quad \hat{x} \quad \bar{x} \quad \dot{x} \quad \tilde{x}

    Accents

  • \overline{AB}  \underbrace{a + b}_{n}
    \displaystyle \overline{AB} \quad \underbrace{a + b}_{n}

Tables

  • \begin{tabular}{lcr}
      \toprule
      Left & Centre & Right \\
      \midrule
      a & b & c \\
      \bottomrule
    \end{tabular}

    Columns l, c, r; & between cells; rules from booktabs

  • \begin{table}[htbp]
      \centering
      % tabular here
      \caption{Results}
      \label{tab:results}
    \end{table}

    Floating table with a caption; refer to it with \ref{tab:results}

Build tables visually in the table generator

Figures

  • \begin{figure}[htbp]
      \centering
      \includegraphics[width=0.8\linewidth]{plot.png}
      \caption{A plot}
      \label{fig:plot}
    \end{figure}

    Needs \usepackage{graphicx}; upload plot.png next to your .tex file

References and citations

  • \label{sec:intro}  \ref{sec:intro}

    Label something, then refer to its number

  • \eqref{eq:euler}  \pageref{fig:plot}

    Equation number in parentheses; page number

  • \cite{knuth1984}

    Cite an entry from your .bib file

  • \bibliographystyle{plain}
    \bibliography{refs}

    BibTeX: list cited works from refs.bib

  • @book{knuth1984,
      author    = {Donald E. Knuth},
      title     = {The TeXbook},
      publisher = {Addison-Wesley},
      year      = {1984}
    }

    An entry in refs.bib

Write the whole document here

Samskrift is a collaborative LaTeX editor in your browser: these tools are built in, the PDF compiles next to your source, and your co-authors can type in the same file.

Create a free account