1

I have a figure with four subfigures, each corresponding to a subcase in a theorem, labeled (a), (b)i, and (b)ii respectively using the enumitem package (see MWE and illustration below; note the reference style in the paragraph following the theorem).

MWE:

\documentclass[a5paper]{scrartcl}

\usepackage{enumitem}
\setlist[enumerate,1]{label=\textnormal{(\emph{\alph*})}}
\setlist[enumerate,2]{labelindent=2\parindent,
label=\textnormal{(\emph{\roman*})},ref=\theenumi\textnormal{\emph{\roman*}}}

\usepackage{subcaption}

\newtheorem{theorem}{Theorem}

\begin{document}

\begin{theorem}
There are two cases and three subcases in this theorem:
\begin{enumerate}
\item \label{itm.a} About the first figure.
\item   About the other figures.
    \begin{enumerate}
    \item \label{itm.bi} About the second figure.
    \item \label{itm.bii} About the third figure.
    \end{enumerate}
\end{enumerate}
\end{theorem}

The theorem talks about \ref{itm.a}, \ref{itm.bi}, and \ref{itm.bii}.

See Figures~\ref{fig.a}, \ref{fig.bi}, and \ref{fig.bii}.

\begin{figure}
\begin{center}
\begin{subfigure}[t]{0.3\textwidth}
\centering
A
\caption{The first picture} \label{fig.a}
\end{subfigure}
%
\begin{subfigure}[t]{0.3\textwidth}
\centering
BI
\caption{The second picture} \label{fig.bi}
\end{subfigure}
%
\begin{subfigure}[t]{0.3\textwidth}
\centering
BII
\caption{The third picture} \label{fig.bii}
\end{subfigure}
\caption{Three different pictures.}
\end{center}
\end{figure}

\end{document}

MWE

Since each of the subfigures corresponds exactly to one subcase in the theorem, I would like the subfigures to be labeled the same as the corresponding subcases, i.e., (a), (b)i, and (b)ii, and the references to these figures should be displayed as such as well. Specifically, I want the subfigure labels to be (a), (b)i, and (b)ii (instead of (a), (b), and (c)), and thus the last paragraph of the document with the references should read "See Figures 1(a), 1(b)i, and 1(b)ii."

How can I do this? I guess the larger question is how to make two different things have the same label.

1 Answer 1

2

Placing \renewcommand\thesubfigure{\ref{itm.a}} inside a subfigure (before the caption) replaces its name with \ref{itm.a}, whatever that is. This is also used when referring to the subfigure.

There is a slight complication in that \ref{itm.a} comes with parentheses, and when it shows up in the subfigure caption it is by default enclosed in more parentheses. This is fixed in the example below by making \thesubfigure include the parentheses.

\documentclass[a5paper]{scrartcl}

\usepackage{enumitem}
\setlist[enumerate,1]{label=\textnormal{(\emph{\alph*})}}
\setlist[enumerate,2]{labelindent=2\parindent,
label=\textnormal{(\emph{\roman*})},ref=\theenumi\textnormal{\emph{\roman*}}}

%% Remove the automatic parentheses and make them part of the label
\usepackage[labelformat=simple]{subcaption}
\renewcommand{\thesubfigure}{(\alph{subfigure})}

\newtheorem{theorem}{Theorem}

\begin{document}

\begin{theorem}
There are two cases and three subcases in this theorem:
\begin{enumerate}
\item \label{itm.a} About the first figure.
\item   About the other figures.
    \begin{enumerate}
    \item \label{itm.bi} About the second figure.
    \item \label{itm.bii} About the third figure.
    \end{enumerate}
\end{enumerate}
\end{theorem}

The theorem talks about \ref{itm.a}, \ref{itm.bi}, and \ref{itm.bii}.

See Figures~\ref{fig.a}, \ref{fig.bi}, and \ref{fig.bii}.

\begin{figure}
\begin{center}
\begin{subfigure}[t]{0.3\textwidth}\renewcommand{\thesubfigure}{\ref{itm.a}}
\centering
A
\caption{The first picture} \label{fig.a}
\end{subfigure}
\quad
\begin{subfigure}[t]{0.3\textwidth}\renewcommand\thesubfigure{\ref{itm.bi}}
\centering
BI
\caption{The second picture} \label{fig.bi}
\end{subfigure}
\quad
\begin{subfigure}[t]{0.3\textwidth}\renewcommand\thesubfigure{\ref{itm.bii}}
\centering
BII
\caption{The third picture} \label{fig.bii}
\end{subfigure}
\caption{Three different pictures.}
\end{center}
\end{figure}

\begin{figure}
  \begin{subfigure}[t]{0.5\textwidth}
    \centering
    Another subfigure
    \caption{Testing to ensure that captions on other subfigures still show with parentheses}
  \end{subfigure}
  \caption{Testing captions on other figures}
\end{figure}

\end{document}

Of course, if you do this often enough you might want to define a macro for it. The same trick will also work for renaming tables, figures, etc. (using \thetable, \thefigure, respectively in place of \thesubfigure).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .