LaTeX Equation Numbering and Referencing: \label, \eqref, \tag and align
LaTeX numbers every equation environment automatically, and a \label inside it lets you cite that number anywhere in the text with \eqref. That is the whole system for a single-line equation. The questions start with everything else: how to number equations per section, how to break a long equation onto a new line, how to number a multi-line derivation once or on every line, how to write (1a) and (1b), how to replace the number with a custom tag, and how to turn numbering off. This guide answers all of them with amsmath and cleveref.
Numbered and Unnumbered Equations
The equation environment produces a centered, numbered display. Its starred twin equation*, provided by amsmath, produces the same display without a number, and \[ ... \] is a shorthand for it. Load amsmath in every document that contains math; almost everything in this guide depends on it.
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{equation}
E = mc^2
\end{equation}
\begin{equation*}
a^2 + b^2 = c^2
\end{equation*}
\[ F = ma \]
\end{document}The first display is “(1)”; the other two are unnumbered. The rule of thumb used by most journals: number an equation only if you refer to it somewhere. Avoid the plain TeX $$ ... $$ form; it has wrong spacing with amsmath and does not support \tag or \label properly.
Referencing an Equation: \label, \ref and \eqref
Put \label anywhere inside the numbered environment. Three commands read it back:
\begin{equation}
\label{eq:energy}
E = mc^2
\end{equation}
Equation~\ref{eq:energy} ... % prints: Equation 1
Equation~(\ref{eq:energy}) ... % prints: Equation (1)
Equation~\eqref{eq:energy} ... % prints: Equation (1), with amsmath
on page~\pageref{eq:energy} % prints: on page 4\refprints the bare number. You add the parentheses yourself.\eqref(amsmath) prints the number with parentheses, in upright text even inside italics, exactly as the equation itself shows it. Use it for equations.- The tilde
~is a non-breaking space; it stops “Equation” and “(1)” from landing on different lines.
Labels are resolved on the next compilation run, so the first build after adding a label shows ?? and the warning Label(s) may have changed. Rerun to get cross-references right. Compile twice, or use latexmk, which reruns as needed.
Pick a naming convention and keep it: eq: for equations, fig: for figures, tab: for tables, sec: for sections. The prefix is only a convention, but it makes \ref commands readable and prevents an equation and a figure from sharing a label by accident.
cleveref: \cref and \Cref
The cleveref package writes the word “equation” for you and handles lists and ranges. Load it after hyperref if you use that, and after amsmath:
\usepackage{amsmath}
\usepackage{hyperref}
\usepackage{cleveref}
See \cref{eq:energy}. % eq. (1)
See \Cref{eq:energy}. % Equation (1), at sentence start
See \cref{eq:energy,eq:momentum}. % eqs. (1) and (2)
See \crefrange{eq:first}{eq:last}. % eqs. (1) to (5)
% Change the wording once in the preamble
\crefname{equation}{Eq.}{Eqs.}
\Crefname{equation}{Equation}{Equations}With hyperref, every reference becomes a clickable link to the equation. See LaTeX Hyperlinks for the loading order and link colors.
Numbering Within Sections or Chapters
In article, equations are numbered 1, 2, 3 through the whole document. In book and report they are numbered per chapter: (2.1), (2.2). To number per section in any class, use \numberwithin from amsmath:
\usepackage{amsmath}
\numberwithin{equation}{section} % (1.1), (1.2), (2.1), ...
% In book/report, per section instead of per chapter:
\numberwithin{equation}{section} % (1.1.1), (1.1.2), ...
% Change only the printed form, keeping the counter global
\renewcommand{\theequation}{\Roman{equation}} % (I), (II), ...
\renewcommand{\theequation}{\thesection-\arabic{equation}} % (1-1), (1-2)\numberwithin both resets the equation counter at each section and prefixes the section number. The kernel command \counterwithin does the same without amsmath, and \counterwithout undoes it, which is how you get document-wide numbering in a book: \counterwithout{equation}{chapter}.
Numbers on the left
Equation numbers sit at the right margin by default. The leqno option moves them to the left, and fleqn left-aligns the equations themselves instead of centering them. Both are class options that amsmath also accepts:
\documentclass[leqno]{article} % numbers on the left
\documentclass[fleqn]{article} % equations flush left
\usepackage[leqno, fleqn]{amsmath} % same, as package optionsCustom Tags: \tag and \tag*
\tag replaces the automatic number with any text for that one equation. The equation counter is not advanced, so the next automatic number continues as if the tagged equation were not there. \tag* prints the tag without parentheses:
\begin{equation}
\nabla \cdot \mathbf{E} = \frac{\rho}{\varepsilon_0} \tag{Gauss}
\end{equation}
\begin{equation}
x^2 + y^2 = r^2 \tag*{(circle)}
\end{equation}
% Tags work in the starred environments too
\begin{align*}
f(x) &= x^2 \tag{A} \\
g(x) &= 2x \tag{B} \label{eq:B}
\end{align*}
% Reuse an earlier number, e.g. when repeating an equation
\begin{equation}
E = mc^2 \tag{\ref{eq:energy}}
\end{equation}A tagged equation can carry a \label, and \eqref then prints the tag. For a primed repeat of equation (3), write \tag{\ref{eq:energy}$'$} to get (3′).
Suppressing Numbers: \nonumber, \notag and Starred Environments
There are three levels of control. For a whole display, use the starred environment (equation*, align*, gather*). For single lines in a multi-line environment, put \notag (or its older synonym \nonumber) before the line break:
\begin{align}
(a+b)^2 &= (a+b)(a+b) \notag \\
&= a^2 + ab + ba + b^2 \notag \\
&= a^2 + 2ab + b^2 \label{eq:binomial}
\end{align}Only the last line gets a number, (1), and the label refers to it. This is the most common pattern in derivations: intermediate steps unnumbered, the result numbered.
Multi-Line Equations: align, split, multline and gather
amsmath offers several environments for displays with more than one line. The choice depends on two things: whether the lines should be aligned on a symbol, and whether you want one number for the whole block or one per line.
| Environment | Alignment | Numbering | Typical use |
|---|---|---|---|
align / align* | At each & | Every line (or none) | Derivations, systems of equations |
split (inside equation) | At & | One number, centered on the block | One long equation broken into aligned lines |
multline / multline* | First line left, last line right | One number on the last line | One long equation with no natural alignment point |
gather / gather* | Each line centered | Every line (or none) | Several unrelated equations in one display |
aligned, gathered | Like align/gather | Inherit from the enclosing equation | Aligned block that is part of a larger equation |
cases | Left-aligned columns with a brace | Inherits | Piecewise definitions |
flalign | Spread to full width | Every line | Equation on the left, condition on the right |
align: a number on every line
\begin{align}
x + y &= 10 \label{eq:sum} \\
x - y &= 2 \label{eq:diff}
\end{align}
Adding \eqref{eq:sum} and \eqref{eq:diff} gives $x = 6$.The & marks the alignment point (usually just before =), and \\ ends each line except the last. A second pair of columns can be added with more ampersands: a &= b & c &= d sets two equations side by side.
split: one number for a broken equation
\begin{equation}
\label{eq:long}
\begin{split}
(a + b)^4 &= a^4 + 4a^3b + 6a^2b^2 \\
&\quad + 4ab^3 + b^4
\end{split}
\end{equation}The number is centered vertically on the whole block, and the label goes on the outer equation. The \quad at the start of the continuation line is the conventional indent that shows the line is a continuation, not a new equation.
multline: long equations without an alignment point
\begin{multline}
\label{eq:series}
1 + \frac{1}{2} + \frac{1}{3} + \frac{1}{4} + \frac{1}{5} + \frac{1}{6}
+ \frac{1}{7} + \frac{1}{8} \\
+ \frac{1}{9} + \frac{1}{10} + \dots + \frac{1}{n} = H_n
\end{multline}gather: centered lines, each numbered
\begin{gather}
a = b + c \\
d + e + f + g = h \notag \\
x = y
\end{gather}aligned and cases inside equation
aligned and gathered are building blocks, not full displays: they take no number of their own and can sit next to other material in an equation. cases is the same idea with a left brace:
\begin{equation}
\label{eq:abs}
|x| =
\begin{cases}
x & \text{if } x \geq 0 \\
-x & \text{if } x < 0
\end{cases}
\end{equation}
\begin{equation}
\left.
\begin{aligned}
u &= x + y \\
v &= x - y
\end{aligned}
\right\} \quad \text{(change of variables)}
\end{equation}Never nest align inside equation: both are top-level displays and amsmath stops with erroneous nesting of equation structures. Use split or aligned inside, and align on its own.
New Line in an Equation: Line Breaks in Long Equations
\\ does not work inside a plain equation; the environment is a single line by design. To start a new line, switch to one of the multi-line environments above. The decision is simple:
- One equation, one number, lines aligned on
=→splitinsideequation. - One equation, one number, no alignment →
multline. - Several equations or derivation steps →
align, with\notagon lines that should not be numbered.
Two related tools: \intertext inserts a line of normal text between aligned lines without breaking the alignment, and \allowdisplaybreaks allows a page break inside a multi-line display, which amsmath forbids by default:
\allowdisplaybreaks % in the preamble, or in a group around one display
\begin{align}
f(x) &= x^2 + 2x + 1 \\
\intertext{which factors as}
f(x) &= (x+1)^2
\end{align}To permit a break at one specific line instead, put \displaybreak just before that line's \\. The mathtools package adds \shortintertext, which uses less vertical space than \intertext.
If you would rather not choose break points by hand, the breqn package provides a dmath environment that breaks and aligns long equations automatically. It is powerful but interacts badly with some other packages, so try it on a copy of the document first.
Subequations: (1a), (1b), (1c)
Wrap any numbered environment in subequations and the lines are numbered with the parent number plus a letter. A label on the wrapper refers to the group:
\begin{subequations}
\label{eq:maxwell}
\begin{align}
\nabla \cdot \mathbf{E} &= \frac{\rho}{\varepsilon_0} \label{eq:gauss} \\
\nabla \cdot \mathbf{B} &= 0 \label{eq:nomonopole} \\
\nabla \times \mathbf{E} &= -\frac{\partial \mathbf{B}}{\partial t} \label{eq:faraday}
\end{align}
\end{subequations}
Maxwell's equations \eqref{eq:maxwell} ... % (1)
Gauss's law \eqref{eq:gauss} ... % (1a)The letter style comes from \theequation inside the group; for roman numerals or another separator, redefine it right after \begin{subequations}: \renewcommand{\theequation}{\theparentequation.\roman{equation}} gives (1.i), (1.ii).
Referencing From the Text
Two conventions are common. Mathematics journals and most physics journals write the number alone in parentheses: “substituting (3) into (5)”. Engineering, computer science and many theses spell it out: “as shown in Equation (3)” or “Eq. (3)”. Either way, \eqref provides the parentheses, so do not add a second pair:
Substituting \eqref{eq:sum} into \eqref{eq:diff} ... % (1) into (2)
As shown in Equation~\eqref{eq:sum} ... % Equation (1)
As shown in Eq.~\eqref{eq:sum} ... % Eq. (1)
As shown in \cref{eq:sum} ... % eq. (1), cleveref
\Cref{eq:sum} shows ... % Equation (1), cleverefWith cleveref the wording lives in one place (\crefname), so a journal's request to switch from “Eq.” to “Equation” is a one-line change. Avoid \autoref from hyperref for equations: it prints “Equation 3” without parentheses, which is inconsistent with \eqref elsewhere.
Manual numbering with \refstepcounter
Occasionally you need an equation number in a place amsmath does not number, such as one line of an align*. Step the counter yourself and use the result as a tag; \refstepcounter (not \stepcounter) is what makes the following \label pick up the new value:
\begin{align*}
a &= b + c \\
\refstepcounter{equation}
d &= e + f \tag{\theequation} \label{eq:manual}
\end{align*}
Only the second line is numbered, as \eqref{eq:manual}.Common Errors
| Message or symptom | Cause | Fix |
|---|---|---|
| Missing $ inserted | Math-only syntax (_, ^, \frac, Greek letters) used outside math, or an unclosed $ | Wrap the expression in $...$ or a display environment; check for a missing \end{equation} |
\\ inside equation does nothing or errors | equation is single-line | Use split, multline or align |
| Label(s) may have changed. Rerun to get cross-references right | Labels are resolved on the next run | Compile again (twice after adding labels), or use latexmk |
| Undefined control sequence \eqref | amsmath not loaded | \usepackage{amsmath} |
| Reference shows ?? | Label misspelled, not yet compiled twice, or placed outside the numbered environment | Check the spelling; keep \label inside the environment |
| Erroneous nesting of equation structures | align or gather inside equation | Use split, aligned or gathered inside; align on its own |
| Multiple \label's: label 'eq:x' will be lost | Two \label commands on the same numbered line | Keep one label per number |
| \tag not allowed here or tag ignored | \tag inside $$...$$, or in an environment that cannot number (aligned, split) | Use \[ \] or equation; put the tag on the outer environment |
Numbers like (0.1) in an article | \numberwithin used but the equation comes before the first \section | Move the equation after a section heading, or drop \numberwithin |
Complete Example
\documentclass{article}
\usepackage{amsmath}
\usepackage[hidelinks]{hyperref}
\usepackage{cleveref}
\numberwithin{equation}{section}
\crefname{equation}{Eq.}{Eqs.}
\Crefname{equation}{Equation}{Equations}
\begin{document}
\section{Kinematics}
A body with constant acceleration satisfies
\begin{equation}
\label{eq:velocity}
v = v_0 + at
\end{equation}
and
\begin{equation}
\label{eq:position}
x = x_0 + v_0 t + \tfrac{1}{2} a t^2 .
\end{equation}
Eliminating $t$ between \cref{eq:velocity,eq:position}:
\begin{align}
t &= \frac{v - v_0}{a} \notag \\
x - x_0 &= v_0 \frac{v - v_0}{a} + \frac{(v - v_0)^2}{2a} \notag \\
v^2 &= v_0^2 + 2a(x - x_0). \label{eq:torricelli}
\end{align}
\Cref{eq:torricelli} contains no time variable.
\section{Field equations}
\begin{subequations}
\label{eq:maxwell}
\begin{align}
\nabla \cdot \mathbf{E} &= \rho / \varepsilon_0 \label{eq:gauss} \\
\nabla \cdot \mathbf{B} &= 0 \label{eq:nomono}
\end{align}
\end{subequations}
Together, \eqref{eq:maxwell} are two of Maxwell's equations;
\eqref{eq:gauss} alone is Gauss's law.
A long identity with a single number:
\begin{equation}
\label{eq:binom}
\begin{split}
(a+b)^4 &= a^4 + 4a^3 b + 6a^2 b^2 \\
&\quad + 4ab^3 + b^4 .
\end{split}
\end{equation}
A named equation instead of a number:
\begin{equation}
e^{i\pi} + 1 = 0 \tag{Euler}
\end{equation}
The piecewise function
\begin{equation*}
|x| =
\begin{cases}
x & \text{if } x \ge 0, \\
-x & \text{otherwise}
\end{cases}
\end{equation*}
is not numbered because it is never referenced; \cref{eq:binom} is.
\end{document}Compile twice. The equations are numbered (1.1), (1.2), (1.3), (2.1a), (2.1b), (2.2) and (Euler), and every \cref and \eqref resolves to the right one.
Quick Reference
| Task | Command |
|---|---|
| Numbered equation | \begin{equation} ... \end{equation} |
| Unnumbered equation | \begin{equation*} ... \end{equation*} or \[ ... \] |
| Label an equation | \label{eq:name} inside the environment |
| Reference with parentheses | \eqref{eq:name} → (3) |
| Reference with the word | \cref{eq:name} → eq. (3); \Cref{eq:name} → Equation (3) |
| Number per section | \numberwithin{equation}{section} |
| Custom tag | \tag{Gauss}; without parentheses \tag*{Gauss} |
| No number on one line | \notag (or \nonumber) before \\ |
| Aligned lines, each numbered | \begin{align} a &= b \\ c &= d \end{align} |
| Aligned lines, one number | \begin{equation}\begin{split} ... \end{split}\end{equation} |
| Long equation, one number | \begin{multline} ... \\ ... \end{multline} |
| Several centered equations | \begin{gather} ... \end{gather} |
| Piecewise definition | \begin{cases} ... \end{cases} inside equation |
| Sub-numbers (1a), (1b) | \begin{subequations} ... \end{subequations} |
| Text between aligned lines | \intertext{...} |
| Allow page breaks in displays | \allowdisplaybreaks in the preamble |
| Numbers on the left | \documentclass[leqno]{article} |
| Manual number | \refstepcounter{equation} + \tag{\theequation} |
Next Steps
Numbering under control? Continue with the rest of the math toolkit:
- Mathematical Expressions – Fractions, roots, operators and the amsmath environments in detail
- Integrals, Sums & Limits – Big operators, limits above and below, and multi-line sums
- Theorems, Lemmas and Proofs – amsthm, \newtheorem and the QED symbol, with the same \label/\cref workflow
- Matrices in LaTeX – pmatrix, bmatrix and augmented matrices inside numbered equations
- Greek Letters & Math Symbols – Every symbol used in the examples above
- LaTeX Hyperlinks – Make equation references clickable with hyperref
Free LaTeX Tools
- Math to LaTeX Converter – Turn handwritten or typed math into LaTeX
- LaTeX Preview – Check equation numbering with a live PDF preview
- Math to LaTeX – Convert handwritten equations to LaTeX
- LaTeX Symbols Reference – Browse math operators and special characters
Related Articles
Degree Symbol: How to Type ° on Keyboard, Mac, iPhone, Word, LaTeX
Best LaTeX Editors for Mac: Complete Comparison Guide 2026
From Crixet to Prism: The Evolution of AI-Powered LaTeX Editing
How to Create a Professional Resume in LaTeX (Complete Guide 2026)
Fix equation errors faster with AI
Octree's AI editor spots undefined labels, picks the right amsmath environment for a multi-line equation, and compiles your document in seconds.
Try Octree Free →