[Tex/LaTex] Reference subfigure by letter only

captionscross-referencing

I have a figure with multiple subfigures. When I reference a subfigure using, for example, Figure \ref{subfig:a}, it (correctly) renders as Figure 1.1a.

However, if I chain many such references together, it would render as, for example, Figure 1.1a-1.1b, as well as 1.1d and 1.1f. I think it would read easier if I could get it to render as Figure 1.1a-b, as well d and f.

I would like a way to suppress the figure number and only display the alphabetical subfigure identifier when referencing a subfigure. Also, I would like to do this on command, only for some references, rather than changing the default behaviour for my document.

For context, I use the caption and subcaption packages to manage subfigures.

Best Answer

Use the \subref-command (from section 6.1 in the subcaption docs):

\documentclass{article}
\usepackage{caption}
\usepackage{subcaption}
\begin{document}
\begin{figure}
    \begin{minipage}[b]{.5\linewidth}
        \centering\large A
        \subcaption{A subfigure}\label{fig:1a}
    \end{minipage}%
    \begin{minipage}[b]{.5\linewidth}
        \centering\large B
        \subcaption{Another subfigure}\label{fig:1b}
    \end{minipage}
    \caption{A figure}\label{fig:1}
\end{figure}
Figure letter: \subref{fig:1a}
\end{document}

Produces this: enter image description here