# subfigure \autoref

I am trying to redefine the subfigure \autoref, but have not been successful. Below is example code for the figure. I am using the acticle documentclass and the subcaption package.

\begin{figure}[H]
\centering
\begin{subfigure}{.48\linewidth}\centering
\includegraphics{figa.eps}
\caption{atest}
\label{a}
\end{subfigure}\hspace{3mm}
\begin{subfigure}{.48\linewidth}\centering
\includegraphics{figb.eps}
\caption{btest}
\label{b}
\end{subfigure}
\end{figure}


I tried to redefine the autorefs using the following

\let\orgautoref\autoref
\providecommand{\Autoref}
{\def\figureautorefname{Figure}%
\def\subfigureautorefname{Panel}%
\orgautoref}
\renewcommand{\autoref}
{\def\figureautorefname{figure}%
\def\subfigureautorefname{panel}%
\orgautoref}


but it did not work. How do I change the autoreference from displaying "figure 1a" to "panel a"?

-
Plwase provide a compilable example instead of mere code snippets. –  lockstep Jan 10 '13 at 14:44
In the compilable example, please be sure to indicate which package you load for creating subfigures: subfigure, subfig, subcaption, or something else? –  Mico Jan 10 '13 at 14:53
I use the subcaption package. –  richtera Jan 10 '13 at 15:09
add comment

## 2 Answers

Two possibilities came into my mind:

1. Redefine \p@subref which will be prepend to every reference typeset with \subref
2. Define and use your own \subref format

Here comes an example code which shows both methods:

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

\DeclareCaptionLabelFormat{panel}{panel~#2}
\DeclareCaptionLabelFormat{Panel}{Panel~#2}

\begin{document}

\begin{figure}
\centering
\begin{subfigure}{.48\linewidth}\centering
\includegraphics{figa}
\caption{atest}
\label{a}
\end{subfigure}\hspace{3mm}
\begin{subfigure}{.48\linewidth}\centering
\includegraphics{figb}
\caption{btest}
\label{b}
\end{subfigure}
\end{figure}

\makeatletter
\renewcommand\p@subref{Panel}
\subref{a}
\makeatother

\captionsetup{subrefformat=Panel}
\subref{a}

\captionsetup{subrefformat=panel}
\subref{a}

\end{document}


P.S.: Please post a minimal but compilable example next time so potential helpers have a document to play around with. I you don't do it, every potential helper has to do this first.

-
For some reason, I cannot get this code to work. What I would like to do is have the subfigure captions say (a) text, (b) text nuder the figure, but when referencing in the body of the text is says Panel (a) and Panel (b). –  richtera Jan 11 '13 at 19:44
@richtera "I cannot get this code to work" gives us no information helping us solving your problem. –  Axel Sommerfeldt Jan 11 '13 at 20:23
add comment

Without seeing your .tex-File I suggest to use \usepackage{subfig}, then you can use \newcommand{\subfigureautorefname}{\figureautorefname} to make \autoref work with \subfloat. I can't recall where I got this snippet from (probably from tex.SE), but anyways; it has worked fine for me.

-
I cannot use the subfig package because I also have subtables. –  richtera Jan 11 '13 at 19:50
According to the subfig manual, the package also supports subtables, although I've never used subtables. –  Habi Jan 15 '13 at 13:03
add comment