子圖到子圖標題

子圖到子圖標題

我是乳膠新手。我不知道如何提出我的問題。但我會對其進行框架,以便可以理解。

我想製作一個子圖,但標題必須是

caption of subfigure a-1 caption of subfigure a-2

caption of subfigure b-1 caption of subfigure b-2

                 `caption  of entire figure`

我嘗試使用 subfigure,但我不斷地獲得a,b,c,d,但我需要如上所述命名它們(a-1、a-2、b-1、b-2)。在我的情況下,子圖可能位於不同的頁面中。

答案1

subequations這使用與 相同的想法amsmath

\documentclass{article}

\usepackage{graphicx}
\usepackage{subcaption}

\makeatletter
\newcounter{parentsubcaption}
\newenvironment{subsubcaption}
 {\refstepcounter{sub\@captype}%
  \protected@edef\theparentsubcaption{\@nameuse{thesub\@captype}}%
  \setcounter{parentsubcaption}{\value{sub\@captype}}%
  \setcounter{sub\@captype}{0}%
  \@namedef{thesub\@captype}{\theparentsubcaption--\arabic{sub\@captype}}%
  \ignorespaces
}{%
  \setcounter{sub\@captype}{\value{parentsubcaption}}%
  \ignorespacesafterend
}
\makeatother

\begin{document}

\begin{figure}
\centering
\begin{subsubcaption}
\begin{subfigure}{5cm}
\includegraphics[width=\linewidth]{example-image}
\caption{caption of subfigure a--1}\label{a--1}
\end{subfigure}\qquad
\begin{subfigure}{5cm}
\includegraphics[width=\linewidth]{example-image}
\caption{caption of subfigure a--2}\label{a--2}
\end{subfigure}
\end{subsubcaption}

\begin{subsubcaption}
\begin{subfigure}{5cm}
\includegraphics[width=\linewidth]{example-image}
\caption{caption of subfigure b--1}\label{b--1}
\end{subfigure}\qquad
\begin{subfigure}{5cm}
\includegraphics[width=\linewidth]{example-image}
\caption{caption of subfigure b--2}\label{b--2}
\end{subfigure}
\end{subsubcaption}

\caption{caption  of entire figure}
\end{figure}

References:
\ref{a--1} and \subref{a--1};
\ref{b--1} and \subref{b--1}.

\end{document}

在此輸入影像描述

編輯

如果更多圖形環境使用subsubcaption.這是一個嘗試與\ContinuedFloat.

\documentclass{article}

\usepackage{graphicx}
\usepackage{subcaption}
\usepackage{etoolbox}
\makeatletter
\newif\ifsubsubcaption@ContinuedFloat
\newif\ifsubsubcaption@nonfirst
\patchcmd{\ContinuedFloat}
  {\caption@ContinuedFloat}
  {\subsubcaption@ContinuedFloattrue\caption@ContinuedFloat}
  {}{}

\newcounter{parentsubcaption}
\newenvironment{subsubcaption}
 {\refstepcounter{sub\@captype}%
  \protected@edef\theparentsubcaption{\@nameuse{thesub\@captype}}%
  \setcounter{parentsubcaption}{\value{sub\@captype}}%
  \setcounter{sub\@captype}{0}%
  \@namedef{thesub\@captype}{\theparentsubcaption--\arabic{sub\@captype}}%
  \ignorespaces
}{%
  \setcounter{sub\@captype}{\value{parentsubcaption}}%
  \ignorespacesafterend
}
\BeforeBeginEnvironment{subsubcaption}{%
  \ifsubsubcaption@ContinuedFloat
  \else
    \ifsubsubcaption@nonfirst
    \else
      \subsubcaption@nonfirsttrue
      \setcounter{sub\@captype}{0}%
    \fi
  \fi
}
\makeatother

\begin{document}

\begin{figure}
\centering
\begin{subsubcaption}
\begin{subfigure}{5cm}
\includegraphics[width=\linewidth]{example-image}
\caption{caption of subfigure a--1}\label{a--1}
\end{subfigure}\qquad
\begin{subfigure}{5cm}
\includegraphics[width=\linewidth]{example-image}
\caption{caption of subfigure a--2}\label{a--2}
\end{subfigure}
\end{subsubcaption}

\begin{subsubcaption}
\begin{subfigure}{5cm}
\includegraphics[width=\linewidth]{example-image}
\caption{caption of subfigure b--1}\label{b--1}
\end{subfigure}\qquad
\begin{subfigure}{5cm}
\includegraphics[width=\linewidth]{example-image}
\caption{caption of subfigure b--2}\label{b--2}
\end{subfigure}
\end{subsubcaption}

\caption{caption  of entire figure}
\end{figure}

References:
\ref{a--1} and \subref{a--1};
\ref{b--1} and \subref{b--1}.

\begin{figure}
\ContinuedFloat
\centering
\begin{subsubcaption}
\begin{subfigure}{5cm}
\includegraphics[width=\linewidth]{example-image}
\caption{caption of subfigure c--1}\label{c--1}
\end{subfigure}\qquad
\begin{subfigure}{5cm}
\includegraphics[width=\linewidth]{example-image}
\caption{caption of subfigure c--2}\label{c--2}
\end{subfigure}
\end{subsubcaption}

\begin{subsubcaption}
\begin{subfigure}{5cm}
\includegraphics[width=\linewidth]{example-image}
\caption{caption of subfigure d--1}\label{d--1}
\end{subfigure}\qquad
\begin{subfigure}{5cm}
\includegraphics[width=\linewidth]{example-image}
\caption{caption of subfigure d--2}\label{d--2}
\end{subfigure}
\end{subsubcaption}

\caption{caption  of entire figure (continued)}
\end{figure}

\begin{figure}
\centering
\begin{subsubcaption}
\begin{subfigure}{5cm}
\includegraphics[width=\linewidth]{example-image}
\caption{caption of subfigure a--1}\label{a--1-x}
\end{subfigure}\qquad
\begin{subfigure}{5cm}
\includegraphics[width=\linewidth]{example-image}
\caption{caption of subfigure a--2}\label{a--2-x}
\end{subfigure}
\end{subsubcaption}

\begin{subsubcaption}
\begin{subfigure}{5cm}
\includegraphics[width=\linewidth]{example-image}
\caption{caption of subfigure b--1}\label{b--1-x}
\end{subfigure}\qquad
\begin{subfigure}{5cm}
\includegraphics[width=\linewidth]{example-image}
\caption{caption of subfigure b--2}\label{b--2-x}
\end{subfigure}
\end{subsubcaption}

\caption{caption  of entire figure}
\end{figure}

\end{document}

在此輸入影像描述

「延續」圖有標籤 c 和 d,而接下來的「新」圖又有 a 和 b。

相關內容