我有许多图像需要在多页上显示,每页并排显示 4 行 2 幅图像(总共 8 幅)。
但是,我不希望最后一页(有时少于 4 行)的图像居中,而是按从上到下的顺序排列。这可以通过指定 来实现\begin{figure}[ht]
。
前 2 幅图像的代码(另外重复 5 次,共 7 行):
\documentclass[]{article}
\usepackage{floatrow}
\usepackage{graphicx}
\begin{figure}[ht]
\begin{floatrow}
\begin{minipage}[t]{0.4\linewidth}
\includegraphics[width=120pt]{image1.pdf}
\end{minipage} \hspace{-55pt}
\begin{minipage}[t]{0.8\linewidth}\vspace{20pt}
\includegraphics[width=370pt]{image2.pdf}
\newline
\vspace{-50pt}
\end{minipage}
\end{floatrow}
\end{figure}
\begin{figure}[ht]
\begin{floatrow}
\begin{minipage}[t]{0.4\linewidth}
\includegraphics[width=120pt]{image3.pdf}
\end{minipage}
\hspace{-55pt}
\begin{minipage}[t]{0.8\linewidth}\vspace{20pt}
\includegraphics[width=370pt]{image4.pdf}
\newline
\vspace{-50pt}
\end{minipage}
\end{floatrow}
\end{figure}
但结果图像排列不正确,第一页只有 3 张图片,第二页有 4 张图片:
所需的输出是完全占据页面(第一页有 4 张图片),然后如果剩余的图片少于 4 张,则在后续页面中从上到下占据:
答案1
- 您没有提供有关您的文档的任何信息。
- 一行中所有元素的宽度总和
minipage
大于文本宽度。这会导致页面上的图形放置出现问题。 - 我宁愿至少对每行使用带有数字的行和 s ,而不是
float
行和s:minipage
tabular
\documentclass{article}
\usepackage[showframe]{geometry}
\usepackage[demo]{graphicx}
\setcounter{totalnumber}{4} % 2 may work better
\renewcommand{\textfraction}{0.05} % allow minimal text w. figs
\begin{document}
\begin{figure}[h]
\setkeys{Gin}{width=\linewidth}
\begin{tabular}{@{} p{\dimexpr0.25\linewidth-\tabcolsep}
p{\dimexpr0.75\linewidth-\tabcolsep} @{}}
\includegraphics{image1.pdf}
& \includegraphics{image2.pdf}
\end{tabular}
\end{figure}
\begin{figure}[h]
\setkeys{Gin}{width=\linewidth}
\begin{tabular}{@{} p{\dimexpr0.25\linewidth-\tabcolsep}
p{\dimexpr0.75\linewidth-\tabcolsep} @{}}
\includegraphics{image3.pdf}
& \includegraphics{image4.pdf}
\end{tabular}
\end{figure}
\begin{figure}[h]
\setkeys{Gin}{width=\linewidth}
\begin{tabular}{@{} p{\dimexpr0.25\linewidth-\tabcolsep}
p{\dimexpr0.75\linewidth-\tabcolsep} @{}}
\includegraphics{image5.pdf}
& \includegraphics{image6.pdf}
\end{tabular}
\end{figure}
\begin{figure}[h]
\setkeys{Gin}{width=\linewidth}
\begin{tabular}{@{} p{\dimexpr0.25\linewidth-\tabcolsep}
p{\dimexpr0.75\linewidth-\tabcolsep} @{}}
\includegraphics{image7.pdf}
& \includegraphics{image8.pdf}
\end{tabular}
\end{figure}
\clearpage
\begin{figure}[h]
\setkeys{Gin}{width=\linewidth}
\begin{tabular}{@{} p{\dimexpr0.25\linewidth-\tabcolsep}
p{\dimexpr0.75\linewidth-\tabcolsep} @{}}
\includegraphics{image9.pdf}
& \includegraphics{image10.pdf}
\end{tabular}
\end{figure}
\begin{figure}[h]
\setkeys{Gin}{width=\linewidth}
\begin{tabular}{@{} p{\dimexpr0.25\linewidth-\tabcolsep}
p{\dimexpr0.75\linewidth-\tabcolsep} @{}}
\includegraphics{image7.pdf}
& \includegraphics{image11.pdf}
\end{tabular}
\end{figure}
\begin{figure}[h]
\setkeys{Gin}{width=\linewidth}
\begin{tabular}{@{} p{\dimexpr0.25\linewidth-\tabcolsep}
p{\dimexpr0.75\linewidth-\tabcolsep} @{}}
\includegraphics{image9.pdf}
& \includegraphics{image12.pdf}
\end{tabular}
\end{figure}
\end{document}
- 不清楚为什么你喜欢将每对数字作为独立的浮点数。您应该考虑将四行或更多行数字合并为一个浮点数:
\documentclass{article}
\usepackage[showframe]{geometry}
\usepackage[demo]{graphicx}
\begin{document}
\begin{figure}[ht]
\setkeys{Gin}{width=\linewidth}
\begin{tabular}{@{} p{\dimexpr0.25\linewidth-\tabcolsep}
p{\dimexpr0.75\linewidth-\tabcolsep} @{}}
\includegraphics{image1.pdf}
& \includegraphics{image2.pdf} \\
\includegraphics{image3.pdf}
& \includegraphics{image4.pdf} \\
\includegraphics{image5.pdf}
& \includegraphics{image6.pdf} \\
\includegraphics{image7.pdf}
& \includegraphics{image8.pdf}
\end{tabular}
\end{figure}
\begin{figure}[ht]
\setkeys{Gin}{width=\linewidth}
\begin{tabular}{@{} p{\dimexpr0.25\linewidth-\tabcolsep}
p{\dimexpr0.75\linewidth-\tabcolsep} @{}}
\includegraphics{image9.pdf}
& \includegraphics{image10.pdf} \\
\includegraphics{image7.pdf}
& \includegraphics{image11.pdf} \\
\includegraphics{image9.pdf}
& \includegraphics{image12.pdf} \\
\end{tabular}
\end{figure}
\end{document}
如果您喜欢为图表添加标题,则需要将其放在单独的表格行中。例如:
\begin{figure}[ht]
\setkeys{Gin}{width=\linewidth}
\begin{tabular}{@{} p{\dimexpr0.25\linewidth-\tabcolsep}
p{\dimexpr0.75\linewidth-\tabcolsep} @{}}
\includegraphics{image1.pdf}
& \includegraphics{image2.pdf} \\
\caption{figure 1}
& \caption{figure 2} \\
% rest of float's body