Technical Writing

Mathematics

Comprehensive guide to typesetting mathematical formulas, notations, equations, and structures in LaTeX.

One of the greatest motivating forces for Donald Knuth when he began developing the original TeX system was to create something that allowed simple construction of mathematical formulas, while looking professional when printed. The fact that he succeeded was most probably why TeX (and later on, LaTeX) became so popular within the scientific community. Typesetting mathematics is one of LaTeX's greatest strengths.

Mathematics Environments

LaTeX needs to know when the text is mathematical. This is because LaTeX typesets math notation differently from normal text. Therefore, special environments have been declared for this purpose. They can be distinguished into two categories:

  • Inline (text): Formulas displayed within the body of text where it is declared (e.g., a+a=2aa+a=2a within a sentence).
  • Displayed: Formulas printed on a line by themselves.

Syntax Shorthands

TypeEnvironmentLaTeX ShorthandTeX Shorthand
Inlinemath\( ... \)$ ... $
Displayeddisplaymath\[ ... \]$$ ... $$
NumberedequationN/AN/A

!WARNINGDo not use $$ ... $$ in LaTeX. It is a Plain TeX construct that breaks spacing in LaTeX and causes conflicts with AMS-LaTeX. Always use \[ ... \] for unnumbered display math, or \begin{equation}...\end{equation} for numbered equations. Using $$ can produce incorrect spacing around operators and relations.

Basic Syntax & Symbols

In math mode, variables are typeset in italic, spaces are ignored, and every character is treated as a mathematical token.

Fractions and Integrals

  • Fractions: \frac{numerator}{denominator} produces ab\frac{a}{b}.
  • Powers & Indices: Use ^ for exponents and _ for subscripts (e.g., x_i^2 produces xi2x_i^2).
  • Integrals & Sums: Use \int and \sum with limits (e.g., \sum_{i=1}^n produces i=1n\sum_{i=1}^n).

Greek Letters

Greek letters are typed by prefixing the letter name with a backslash:

  • Lowercase: \alpha (α\alpha), \beta (β\beta), \gamma (γ\gamma), \theta (θ\theta), \lambda (λ\lambda)
  • Uppercase: \Gamma (Γ\Gamma), \Delta (Δ\Delta), \Theta (Θ\Theta), \Lambda (Λ\Lambda)

Delimiters and Brackets

Use \left and \right to auto-size delimiters:

\left( \frac{a}{b} \right)
\left[ \sum_{i=1}^n x_i \right]
\left\{ x \in \mathbb{R} : x > 0 \right\}

Common delimiter pairs: \left( ... \right), \left[ ... \right], \left\{ ... \right\}, \left| ... \right|, \left\langle ... \right\rangle.

For manual sizing: \big, \Big, \bigg, \Bigg (each with (, ), [, ], \{, \}, |, / variants).

Math Spacing

LaTeX provides fine control over spacing in math mode:

CommandDescriptionExample
\,Thin space (3/18 em)f(x)dx\int f(x)\,dx
\:Medium space (4/18 em)aba \: b
\;Thick space (5/18 em)a  ba \; b
\!Negative thin space (-3/18 em) ⁣f(x)dx\int\! f(x)\,dx
\quad1 em spaceaba \quad b
\qquad2 em spaceaba \qquad b

Matrices

The amsmath package provides several matrix environments:

\begin{pmatrix}  % parenthesized
  a & b \\ c & d
\end{pmatrix}

\begin{bmatrix}  % bracketed
  a & b \\ c & d
\end{bmatrix}

\begin{vmatrix}  % vertical bars (determinant)
  a & b \\ c & d
\end{vmatrix}

\begin{Bmatrix}  % curly braces
  a & b \\ c & d
\end{Bmatrix}

\begin{Vmatrix}  % double vertical bars
  a & b \\ c & d
\end{Vmatrix}

Cases and Piecewise Functions

The cases environment is used for piecewise-defined functions:

f(x) = \begin{cases}
  x^2 & \text{if } x \geq 0 \\
  -x  & \text{if } x < 0
\end{cases}

Advanced Math (amsmath)

For document structures containing numerous complex formulas, load amsmath or mathtools in your preamble:

\usepackage{amsmath}

This unlocks advanced alignment environments:

\begin{align}
  f(x) &= (x + a)^2 \\
       &= x^2 + 2ax + a^2
\end{align}

Other amsmath Environments

EnvironmentDescription
gatherMultiple centered equations, auto-numbered
multlineLong equations split across lines, first left-aligned, last right-aligned
flalignFull-length alignment (spans entire line width)
alignat{N}Alignment with N alignment columns

Custom Operators

Define your own operators with \DeclareMathOperator:

\DeclareMathOperator{\Tr}{Tr}      % Trace
\DeclareMathOperator{\diag}{diag}  % Diagonal
\DeclareMathOperator*{\esssup}{ess\,sup}  % ess sup with limits above/below

Common Math Symbols

Relations

SymbolCommandDescription
\leq\leqLess than or equal
\geq\geqGreater than or equal
\neq\neqNot equal
\approx\approxApproximately equal
\equiv\equivEquivalent
\sim\simSimilar to
\propto\proptoProportional to

Operators

SymbolCommandDescription
\cup\cupUnion
\cap\capIntersection
\in\inElement of
\subset\subsetSubset
\forall\forallFor all
\exists\existsThere exists
\nabla\nablaNabla/gradient

Arrows

SymbolCommandDescription
\rightarrow\rightarrowRight arrow
\leftarrow\leftarrowLeft arrow
\leftrightarrow\leftrightarrowLeft-right arrow
\Rightarrow\RightarrowDouble right arrow
\Leftarrow\LeftarrowDouble left arrow
\mapsto\mapstoMaps to

The mathtools Package

The mathtools package extends amsmath with additional features:

\usepackage{mathtools}

Useful additions include:

  • \coloneqq for definition arrows (:=)
  • \DeclarePairedDelimiter for custom delimiters
  • \mathclap to reduce spacing in subscripts
\DeclarePairedDelimiter{\norm}{\lVert}{\rVert}
% Usage: $\norm{x}$ or $\norm*{\frac{x}{y}}$
Copyright © 2026