How to Control Equation Numbering in LaTeX
LaTeX numbers equation and align automatically. To remove one number, put \notag (or \nonumber) before the \\ on that line; to remove them all, use equation* or align*. Set your own label with \tag{...}, number by section with \numberwithin{equation}{section}, and group lines as (1a), (1b) with subequations. All of these need amsmath. Cite with \label and \eqref.
Not sure it worked on your document? Paste it into LetX and compile it, free and in the browser.
Why it happens
Each numbered environment steps the equation counter once per numbered line and prints the value in parentheses at the right margin. Starred environments and \[ ... \] never step it. align numbers every line by default, which is why a derivation written in align ends up with a number on each step unless you suppress them.
Example
\usepackage{amsmath}
% in the document:
\begin{align}
E &= mc^2 \label{eq:e} \\
F &= ma \notag
\end{align}
See \eqref{eq:e}.
\begin{subequations}
\begin{align}
a &= 1 \\
b &= 2
\end{align}
\end{subequations}Numbering by section or chapter
In article, equations run (1), (2), (3) through the whole document. \numberwithin{equation}{section} in the preamble (amsmath) gives (1.1), (1.2), (2.1) and restarts the count in each section. The kernel command \counterwithin{equation}{section} does the same without amsmath. In report and book, equations are numbered by chapter already, as (2.1).
\usepackage{amsmath}
\numberwithin{equation}{section}
% in the document:
\section{Model}
\begin{equation}
y = ax + b % numbered (1.1)
\end{equation}One number for a multi-line equation
align gives each line its own number. When several lines are one equation, such as a derivation, put split inside equation: the lines align at &, and the single number is centred vertically beside them. multline does the same for a long expression with no alignment point. gather centres lines without aligning them and numbers each one.
A \\ inside a plain equation environment is ignored without any message, and the lines run together. That is the sign you need split.
\usepackage{amsmath}
% in the document:
\begin{equation}
\begin{split}
(a+b)^2 &= (a+b)(a+b) \\
&= a^2 + 2ab + b^2
\end{split}
\end{equation}Custom tags, left numbers and starred environments
\tag{*} replaces the number with (*), and \tag*{...} prints its text without parentheses. Tagged equations do not step the counter, so the next numbered equation continues from the last real number. \tag also works in equation* and \[ ... \], which is how you label one important display in an otherwise unnumbered passage.
For numbers on the left, pass leqno to the class: \documentclass[leqno]{article}. The fleqn option sets displays flush left instead of centred.
\usepackage{amsmath}
% in the document:
\begin{equation}
a^2 + b^2 = c^2 \tag{Pythagoras}
\end{equation}
\begin{equation}
e^{i\pi} + 1 = 0 % numbered (1): the tag did not use a number
\end{equation}
\[
E = mc^2 \tag{$\ast$}
\]Referencing equations
Put \label{eq:name} inside the environment, on the line it names (before the \\ in align). \eqref{eq:name} prints the number in parentheses, (3); \ref{eq:name} prints 3 alone, for ranges such as "Equations 3 to 5". With cleveref, \cref{eq:name} prints "eq. (3)" and \Cref prints "Equation (3)".
A \label on a line that carries \notag never receives a number, so references to it print ??. Two \labels in one equation stop the compile with "Package amsmath Error: Multiple \label's: label 'x' will be lost".
Mistakes that produce odd numbers
A \\ after the last line of align adds an empty line with its own number, such as a stray (3) under two equations. Delete the final \\.
A blank line inside align is an error, "Paragraph ended before \align was complete"; inside equation it shows up as "Missing $ inserted". Remove the blank line, or put a lone % on it if you want the gap in the source.
A reference that prints ?? or an old number needs another compile. LaTeX reads references from the .aux file written on the previous run.
Frequently asked questions
How do I remove the number from one equation?
Put \nonumber (or \notag) before the \\ on that line inside align, or use a starred environment (equation*, align*) to remove all numbers in the block.
How do I reference an equation?
Add \label{eq:key} on the line and cite it with \eqref{eq:key} (from amsmath), which prints the number in parentheses, e.g. (3).
How do I get sub-numbers like (1a) and (1b)?
Wrap the equations in the subequations environment from amsmath; each numbered inner line becomes 1a, 1b, and so on.
How do I number equations by section?
Add \numberwithin{equation}{section} to the preamble (it needs amsmath). Equations become (1.1), (1.2) and restart in each section.
How do I put equation numbers on the left?
Use the leqno class option: \documentclass[leqno]{article}. Every equation number moves to the left margin.
Why is there an extra equation number on an empty line?
The last line of your align ends with \\, so amsmath starts a new, empty, numbered line after it. Delete the final \\.
Related LaTeX fixes
Browse all LaTeX problems & fixes, or start with the LaTeX guide.
Learn the topic properly
Try the fix in LetX
Open the editor, paste your code, and compile in seconds to see the error clear. Free, in your browser.
Open LetX Free