LaTeX Typeset documents

Version 2026-06-01 · source

Start here

\documentclass{article}
Pick the document type
\begin{document} ... \end{document}
Body goes between these
\section{<title>}
Start a section
\textbf{<text>}
Bold text
$<formula>$
Inline math
\begin{itemize}
Bullet list
\label{<key>} \ref{<key>}
Cross-reference
latexmk -pdf <file>.tex
Build the PDF

Concepts

  1. .tex source your text
  2. .aux .toc .bbl refs, contents, citations
  3. PDF final output

Document structure

\documentclass[11pt,a4paper]{article}
Class and options
\usepackage{<pkg>}
Load a package (preamble)
\title{<t>} \author{<a>} \date{\today}
Title block data
\maketitle
Print the title block
\section{<t>}
Numbered section
\subsection{<t>}
Subsection
\section*{<t>}
Unnumbered section
\tableofcontents
Insert table of contents
\input{<file>}
Include another file inline
\usepackage[margin=2.5cm]{geometry}
Set page margins
\usepackage{hyperref}
Clickable links; load last
\usepackage[<l>]{babel}
Language, hyphenation
\newcommand{\<n>}{<def>}
Define your own macro

Text

\textbf{<text>}
Bold
\textit{<text>}
Italic
\emph{<text>}
Emphasis
\texttt{<text>}
Monospace
\footnote{<text>}
Footnote
\\
Line break
\newpage
Page break
\begin{center} ... \end{center}
Centre content
\url{<url>} \href{<url>}{<text>}
Links (hyperref)
\includegraphics[width=\linewidth]{<img>}
Insert image (graphicx)

Lists

\begin{itemize} \item <a> \end{itemize}
Bullet list
\begin{enumerate} \item <a> \end{enumerate}
Numbered list
\begin{description} \item[<term>] <a> \end{description}
Term list

Math

$ a^2 + b^2 $
Inline math
\[ <formula> \]
Display math, unnumbered
\begin{equation} ... \end{equation}
Numbered equation
\begin{align} a &= b \\ &= c \end{align}
Aligned multi-line (amsmath)
x^{2} x_{i}
Superscript, subscript
\frac{<a>}{<b>}
Fraction
\sum_{i=1}^{n} \int_a^b \prod
Sum, integral, product
\alpha \beta \pi \Delta
Greek letters
\left( ... \right)
Auto-sized delimiters
\text{<words>}
Text inside math
\begin{pmatrix} a & b \\ c & d \end{pmatrix}
Matrix
\usepackage{amsmath}
Needed for align and friends

Tables

\begin{tabular}{lcr}
Columns: left, centre, right
a & b & c \\
Cells split by &, row ends \\
\hline
Horizontal rule
p{4cm}
Fixed-width wrapping column
\multicolumn{2}{c}{<t>}
Span columns
\usepackage{booktabs}
Professional rules
\begin{table}[htbp] ... \end{table}
Floating table with caption

Figures and references

\begin{figure}[htbp] ... \end{figure}
Floating figure
\caption{<text>}
Caption inside float
\label{<key>}
Name a place (after \caption)
\ref{<key>}
Number of labelled item
\autoref{<key>}
Ref with type word (hyperref)
\centering
Centre inside a float

Bibliography

\cite{<key>}
Cite an entry
\bibliography{<file>}
BibTeX database (no .bib)
\bibliographystyle{plain}
BibTeX style
\usepackage[backend=biber]{biblatex}
Modern bibliography
\addbibresource{<file>.bib}
biblatex database
\printbibliography
biblatex output spot
@article{<key>, title={...}, author={...}}
Entry in .bib file

Build

latexmk -pdf <file>.tex
Build, rerun as needed
latexmk -pdf -pvc <file>.tex
Rebuild when files change
latexmk -c
Remove aux files, keep PDF
pdflatex <file>.tex
Single pass to PDF
xelatex <file>.tex
Unicode and system fonts
lualatex <file>.tex
Unicode, Lua scripting
latexmk -pdfxe <file>.tex
Build with XeLaTeX
texdoc <package>
Open a package manual

Recipes

Minimal article
\documentclass{article}\usepackage[margin=2.5cm]{geometry}\begin{document}Hello, $E = mc^2$.\end{document}
Figure with caption and ref
\begin{figure}[htbp]  \centering  \includegraphics[width=.8\linewidth]{plot.pdf}  \caption{Results}  \label{fig:res}\end{figure}See Figure~\ref{fig:res}.
Cited article, biblatex
\usepackage[backend=biber]{biblatex}\addbibresource{refs.bib}...As shown by \textcite{knuth84}.\printbibliography