Math and Equations

What packages can I use for mathematics in LaTeX?

The main LaTeX packages for mathematics: amsmath as the base, plus amssymb, amsthm, mathtools, bm, physics and siunitx, and when to use each one.

On this page
  1. amsmath: the starting point
  2. amssymb: extra symbols
  3. amsthm: theorems and proofs
  4. mathtools: extensions to amsmath
  5. bm: bold math
  6. physics: notation for physics
  7. siunitx: units and numbers
  8. unicode-math: for XeLaTeX and LuaLaTeX
  9. Fractions and chemistry
  10. Load order and checking the docs
  11. Quick reference

Start with amsmath. It is the standard package for mathematics in LaTeX, and most math documents load it. Add amssymb for extra symbols and amsthm for theorems when you need them. Load mathtools, bm, physics or siunitx only for the tasks they cover.

amsmath: the starting point

amsmath comes from the American Mathematical Society. It provides the core math environments and commands: align, cases, the matrix environments, \text{}, \dfrac and \tfrac, \eqref, \cfrac, \lvert and \rvert, and \DeclareMathOperator.

\usepackage{amsmath}

amssymb: extra symbols

amssymb adds symbols that base LaTeX does not provide. Two examples are blackboard bold letters such as \mathbb{R}, and the variant empty set \varnothing. Set, number and currency symbols lists the commands most likely to be needed.

amsthm: theorems and proofs

amsthm provides the theorem, lemma, definition and proof environments, along with \theoremstyle to set how they look. The advanced mathematics guide shows how to declare them and how to change the name of a proof.

mathtools: extensions to amsmath

mathtools loads amsmath itself and adds commands on top of it. Useful ones include dcases and rcases for piecewise functions, \coloneqq for the colon-equals symbol, and \DeclarePairedDelimiter for defining your own delimiters. Piecewise functions with cases shows dcases in use.

bm: bold math

bm provides \bm and \boldsymbol for bold math symbols. \mathbf does not usually embolden Greek letters in the default setup, so use bm for them. How to write the rho symbol shows an example.

physics: notation for physics

physics provides bra-ket commands such as \ket and \braket, plus shortcuts for derivatives such as \dv and \pdv. Bra-ket and physics notation covers the bra-ket commands in detail.

siunitx: units and numbers

siunitx formats units and numbers consistently. \SI{9.81}{\meter\per\second\squared} prints a value with its unit, and \num{12345.678} formats a number. Using the package keeps the style of units the same across a document.

unicode-math: for XeLaTeX and LuaLaTeX

unicode-math sets the math font for XeLaTeX and LuaLaTeX, which both support Unicode fonts. It does not work with pdfLaTeX, so check which engine your document uses before loading it.

Fractions and chemistry

Two packages sit alongside the math tools. xfrac provides \sfrac for slanted fractions in running text, and nicefrac provides \nicefrac. Fractions with frac and dfrac shows them in context.

mhchem formats chemical formulas, so \ce{H2O} prints water with the subscript in place. How to use subscript in LaTeX explains the subscript side of this.

Load order and checking the docs

  • Load packages in the preamble with \usepackage{...}. If a package is not installed yet, installing LaTeX packages covers Windows, Ubuntu and manual installs.
  • mathtools loads amsmath itself. Listing both is harmless and makes the dependency clear.
  • hyperref is usually loaded near the end of the preamble.
  • In a terminal, texdoc amsmath opens the documentation for a package. Replace amsmath with the package you need.
  • If something breaks after you add a package, comment out the newest one first. Packages occasionally conflict.

Quick reference

Package Use it for Example
amsmath Align, cases, matrices, text in math \begin{align}
amssymb Blackboard bold, extra symbols \mathbb{R}
amsthm Theorems and proofs \newtheorem
mathtools Extensions to amsmath \coloneqq
bm Bold math symbols \boldsymbol{\rho}
physics Bra-ket and derivative notation \ket{\psi}
siunitx Units and numbers \SI{9.81}{\meter\per\second\squared}
unicode-math Math fonts for XeLaTeX and LuaLaTeX \setmathfont

For the operators, theorems and proofs that build on these packages, see the advanced mathematics guide.

The complete guide to math and equations

Advanced Mathematics in LaTeX: Operators, Theorems and Proofs
Read the guide

Keep exploring

Guides from other topics

All topics →