LaTeX Cheatsheet

Document structure, math, formatting & common commands

Language
Contents
📝

Basics

% Basic document
\documentclass{article}
\usepackage[utf8]{inputenc}

\title{My Document}
\author{Alice}
\date{\today}

\begin{document}
\maketitle

\section{Introduction}
Hello World.

\subsection{Sub-section}
\subsubsection{Sub-sub-section}

\end{document}

% Document classes
\documentclass{article}    % short docs
\documentclass{report}     % longer docs
\documentclass{book}       % books
\documentclass{beamer}     % presentations

Math

% Inline math
$E = mc^2$
$x_{i} + y^{2}$

% Display math
\[ \sum_{i=1}^{n} x_i = x_1 + x_2 + \cdots + x_n \]

% Equation (numbered)
\begin{equation}
  f(x) = ax^2 + bx + c
\end{equation}

% Fractions
$\frac{a}{b}$    $\dfrac{a}{b}$

% Roots
$\sqrt{x}$    $\sqrt[3]{x}$

% Greek letters
$\alpha \beta \gamma \delta \epsilon$
$\pi \sigma \theta \lambda \omega$

% Operators
$\int_{0}^{\infty}$   $\prod$   $\sum$
$\lim_{x \to \infty}$  $\partial$
✏️

Formatting

% Text styles
\textbf{bold}
\textit{italic}
\underline{underline}
\texttt{monospace}
\textsc{Small Caps}
\emph{emphasis}

% Font sizes
{\tiny text}  {\small text}  {\normalsize text}
{\large text}  {\Large text}  {\LARGE text}
{\huge text}   {\Huge text}

% Alignment
\begin{center} centered \end{center}
\begin{flushleft} left \end{flushleft}
\begin{flushright} right \end{flushright}

% Spacing
\\                % line break
\newpage          % page break
\vspace{1cm}      % vertical space
\hspace{1cm}      % horizontal space
📋

Lists & Tables

% Itemized (bullets)
\begin{itemize}
  \item First
  \item Second
  \item Third
\end{itemize}

% Enumerated (numbered)
\begin{enumerate}
  \item First
  \item Second
\end{enumerate}

% Table
\begin{tabular}{|l|c|r|}
  \hline
  Left & Center & Right \\
  \hline
  A & B & C \\
  D & E & F \\
  \hline
\end{tabular}

% l=left  c=center  r=right  |=border
🖼️

Figures

% Include image
\usepackage{graphicx}

\begin{figure}[h]
  \centering
  \includegraphics[width=0.8\textwidth]{image.png}
  \caption{My figure caption}
  \label{fig:myfig}
\end{figure}

% Reference: See Figure~\ref{fig:myfig}

% Placement options: h=here t=top b=bottom p=page
📚

References

% Labels and cross-references
\label{sec:intro}
\ref{sec:intro}           % section number
\pageref{sec:intro}       % page number

% Bibliography
\begin{thebibliography}{9}
  \bibitem{knuth} Knuth, D. \textit{The Art}.
\end{thebibliography}

\cite{knuth}              % citation [1]

% BibTeX (separate .bib file)
\bibliographystyle{plain}
\bibliography{refs}
🔣

Symbols

% Arrows
$\rightarrow$  $\leftarrow$  $\Rightarrow$
$\leftrightarrow$  $\uparrow$  $\downarrow$

% Relations
$\leq$  $\geq$  $\neq$  $\approx$
$\equiv$  $\sim$  $\subset$  $\in$

% Operators
$\times$  $\div$  $\pm$  $\cdot$
$\cap$  $\cup$  $\wedge$  $\vee$

% Misc
$\infty$  $\forall$  $\exists$  $\nabla$
$\emptyset$  $\neg$  $\ldots$  $\cdots$