Your Equations Can Look Like a Textbook
You've seen papers where the mathematics is beautiful. Multi-line derivations that flow naturally. Perfectly aligned equals signs. Custom operators that match the surrounding text. Equation numbering that makes sense.
Then you look at your own LaTeX—a mess of equation environments and manual spacing.
The difference isn't talent. It's knowing the right techniques. Let's go beyond $x^2$ and \frac{}{} into the advanced formatting that makes complex mathematics readable. (Need to find a specific symbol? Try our symbol finder.)
The AMS Packages
For serious math typesetting, load the AMS packages:
\usepackage{amsmath} % Core math enhancements
\usepackage{amssymb} % Additional symbols
\usepackage{amsthm} % Theorem environments
\usepackage{mathtools} % Extensions to amsmathamsmath is essential. The others add useful extensions.
Multi-Line Equations
The align Environment
For equations with alignment points:
\begin{align}
f(x) &= x^2 + 2x + 1 \\
&= (x + 1)^2
\end{align}The & marks alignment points. Use \\ for line breaks.
Multiple Alignment Points
\begin{align}
a &= b + c &\quad d &= e + f \\
g &= h &\quad i &= j + k + l
\end{align}This creates two columns of aligned equations.
Unnumbered Equations
% No numbers at all
\begin{align*}
y &= mx + b \\
&= 2x + 3
\end{align*}
% Selective numbering
\begin{align}
y &= mx + b \nonumber \\
&= 2x + 3
\end{align}The gather Environment
For centered equations without alignment:
\begin{gather}
E = mc^2 \\
F = ma \\
PV = nRT
\end{gather}Equation Groups
The subequations Environment
For labeling related equations:
\begin{subequations}
\label{eq:maxwell}
\begin{align}
\nabla \cdot \mathbf{E} &= \frac{\rho}{\epsilon_0} \label{eq:maxwell-gauss} \\
\nabla \cdot \mathbf{B} &= 0 \label{eq:maxwell-divb} \\
\nabla \times \mathbf{E} &= -\frac{\partial \mathbf{B}}{\partial t} \label{eq:maxwell-faraday} \\
\nabla \times \mathbf{B} &= \mu_0 \mathbf{J} + \mu_0 \epsilon_0 \frac{\partial \mathbf{E}}{\partial t} \label{eq:maxwell-ampere}
\end{align}
\end{subequations}This produces equations (1a), (1b), (1c), (1d).
The split Environment
For a single equation number across multiple lines:
\begin{equation}
\begin{split}
f(x) &= a + b + c + d \\
&\quad + e + f + g \\
&= \text{result}
\end{split}
\end{equation}One equation number for all lines.
Conditional Expressions
Cases
\begin{equation}
f(x) = \begin{cases}
x^2 & \text{if } x \geq 0 \\
-x & \text{if } x < 0
\end{cases}
\end{equation}More Complex Conditions
\begin{equation}
\delta_{ij} = \begin{cases}
1 & \text{if } i = j \\
0 & \text{otherwise}
\end{cases}
\end{equation}dcases for Better Spacing
From mathtools:
\usepackage{mathtools}
\begin{equation}
f(x) = \begin{dcases}
\frac{x^2}{2} & \text{if } x \geq 0 \\
\frac{-x}{2} & \text{if } x < 0
\end{dcases}
\end{equation}dcases uses display-style fractions inside cases.
Matrices
Basic Matrices
\begin{equation}
A = \begin{pmatrix}
a & b \\
c & d
\end{pmatrix}
\end{equation}Matrix Types
% Parentheses
\begin{pmatrix} a & b \\ c & d \end{pmatrix}
% Brackets
\begin{bmatrix} a & b \\ c & d \end{bmatrix}
% Braces
\begin{Bmatrix} a & b \\ c & d \end{Bmatrix}
% Vertical bars (determinant)
\begin{vmatrix} a & b \\ c & d \end{vmatrix}
% Double vertical bars
\begin{Vmatrix} a & b \\ c & d \end{Vmatrix}
% No delimiters
\begin{matrix} a & b \\ c & d \end{matrix}Small Matrices
For inline use:
The matrix $\begin{psmallmatrix} a & b \\ c & d \end{psmallmatrix}$
is invertible.Large Matrices with Ellipses
\begin{equation}
A = \begin{pmatrix}
a_{11} & a_{12} & \cdots & a_{1n} \\
a_{21} & a_{22} & \cdots & a_{2n} \\
\vdots & \vdots & \ddots & \vdots \\
a_{m1} & a_{m2} & \cdots & a_{mn}
\end{pmatrix}
\end{equation}Custom Operators
Defining Operators
% Simple operator
\DeclareMathOperator{\argmax}{arg\,max}
\DeclareMathOperator{\argmin}{arg\,min}
\DeclareMathOperator{\tr}{tr}
\DeclareMathOperator{\diag}{diag}
\DeclareMathOperator{\rank}{rank}
% With limits (like \lim)
\DeclareMathOperator*{\argmax}{arg\,max}Usage:
\begin{equation}
\hat{\theta} = \argmax_\theta \mathcal{L}(\theta)
\end{equation}Common Custom Operators
\DeclareMathOperator{\sgn}{sgn} % Sign function
\DeclareMathOperator{\sinc}{sinc} % Sinc function
\DeclareMathOperator{\Var}{Var} % Variance
\DeclareMathOperator{\Cov}{Cov} % Covariance
\DeclareMathOperator{\E}{\mathbb{E}} % ExpectationDelimiters
Automatic Sizing
% Automatic sizing
\left( \frac{a}{b} \right)
\left[ \sum_{i=1}^n x_i \right]
\left\{ \int_0^\infty f(x)\,dx \right\}
% Manual sizing
\bigl( \Bigl( \biggl( \Biggl(
\bigr) \Bigr) \biggr) \Biggr)Mixed Delimiters
\left. \frac{df}{dx} \right|_{x=0} % Right bar only
\left( x + y \right. % Left paren, nothing rightAbsolute Value and Norms
\usepackage{mathtools}
\DeclarePairedDelimiter\abs{\lvert}{\rvert}
\DeclarePairedDelimiter\norm{\lVert}{\rVert}
% Usage:
\abs{x} % |x|
\abs*{\frac{a}{b}} % Auto-sized
\norm{v} % ||v||Spacing Control
Standard Spaces
a\,b % Thin space (6/18 quad)
a\:b % Medium space (4/18 quad)
a\;b % Thick space (5/18 quad)
a\quad b % Full quad
a\qquad b % Double quad
a\ b % Normal text space
a\! b % Negative thin spaceIn Practice
% Integral spacing
\int f(x) \, dx % Thin space before dx
% Function notation
\sin x % sin x (correct)
sin x % Wrong: si n x
% Abbreviations
\text{s.t.}\quad x > 0 % "such that"Text in Equations
The text Command
\begin{equation}
x = y \quad \text{if and only if} \quad y = x
\end{equation}The intertext Command
\begin{align}
a &= b + c \\
\intertext{Substituting the expression for $b$:}
a &= (d + e) + c \\
&= d + e + c
\end{align}Short Intertext
\begin{align}
x &= y \\
\shortintertext{and}
z &= w
\end{align}Advanced Techniques
Phantom for Alignment
\begin{align}
x + y &= 10 \\
\phantom{x +{}} y &= 3 % Align the y's
\end{align}Overlapping Notation
% Stack symbols
\overset{?}{=} % =? above
\underset{\text{def}}{=} % def below
\stackrel{\text{def}}{=} % Alternative
% Overbrace and underbrace
\underbrace{a + b + c}_{3 \text{ terms}}
\overbrace{x_1 + x_2 + \cdots + x_n}^{n \text{ terms}}Boxed Equations
\begin{equation}
\boxed{E = mc^2}
\end{equation}Colored Equations
\usepackage{xcolor}
\begin{equation}
y = \textcolor{blue}{ax^2} + \textcolor{red}{bx} + c
\end{equation}Common Symbols
Greek Letters
% Variants
\epsilon, \varepsilon % ε, ε
\theta, \vartheta % θ, ϑ
\phi, \varphi % φ, ϕ
\pi, \varpi % π, ϖ
\rho, \varrho % ρ, ϱArrows
\rightarrow, \to % →
\leftarrow, \gets % ←
\Rightarrow, \Implies % ⇒
\Leftarrow % ⇐
\Leftrightarrow, \iff % ⇔
\mapsto % ↦
\hookrightarrow % ↪Relations
\leq, \geq % ≤, ≥
\ll, \gg % ≪, ≫
\approx, \sim % ≈, ∼
\equiv % ≡
\propto % ∝
\neq % ≠
\in, \notin % ∈, ∉
\subset, \supset % ⊂, ⊃
\subseteq, \supseteq % ⊆, ⊇Big Operators
\sum_{i=1}^n % Summation
\prod_{i=1}^n % Product
\int_a^b % Integral
\oint % Contour integral
\iint, \iiint % Multiple integrals
\bigcup, \bigcap % Set operationsTroubleshooting
Common Issues
Equation too wide:
% Use split or multline
\begin{multline}
a + b + c + d + e + f + g \\
= h + i + j + k
\end{multline}Poor fraction rendering:
% In text, use \tfrac for small fractions
The ratio is $\tfrac{1}{2}$.
% In display, \dfrac forces display style
$\dfrac{a}{b}$Inconsistent operator spacing:
% Always use \DeclareMathOperator for functions
\DeclareMathOperator{\myop}{myop}
% Not: $myop$ or $\mathrm{myop}$Quick Reference
Environment Summary
| Environment | Use For |
|-------------|---------|
| equation | Single numbered equation |
| equation* | Single unnumbered equation |
| align | Multiple aligned equations |
| gather | Multiple centered equations |
| multline | Single long equation |
| split | Multi-line, one number |
| cases | Conditional expressions |
Useful Commands
% Fractions
\frac{a}{b}, \tfrac{a}{b}, \dfrac{a}{b}
% Roots
\sqrt{x}, \sqrt[n]{x}
% Over/under
\hat{x}, \bar{x}, \vec{v}, \tilde{x}
\dot{x}, \ddot{x}
\overline{abc}, \underline{abc}
% Big operators with limits
\sum_{i=1}^n, \prod, \int, \ointConclusion
Advanced math typesetting requires knowing the right environments and commands. Master align for multi-line equations, cases for conditionals, and mathtools for enhanced delimiters—these cover most needs.
The key principles:
- Use AMS packages
- Align at meaningful points
- Control numbering intentionally
- Define custom operators for consistency
- Let LaTeX handle spacing (mostly)
With these tools, you can typeset any mathematical notation beautifully.