![强制图像网格单独位于页面中央](https://linux22.com/image/271667/%E5%BC%BA%E5%88%B6%E5%9B%BE%E5%83%8F%E7%BD%91%E6%A0%BC%E5%8D%95%E7%8B%AC%E4%BD%8D%E4%BA%8E%E9%A1%B5%E9%9D%A2%E4%B8%AD%E5%A4%AE.png)
我总是在处理图像时遇到同样的问题。有时我需要将一张图片单独放置在页面的中心,但它总是停留在页面顶部。我曾将一些图像用于环境minipage
。但现在我需要用 20 张图片的网格来执行此操作,但什么都不起作用。
\newpage
\begin{figure}[p]
\centering
\captionsetup[subfigure]{justification=raggedright}
\subcaptionbox*{0,1 s}{\includegraphics[width=1.2in,height=1.2in]{25.png}}\hspace{1em}
\subcaptionbox*{25 s}{\includegraphics[width=1.2in,height=1.2in]{26.png}}\hspace{1em}
\subcaptionbox*{750 s}{\includegraphics[width=1.2in,height=1.2in]{27.png}}\hspace{1em}
\subcaptionbox*{1618,55 s}{\includegraphics[width=1.2in,height=1.2in]{28.png}}\hspace{1em}
\subcaptionbox*{Al}{\includegraphics[width=0.15in,height=1.2in]{29.png}}\\
\subcaptionbox*{0,1 s}{\includegraphics[width=1.2in,height=1.2in]{30.png}}\hspace{1em}
\subcaptionbox*{25 s}{\includegraphics[width=1.2in,height=1.2in]{31.png}}\hspace{1em}
\subcaptionbox*{750 s}{\includegraphics[width=1.2in,height=1.2in]{32.png}}\hspace{1em}
\subcaptionbox*{1618,55 s}{\includegraphics[width=1.2in,height=1.2in]{33.png}}\hspace{1em}
\subcaptionbox*{Re}{\includegraphics[width=0.15in,height=1.2in]{34.png}}\\
\subcaptionbox*{0,1 s}{\includegraphics[width=1.2in,height=1.2in]{35.png}}\hspace{1em}
\subcaptionbox*{25 s}{\includegraphics[width=1.2in,height=1.2in]{36.png}}\hspace{1em}
\subcaptionbox*{750 s}{\includegraphics[width=1.2in,height=1.2in]{37.png}}\hspace{1em}
\subcaptionbox*{1618,55 s}{\includegraphics[width=1.2in,height=1.2in]{38.png}}\hspace{1em}
\subcaptionbox*{Ta}{\includegraphics[width=0.15in,height=1.2in]{39.png}}\\
\subcaptionbox*{0,1 s}{\includegraphics[width=1.2in,height=1.2in]{40.png}}\hspace{1em}
\subcaptionbox*{25 s}{\includegraphics[width=1.2in,height=1.2in]{41.png}}\hspace{1em}
\subcaptionbox*{750 s}{\includegraphics[width=1.2in,height=1.2in]{42.png}}\hspace{1em}
\subcaptionbox*{1618,55 s}{\includegraphics[width=1.2in,height=1.2in]{43.png}}\hspace{1em}
\subcaptionbox*{W}{\includegraphics[width=0.15in,height=1.2in]{44.png}}\\
\end{figure}
是否有一种“干净”的方法来对所有类型的图像执行此操作,因为这确实令人沮丧。
答案1
\documentclass{article}
\usepackage{float}
\usepackage{subcaption}
\usepackage[demo]{graphicx}
\usepackage[margin = 1in]{geometry}
\begin{document}
\vspace*{\fill}
\begin{figure}[p]
\centering
\captionsetup[subfigure]{justification=raggedright}
\begin{tabular}{ccccc}
\subcaptionbox*{0,1 s}{\includegraphics[width=1.2in,height=1.2in]{25.png}}&
\subcaptionbox*{25 s}{\includegraphics[width=1.2in,height=1.2in]{26.png}}&
\subcaptionbox*{750 s}{\includegraphics[width=1.2in,height=1.2in]{27.png}}&
\subcaptionbox*{1618,55 s}{\includegraphics[width=1.2in,height=1.2in]{28.png}}&
\subcaptionbox*{Al}{\includegraphics[width=0.15in,height=1.2in]{29.png}}\\
\subcaptionbox*{0,1 s}{\includegraphics[width=1.2in,height=1.2in]{30.png}}&
\subcaptionbox*{25 s}{\includegraphics[width=1.2in,height=1.2in]{31.png}}&
\subcaptionbox*{750 s}{\includegraphics[width=1.2in,height=1.2in]{32.png}}&
\subcaptionbox*{1618,55 s}{\includegraphics[width=1.2in,height=1.2in]{33.png}}&
\subcaptionbox*{Re}{\includegraphics[width=0.15in,height=1.2in]{34.png}}\\
\subcaptionbox*{0,1 s}{\includegraphics[width=1.2in,height=1.2in]{35.png}}&
\subcaptionbox*{25 s}{\includegraphics[width=1.2in,height=1.2in]{36.png}}&
\subcaptionbox*{750 s}{\includegraphics[width=1.2in,height=1.2in]{37.png}}&
\subcaptionbox*{1618,55 s}{\includegraphics[width=1.2in,height=1.2in]{38.png}}&
\subcaptionbox*{Ta}{\includegraphics[width=0.15in,height=1.2in]{39.png}}\\
\subcaptionbox*{0,1 s}{\includegraphics[width=1.2in,height=1.2in]{40.png}}&
\subcaptionbox*{25 s}{\includegraphics[width=1.2in,height=1.2in]{41.png}}&
\subcaptionbox*{750 s}{\includegraphics[width=1.2in,height=1.2in]{42.png}}&
\subcaptionbox*{1618,55 s}{\includegraphics[width=1.2in,height=1.2in]{43.png}}&
\subcaptionbox*{W}{\includegraphics[width=0.15in,height=1.2in]{44.png}}
\end{tabular}
\end{figure}
\vspace*{\fill}
\end{document}
我习惯\vspace*{\fill}
将图形垂直居中。我喜欢使用表格来处理这么多图形,但如果你不想,你也不需要。我使用了geometry
标准 1 英寸边距的包,一切都合适。你的第 5 张图片的宽度是0.15in
拼写错误吗?事实上,我认为这就是你想要的。
如果第五张图片的尺寸有拼写错误:
我必须将边距设置为.75in
。如果您希望对文档使用 1 英寸边距,则可以单独设置该页面的边距.75in
以使其也居中。
答案2
如果您的数字超出了右边距,则可能会出现部分问题。您没有包含完整的 MWE,因此无法检查。但是,如果右边距不是问题,这里有一种方法可以实现我认为您的目标。
在第一个图中,我使用了,只是为了显示它的工作原理。对于其余部分,为了简单起见,\includegraphics
我将其保留为。\rule
\documentclass{article}
\usepackage[oldsyntax]{stackengine}
\usepackage[demo]{graphicx}
\usepackage[letterpaper, portrait]{geometry}
% DEFINE TEXT LIMITS ON LETTER PAPER ACCORDING TO ARL STYLE.
\setlength\paperheight {11in}
\setlength\paperwidth {8.5in}
\setlength\textwidth {7in}
\setlength\oddsidemargin {-0.3in}
\setlength\evensidemargin {-0.3in}
\setlength\topmargin {-0.5in}
\setlength\textheight {9.0in}
\raggedbottom
\begin{document}
\def\stackalignment{l}
\def\myfiga{\stackunder[3pt]{%
\includegraphics[width=1.2in,height=1.2in]{demo}}{0,1 s}}
\def\myfigb{\stackunder[3pt]{\rule{1.2in}{1.2in}}{25 s}}
\def\myfigc{\stackunder[3pt]{\rule{1.2in}{1.2in}}{750 s}}
\def\myfigd{\stackunder[3pt]{\rule{1.2in}{1.2in}}{1618,55 s}}
\def\myfige{\stackunder[3pt]{\rule{1.2in}{1.2in}}{Al}}
\def\myfigf{\stackunder[3pt]{\rule{1.2in}{1.2in}}{0,1 s}}
\def\myfigg{\stackunder[3pt]{\rule{1.2in}{1.2in}}{25 s}}
\def\myfigh{\stackunder[3pt]{\rule{1.2in}{1.2in}}{750 s}}
\def\myfigi{\stackunder[3pt]{\rule{1.2in}{1.2in}}{1618,55 s}}
\def\myfigj{\stackunder[3pt]{\rule{1.2in}{1.2in}}{Re}}
\def\myfigk{\stackunder[3pt]{\rule{1.2in}{1.2in}}{0,1 s}}
\def\myfigl{\stackunder[3pt]{\rule{1.2in}{1.2in}}{25 s}}
\def\myfigm{\stackunder[3pt]{\rule{1.2in}{1.2in}}{750 s}}
\def\myfign{\stackunder[3pt]{\rule{1.2in}{1.2in}}{1618,55 s}}
\def\myfigo{\stackunder[3pt]{\rule{1.2in}{1.2in}}{Ta}}
\def\myfigp{\stackunder[3pt]{\rule{1.2in}{1.2in}}{0,1 s}}
\def\myfigq{\stackunder[3pt]{\rule{1.2in}{1.2in}}{25 s}}
\def\myfigr{\stackunder[3pt]{\rule{1.2in}{1.2in}}{750 s}}
\def\myfigs{\stackunder[3pt]{\rule{1.2in}{1.2in}}{1618,55 s}}
\def\myfigt{\stackunder[3pt]{\rule{1.2in}{1.2in}}{W}}
\Sstackgap=1em
\begin{figure}
\centering
\Lstackgap=1.45in
\Longstack{%
{\protect\myfiga} {\protect\myfigf} {\protect\myfigk} {\protect\myfigp}%
}%
\hspace{1em}%
\Longstack{%
{\protect\myfigb} {\protect\myfigg} {\protect\myfigl} {\protect\myfigq}%
}%
\hspace{1em}%
\Longstack{%
{\protect\myfigc} {\protect\myfigh} {\protect\myfigm} {\protect\myfigr}%
}%
\hspace{1em}%
\Longstack{%
{\protect\myfigd} {\protect\myfigi} {\protect\myfign} {\protect\myfigs}%
}
\hspace{1em}%
\Longstack{%
{\protect\myfige} {\protect\myfigj} {\protect\myfigo} {\protect\myfigt}%
}
\end{figure}
\end{document}
[编辑:此 MWE 使用过时的 stackengine 语法来设置 stackgap 长度(例如 \Sstackgap=1ex),这阻止了可缩放长度在字体大小更改下缩放。该软件包的第 2 版(提交于 2013 年 7 月 11 日)通过小的语法更改解决了该问题。]