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.
Asked
Active
Viewed 1,400 times
16
-
2See also http://tex.stackexchange.com/questions/4728/how-do-i-number-equations-only-if-they-are-referred-to-in-the-text – Lev Bishop Apr 14 '11 at 14:12
2 Answers
13
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
3
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}
\begin{equation}
A = A
\end{equation}
\begin{equation}\label{B}
B = B
\end{equation}
\begin{equation}
C = C
\end{equation}
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.
Matthew Leingang
- 44,937
- 14
- 131
- 195