LaTeX quick reference
The commands people look up most, as you type them. The Insert and Format menus write many of these for you.
How to…
Figures
- Two figures side by side in LaTeXPut two or three images side by side in LaTeX with subcaption (each with its own (a), (b) subcaption) or with minipage (each its own Figure number).
- Subfigures (a), (b), (c) in LaTeX and how to reference themNumber panels (a), (b), (c) inside one figure with subcaption, refer to them as Figure 1a or just (a), and change the label style.
- Place a figure exactly here in LaTeX (stop it floating)Keep a LaTeX figure where you wrote it: [htbp] options, [H] from the float package, \FloatBarrier from placeins, and \clearpage to flush waiting figures.
- Wrap text around a figure in LaTeX (wrapfig)Put a figure beside the text with the text flowing around it, using the wrapfig package's wrapfigure environment, and avoid its usual problems.
Tables
- Merge cells in a LaTeX table: multirow and multicolumnMerge table cells across columns with \multicolumn and across rows with \multirow (multirow package), with booktabs rules and \cline/\cmidrule.
- A table across several pages in LaTeX (longtable)Break a long LaTeX table across pages with longtable, repeating the header on each page and adding a "continued" note, with booktabs rules.
- A landscape table or page in LaTeXTurn a wide table sideways: pdflscape's landscape environment rotates whole pages (upright on screen); rotating's sidewaystable rotates a float.
- Make a LaTeX table fit the page widthFit a too-wide LaTeX table: tabularx X columns, p{} columns that wrap, a smaller font, less column spacing, and why \resizebox is a last resort.
- Table notes and footnotes in a LaTeX table (threeparttable)Add notes under a LaTeX table with markers in the cells, using threeparttable's \tnote and tablenotes, and why \footnote inside a table goes missing.
- Professional-looking tables in LaTeX with booktabsMake LaTeX tables look typeset: booktabs rules (\toprule, \midrule, \bottomrule, \cmidrule), no vertical lines, and aligned numbers.
Equations
- Aligning equations in LaTeX: align, aligned and splitAlign multi-line equations at = with amsmath: align for numbered lines, aligned and split for one number, \notag to number only some lines.
- Referencing equations, figures and tables in LaTeXPut \label after \caption or inside the equation, refer with \ref, \eqref or cleveref's \cref, and compile twice so the numbers appear.
- Writing an algorithm in pseudocode in LaTeXTypeset pseudocode with the algorithm float and algpseudocode: \State, \If, \For, \While, \Function, line numbers, captions and references.
References and citations
- BibTeX or biblatex: which to use, and how to set up eachBibTeX uses a journal's .bst style and \bibliography; biblatex uses biber, \addbibresource and \printbibliography. When to choose each.
- Author-year citations in LaTeX with natbib: \citep and \citetCite author-year with natbib: \citet for Smith (2020), \citep for (Smith, 2020), page notes, et al., brackets, and author-year bibliography styles.
Review and submission
- Adding line numbers to a LaTeX manuscript for peer reviewNumber the lines of a manuscript with the lineno package: \linenumbers, every fifth line, both columns, around equations, and journal review options.
- Double spacing a LaTeX manuscript for submissionDouble-space a LaTeX document with the setspace package (\doublespacing, \setstretch), or a journal class's review option.
- Show changes between two versions of a LaTeX paperMark a revision's changes for reviewers: latexdiff compares old and new .tex files; the changes package marks additions and deletions by hand.
Document layout
- Adding appendices in LaTeXStart appendices with \appendix so sections become A, B, C, or use the appendix package for "Appendix A" headings and contents entries.
- Adding authors, affiliations and ORCID iDs in LaTeXNumbered affiliations with authblk, ORCID iD links with orcidlink, and the author macros of elsarticle, IEEEtran, revtex and acmart.
Document structure
| You type | You get |
|---|---|
\documentclass[11pt]{article} | The class: article, report, book, beamer, or a journal's own |
\usepackage{amsmath} | Load a package (in the preamble, before \begin{document}) |
\title{…} \author{…} \date{…} \maketitle | The title block |
\begin{abstract} … \end{abstract} | The abstract |
\chapter{…} \section{…} \subsection{…} \subsubsection{…} \paragraph{…} | Headings; \section*{…} is unnumbered |
\tableofcontents | The table of contents (compile twice) |
\input{file} · \include{chapter} | Bring in another .tex file; \include starts a new page |
\appendix | What follows is lettered A, B, … |
\newpage · \clearpage | A new page; \clearpage also places waiting figures |
Text
| You type | You get |
|---|---|
\textbf{…} · \emph{…} · \textit{…} | Bold · emphasis · italic |
\underline{…} · \texttt{…} · \textsc{…} | Underline · monospace · small capitals |
{\small …} · {\large …} · {\Large …} | Size: \tiny \footnotesize \small \normalsize \large \Large \LARGE \huge |
\footnote{…} | A footnote |
\href{https://…}{text} · \url{…} | A link (needs hyperref) |
`` … '' · ` … ' | Opening and closing double · single quotes |
-- · --- | En dash (pages 1--9) · em dash |
~ | A space that never breaks (Fig.~\ref{f}) |
\\ · \par | New line · new paragraph (or an empty line) |
\% \$ \& \# \_ \{ \} | The special characters themselves |
\textbackslash · \textasciitilde | \ and ~ |
Lists
| You type | You get |
|---|---|
\begin{itemize} \item … \end{itemize} | Bullets |
\begin{enumerate} \item … \end{enumerate} | Numbers |
\begin{description} \item[Term] … \end{description} | Terms and definitions |
Maths
| You type | You get |
|---|---|
$ … $ | Maths in the line of text |
\[ … \] | Displayed maths, unnumbered |
\begin{equation} … \label{eq:x} \end{equation} | Numbered equation; cite it with \eqref{eq:x} |
\begin{align} a &= b \\ c &= d \end{align} | Aligned equations (amsmath); align* is unnumbered |
x^{2} · x_{i} · x_{i}^{2} | Superscript · subscript · both |
\frac{a}{b} · \sqrt{x} · \sqrt[n]{x} | Fraction · square root · n-th root |
\sum_{i=1}^{n} · \prod · \int_{a}^{b} · \lim_{x \to 0} | Sum · product · integral · limit |
\left( … \right) | Brackets that grow with their contents |
\mathbf{x} · \mathrm{d} · \mathcal{L} · \mathbb{R} | Bold · upright · calligraphic · blackboard (amssymb) |
\hat{x} · \bar{x} · \tilde{x} · \vec{x} · \dot{x} | Accents |
\begin{pmatrix} a & b \\ c & d \end{pmatrix} | A matrix in round brackets (bmatrix: square) |
\text{…} | Ordinary text inside maths (amsmath) |
Symbols
Inside maths. Insert → Symbol inserts them for you.
| You type | You get |
|---|---|
\alpha \beta \gamma \delta \epsilon \theta \lambda \mu \pi \sigma \phi \omega | Greek letters; capitals: \Gamma \Delta \Theta \Lambda \Sigma \Phi \Omega |
\leq \geq \neq \approx \sim \equiv \propto | ≤ ≥ ≠ ≈ ∼ ≡ ∝ |
\times \cdot \pm \div \circ | × · ± ÷ ∘ |
\in \notin \subset \subseteq \cup \cap \emptyset | ∈ ∉ ⊂ ⊆ ∪ ∩ ∅ |
\forall \exists \neg \land \lor | ∀ ∃ ¬ ∧ ∨ |
\rightarrow \Rightarrow \leftrightarrow \mapsto | → ⇒ ↔ ↦ |
\infty \partial \nabla \ldots \cdots | ∞ ∂ ∇ … ⋯ |
Figures and tables
| You type | You get |
|---|---|
\usepackage{graphicx} | Needed for \includegraphics |
\begin{figure}[t] \centering \includegraphics[width=\columnwidth]{figures/f.pdf} \caption{…} \label{fig:f} \end{figure} | A figure; [t] top, [b] bottom, [h] here, [p] own page |
\begin{table}[t] \caption{…} \begin{tabular}{lcr} a & b & c \\ \hline \end{tabular} \end{table} | A table: l, c, r align columns; & separates cells; \\ ends a row |
\toprule \midrule \bottomrule | Better table rules (booktabs) |
\multicolumn{2}{c}{…} | A cell across two columns |
References and citations
| You type | You get |
|---|---|
\label{sec:intro} · \ref{sec:intro} · \pageref{…} | Name a place · refer to its number · its page |
\eqref{eq:x} · \cref{…} | An equation number in brackets · a reference with its word (cleveref) |
\cite{key} · \cite{a,b} | Cite one or several works |
\citep{key} · \citet{key} | (Author, year) · Author (year) — natbib |
\parencite{key} · \textcite{key} | The same with biblatex |
\bibliographystyle{plain} \bibliography{refs} | A BibTeX bibliography from refs.bib |
\addbibresource{refs.bib} … \printbibliography | A biblatex bibliography (compiled with biber) |
\nocite{*} | List every entry of the .bib, cited or not |
Spacing and layout
| You type | You get |
|---|---|
\vspace{1em} · \hspace{1em} | Vertical · horizontal space |
\noindent | No indent for this paragraph |
\centering · \begin{center} … \end{center} | Centre text or a figure |
\usepackage[margin=2.5cm]{geometry} | Page margins |
\linewidth · \columnwidth · \textwidth | Widths to size figures by |