如何将子图拆分到多页上(a、b、c 在一页中,d、e 在第二页中?

如何将子图拆分到多页上(a、b、c 在一页中,d、e 在第二页中?

我正在关注这个问题将子图拆分到多个页面

效果很好。但是,当我想在第一页添加一个子图(如 (c))时,效果就不好了。

\documentclass{article}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}

%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\usepackage{lipsum}

    \begin{document}



\begin{figure}[h!]
    \centering
    \begin{subfigure}[b]{0.6\textwidth}
        \includegraphics[width=\textwidth]{example-image}
        \subcaption{$Q^{*}$ values for arm 1}
        \label{fig:arm1}
    \end{subfigure}
%
    \begin{subfigure}[b]{0.6\textwidth}
        \includegraphics[width=\textwidth]{example-image}
        \subcaption{$Q^{*}$ values for arm 2}
        \label{fig:arm2}
    \end{subfigure}
    \caption{$Q^{*}$ values for different arms}
%
    \begin{subfigure}[b]{0.6\textwidth}
        \includegraphics[width=\textwidth]{example-image}
        \subcaption{$Q^{*}$ values for arm 3}
        \label{fig:arm2}
    \end{subfigure}
    \caption{$Q^{*}$ values for different arms}

\end{figure}%

\begin{figure}[htb]\ContinuedFloat
    \centering
    \begin{subfigure}[b]{0.6\textwidth}
        \includegraphics[width=\textwidth]{example-image}
        \subcaption{$Q^{*}$ values for arm 4}
        \label{fig:arm3}
    \end{subfigure}
%
    \begin{subfigure}[b]{0.6\textwidth}
        \includegraphics[width=\textwidth]{example-image}
        \subcaption{$Q^{*}$ values for arm 5}
        \label{fig:arm4}
    \end{subfigure}
    \caption{$Q^{*}$ values for different arms (cont.)}
    \label{fig:arms}
\end{figure}


    \end{document}

不确定添加会带来什么问题:

\begin{subfigure}[b]{0.6\textwidth}
    \includegraphics[width=\textwidth]{example-image}
    \subcaption{$Q^{*}$ values for arm 3}
    \label{fig:arm2}
\end{subfigure}
\caption{$Q^{*}$ values for different arms}

在此处输入图片描述

在此处输入图片描述

答案1

发生这种情况是因为第一个图(部分)中有两个标题。

命令\caption[<optional short text>]{<long caption text>}执行(简化解释)下列操作:

  1. <long caption text>作为标题文本插入到figure(或 table)浮动环境中以及<optional short text>图形或表格列表中
  2. 增加标题编号
  3. 通过第二个动作重置最终的子标题编号

第二个动作可以用命令来阻止\ContinuedFloat

在您的情况下,上述意思是,在图表的第二部分中不增加最后一个标题编号,也不(因此)重置子标题编号。由于图表的第一部分有两个标题,因此\ContinuedFloat在图表的第二部分中,阻止增加图表第一部分中第二个标题的标题编号,从而允许图表第二部分中的子标题编号从此继续。

至少对我来说,不清楚为什么您在图的第一部分有两个标题。如果有意有两个标题,但您希望后面的标题数量相同,则将其插入\ContinuedFloat第一个标题之后;如果您不小心将其留在代码中,则只需将其删除即可。

在第二种情况下,您将获得以下结果:

在此处输入图片描述

编辑: 上图由以下 MWE 制作:

\documentclass{article}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}

%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\usepackage{lipsum}

    \begin{document}
\begin{figure}[hb!]
    \centering
    \begin{subfigure}{0.6\textwidth}
        \includegraphics[width=\textwidth]{example-image}
        \subcaption{$Q^{*}$ values for arm 1}
        \label{fig:arm1}
    \end{subfigure}

    \begin{subfigure}{0.6\textwidth}
        \includegraphics[width=\textwidth]{example-image}
        \subcaption{$Q^{*}$ values for arm 2}
        \label{fig:arm2}
    \end{subfigure}

    \begin{subfigure}{0.6\textwidth}
        \includegraphics[width=\textwidth]{example-image}
        \subcaption{$Q^{*}$ values for arm 3}
        \label{fig:arm2}
    \end{subfigure}
    \caption{$Q^{*}$ values for different arms}
\end{figure}%
\begin{figure}[ht]\ContinuedFloat
    \centering
    \begin{subfigure}{0.6\textwidth}
        \includegraphics[width=\textwidth]{example-image}
        \subcaption{$Q^{*}$ values for arm 4}
        \label{fig:arm3}
    \end{subfigure}

    \begin{subfigure}{0.6\textwidth}
        \includegraphics[width=\textwidth]{example-image}
        \subcaption{$Q^{*}$ values for arm 5}
        \label{fig:arm4}
    \end{subfigure}
    \caption{$Q^{*}$ values for different arms (cont.)}
    \label{fig:arms}
\end{figure}
    \end{document}

答案2

\ContinuedFloatsubfig包中执行此操作。

有时,尤其是在使用子浮点数时,单个图形需要跨页面延续。\ContinuedFloat 命令放置在浮动环境的开头或在浮动环境内更改 @captype 之后,以使下一个图形、表格或其他浮动 \caption 成为相同类型的最后一个浮点 \caption 的延续。它通过在内部保存子浮点数并阻止浮点数前进来实现这一点。


更新:

MWE 基本上是:

\begin{figure}
\subfloat[][]{A}
\subfloat[][]{B}
\caption{Fig. 1}
\end{figure}
\begin{figure}
\ContinuedFloat
\subfloat[][]{C}
\subfloat[][]{D}
\caption{Fig. 2}
\end{figure}

生产代码如下所示,有很多调整,我不记得为什么要这样做。其中包括对计数器进行一些调整figure以保持相同的数字。

\begin{figure}[pt]
\let\tabsepbakup\tabcolsep
\renewcommand{\tabcolsep}{0.1ex}
\begin{tabular}{rl}
\multicolumn{2}{r}{%
\sidebysidecaption{0.75\linewidth}{0.23\linewidth}{%
\subfloat[R1: The first section]{\begin{tabular}[b]{c}
\includegraphics[width=0.495\linewidth]{R1_scan.png}
\\
\includegraphics[width=0.495\linewidth]{scale.png}
\end{tabular}
\label{fig:km-4-a}}
%\hspace*{0.1ex}
\setcounter{subfigure}{3}%
\subfloat[R2: The first section]{\begin{tabular}[b]{c}
\includegraphics[width=0.495\linewidth]{R2_scan.png}
\\
\includegraphics[width=0.495\linewidth]{scale.png}
\end{tabular}
\label{fig:km-4-d}}
}{% \vspace*{1em}
  \hspace*{\tabcolsep}\hspace*{0.1\linewidth}\vspace*{0pt}%
  \hfill%
  \caption[Regions of interest as sections and as reconstructions]{First scan of R1, R2
  immunostaining in combination with front views of the 3D models
  coloured for shape diameter and connectivity visualisation. Scale
  bar for all images~$=$ \SI{200}{\micro\meter}. \emph{(Continued on the next page, full caption on page~\pageref{fig:km-4-caption}.)}}%
\label{fig:km-4}
}}
%
\setcounter{subfigure}{2} \\

\setcounter{subfigure}{1}%
\subfloat[R1: The shape diameter]{\includegraphics[width=0.495\linewidth]{r1_red_frame_br_.png}\label{fig:km-4-b}} &
\setcounter{subfigure}{4}%
\subfloat[R2: The shape diameter]{\includegraphics[width=0.495\linewidth]{r2_red-from_blue_y_bg.png}\label{fig:km-4-e}}
\\
\setcounter{subfigure}{2}%
\subfloat[R1: The connectivity study]{\includegraphics[width=0.495\linewidth]{r1_overview_frame_y_.png}\label{fig:km-4-c}} &
\setcounter{subfigure}{5}%
\subfloat[R2: The connectivity study]{\includegraphics[width=0.495\linewidth]{r2_overview_frame_y-border.png}\label{fig:km-4-f}} \\
\end{tabular}
\renewcommand{\tabcolsep}{\tabsepbakup}
%%% need a hack for contcaption
%%% increment the figure counter so it might be decremented again
\stepcounter{figure}
\end{figure}
\begin{figure}[tp]
\ContinuedFloat
%% <-------------------- that's the point
\let\tabsepbakup\tabcolsep
\renewcommand{\tabcolsep}{0.1ex}
\begin{tabular}{rl}
\multicolumn{2}{r}{%
\sidebysidecaption{0.24\linewidth}{0.75\linewidth}{%
  \contcaption{\emph{(Continued from previous page.)} First scan of R3, R4
  immunostaining and front views of the 3D models
  coloured for shape diameter and connectivity visualisation. % Scale
  % bar for all images~$=$ \SI{200}{\micro\meter}.
  \emph{(Full caption on the next page.)}}
}{%
\hspace*{0pt}%
\vspace*{0pt}%
\hspace*{-0.5\linewidth}%
\hfill%
\subfloat[R3: The first section]{%
\renewcommand{\tabcolsep}{0ex}
\begin{tabular}[b]{c}
\includegraphics[height=0.495\linewidth]{R3_scan.png}
\\
\includegraphics[width=0.495\linewidth]{scale.png}\label{fig:km-4-g}
\end{tabular}%
\renewcommand{\tabcolsep}{0.1ex}
}%
\setcounter{subfigure}{9}%
\subfloat[R4: The first section]{%
\renewcommand{\tabcolsep}{0ex}
\begin{tabular}[b]{c}
\includegraphics[height=0.495\linewidth]{R4_scan.png}
\\
\includegraphics[width=0.495\linewidth]{scale.png}\label{fig:km-4-j}
\end{tabular}%
\renewcommand{\tabcolsep}{0.1ex}
}%
}\setcounter{subfigure}{7}}
\\
\subfloat[R3: The shape diameter]{\includegraphics[width=0.495\linewidth]{r3_red_frame_.png}\label{fig:km-4-h}} &
\setcounter{subfigure}{10}%
\subfloat[R4: The shape diameter]{\includegraphics[width=0.495\linewidth]{r4_red_frame_.png}\label{fig:km-4-i}}
\\
\setcounter{subfigure}{8}%
\subfloat[R3: The connectivity study]{\includegraphics[width=0.495\linewidth]{r3_blue_.png}\label{fig:km-4-k}}
 &
\setcounter{subfigure}{11}%
\subfloat[R4: The connectivity study]{\includegraphics[width=0.495\linewidth]{r4_overview_front_.png}\label{fig:km-4-l}}
\\
\end{tabular}
\renewcommand{\tabcolsep}{\tabsepbakup}
\end{figure}
\begin{figure}[th]
\contcaption{\emph{(On two previous pages)} First scan of R1 (a), R2 (d), R3 (g) and R4 (j)
 immunostaining in combination with front views of the 3D models
 coloured for shape diameter (b, e, h, k) and connectivity visualisation
 (c, f, i, l). In (b), (e), (h), and (k) a shape diameter below \SI{20}{\micro\meter} is
 depicted in red and above \SI{40}{\micro\meter} in green. A transition from red to
 green occurs in microvessels of shape diameters from \SI{20}{\micro\meter} to \SI{40}{\micro\meter} with middle at \SI{23.5}{\micro\meter}. 
 In (c), (i), and (l) the largest continuous microvessel network is depicted in light blue and all smaller networks are green. In (f)
 there are several large networks, all coloured in blue. Small
 structures sized between \SI{50}{\micro\meter} and \SI{12.5}{\micro\meter} are red in (c), (f), (i), and
 (l), and all structures with a diameter less than \SI{12.5}{\micro\meter} in any
 dimension are omitted. (b, c) R1; (e, f) R2; (h, i) R3; (k, l) R4. Scale
 bar for all images: \SI{200}{\micro\meter}.}
\label{fig:km-4-caption}
\end{figure}

\sidebysidecaption实际上没有关系,但为了完整性:

\newcommand{\sidebysidecaption}[4]{%
\RaggedRight%
% https://tex.stackexchange.com/questions/29143/caption-on-the-side-of-a-figure
  \begin{minipage}[t]{#1}
    \vspace*{0pt}
    #3
  \end{minipage}
  % \mbox{}\\[-\baselineskip]
  \hfill%
  \begin{minipage}[t]{#2}
    \vspace*{0pt}
    #4
\end{minipage}%
% \mbox{}\\[-\baselineskip]
}

上面的生产代码需要:

\usepackage[font=footnotesize,labelfont=sf,textfont=sf]{subfig}

\usepackage[footnotes]{ragged2e} % for RaggedRight
%% it is used with microtype
%% http://tex.stackexchange.com/questions/134303/does-combining-microtype-with-ragged-right-make-any-sense
\setlength\RaggedRightRightskip{1pt plus 2em minus 1pt} % default is: 0pt plus 2em

最终结果如下:

示例截图

答案3

我支持“Mr. Zarko”尤其是 Elsevier 格式 && 它也支持其他格式 &&&&&& 如果您正在使用 overleaf 那么它对我非常有帮助。

Extra Package require:-#### 
%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{caption}
\usepackage{subcaption}
%%%%%%%%%%%%%%%%%%%%%%%%

总结“扎科先生”的回答

\begin{figure}[h!]
    \centering
     \begin{subfigure}{0.6\textwidth}
     \centering
     .
     .
     \end{subfigure}
     \hfill
     \begin{subfigure}{0.6\textwidth}
     \centering
     .
     .
     \end{subfigure}
     .
     .
\end{figure}
\begin{figure}[ht]\ContinuedFloat
    \centering
     \begin{subfigure}{0.6\textwidth}
     \centering
     .
     .
     \end{subfigure}
     \hfill
     \begin{subfigure}{0.6\textwidth}
     \centering
     .
     .
     \end{subfigure}
     .
     .
\end{figure}

笔记:

    1. 缩进很重要(例如:- \hfill 和 \end{figure} 在一行)。

相关内容