I would like to style my subfigure references as Fig. 1(a) in running text and (Fig. 1a) when parenthetical. The subfigure labels are created using this code. (I would prefer to use subcaption like in this answer, but it causes a warning with the severely outdated journal class I'm stuck with.)

It is easy enough to get the first format with \renewcommand{\thesubfigure}{\thefigure(\alph{subfigure})}, and I tried to follow this answer for the second step, but no matter what I try, it does not seem to work.



% Sub-figure references b/c class is broken. See link above.

% Special format when within enclosing parentheses



Some text referencing the figure: \cref{fig:example},
and in parentheses: \crefp{fig:example}.
Some text referencing the subfigure: \cref{fig:example-1},
and in parentheses: \crefp{fig:example-1}.

The result is:

Some text referencing the figure: fig. 1, and in parentheses: (fig. 1). Some
text referencing the subfigure: fig. 1(a), and in parentheses: (fig. 1(a)).

I also tried messing with \p@subfigure instead or adding an extra macro around everything, but have so far not been successful.

(Note: I also could have left hyperref or cleveref out of the MWE, but since they do magical things with references and I'm go to use them anyway, I left them in.)

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.