Set counter of subfigures of figures

This question builds off on the question here Subfigures in subfigures in latex enter link description here

However, what I would like to have is an additional level of subcaptions for the individual figures. Say, I would like (i) and (ii) for each of the figures in (a) and (b).

I tried modifying the code as follows:

\documentclass{article}
\usepackage{subcaption}
\usepackage{graphicx}

\begin{document}

\begin{figure}
\centering

\begin{subfigure}[b]{.4\textwidth}
\centering
\includegraphics[width=.4\textwidth]{example-image}
\subcaption{fig. (i)}
\includegraphics[width=.4\textwidth]{example-image}
\subcaption{fig. (ii)}
\caption{My compound subfigure (a)}
\begin{subfigure}[b]{.4\textwidth}
\centering
\includegraphics[width=.4\textwidth]{example-image}
\subcaption{fig. (i)}
\includegraphics[width=.4\textwidth]{example-image}
\subcaption{fig. (ii)}
\caption{My compound subfigure (b)}
\end{subfigure}
\caption{A caption}

\end{figure}

\end{document}


But this was not correct and gave me the following:

Any suggestions on how I get the second layer of subcaptioning inside the subfigures?

Update: I would like to have (i) and (ii) in each subfigure side-by-side. Also, is it possible to automate the (i) and (ii), etc, this more for general reference for later generations?

• Sep 4, 2022 at 14:16
• Please, provide an sketch, what you like to get. Your question is still unclear, and as I see, all only guess, what you after Sep 4, 2022 at 14:27

Sorry, your question is not entirely clear (tome), so I guess, that you after the following:

For above images you need manually set subcaption counters:

\documentclass{article}
\usepackage{subcaption}
\usepackage{graphicx}

\begin{document}

\begin{figure}
\centering

\begin{subfigure}[b]{.4\textwidth}
\renewcommand\thesubfigure{\roman{subfigure}}
\includegraphics[width=\linewidth]{example-image-a}
\subcaption{fig. (i)}

\includegraphics[width=\linewidth]{example-image-b}
\subcaption{fig. (ii)}
\setcounter{subfigure}{0}
\renewcommand\thesubfigure{\alph{subfigure}}
\caption{My compound subfigure (a)}
\end{subfigure}
\hfill
\begin{subfigure}[b]{.4\textwidth}
\setcounter{subfigure}{0}
\renewcommand\thesubfigure{\roman{subfigure}}
\includegraphics[width=\linewidth]{example-image-a}
\subcaption{fig. (i)}

\includegraphics[width=\linewidth]{example-image-b}
\subcaption{fig. (ii)}
\setcounter{subfigure}{1}
\renewcommand\thesubfigure{\alph{subfigure}}
\caption{My compound subfigure (b)}
\end{subfigure}

\caption{A caption}
\end{figure}

\end{document}

• Thanks, I would like (i) and (ii) side-by-side. Also, can one automate the (i) and (ii)? I think it would be good to have a general solution. Sep 4, 2022 at 10:46
• @user3236841, please make your question more clear. ALso your comment not make it sufficient clear. The best is, that you provide a sketch, what you looking for. For your demand doesn't exist general solution. Sep 4, 2022 at 11:41
• Updated. I also decided that my actual question is more complicated, and have posted it here: tex.stackexchange.com/questions/656125/… Sep 4, 2022 at 13:11

Something like this?

The subcaption package typesets the subfigure captions at \small, for a ca. 10% linear reduction in font size. In view of this factoid, I've chosen to insert \footnotesize directives at the top of each subfigure environment, for a further ca. 10% reduction in font size of the manually-numbered second-level captions.

I trust that having to enumerate the subsubcaptions manually won't be much of a chore, since the number of subsubfigures within each subfigure will be rather small -- 2 or max 3, right?

\documentclass{article}
\usepackage{subcaption}
\usepackage{graphicx}

\begin{document}
\begin{figure}[ht]

\begin{subfigure}[b]{.45\textwidth}
\centering\footnotesize

\includegraphics[width=\linewidth]{example-image}
(i) Some text

\bigskip
\includegraphics[width=\linewidth]{example-image}
(ii) Some more text

\caption{First compound subfigure}
\end{subfigure}%
\hfill% maximize the horizontal separation
\begin{subfigure}[b]{.45\textwidth}
\centering\footnotesize

\includegraphics[width=\linewidth]{example-image}
(i) Some text

\bigskip
\includegraphics[width=\linewidth]{example-image}
(ii) Some more text

\caption{Second compound subfigure}
\end{subfigure}

\caption{A figure with two compound subfigures}
\end{figure}

\end{document}

• Thank you! Also for the explanations. Btw, I do have 9 sub-figures, each subfigure of the compound one is in a 3x3 grid:-( Sep 4, 2022 at 10:47
• @user3236841 - Not sure I understand your comment. Are you saying that some figure environments in your document have three columns of subfigure environmens, with each subfigure containing three graphs and associated captions, and hence that some figure environments contain a total of 9 graphs? Please advise.
– Mico
Sep 4, 2022 at 14:59