问题:我有一组图像需要一起显示在一页上。它们是两张、三张、四张或五张一组。有些图像应该水平分组/显示在一页上,标题居中,而其他图像应该垂直分组/显示。对于某些组,间距应该非常小但明显。
问题:我如何控制图像的间距或定位以使它们彼此相邻,正如描述的那样?
示例(针对我使用的每个包):
% BEGIN PREAMBLE
\documentclass[fleqn,12pt]{memoir}
\pagestyle{headings}
\setlength{\headheight}{14.5pt}
\usepackage{calc}
\makeevenhead{headings}{}{}{Some Images}
\makeoddhead{headings}{Some Images}{}{}
\makeevenfoot{headings}{}{}{\thepage}
\makeoddfoot{headings}{\thepage}{}{}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{latexsym}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{microtype}
\usepackage{booktabs}
\usepackage{enumitem}
\addtolength{\oddsidemargin}{-.875in}
\addtolength{\evensidemargin}{-.875in}
\addtolength{\textwidth}{1.75in}
\addtolength{\topmargin}{-.875in}
\addtolength{\textheight}{1.75in}
% END PREAMBLE
\begin{document}\thispagestyle{empty}
\vspace*{200pt}
\begin{center}
\Huge{\textbf{Some Images}}
\end{center}
\newpage
\vspace*{200pt}
\noindent Some introductory paragraph goes here.
\bigskip
A second introductory paragraph here.
\newpage
\vspace*{75pt}
\begin{center}
\includegraphics[scale=0.60]{image file name #1}
\captionof*{figure}{Image Name #1}
\end{center}
\begin{center}
\includegraphics[scale=0.90]{Image file name #2}
\captionof*{figure}{Image Name #2}
\end{center}
\end{document}
答案1
首先,我建议加载blindtext
包并用它\Blinddocument
来测试布局。如果插入\blindmathtrue
,虚拟文本也包含方程式。
您可以轻松地在页面上分布图像。逐行堆叠图像(没有双空行),Latex 会将所有图像放在一起。只需确保它们适合宽度即可。此外,副标题帮助添加字幕。下面的示例基于\subcaptionbox
但还有许多其他解决方案。
制作水平组时,有几种可能的选择。它们会导致不同的排列。下面讨论的所有情况都假设通过\centering
宏进行居中:
- 不要在图像后添加任何内容,让 LaTeX 添加空格
\subcaptionbox{...}{...}
% ...
\subcaptionbox{...}{...}
如果要增加间距,请使用\hspace{}
等\qquad
。
- 在图像之前、之后和图像之间以相等的间距分布图像;在这里你应该
\hfil
在除了最后一幅图像之外的每一幅图像之后附加
\subcaptionbox{...}{...}\hfil
\subcaptionbox{...}{...}\hfil
% ...
\subcaptionbox{...}{...}
- 与前一种情况类似,以相等的间距分布图像,但让图像贴近边距;只需附加
\hfill
而不是\hfil
。
下面是一个带有示例的代码。 行geometry
仅用于演示,它生成一个参考框架来显示当前布局。sidewaysfigure
(包rotating
)是垂直呈现内容的一种方法。您应该使用\clearpage
而不是\newpage
。我还建议使用figure
浮动,以便让 LaTeX 优化页面。
\documentclass[fleqn,12pt]{memoir}
% \usepackage{calc}
% \usepackage{amssymb}
% \usepackage{amsmath}
\usepackage{graphicx}
\usepackage{subcaption}
% \usepackage{microtype}
% \usepackage{booktabs}
% \usepackage{enumitem}
\usepackage{rotating}
\usepackage{blindtext}
\makeevenhead{headings}{}{}{Some Images}
\makeoddhead{headings}{Some Images}{}{}
\makeevenfoot{headings}{}{}{\thepage}
\makeoddfoot{headings}{\thepage}{}{}
\addtolength{\oddsidemargin}{-.875in}
\addtolength{\evensidemargin}{-.875in}
\addtolength{\textwidth}{1.75in}
\addtolength{\topmargin}{-.875in}
\addtolength{\textheight}{1.75in}
\pagestyle{headings}
\setlength{\headheight}{14.5pt}
% END PREAMBLE
\usepackage[pass,showframe]{geometry}
%%% DOCUMENT
\begin{document}
\thispagestyle{empty}
\vspace*{200pt}
\begin{center}
\Huge{\textbf{Some Images}}
\end{center}
\blindmathtrue\Blinddocument
\begin{figure}[tbh]
\setkeys{Gin}{width=0.3\linewidth} % all immages in the group gain optioanal arguments
\centering
\subcaptionbox{Image Name 1}{\includegraphics{example-image-a}}\qquad
\subcaptionbox{Image Name 2}{\includegraphics{example-image-b}}
\caption{Group of two images}\label{fig:group-imageb1}
\end{figure}
\blindtext
\begin{figure}[tbh]
\setkeys{Gin}{width=0.3\linewidth} % all immages in the group gain optioanal arguments
\centering
\subcaptionbox{Image Name 1\label{fig:11}}{\includegraphics{example-image-a}}\hfil
\subcaptionbox{Image Name 2\label{fig:12}}{\includegraphics{example-image-b}}\hfil
\subcaptionbox{Image Name 3\label{fig:13}}{\includegraphics{example-image-c}}
\caption{Group of three images}\label{fig:group-images2}
\end{figure}
\blindtext
\begin{figure}[tbh]
\setkeys{Gin}{width=0.18\linewidth}
\centering
\subcaptionbox{Image 1\label{fig:21}}{\includegraphics{example-image-duck}}\hfill
\subcaptionbox{Image 2\label{fig:22}}{\includegraphics{example-image-duck}}\hfill
\subcaptionbox{Image 3\label{fig:23}}{\includegraphics{example-image-duck}}\hfill
\subcaptionbox{Image 4\label{fig:24}}{\includegraphics{example-image-duck}}\hfill
\subcaptionbox{Image 5\label{fig:25}}{\includegraphics{example-image-duck}}
\caption{Group of five images}\label{fig:group-images-3}
\end{figure}
\blindtext
\begin{sidewaysfigure}[tbh]
\setkeys{Gin}{width=0.14\linewidth}
\captionsetup{position=bottom,belowskip=3ex}
\centering
\subcaptionbox{Image 1}{\includegraphics{example-image}}\hfill
\subcaptionbox{Image 2}{\includegraphics{example-image}}\hfill
\subcaptionbox{Image 3}{\includegraphics{example-image}}\hfill
\subcaptionbox{Image 4}{\includegraphics{example-image}}\hfill
\subcaptionbox{Image 5}{\includegraphics{example-image}}\hfill
\subcaptionbox{Image 6}{\includegraphics{example-image}}
\par
\subcaptionbox{Image 7}{\includegraphics{example-image}}\hfill
\subcaptionbox{Image 8}{\includegraphics{example-image}}\hfill
\subcaptionbox{Image 9}{\includegraphics{example-image}}\hfill
\subcaptionbox{Image 10}{\includegraphics{example-image}}\hfill
\subcaptionbox{Image 11}{\includegraphics{example-image}}\hfill
\subcaptionbox{Image 12}{\includegraphics{example-image}}
\par
\subcaptionbox{Image 13}{\includegraphics{example-image}}\hfill
\subcaptionbox{Image 14}{\includegraphics{example-image}}\hfill
\subcaptionbox{Image 15}{\includegraphics{example-image}}\hfill
\subcaptionbox{Image 16}{\includegraphics{example-image}}\hfill
\subcaptionbox{Image 17}{\includegraphics{example-image}}\hfill
\subcaptionbox{Image 18}{\includegraphics{example-image}}
\caption{Grid of images}\label{fig:grid-images}
\end{sidewaysfigure}
Reference: figure~\ref{fig:11} and figure~\ref{fig:23}.
\end{document}