使用子标题为嵌套子图添加字幕

使用子标题为嵌套子图添加字幕

下面创建一个图形,其中三幅图像排列得当。如果我删除这两\caption{}行,它会按我想要的方式对主要子图进行编号,而保留这两\caption{}行会将子图字母放在子子图的正确位置,但字母是错误的。

我怎样才能将子图标识从 a、b、c、d 更改为 a、b1、b2、b 或类似标识?

\documentclass{article}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{fancyref}
\usepackage{subcaption}
\begin{document}
\begin{figure}
  \begin{subfigure}{0.5\textwidth}
    \centering
    \includegraphics[width=\textwidth]{wu8_wedges}
    \caption{With wedges.}
    \label{fig:wedges}
  \end{subfigure}
  \begin{subfigure}{0.5\textwidth}
    \begin{subfigure}{\textwidth}
      \centering
      \includegraphics[width=\textwidth]{wu8_flat1}
      \caption{}
      \label{fig:flat1}
    \end{subfigure}
    \begin{subfigure}{\textwidth}
      \centering
      \includegraphics[width=\textwidth]{wu8_flat2}
      \caption{}
      \label{fig:flat2}
    \end{subfigure}
    \caption{Without wedges}
    \label{fig:flat}
  \end{subfigure}
  \caption{Interactions between the railcar and the man's feet.}
  \label{fig:interactions}
\end{figure}
\end{document}

答案1

一种可能性是手动调整计数器和\thesubfigure

\documentclass{article}
\usepackage{amsmath}
\usepackage[demo]{graphicx}
\usepackage{fancyref}
\usepackage{subcaption}

\begin{document}

\begin{figure}
  \begin{subfigure}{0.5\textwidth}
    \centering
    \includegraphics[width=.95\textwidth]{wu8_wedges}
    \caption{With wedges.}
    \label{fig:wedges}
  \end{subfigure}%
  \begin{subfigure}{0.5\textwidth}
    \begin{subfigure}{\textwidth}
      \renewcommand\thesubfigure{\alph{subfigure}1}
      \centering
      \includegraphics[width=.95\textwidth]{wu8_flat1}
      \caption{}
      \label{fig:flat1}
    \end{subfigure}
    \begin{subfigure}{\textwidth}
      \addtocounter{subfigure}{-1}
      \renewcommand\thesubfigure{\alph{subfigure}2}
      \centering
      \includegraphics[width=.95\textwidth]{wu8_flat2}
      \caption{}
      \label{fig:flat2}
    \end{subfigure}
    \addtocounter{subfigure}{-1}
    \caption{Without wedges}
    \label{fig:flat}
  \end{subfigure}
  \caption{Interactions between the railcar and the man's feet.}
  \label{fig:interactions}
\end{figure}

\end{document}

在此处输入图片描述

选项demo只是graphicx用黑色矩形替换实际图形;不是在实际文档中使用该选项。

答案2

根据@Gonzalo 的回答,一种更通用的方法涉及定义一个subsubfigure环境:

\newenvironment{subsubfigure}[2][]{%
  \begin{subfigure}[#1]{#2}%
    \stepcounter{subsubfigure}%
    \renewcommand{\thesubfigure}{\alph{subfigure}.\roman{subsubfigure}}%
}{%
    \addtocounter{subfigure}{-1}%
  \end{subfigure}%
}

\newcounter{subsubfigure}

只需确保subsubfigure在每次新操作后将计数器重置为 0 \begin{subfigure}

\begin{figure}
  \begin{subfigure}{0.5\linewidth}
    \setcounter{subsubfigure}{0}%         IMPORTANT
    \centering
    \begin{subsubfigure}{0.5\linewidth}
      \centering
      \includegraphics[width=\linewidth]{img_1_a_i}
      \caption{}
    \end{subsubfigure}%
    \begin{subsubfigure}{0.5\linewidth}
      \centering
      \includegraphics[width=\linewidth]{img_1_a_ii}
      \caption{}
    \end{subsubfigure}%
    \caption{}
  \end{subfigure}%
  % ...
  % more subfigures
  % ...
  \caption{}
\end{figure}

...从理论上讲,可以修补subfigure环境来为您完成此操作,但我还不想陷入这种困境...


原始问题的用法示例:

\documentclass{article}
\usepackage{amsmath}
\usepackage[demo]{graphicx}
\usepackage{fancyref}
\usepackage{subcaption}

\newenvironment{subsubfigure}[2][]{%
  \begin{subfigure}[#1]{#2}%
    \stepcounter{subsubfigure}%
    \renewcommand{\thesubfigure}{\alph{subfigure}.\roman{subsubfigure}}%
}{%
    \addtocounter{subfigure}{-1}%
  \end{subfigure}%
}

\newcounter{subsubfigure}

\begin{document}

\begin{figure}
  \begin{subfigure}{0.5\textwidth}
    \centering
    \includegraphics[width=.95\textwidth]{wu8_wedges}
    \caption{With wedges.}
    \label{fig:wedges}
  \end{subfigure}%
  \begin{subfigure}{0.5\textwidth}
    \setcounter{subsubfigure}{0}
    \begin{subsubfigure}{\textwidth}
      \centering
      \includegraphics[width=.95\textwidth]{wu8_flat1}
      \caption{}
      \label{fig:flat1}
    \end{subsubfigure}
    \begin{subsubfigure}{\textwidth}
      \centering
      \includegraphics[width=.95\textwidth]{wu8_flat2}
      \caption{}
      \label{fig:flat2}
    \end{subsubfigure}
    \caption{Without wedges}
    \label{fig:flat}
  \end{subfigure}
  \caption{Interactions between the railcar and the man's feet.}
  \label{fig:interactions}
\end{figure}

\end{document}

相关内容