我正在尝试将多个子图放入 3 列。我要显示大量的图。当然,为了让读者在文章中看到这些图,我试图在一页中放入 9 或 12 个图。但是使用子图时,这些图会进入页脚区域和边距区域。如何克服这个问题,以免发生这种情况。建议一种排列这些图的方法,使它们在多个页面中都能漂亮地呈现。
我的代码如下:(针对 12 幅图像)float
、、、subcaption
所有包都在序言中caption
。graphicx
\begin{figure}[H]
\centering
\begin{subfigure}{0.3\textwidth}
\centering
\includegraphics[height=1.8in]{images/bfly-primary/2.png}
\caption{2 by 2}
\end{subfigure}
\hfill
\begin{subfigure}{0.3\textwidth}
\centering
\includegraphics[height=1.8in]{images/bfly-primary/3.png}
\caption{3 by 3}
\end{subfigure}
\hfill
\begin{subfigure}{0.3\textwidth}
\centering
\includegraphics[height=1.8in]{images/bfly-primary/4.png}
\caption{4 by 4}
\end{subfigure}
\begin{subfigure}{0.3\textwidth}
\centering
\includegraphics[height=1.8in]{images/bfly-primary/5.png}
\caption{5 by 5}
\end{subfigure}
\hfill
\begin{subfigure}{0.3\textwidth}
\centering
\includegraphics[height=1.8in]{images/bfly-primary/6.png}
\caption{6 by 6}
\end{subfigure}
\hfill
\begin{subfigure}{0.3\textwidth}
\centering
\includegraphics[height=1.8in]{images/bfly-primary/7.png}
\caption{7 by 7}
\end{subfigure}
\begin{subfigure}{0.3\textwidth}
\centering
\includegraphics[height=1.8in]{images/bfly-primary/8.png}
\caption{8 by 8}
\end{subfigure}
\hfill
\begin{subfigure}{0.3\textwidth}
\centering
\includegraphics[height=1.8in]{images/bfly-primary/9.png}
\caption{9 by 9}
\end{subfigure}
\hfill
\begin{subfigure}{0.3\textwidth}
\centering
\includegraphics[height=1.8in]{images/bfly-primary/10.png}
\caption{10 by 10}
\end{subfigure}
\begin{subfigure}[hb]{0.3\textwidth}
\centering
\includegraphics[height=1.8in]{images/bfly-primary/11.png}
\caption{11 by 11}
\end{subfigure}
\hfill
\begin{subfigure}[hb]{0.3\textwidth}
\centering
\includegraphics[height=1.8in]{images/bfly-primary/12.png}
\caption{12 by 12}
\end{subfigure}
\hfill
\begin{subfigure}[hb]{0.3\textwidth}
\centering
\includegraphics[height=1.8in]{images/bfly-primary/15p.png}
\caption{15 by 15}
\end{subfigure}
\begin{subfigure}[t]{0.3\textwidth}
\centering
\includegraphics[height=1.8in]{images/bfly-primary/20p.png}
\caption{20 by 20}
\end{subfigure}
\hfill
\begin{subfigure}[t]{0.3\textwidth}
\centering
\includegraphics[height=1.8in]{images/bfly-primary/25p.png}
\caption{25 by 25}
\end{subfigure}
\hfill
\begin{subfigure}[t]{0.3\textwidth}
\centering
\includegraphics[height=1.8in]{images/bfly-primary/30p.png}
\caption{30 by 30}
\end{subfigure}
\end{figure}
答案1
但是使用子图时,图形会进入页脚区域和边距区域。
您需要为图表指定一个目标宽度。我建议您选择 的\linewidth
可选参数中指定的目标宽度\includegraphics
。而且,除非您的纸张尺寸异常高,否则 5 行图表不可能放在一页上。我建议您在一页上放置 4 行图表,在下一页上放置 1 行图表,\ContinuedFloat
在第二个环境的开头使用指令figure
,以继续对图形和子图进行编号。
demo
请确保在实际文档中省略文档类选项。
\documentclass[demo]{article} % remove 'demo' option in real document
\usepackage[letterpaper,margin=1in]{geometry}
% or maybe \usepackage[a4paper,margin=2.5cm]{geometry}
\usepackage{subcaption,graphicx}
\usepackage{lipsum} % filler text
\begin{document}
\begin{figure}[p!]
\setkeys{Gin}{width=\linewidth,height=1.8in} % global placement options
\caption{Some graphics}
\begin{subfigure}{0.32\textwidth}
\includegraphics{images/bfly-primary/2.png}
\caption{2 by 2}
\end{subfigure}%
\hfill
\begin{subfigure}{0.32\textwidth}
\includegraphics{images/bfly-primary/3.png}
\caption{3 by 3}
\end{subfigure}%
\hfill
\begin{subfigure}{0.32\textwidth}
\includegraphics{images/bfly-primary/4.png}
\caption{4 by 4}
\end{subfigure}
\medskip
\begin{subfigure}{0.32\textwidth}
\includegraphics{images/bfly-primary/5.png}
\caption{5 by 5}
\end{subfigure}%
\hfill
\begin{subfigure}{0.32\textwidth}
\includegraphics{images/bfly-primary/6.png}`
\caption{6 by 6}
\end{subfigure}%
\hfill
\begin{subfigure}{0.32\textwidth}
\includegraphics{images/bfly-primary/7.png}
\caption{7 by 7}
\end{subfigure}
\medskip
\begin{subfigure}{0.32\textwidth}
\includegraphics{images/bfly-primary/8.png}
\caption{8 by 8}
\end{subfigure}%
\hfill
\begin{subfigure}{0.32\textwidth}
\includegraphics{images/bfly-primary/9.png}
\caption{9 by 9}
\end{subfigure}%
\hfill
\begin{subfigure}{0.32\textwidth}
\includegraphics{images/bfly-primary/10.png}
\caption{10 by 10}
\end{subfigure}
\medskip
\begin{subfigure}{0.32\textwidth}
\includegraphics{images/bfly-primary/11.png}
\caption{11 by 11}
\end{subfigure}%
\hfill
\begin{subfigure}{0.32\textwidth}
\includegraphics{images/bfly-primary/12.png}
\caption{12 by 12}
\end{subfigure}%
\hfill
\begin{subfigure}{0.32\textwidth}
\includegraphics{images/bfly-primary/15p.png}
\caption{15 by 15}
\end{subfigure}
\end{figure}
\clearpage
\begin{figure}[ht!]
\ContinuedFloat
\setkeys{Gin}{width=\linewidth,height=1.8in} % global placement options
\caption{Some graphics, cont'd}
\begin{subfigure}{0.32\textwidth}
\includegraphics{images/bfly-primary/20p.png}
\caption{20 by 20}
\end{subfigure}%
\hfill
\begin{subfigure}{0.32\textwidth}
\includegraphics{images/bfly-primary/25p.png}
\caption{25 by 25}
\end{subfigure}%
\hfill
\begin{subfigure}{0.32\textwidth}
\includegraphics{images/bfly-primary/30p.png}
\caption{30 by 30}
\end{subfigure}
\end{figure}
\lipsum[1-2] % filler text
\end{document}
答案2
使用\ContinuedFloat
(caption 包)可以将每行放入单独的浮动中。\medskip
行的插入将由 分隔\floatsep
。这在放置方面提供了更多的灵活性。
\documentclass[demo]{article} % remove 'demo' option in real document
\usepackage[letterpaper,margin=1in]{geometry}
% or maybe \usepackage[a4paper,margin=2.5cm]{geometry}
\usepackage{subcaption,graphicx}
\usepackage{lipsum} % filler text
\begin{document}
\begin{figure}[bp]
\caption{Some graphics}
\begin{subfigure}{0.32\textwidth}
\includegraphics{images/bfly-primary/2.png}
\caption{2 by 2}
\end{subfigure}%
\hfill
\begin{subfigure}{0.32\textwidth}
\includegraphics{images/bfly-primary/3.png}
\caption{3 by 3}
\end{subfigure}%
\hfill
\begin{subfigure}{0.32\textwidth}
\includegraphics{images/bfly-primary/4.png}
\caption{4 by 4}
\end{subfigure}
\end{figure}
\begin{figure}[tbp!]
\ContinuedFloat
\begin{subfigure}{0.32\textwidth}
\includegraphics{images/bfly-primary/5.png}
\caption{5 by 5}
\end{subfigure}%
\hfill
\begin{subfigure}{0.32\textwidth}
\includegraphics{images/bfly-primary/6.png}`
\caption{6 by 6}
\end{subfigure}%
\hfill
\begin{subfigure}{0.32\textwidth}
\includegraphics{images/bfly-primary/7.png}
\caption{7 by 7}
\end{subfigure}
\end{figure}
\begin{figure}[tbp!]
\ContinuedFloat
\begin{subfigure}{0.32\textwidth}
\includegraphics{images/bfly-primary/8.png}
\caption{8 by 8}
\end{subfigure}%
\hfill
\begin{subfigure}{0.32\textwidth}
\includegraphics{images/bfly-primary/9.png}
\caption{9 by 9}
\end{subfigure}%
\hfill
\begin{subfigure}{0.32\textwidth}
\includegraphics{images/bfly-primary/10.png}
\caption{10 by 10}
\end{subfigure}
\end{figure}
\begin{figure}[tbp!]
\ContinuedFloat
\begin{subfigure}{0.32\textwidth}
\includegraphics{images/bfly-primary/11.png}
\caption{11 by 11}
\end{subfigure}%
\hfill
\begin{subfigure}{0.32\textwidth}
\includegraphics{images/bfly-primary/12.png}
\caption{12 by 12}
\end{subfigure}%
\hfill
\begin{subfigure}{0.32\textwidth}
\includegraphics{images/bfly-primary/15p.png}
\caption{15 by 15}
\end{subfigure}
\end{figure}
\begin{figure}[tbp!]
\ContinuedFloat
\begin{subfigure}{0.32\textwidth}
\includegraphics{images/bfly-primary/20p.png}
\caption{20 by 20}
\end{subfigure}%
\hfill
\begin{subfigure}{0.32\textwidth}
\includegraphics{images/bfly-primary/25p.png}
\caption{25 by 25}
\end{subfigure}%
\hfill
\begin{subfigure}{0.32\textwidth}
\includegraphics{images/bfly-primary/30p.png}
\caption{30 by 30}
\end{subfigure}
\end{figure}
\lipsum[1-3]
\end{document}
此版本使用\label
和\pageref
来自动显示“从第...页继续”通知。需要运行两次才能工作(辅助文件)。
\documentclass[demo]{article} % remove 'demo' option in real document
\usepackage[letterpaper,margin=1in]{geometry}
% or maybe \usepackage[a4paper,margin=2.5cm]{geometry}
\usepackage{subcaption,graphicx}
\usepackage{lipsum} % filler text
\usepackage{refcount}% or hyperref
\newcounter{figurerow}[figure]
\newcommand{\ContinuedNotice}{%
\edef\lastpage{\getpagerefnumber{fig.\thefigure.\thefigurerow}}%
\refstepcounter{figurerow}%
\label{fig.\thefigure.\thefigurerow}%
\edef\thispage{\getpagerefnumber{fig.\thefigure.\thefigurerow}}%
\ifnum\getpagerefnumber{fig.\thefigure.1}=\thispage\relax
\else
\ifnum\lastpage=\thispage\relax
\else
\centerline{Continued from page \lastpage}
\par\medskip
\fi
\fi}
\begin{document}
\begin{figure}[bp]
\caption{Some graphics}
\ContinuedNotice% setup
\begin{subfigure}{0.32\textwidth}
\includegraphics{images/bfly-primary/2.png}
\caption{2 by 2}
\end{subfigure}%
\hfill
\begin{subfigure}{0.32\textwidth}
\includegraphics{images/bfly-primary/3.png}
\caption{3 by 3}
\end{subfigure}%
\hfill
\begin{subfigure}{0.32\textwidth}
\includegraphics{images/bfly-primary/4.png}
\caption{4 by 4}
\end{subfigure}
\end{figure}
\begin{figure}[tbp!]
\ContinuedFloat
\ContinuedNotice
\begin{subfigure}{0.32\textwidth}
\includegraphics{images/bfly-primary/5.png}
\caption{5 by 5}
\end{subfigure}%
\hfill
\begin{subfigure}{0.32\textwidth}
\includegraphics{images/bfly-primary/6.png}`
\caption{6 by 6}
\end{subfigure}%
\hfill
\begin{subfigure}{0.32\textwidth}
\includegraphics{images/bfly-primary/7.png}
\caption{7 by 7}
\end{subfigure}
\end{figure}
\begin{figure}[tbp!]
\ContinuedFloat
\ContinuedNotice
\begin{subfigure}{0.32\textwidth}
\includegraphics{images/bfly-primary/8.png}
\caption{8 by 8}
\end{subfigure}%
\hfill
\begin{subfigure}{0.32\textwidth}
\includegraphics{images/bfly-primary/9.png}
\caption{9 by 9}
\end{subfigure}%
\hfill
\begin{subfigure}{0.32\textwidth}
\includegraphics{images/bfly-primary/10.png}
\caption{10 by 10}
\end{subfigure}
\end{figure}
\begin{figure}[tbp!]
\ContinuedFloat
\ContinuedNotice
\begin{subfigure}{0.32\textwidth}
\includegraphics{images/bfly-primary/11.png}
\caption{11 by 11}
\end{subfigure}%
\hfill
\begin{subfigure}{0.32\textwidth}
\includegraphics{images/bfly-primary/12.png}
\caption{12 by 12}
\end{subfigure}%
\hfill
\begin{subfigure}{0.32\textwidth}
\includegraphics{images/bfly-primary/15p.png}
\caption{15 by 15}
\end{subfigure}
\end{figure}
\begin{figure}[tbp!]
\ContinuedFloat
\ContinuedNotice
\begin{subfigure}{0.32\textwidth}
\includegraphics{images/bfly-primary/20p.png}
\caption{20 by 20}
\end{subfigure}%
\hfill
\begin{subfigure}{0.32\textwidth}
\includegraphics{images/bfly-primary/25p.png}
\caption{25 by 25}
\end{subfigure}%
\hfill
\begin{subfigure}{0.32\textwidth}
\includegraphics{images/bfly-primary/30p.png}
\caption{30 by 30}
\end{subfigure}
\end{figure}
\lipsum[1-3]
\end{document}