我有以下具有 4 个子图的图形代码:
\documentclass{article}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\begin{document}
\begin{figure}[b]
\centering
\begin{subfigure}[b]{\textwidth}
\includegraphics[width=\textwidth]{./plots/arm1.pdf}
\subcaption{$Q^{*}$ values for arm 1}
\label{fig:arm1}
\end{subfigure}
~
\begin{subfigure}[b]{\textwidth}
\includegraphics[width=\textwidth]{./plots/arm2.pdf}
\subcaption{$Q^{*}$ values for arm 2}
\label{fig:arm2}
\end{subfigure}
~
\begin{subfigure}[b]{\textwidth}
\includegraphics[width=\textwidth]{./plots/arm3.pdf}
\subcaption{$Q^{*}$ values for arm 3}
\label{fig:arm3}
\end{subfigure}
~
\begin{subfigure}[b]{\textwidth}
\includegraphics[width=\textwidth]{./plots/arm4.pdf}
\subcaption{$Q^{*}$ values for arm 4}
\label{fig:arm4}
\end{subfigure}
\caption{$Q^{*}$ values for different arms}
\label{fig:arms}
\end{figure}
\end{document}
这导致这一页
但这样,4 个子图太大,无法放在 1 页上。我想将其分成 2 页,保留子标题a
, b
, ... 我该怎么做?
答案1
\begin{figure}
将您的图形拆分为两个图形,然后在添加命令后立即拆分第二个图形\ContinuedFloat
。这样,两个图形将具有相同的标题编号,但子标题编号是从上一个图形继续的:
\documentclass{article}
\usepackage{graphicx}
\usepackage{caption}
\usepackage[skip=0.5ex]{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}
\lipsum[1]
\begin{figure}[!b]
\centering
\begin{subfigure}{0.6\textwidth}
\includegraphics[width=\linewidth]{example-image}
\subcaption{$Q^{*}$ values for arm 1}
\label{fig:arm1}
\end{subfigure}
\medskip
\begin{subfigure}{0.6\textwidth}
\includegraphics[width=\linewidth]{example-image}
\subcaption{$Q^{*}$ values for arm 2}
\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=\linewidth]{example-image}
\subcaption{$Q^{*}$ values for arm 3}
\label{fig:arm3}
\end{subfigure}
\medskip
\begin{subfigure}{0.6\textwidth}
\includegraphics[width=\linewidth]{example-image}
\subcaption{$Q^{*}$ values for arm 4}
\label{fig:arm4}
\end{subfigure}
\caption[]{$Q^{*}$ values for different arms (cont.)}
\label{fig:arms}
\end{figure}
\lipsum[2-3]
\end{document}