Skip to main content
Use \begin{equation}...\end{equation} for a numbered display equation and \begin{equation*}...\end{equation*} (from amsmath) or \[...\] for an unnumbered one. To define a piecewise function use \begin{cases}...\end{cases}, and to write a braced system of aligned equations combine \left\{ with \begin{aligned}...\end{aligned} and \right.. For equations written inside a sentence (inline math), see Inline and display math.

Numbered equations and cross-references

LaTeX numbers every equation environment automatically. Put \label{eq:name} inside the environment to refer to it later: \ref{eq:name} prints the bare number, while \eqref{eq:name} (from amsmath) wraps the number in upright parentheses matching the equation tag.
display-equations.tex
Ready to use this syntax? Continue in the browser editor when you want to adapt the example in a real project.Open LaTeX Cloud Studio
If you want to draft an equation interactively first, you can type it into the LaTeX equation editor and copy the code.

Controlling equation numbers

amsmath gives you fine-grained control over numbering without redefining internal counters:
  • Turn off numbering for an entire display: use \[...\] or the starred form (equation*, align*, gather*).
  • Turn off numbering on one line of a multi-line environment: add \notag (or \nonumber) before \\.
  • Replace the number with a custom label: \tag{N2} prints (N2); \tag*{$\star$} prints the label without surrounding parentheses.
  • Group related equations as (1a), (1b): wrap them in \begin{subequations}...\end{subequations}.
  • Frame a final result: wrap the formula inside \boxed{...}.
equation-numbering.tex

Piecewise functions with cases

The cases environment (from amsmath) draws a left curly brace and arranges two left-aligned columns separated by &, with \\ between rows. Both columns are set in text-style math mode, so wrap words such as if in \text{...}. Loading mathtools (which loads amsmath automatically) adds three useful variants:
  • cases*: sets the second column in normal text mode, so you do not need \text{...} around prose conditions.
  • dcases: sets both columns in display style, keeping fractions full-sized.
  • rcases: places the curly brace on the right side instead of the left.
cases-environment.tex

Systems of equations

When every equation in a system should align on its = sign under a single left brace, wrap an aligned block inside \left\{ ... \right. inside equation (or \[...\] for an unnumbered system). Place & immediately before each = so amsmath preserves normal relation spacing around the equals sign.
system-equations.tex
Use cases when you only want left-aligned lines with a condition column; use \left\{\begin{aligned}...\end{aligned}\right. when the equations themselves need alignment at =.

Multi-line equations

For splitting one long equation across lines (split), multi-line derivations numbered line by line (align), and unaligned long expressions (multline), see Multline and align environments.

Common mistakes

  • Using eqnarray: The legacy eqnarray environment inserts oversized gaps around the middle column (=) and handles equation numbering poorly. Use align or aligned from amsmath instead.
  • Forgetting \text{...} inside cases: Writing x^2 & if x \ge 0 renders if as italic variables with no space after it. Write \text{if } x \ge 0 or switch to cases* from mathtools.
  • Blank lines inside equation environments: An empty line inside equation or aligned causes a compilation error. Use % on a line by itself if you want visual separation in the source.
  • Missing \usepackage{amsmath}: equation*, \eqref, \tag, subequations, cases, aligned, and split all require amsmath (or mathtools, which loads amsmath).

Try it in the editor

LaTeX Cloud Studio compiles with TeX Live 2026 (full distribution), so amsmath and mathtools are preinstalled. Start from the Basic Article template in LaTeX Cloud Studio and replace main.tex with either complete example above.