# Package mathtools with showonlyrefs switch swallows parts of equation numbers in appendices

I want to use the mathtools package with showonlyrefs to achieve that only referenced equations are numbered. In the complete document I get the expected behavior for regular equations in the subsections. In the MWE the behavior for main text and appendix is the same. For example the reference to the first numbered equation would appear as (1) in the text. However it doesn't work for equations in appendices which should (with my preamble below) appear as (A1) and (A2) etc. but do all appear as (A). My example is:

\documentclass{revtex4}% same issue for e.g. article

\usepackage{mathtools}
\mathtoolsset{showonlyrefs}

\begin{document}
\section{section}
See \ref{eqn a b} and \ref{eqn b c}.

\begin{align}
a=b \label{eqn a b}
\end{align}

\begin{appendix}
\section{appendix}

\begin{align}
b=c \label{eqn b c}
\end{align}
\end{appendix}
\end{document}


Any idea how to have it display the complete unique reference?

-
please post a full minimal example that we can copy'n'paste, that will increase the possibility of help – daleif Oct 17 '12 at 14:34
Are you sure it works for equations before the appendix? I'm not: for an equation in section 1 I get as reference "I" and no number next to the equation. – egreg Oct 18 '12 at 6:27
I agree that in this short example the same happens in ordinary section. I don't know why, but I observer different behavior in the complete document. Note that it fails even if all the usepackage commands (except mathtools) are removed. So is there an incompatibility between revtex and mathtools? – highsciguy Oct 18 '12 at 9:27
@highsciguy: I minimized your example. The problem also appears when using the article document class instead of revtex4. – Stephen Nov 4 '12 at 16:14

For this feature of \mathtools to work you need to reference the equations using \eqref, not \ref.

\documentclass{revtex4}

\usepackage{mathtools}
\mathtoolsset{showonlyrefs}

\begin{document}
\section{section}
See \eqref{eqn a b} and \eqref{eqn b c}.

\begin{align}
a=b \label{eqn a b}
\end{align}

\begin{appendix}
\section{appendix}

\begin{align}
b=c \label{eqn b c}
\end{align}
\end{appendix}

\end{document}


-