Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}

output

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

share|improve this question
1  
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
2  
@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
add comment

1 Answer

up vote 4 down vote accepted

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}

Sample output

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.