设置图形子图的计数器

设置图形子图的计数器

这个问题是基于这里的问题 latex 中的子图中的子图 在此处输入链接描述

但是,我希望为单个图形添加额外的子标题。比如,我希望 (a) 和 (b) 中的每个图形都有 (i) 和 (ii)。

我尝试修改代码如下:

\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)}
\end{subfigure}\quad
\begin{subfigure}[b]{.4\textwidth}
\centering
\includegraphics[width=.4\textwidth]{example-image}
\subcaption{fig. (i)}
    \quad
\includegraphics[width=.4\textwidth]{example-image}
\subcaption{fig. (ii)}
\caption{My compound subfigure (b)}
\end{subfigure}
\caption{A caption}
    
\end{figure}
    
\end{document}

但这并不正确,并给出了以下结果:

在此处输入图片描述

关于如何在子图内获取第二层子字幕,有什么建议吗?

更新:我希望每个子图中并排显示 (i) 和 (ii)。此外,是否可以自动化 (i) 和 (ii) 等,这更适合后代的一般参考?

答案1

抱歉,您的问题不太清楚,所以我想您可以按照以下方法进行:

在此处输入图片描述

对于上述图像,您需要手动设置子标题计数器:

\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}

答案2

像这样吗?

在此处输入图片描述

subcaption包将子图标题排版为\small,字体大小线性减少约 10%。考虑到这一事实,我选择\footnotesize在每个环境的顶部插入指令subfigure,以便将手动编号的二级标题的字体大小进一步减少约 10%。

我相信手动枚举子子标题不会是一件苦差事,因为每个子图内的子子图的数量相当小 - 2 或最多 3,对吗?

\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}

相关内容