하위 그림으로 캡션을 하위 그림으로 표현

하위 그림으로 캡션을 하위 그림으로 표현

저는 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가 있습니다.

관련 정보