私は LaTeX の初心者です。質問の書き方がよくわかりません。しかし、理解しやすいように書きます。
サブ図を作りたいのですが、キャプションは
caption of subfigure a-1
caption of subfigure a-2
caption of subfigure b-1
caption of subfigure b-2
`caption of entire figure`
サブ図を使用しようとしましたが、連続して表示されます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 のラベルが付いています。