LaTeX Equation Numbering: label, eqref and tag
November 11, 2026 · 10 min read
LaTeX Equation Numbering: Label, Reference and Tag Equations
LaTeX equation numbering is automatic: wrap a formula in \begin{equation} and LaTeX prints (1), (2), (3) at the right margin. Attach a name with \label, point back to it with \eqref, and replace any number with \tag. This page covers each step, plus what still works when your math lives in Markdown.
Here's the whole toolkit at a glance. The equation environment, \[ ... \], \nonumber, \label and \ref are base LaTeX. Everything else needs \usepackage{amsmath}.
| You want | Write | Result |
|---|---|---|
| A numbered display | \begin{equation} ... \end{equation} | (1) on the right |
| No number | equation* or \[ ... \] | No number |
| A name to cite | \label{eq:name} inside the display | Nothing visible |
| A reference | \eqref{eq:name} | (1) |
Skip one align row | \notag or \nonumber | Row has no number |
| Your own number | \tag{A} or \tag*{A} | (A) or A |
| Numbers like 2.3 | \numberwithin{equation}{section} | (2.3) |
| Numbers like 4a, 4b | subequations | (4a), (4b) |
Numbered or Not: equation, equation* and \[...\]
A LaTeX \begin{equation} block gives its formula the next number in the sequence, set in parentheses on the right. The starred equation* prints the same formula with no number, and the \[ ... \] wrapper does the same. The amsmath package defines equation*, so load it in the preamble.
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{equation}
E = mc^2
\end{equation}
\begin{equation*}
F = ma
\end{equation*}
\[
a^2 + b^2 = c^2
\]
\end{document}
The first formula prints with (1) beside it. The other two sit centered with no number, and the next numbered equation you write becomes (2). Without amsmath, base LaTeX calls its unnumbered display displaymath instead.
Which one should you use? We prefer numbering only the equations you actually refer back to. When every display carries a number, readers can't tell which ones matter, and the numbers in your references climb for no reason.
How Do You Label an Equation in LaTeX?
A LaTeX equation label is a private name you attach with \label{...}. It never prints. LaTeX records the equation's number under that name so a later reference can fetch it. Put the label inside the environment, either right after the math or on its own line.
\begin{equation}
E = mc^2
\label{eq:energy}
\end{equation}
The eq: prefix means nothing to LaTeX. It's a naming habit that keeps eq:energy apart from fig:energy when your document grows. The same \label mechanism works for sections, figures and tables too. In a table in LaTeX, the label goes after the caption.
Three placement mistakes cause most broken references:
- Label after
\end{equation}. The learnlatex.org cross-referencing lesson explains that\labelrefers to the most recent numbered thing. Outside the environment, that's usually the current section, so your reference shows the section number. - Label in an unnumbered display. Inside
equation*or\[...\]there's no equation number to record, so the reference shows an earlier number, often the section's, or nothing at all. - The same name twice. LaTeX warns that a label is multiply defined, and references may point at the wrong equation. Keep names unique and descriptive.
How Do You Reference an Equation in LaTeX?
Use \eqref{eq:energy}. It's an amsmath command that prints the number with its parentheses, so you get (1), the usual style for equation references. Plain \ref{eq:energy} prints the bare number. The amsmath guide puts it simply: if \ref gives 3.2, \eqref gives (3.2).
Einstein's relation \eqref{eq:energy} links mass and energy.
Equation~\ref{eq:energy} is the same reference without parentheses.
That renders as "Einstein's relation (1) links mass and energy. Equation 1 is the same reference without parentheses." The tilde is a non-breaking space, so "Equation" and its number never split across lines.
Seeing ?? instead of a number? That's normal after the first compile. LaTeX writes labels to an auxiliary .aux file on one run and reads them back on the next, so compile again. If the question marks survive a second run, the label name is misspelled or missing.
Typing "Eq." by hand gets old in a long paper. The cleveref package adds the word for you: per its manual, \cref{eq:energy} prints eq. (1). Automatic cross-references like these are a big part of why people choose LaTeX over Markdown for papers.
To cite an equation from someone else's paper, \eqref can't help, because the label lives in their document. Write the number yourself and cite the source, as in Eq. (3) of \cite{einstein1905}.
Numbering Rows in align with \notag and Per-Row Labels
Every row of align and gather gets its own number unless you switch it off. End a row with \notag (amsmath) or \nonumber (the older base LaTeX command) to skip it, and give any row its own \label.
\begin{align}
f(x) &= x^2 + 2x + 1 \notag \\
&= (x+1)^2 \label{eq:factored} \\
g(x) &= 3x - 4 \label{eq:linear}
\end{align}
The three rows line up on their equal signs. The first row has no number, and the other two get consecutive numbers that \eqref{eq:factored} and \eqref{eq:linear} can cite.
Want one number for a whole derivation instead? Put split inside equation. The whole block shares one number, and amsmath centers it vertically beside the block by default.
\begin{equation}
\begin{split}
f(x) &= x^2 + 2x + 1 \\
&= (x+1)^2
\end{split}
\label{eq:derivation}
\end{equation}
Custom Equation Numbers with \tag and \tag*
\tag{...} replaces the automatic number with any text, wrapped in parentheses. \tag*{...} prints your text exactly as typed, without parentheses. Both come from amsmath, and the guide notes they also work in the unnumbered forms such as align*.
\begin{equation}
F = ma \tag{N2}
\label{eq:newton}
\end{equation}
\begin{equation*}
p = mv \tag*{(momentum)}
\end{equation*}
The first equation shows (N2) at the right, and \eqref{eq:newton} prints (N2) as well. The second shows the word in parentheses because you typed them. Tags suit named laws, repeated equations and documents that must match a printed source's numbering.
Inside align, each row can carry its own tag. That's the cleanest way to hand-number a short system, and it works the same in KaTeX:
\begin{align}
x + y &= 5 \tag{1a} \\
x - y &= 1 \tag{1b}
\end{align}
LaTeX Equation Numbering by Section and 1a, 1b Subequations
Long documents usually number equations by section: (1.1), (1.2), then (2.1) in section 2. One amsmath command sets that up and resets the counter at each new section.
\documentclass[leqno]{article}
\usepackage{amsmath}
\numberwithin{equation}{section}
The book and report classes already number equations by chapter, so you mostly need this in article. Watch the argument order: the amsmath guide's troubleshooting section shows that \numberwithin{section}{equation} turns your section numbers into oddities like 0.1 and 5.1. The leqno class option in that example moves every number to the left margin, and reqno puts them back on the right.
For a family of related equations numbered 4a, 4b, 4c, wrap them in subequations:
\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}
If the previous numbered equation was (3), these rows print as (4a) and (4b). The label placed right after \begin{subequations} refers to the parent, so \eqref{eq:maxwell} prints (4) while \eqref{eq:gauss} prints (4a).
Can You Add a Caption to an Equation in LaTeX?
Not directly. There's no LaTeX equation caption command, because \caption only works inside floats such as figure and table. You have three practical options:
- Name it in the sentence. A lead-in such as
The heat equation \eqref{eq:heat} describesdoes the job of a caption and reads naturally. - Use a text tag.
\tag*{Heat equation}puts a short name where the number would go. - Use a float only if you must. If a style guide demands a captioned display, place the equation in a
figurewith\caption. It's then numbered as a figure, not as an equation.
The first option fits almost every paper. The float route also lets LaTeX move the equation to another page, which rarely helps a derivation. For a short note inside the display itself, our guide to text in LaTeX equations covers "where" clauses and text under a symbol.
Equation Numbering in Markdown with KaTeX
In Markdown, math is drawn by a JavaScript library rather than by LaTeX, so the numbering rules shrink. Our editor renders $$...$$ blocks with KaTeX (the Markdown equation guide covers the delimiters). KaTeX numbers rows of equation, align and gather, and it accepts \tag, \tag*, \notag and \nonumber.
The gap is cross-referencing. The KaTeX support table lists \label, \ref and \eqref as not supported. In our test with KaTeX 0.16, subequations and \numberwithin failed too. Our preview doesn't crash on them, though: it shows the unsupported command, or the whole block for subequations, as red KaTeX error text and keeps rendering everything else.
There's a quieter catch. KaTeX draws its automatic numbers with a CSS counter that resets once per page, not per section. Every numbered block on the page shares one sequence, so adding a block near the top shifts every number below it. That's why we prefer a typed \tag in Markdown: the number you write is the number readers see.
MathJax, the other common web renderer, behaves differently. It resolves \label and \eqref, but its automatic numbering stays off until the site sets tags: 'ams' in its configuration.
Converting Markdown to a LaTeX paper later? Pandoc turns $$ blocks into unnumbered \[...\] displays, so switch the ones you cite to equation after converting Markdown to LaTeX. If you need one formula as an image, the LaTeX equation editor renders it with KaTeX in your browser and exports PNG or SVG. It doesn't do cross-references either.
Questions About Numbering and Citing Equations
LaTeX equation numbering comes down to a short toolkit. Use equation for a number, a starred form for none, \label plus \eqref to cite and \tag to override. Add \numberwithin or subequations when you need structure. In Markdown, keep the toolkit to \tag and \notag, since KaTeX can't resolve labels. Paste any display from this page between $$ lines in the editor to see which numbers render before they go into your notes.