All guides

Equation numbering in LaTeX

Updated:

An equation with its number on the right is written with the equation environment. Give it a \label and refer to it in the text with \eqref, which adds the parentheses for you. The number updates automatically when you add an equation earlier in the document.

Equation with a label

\begin{equation}
  T = 2\pi \sqrt{\frac{L}{g}} \label{eq:period}
\end{equation}
T=2πLg(1)T = 2\pi \sqrt{\frac{L}{g}} \tag{1}

Put the label inside the environment, ideally right before \end{equation}. The eq: prefix is optional, but once a report has dozens of labels it tells you at a glance that this one belongs to an equation and not a figure.

Copying this from handwritten notes? Snap a photo of the page and CamteX turns the formulas into LaTeX. Try it free

Reference in the text

From equation \eqref{eq:period} we determine the gravitational acceleration.

\eqref comes from the amsmath package and prints the number in parentheses, exactly as it appears next to the equation: "from equation (1)". A plain \ref gives the bare number.

Equation without a number

\begin{equation*}
  g = \frac{4\pi^2 L}{T^2}
\end{equation*}
g=4π2LT2g = \frac{4\pi^2 L}{T^2}

The starred form (from amsmath) drops the number; the shorter \[ ... \] does the same. Number only the equations you actually refer to. A number on every intermediate step tells the reader nothing.

Several equations, each numbered

\begin{align}
  v &= \frac{s}{t} \label{eq:v} \\
  a &= \frac{\Delta v}{\Delta t} \nonumber
\end{align}

In the align environment every row gets its own number, and \nonumber (or \notag) switches it off for a single row. The & character lines the equations up on their equals signs.

One number for a whole block

\begin{equation}
  \begin{aligned}
    x &= r\cos\varphi \\
    y &= r\sin\varphi
  \end{aligned}
  \label{eq:polar}
\end{equation}
x=rcos⁡φy=rsin⁡φ(3)\begin{aligned} x &= r\cos\varphi \\ y &= r\sin\varphi \end{aligned} \tag{3}

aligned inside equation produces a single number, centred vertically on the block. Use it for a pair of formulas you treat as one equation in the text, such as a change of coordinates.

Numbers within sections

\usepackage{amsmath}
\numberwithin{equation}{section}

This goes in the preamble, after amsmath is loaded. Equations in section 2 are then numbered (2.1), (2.2) and so on, which keeps numbers short in a longer thesis where a single sequence would run into the dozens.

Common mistakes

See also

Don't want to memorize commands?

Draw a formula or paste a screenshot, and CamteX turns it into ready LaTeX.

Try it free