6

When using \documentclass{article} and \usepackage{hyperref} as in the MWE below, the \autoref command correctly formats the reference as Appendix A.

\documentclass{article}
\usepackage{hyperref}

\begin{document}

\section{Intro}
\label{sec:intro}

See \autoref{apx:details}.

\appendix

\section{Details}
\label{apx:details}

See \autoref{sec:intro}.

\end{document}

When I change the document class to {revtex4-1}, however, the same example now formats both \autoref commands as Section.

\documentclass{revtex4-1}
\usepackage{hyperref}

\begin{document}

\section{Intro}
\label{sec:intro}

See \autoref{apx:details}.

\appendix

\section{Details}
\label{apx:details}

See \autoref{sec:intro}.

\end{document}

Digging into hyperref.sty, the main logic to detect appendices is in the \hyper@makecurrent command (in particular, this is where \hy@chapapp gets used). Thus, I attempted to diagnose the problem by using {etoolbox} to debug when this command is given a counter:

\usepackage{etoolbox}

\makeatletter
\pretocmd{\hyper@makecurrent}{
    \message{hyper@makecurrent: #1}
}{}{}
\makeatother

For the MWE with \documentclass{article}, this gives the log output that one would expect:

hyper@makecurrent: section hyper@makecurrent: section

For the MWE with \documentclass{revtex4-1}, no calls to \hyper@makecurrent are generated. This, in particular, defeats the strategy given by cyberSingularity, such that including their solution does not cause \autoref to correctly format as Appendix.

Is it possible to fix this behavior without using {cleveref}?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.