# Suppress equation number when not refered to [duplicate]

Is is possible to use only equation or align environments without the * and then automatically suppress the equation number if there is nothing refering to that equation? It would make the LaTeX-life much easier I think.

-

## marked as duplicate by lockstep, Jesse, Thorsten, Martin Schröder, Peter JanssonJan 23 '14 at 13:23

– Lev Bishop Apr 14 '11 at 14:12

see package mathtools and section "3.2.2 Showing only referenced tags". You'll get the documentation by running texdoc mathtools or run texdoctk if you run Linux

-
Thanks! The package looks very useful. – Jonas Teuwen Apr 14 '11 at 13:31

I coded up a workaround before I noticed Herbert's answer. Here it is anyway:

\documentclass{article}
% TEX.SE \url{http://tex.stackexchange.com/q/15820/1402}
\usepackage{amsmath}
\usepackage{etoolbox}

\makeatletter
\appto{\equation}{%
\notag
\preto{\label}{%
\refstepcounter{equation}
\tag{\arabic{equation}}%
}
}
\makeatother

\begin{document}

$$A = A$$

$$\label{B} B = B$$

$$C = C$$

Proof: See Equation~\ref{B}.

\end{document}


It's my first use of the etoolbox macros to prepend and append code to hooks. This method first appends \notag to every equation beginning, thus suppressing equation numbering; then prepends to \label the code which steps the counter and resets the tag.

-