我需要在单个页面上使用这样的布局,没有任何其他文本或浮动内容。
| figure 1a | figure 1b |
Caption for Figure 1
| figure 2a | figure 2b |
Caption for Figure 2
有人知道该怎么处理它吗?
答案1
如果您对每个子图的单独子标题不感兴趣,那么您只需执行以下操作即可:
\documentclass{article}
\usepackage{lipsum,graphicx,afterpage}
\begin{document}
\lipsum[1-3]
\afterpage{\clearpage}% To make sure the image appears on the following page
\begin{figure}[p]
\centering
\null\hfill%
\includegraphics[width=.3\linewidth]{example-image-a}%
\hfill%
\includegraphics[width=.3\linewidth]{example-image-b}%
\hfill\null%
\caption{This is the first figure}
\null\hfill%
\includegraphics[width=.3\linewidth]{example-image-b}%
\hfill%
\includegraphics[width=.3\linewidth]{example-image-a}%
\hfill\null%
\caption{This is the second figure}
\end{figure}
\lipsum[4-10]
\end{document}
\hfill
s 拉伸每个子浮动元素旁边的空间,类似于减少两个子图之间的空间(和\hspace*{\fill}
)。
如果你还想要子标题,那么你需要包含一个提供该功能的包。下面是使用subcaption
包裹:
\usepackage{subcaption}
%...
\begin{figure}[p]
\centering
\null\hfill%
\subcaptionbox{sub 1a}
{\includegraphics[width=.3\linewidth]{example-image-a}}%
\hfill%
\subcaptionbox{sub 1b}
{\includegraphics[width=.3\linewidth]{example-image-b}}%
\hfill\null%
\caption{This is the first figure}
\null\hfill%
\subcaptionbox{sub 2a}
{\includegraphics[width=.3\linewidth]{example-image-b}}%
\hfill%
\subcaptionbox{sub 2b}
{\includegraphics[width=.3\linewidth]{example-image-a}}%
\hfill\null%
\caption{This is the second figure}
\end{figure}