I want to only show equations that I label/ref later in text. However I am doing something wrong, as there is not equation number shown, although I referenced it:
\documentclass[a4paper]{article}
\usepackage{mathtools}
\mathtoolsset{showonlyrefs}
\begin{document}
Here have an equation:
\begin{align}
A=B\label{eq:AB}\\
C=D
\end{align}
Only number equation \ref{eq:AB}.
\end{document}
which results in
Without \mathtoolsset{showonlyrefs}
it looks fine but also equation C=D is displayed as (2):
What should I do to solve this issue? I want that it looks exactly like in the second picture but without the (2).
Best Answer
You need
\eqref
not\ref
to trigger theshowonlyrefs
processing.