Tx · LaTeX & TikZ

How to Change Equation Numbering Locally in LaTeX

Published By the 9to5Science editorial team

At a glance

  1. 1. Choose the scope

    Use a custom tag for one equation, or temporarily redefine the number format for a group.

  2. 2. Load amsmath

    Add amsmath to the preamble to use commands such as \tag and equation environments.

  3. 3. Apply the change

    Set the tag on an individual equation or group equations under a local numbering format.

  4. 4. Check references

    Put \label inside the equation and confirm that references display the intended number.

Title: How to Change Equation Numbering Locally in LaTeX Category: latex

LaTeX’s equation counter and the way its value is printed are separate things. If you want to change only one displayed equation number, use a manual tag. If you want several equations to use a different format temporarily, redefine the printed form of the counter inside a group.

Both approaches below use the amsmath package. They leave the document’s usual numbering style unchanged outside the local change.

Change the number of one equation

Load amsmath in the preamble, then put \tag{...} inside a numbered display. The tag replaces the automatically printed number for that equation.

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{equation}
  x + y = 1
  \tag{A}
  \label{eq:constraint}
\end{equation}

The constraint is equation~\ref{eq:constraint}.

\begin{equation}
  x - y = 0
\end{equation}

\end{document}

The first display is labeled “A”; the next ordinary equation continues the normal numeric sequence. Add parentheses yourself in the tag only if you want them included literally: \tag{A} normally prints (A). For a tag without the surrounding parentheses, use \tag*{A}.

Place \label after \tag in the same equation environment. A reference to that label then uses the custom tag. Compile at least twice so LaTeX can resolve the reference.

Change the format for a group of equations

If you want a block of equations to retain automatic counting but display a temporary format, locally redefine \theequation. A TeX group confines the redefinition to the block:

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{equation}
  a = b
\end{equation}

\begingroup
\renewcommand{\theequation}{A\arabic{equation}}
\begin{equation}
  c = d
  \label{eq:local-one}
\end{equation}
\begin{equation}
  e = f
\end{equation}
\endgroup

\begin{equation}
  g = h
\end{equation}

\end{document}

The first equation uses the document’s ordinary format. The two equations inside the group display with an A prefix, and the equation after the group returns to the ordinary format. The counter continues through the block: grouping the redefinition changes how the counter is printed, not whether the counter advances.

The same idea works with other formats. For example, \renewcommand{\theequation}{\Roman{equation}} prints Roman numerals, while \renewcommand{\theequation}{\thesection.\arabic{equation}} includes the section number in the displayed form. Choose the representation to match the numbering you need.

Which method should you use?

GoalUse
Give one equation a special number or symbol\tag{...}
Temporarily change the format for several automatically numbered equationsGroup a redefinition of \theequation
Number every equation by section throughout the document\numberwithin{equation}{section}

For document-wide section numbering, put \numberwithin{equation}{section} in the preamble after loading amsmath. It is not a local setting: it changes the numbering scheme throughout the document. Use the grouped redefinition when the format should change only in one region.

Common mistakes

  • Using \tag outside a display math environment: \tag belongs inside a display environment that supports tags. It can also be used in an unnumbered display such as equation* when you want to supply a tag manually; without a \tag, equation* produces no number.
  • Expecting a group to undo counter increments: The group restores the local redefinition of \theequation, but the equation counter advances. If you need a custom label on just one equation, use \tag rather than resetting the counter.
  • Changing \theequation without checking references: A label records the equation’s printed representation. Compile twice and check that references show the intended format.
  • Using a global command for a local effect: \numberwithin{equation}{section} is intended to set a numbering relationship across the document, not just a short block.

References

  1. User's Guide for the amsmath Package

Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.