Ich bin neu bei LaTeX. Ich bin nicht sicher, wie ich meine Frage formulieren soll. Aber ich werde sie so formulieren, dass sie verständlich ist.
Ich möchte eine Unterfigur machen, aber die Beschriftung muss sein
caption of subfigure a-1
caption of subfigure a-2
caption of subfigure b-1
caption of subfigure b-2
`caption of entire figure`
Ich habe versucht, Unterabbildungen zu verwenden, aber ich bekomme ständig a,b,c,d
, aber ich muss sie wie oben erwähnt benennen (a-1, a-2, b-1, b-2). In meiner Situation besteht die Möglichkeit, dass sich die Unterabbildungen auf verschiedenen Seiten befinden.
Antwort1
Dies verwendet dieselbe Idee subequations
wie 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}
BEARBEITEN
Der obige Code funktioniert nicht wirklich, wenn mehrere Figure-Umgebungen verwenden subsubcaption
. Hier ist ein Workaround, der auch mit gut zu funktionieren scheint \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}
Die „Fortsetzungs“-Abbildung hat die Beschriftungen c und d, während die folgende „neue“ Abbildung wieder a und b hat.