0

The \autoref command is not giving me a "Figure" label name for subfigures made inside subfloats. There are answers how to control the label numbering but the label name I was not lucky to find an answer to that. I am doing a workaround identifying a \newcommand at the preamble as shown in the following MWE, but I love to see more control over the hyperref/subfig packages behaviour.

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{hyperref}
\usepackage{subfig}

%Command to add Figure word to the autoref command
\newcommand\sfigautoref[1]{Figure~\autoref{#1}}

\begin{document}

\begin{figure}
  \centering
  \subfloat[]{
    \includegraphics{figa}
    %\caption{atest}
    \label{a}
}
  \subfloat[]{

    \includegraphics{figb}
    %\caption{btest}
    \label{b}
}
\end{figure}

Now this \sfigautoref{a} works, although the link is just on the number a direct use of \texttt{\textbackslash autoref\{text\}} use with controlled behaviour is preferred.
Thanks all in advance,

\end{document}
1

See page 18 of the hyperref manual. Note that \subfigurename is also used by \subfloat (bad).

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{hyperref}
\usepackage{subfig}
\let\subfigureautorefname=\figurename

\begin{document}

\begin{figure}
  \centering
  \subfloat[\label{a}]{
    \includegraphics{figa}
}
  \subfloat[\label{b}]{
    \includegraphics{figb}
}
\end{figure}

Now this \autoref{a} works as expected.
\end{document}

Your Answer

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

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