LaTeX quick reference
Dense one-page card for skeleton, text, math, floats, cites, layout, engines, TikZ, Beamer, and common log errors.
Desk referencebeginnercheatsheetreference
LaTeX quick reference
Park this next to the editor. Every row is paste-ready. For longer lessons, open the matching track on Learn.
Jump:
Skeleton ·
Preamble ·
Text ·
Sections ·
Refs ·
Math ·
Tables ·
Figures ·
Cites ·
Layout ·
Engines ·
TikZ ·
Beamer ·
Theorems ·
Fields ·
Compile ·
Errors ·
Package order
Document skeleton
\documentclass[11pt,a4paper]{article} % or report, book, beamer
\usepackage[margin=1in]{geometry}
\usepackage{amsmath,amssymb,amsfonts}
\usepackage{graphicx,booktabs}
\usepackage[colorlinks=true,linkcolor=blue,citecolor=blue,urlcolor=blue]{hyperref}
% \usepackage[backend=biber,style=numeric]{biblatex}
% \addbibresource{refs.bib}
\begin{abstract} ... \end{abstract}
% \bibliographystyle{plain}\bibliography{refs} % BibTeX
% \printbibliography % biblatex
| Class |
Typical use |
article |
Papers, notes, homework |
report |
Longer reports with chapters |
book |
Books / many theses |
beamer |
Slides |
University .cls |
Thesis templates |
| File |
Role |
.tex |
Source |
.bib |
Bibliography database |
.cls / .sty |
Class / package |
.aux .log .toc |
Generated; do not edit |
Preamble patterns
\usepackage[margin=1in]{geometry}
\usepackage{setspace}\onehalfspacing
\usepackage{siunitx} % units and numbers
\usepackage{cleveref} % after hyperref
\DeclareMathOperator*{\argmax}{arg\,max}
\newcommand{\vect}[1]{\boldsymbol{#1}}
Load hyperref late. Load cleveref after hyperref.
Text and formatting
| Want |
Type |
| Bold / italic / mono |
\textbf{} \textit{} \texttt{} |
| Emphasis (nests) |
\emph{} |
| Small caps |
\textsc{} |
| Underline (rare) |
\underline{} |
| Sizes |
{\small } {\large } {\Large } {\footnotesize } |
| New paragraph |
blank line |
| Line break |
\\ or \newline |
| Non-breaking space |
~ |
| Horizontal space |
\quad \qquad \hspace{1em} |
| Vertical space |
\vspace{1em} \bigskip |
| Center / flush |
center / flushright environments |
| Quote |
quote or quotation |
| Footnote |
\footnote{...} |
| Comment |
% rest of line |
Escape specials (text mode)
| Char |
Code |
Char |
Code |
% |
\% |
$ |
\$ |
& |
\& |
# |
\# |
_ |
\_ |
{ } |
\{ \} |
~ |
\textasciitilde |
^ |
\textasciicircum |
\ |
\textbackslash |
|
|
Lists
Custom label: \item[(a)] ...
Page numbers and breaks
| Want |
Type |
| Style |
\pagestyle{plain} / empty / fancy |
| This page only |
\thispagestyle{empty} |
| Roman / arabic |
\pagenumbering{roman} then arabic |
| New page |
\newpage \clearpage |
| Soft break request |
\pagebreak[3] |
| Keep together |
\nopagebreak |
Sectioning and structure
\chapter{...} % report/book
\addcontentsline{toc}{section}{Unnumbered}
| Want |
Type |
| TOC |
\tableofcontents |
| List of figures/tables |
\listoffigures \listoftables |
| Abstract |
\begin{abstract}...\end{abstract} |
| Appendix |
\appendix then \section / \chapter |
| Multi-file |
\include{chapters/intro} or \input{...} |
| Draft one chapter |
\includeonly{chapters/methods} |
Cross-references and links
\section{Methods}\label{sec:methods}
\begin{equation}\label{eq:main} E=mc^2 \end{equation}
\caption{Pipeline}\label{fig:pipe}
See Section~\ref{sec:methods}, Eq.~\eqref{eq:main}, Figure~\ref{fig:pipe}.
% \cref{fig:pipe} \Cref{sec:methods}
\url{https://oleafly.com}
\href{https://oleafly.com}{Oleafly}
\hypersetup{pdftitle={My Paper}, pdfauthor={You}}
Put \label after \caption so the number is correct.
Math mode
| Want |
Type |
| Inline |
$...$ or \( ... \) |
| Display unnumbered |
\[ ... \] |
| Display numbered |
equation + \label |
| Multi-line aligned |
align / align* |
| Centered multi-line |
gather / gather* |
| One number, many lines |
equation + split |
| Long broken line |
multline |
| Suppress one number |
\notag or \nonumber |
| Reference |
\ref{eq:x} or \eqref{eq:x} |
a &= b + c \label{eq:a} \\
Fractions, roots, scripts
\frac{a}{b} \dfrac{a}{b} \tfrac{a}{b}
Greek (math mode)
\alpha \beta \gamma \delta \epsilon \varepsilon \zeta \eta
\theta \vartheta \iota \kappa \lambda \mu \nu \xi
\pi \varpi \rho \varrho \sigma \varsigma \tau \upsilon
\phi \varphi \chi \psi \omega
\Gamma \Delta \Theta \Lambda \Xi \Pi \Sigma \Upsilon \Phi \Psi \Omega
Operators, relations, sets, arrows
\pm \mp \cdot \times \div \ast \star \circ \bullet
\leq \geq \neq \approx \equiv \sim \simeq \propto \ll \gg
\in \notin \subset \subseteq \supset \supseteq \cup \cap \emptyset
\to \mapsto \Rightarrow \Leftrightarrow \uparrow \downarrow
\infty \partial \nabla \ell \forall \exists \neg \land \lor
Accents and alphabets
\hat{x} \bar{x} \tilde{x} \vec{x} \dot{x} \ddot{x}
\widehat{xyz} \overline{ABC}
\mathbb{N Z Q R C} \mathcal{L} \mathfrak{g}
\mathrm{d}x \mathbf{A} \boldsymbol{\beta}
Big operators and calculus
\sum_{i=1}^n \prod_{i=1}^n \int_a^b \oint \iint
\lim_{x \to 0} \max_x \min_x \inf \sup
\frac{dy}{dx} \frac{\partial f}{\partial x}
\argmax_x % after \DeclareMathOperator*{\argmax}{arg\,max}
Matrices
\begin{pmatrix} a & b \\ c & d \end{pmatrix} % ( )
\begin{bmatrix} a & b \\ c & d \end{bmatrix} % [ ]
\begin{vmatrix} a & b \\ c & d \end{vmatrix} % | |
\begin{array}{r|cc} 1 & 2 & 3 \\ \hline 4 & 5 & 6 \end{array}
Piecewise
Delimiters
\left( \frac{a}{b} \right)
\left\{ x : x > 0 \right\}
\lvert x \rvert \lVert v \rVert
Live preview: equation tool.
Tables
\caption{Results}\label{tab:res}
Baseline & 0.81 & 0.79 \\
| Want |
Type |
| Align columns |
l c r p{3cm} |
| Vertical rule (avoid) |
` |
| Span columns |
\multicolumn{2}{c}{...} |
| Span rows |
\multirow{2}{*}{...} (multirow) |
| Multi-page |
longtable |
| Visual builder |
table generator |
Design habit: three horizontal rules, no vertical lines.
\includegraphics[width=0.8\textwidth]{figures/plot.pdf}
\caption{Overview.}\label{fig:plot}
| Want |
Type |
| Width |
width=0.5\textwidth or width=\linewidth |
| Height |
height=4cm (avoid both unless you must) |
| Page of PDF |
page=2 option |
| Side by side |
two minipages at 0.48\textwidth |
| Subfigures |
subcaption package |
| Placement |
[htbp] (here, top, bottom, page) |
| Barrier |
\usepackage{placeins} + \FloatBarrier |
Citations and bibliography
BibTeX (classic)
See \cite{knuth84} and \cite{a,b}.
\bibliographystyle{plain} % abbrv, alpha, ieeetr, apalike, ...
biblatex + biber
\usepackage[backend=biber,style=numeric]{biblatex}
\addbibresource{refs.bib}
\cite{knuth84} \parencite{knuth84} \textcite{knuth84}
natbib
\citet{key} % Author (year)
\citep{key} % (Author, year)
\citep*{key} % Author, year
Minimal .bib entry
author = {Knuth, Donald E.},
title = {Literate Programming},
journal = {The Computer Journal},
Validate: BibTeX validator.
| Symptom |
Fix |
[?] or ? |
Wrong key, missing pass, or BibTeX vs Biber mismatch |
| Empty bibliography |
Path, backend, or no \cite / wrong print command |
Layout
\usepackage[a4paper,margin=1in]{geometry}
\usepackage{setspace}\onehalfspacing
\setlength{\parindent}{0pt}
\setlength{\parskip}{0.6em}
| Want |
Type |
| One-off no indent |
\noindent |
| Manual length |
\hspace{2em} \vspace{1ex} |
| Units |
pt em ex cm mm in \textwidth \linewidth |
Engines and packages
| Engine |
Good for |
| pdfLaTeX |
Max journal compatibility |
| XeLaTeX |
System fonts, many scripts (fontspec) |
| LuaLaTeX |
Modern Unicode + scripting |
| Tectonic |
Bundled / on-demand packages (Oleafly default) |
\setmainfont{Times New Roman}
Missing package (TeX Live): tlmgr install siunitx
Color
\textcolor[HTML]{2563EB}{brand}
\definecolor{brand}{HTML}{2563EB}
\colorbox{gray!12}{highlight}
TikZ (minimal)
\usetikzlibrary{positioning,arrows.meta}
\begin{tikzpicture}[node distance=1.4cm]
\node[draw,rounded corners] (a) {In};
\node[draw,rounded corners,right=of a] (b) {Out};
\draw[-Latex] (a) -- (b);
Commutative diagrams: tikz-cd. Standalone export: \documentclass[tikz]{standalone}.
Beamer (minimal)
Theorems
\newtheorem{theorem}{Theorem}[section]
\newtheorem{lemma}[theorem]{Lemma}
Field bits
\usepackage[version=4]{mhchem}
\ce{H2O} \ce{CO2 + C -> 2CO}
\braket{\psi|\phi} \braket{\psi|A|\phi}
\begin{lstlisting}[language=Python]
Compile loop
- Edit
.tex
- Run engine (pdfLaTeX / XeLaTeX / LuaLaTeX / Tectonic)
- If citations: BibTeX or Biber
- Run engine again (often twice) until
?? and TOC settle
In Oleafly, compile (or auto-compile) handles the loop; SyncTeX jumps between source and PDF.
Log errors (decode the first one)
| Symptom |
Usual cause |
| Text vanishes mid-line |
Bare % started a comment |
Missing $ inserted |
_ or ^ or math command in text |
Undefined control sequence |
Typo or missing package |
File not found |
Wrong path / extension for input or image |
References print ?? |
Need another compile pass |
Citations [?] |
Bad key, wrong backend, or missing bib pass |
| Empty bibliography |
Wrong \bibliography path or biblatex mismatch |
Overfull \hbox |
Unbreakable line (URL, long math, no hyphen) |
| Emergency stop |
Missing \end{document}, bad include, runaway brace |
| Runaway argument |
Missing } or \end{...} |
Package load order (rules of thumb)
- Class options first
- Encoding / fonts
- Geometry, setspace, language
- Math, graphics, tables
- Domain packages
hyperref near the end
cleveref after hyperref
Useful links in Oleafly Learn
Full map: /learn/.
Back to Desk reference