Math and Equations

Advanced Mathematics in LaTeX: Operators, Theorems and Proofs

Advanced math in LaTeX: amsmath essentials, operators with subscripts, theorems and named proofs, and links to guides on symbols, matrices and equations.

On this page
  1. Load the packages first
  2. Operators with subscripts
  3. Fractions, roots and brackets
  4. Matrices and determinants
  5. Multi-line derivations and labels
  6. Theorems, lemmas and proofs
  7. Sets, physics and Greek letters
  8. Where to go next

Load the packages first

Most math-heavy documents start with amsmath, which provides display environments, matrices, \text{} and most of the commands in this guide. Add amssymb for extra symbols such as \mathbb{R}, amsthm for theorem environments, and mathtools for extensions that build on amsmath. Which math packages to use, and when covers the choice in more detail.

\documentclass{article}
\usepackage{amsmath,amssymb,amsthm}

\begin{document}
% your mathematics here
\end{document}

Operators with subscripts

Operators such as \sup, \inf, \max, \min and \lim take subscripts the same way ordinary symbols do. A supremum over a set is written with an underscore:

\[
  M = \sup_{x \in [0,1]} \lvert f(x) \rvert
\]

\lvert and \rvert come from amsmath and give the bars the right spacing.

Sometimes the subscript lands beside the operator when you want it underneath. \limits places it underneath, and \nolimits places it beside:

$\sup\limits_{x \in S} f(x)$     % subscript underneath, even inline
$\sum\nolimits_{i=1}^{n} a_i$    % subscript beside, even in display

For an operator that LaTeX does not provide, declare it once in the preamble with \DeclareMathOperator from amsmath. The starred form places the limits above and below the operator in display math:

\DeclareMathOperator*{\argmax}{arg\,max}
...
\[
  \hat{\theta} = \argmax_{\theta \in \Theta} \ell(\theta)
\]

The subscript guide explains the underscore syntax in more detail, including braces for longer subscripts.

Fractions, roots and brackets

Larger expressions often combine fractions, roots and delimiters. In the example below, \frac builds the fraction, and \left and \right make the parentheses grow with the content:

\[
  \left( \frac{a}{b} + \sqrt{c} \right)^2
\]

Each topic has its own guide:

Matrices and determinants

The pmatrix, bmatrix and vmatrix environments from amsmath cover most matrices. Each uses & to separate columns and \\ to end a row. The matrix and determinant guide lists every matrix environment and shows how to write a determinant.

Multi-line derivations and labels

The align environment lines up a derivation at a chosen symbol, usually the equals sign. Each line can carry its own equation number, or none. Aligning equations with align explains the environment and its variants.

Equations can also be labeled and cited in the text with \label and \eqref. How to label an equation covers numbering, cross-references and common mistakes.

Theorems, lemmas and proofs

The amsthm package defines theorem-style environments. Declare them in the preamble:

\usepackage{amsthm}

\theoremstyle{plain}
\newtheorem{theorem}{Theorem}
\newtheorem{lemma}[theorem]{Lemma}

\theoremstyle{definition}
\newtheorem{definition}[theorem]{Definition}

\newtheorem{lemma}[theorem]{Lemma} shares the counter with theorem, so lemmas and theorems number in one sequence. The \theoremstyle command sets the font and spacing for the environments declared after it.

\begin{theorem}
  Every bounded monotone sequence of real numbers converges.
\end{theorem}

Changing the name of a proof

The proof environment from amsthm prints “Proof.” before its text and adds an end mark automatically. There are two ways to change the heading:

  • For one proof, give the heading in square brackets: \begin{proof}[Solution]. The bracketed text replaces “Proof”.
  • For the whole document, redefine \proofname in the preamble: \renewcommand{\proofname}{Solution}.

If the global change does not take effect, check whether a language package such as babel is resetting the name. Writing Spanish documents with babel shows how babel sets the caption names for one language.

Sets, physics and Greek letters

Some notation comes up in many math documents:

Where to go next

Each topic in this cluster has a focused guide:

Keep exploring

Guides from other topics

All topics →