MWE first.
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{hyperref}
\usepackage[subrefformat=simple,labelformat=simple]{subfig}
%\newcommand{\subfigureautorefname}{\figureautorefname}
%\renewcommand\thesubfigure{(\alph{subfigure})}
\begin{document}
\begin{figure}
\subfloat[]{\label{a}\qquad}
\caption{}
\end{figure}
\begin{tabular}{|c|c|}
\hline
&Result\\\hline
ref&\ref{a}\\\hline
subref&\subref{a}\\\hline
autoref&\autoref{a}\\\hline
subref*&\subref*{a}\\\hline
\end{tabular}
\end{document}
I use package subfig
to create subfigures and I want to use both \subref
in captions and \autoref
in the context.
My desired output of \subref
and \autoref
are (a)
and Figure 1(a)
respectively, but I'm not able to achieve them at the same time. I have tried different options for subfig
and the solution here(where this question title came from). I also tried to create a new command but failed because I know little about macro or something like that.
Edit: Thanks for @Mico 's solution using package subcaption
! I prefer to stick to subfig
because it's exhausting to edit all floats in my document.
So I didn't check the subfig
manual carefully enough. There are 3 options for typesetting subfloat labels. labelformat
sets the label displayed under each subfloat. listofformat
sets the output of \subref
. subrefformat
sets
the output of \subref*
.
In my case, I only need to add listofformat=subsimple
to get rid of the extra pair of parens in \subref
, then I could use \renewcommand\thesubfigure{(\alph{subfigure})}
to add the parens to \autoref
. Full solution below. I didn't notice listofformat
because its name can't seem to do anything, compared to subrefformat
.
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{hyperref}
\usepackage[listofformat=subsimple,labelformat=simple]{subfig}
\newcommand{\subfigureautorefname}{\figureautorefname}
\renewcommand\thesubfigure{(\alph{subfigure})}
\begin{document}
\begin{figure}
\subfloat[]{\label{a}\qquad}
\caption{}
\end{figure}
\begin{tabular}{|c|c|}
\hline
&Result\\\hline
subref&\subref{a}\\\hline
autoref&\autoref{a}\\\hline
\end{tabular}
\end{document}
subfig
package, or are you willing to entertain a solution based on thesubcaption
package?hyperref
last