我有三张图片,我想将它们对齐,使其中一张图像位于另外两张图像上方。以下是示例:
我该如何实现这一点?对于我的其他图形,我使用 subcaption 包,但我无法用它对齐图片。
感谢大家的回复!回答对我有用的是karlkoeller假设的:
\documentclass{article}
\usepackage{graphicx}
\usepackage{subcaption}
\begin{document}
\begin{figure}
\centering
\begin{subfigure}[b]{.45\linewidth}
\includegraphics[width=\linewidth]{example-image-a}
\caption{A mouse}\label{fig:mouse}
\end{subfigure}
\begin{subfigure}[b]{.45\linewidth}
\includegraphics[width=\linewidth]{example-image-b}
\caption{A gull}\label{fig:gull}
\end{subfigure}
\begin{subfigure}[b]{.45\linewidth}
\includegraphics[width=\linewidth]{example-image-c}
\caption{A tiger}\label{fig:tiger}
\end{subfigure}
\caption{Picture of animals}
\label{fig:animals}
\end{figure}
\end{document}
答案1
您已经在使用该subcaption
软件包,并且使用它非常简单。
这是您需要的代码
\documentclass{article}
\usepackage{graphicx}
\usepackage{subcaption}
\begin{document}
\begin{figure}
\centering
\begin{subfigure}[b]{.45\linewidth}
\includegraphics[width=\linewidth]{example-image-a}
\caption{A mouse}\label{fig:mouse}
\end{subfigure}
\begin{subfigure}[b]{.45\linewidth}
\includegraphics[width=\linewidth]{example-image-b}
\caption{A gull}\label{fig:gull}
\end{subfigure}
\begin{subfigure}[b]{.45\linewidth}
\includegraphics[width=\linewidth]{example-image-c}
\caption{A tiger}\label{fig:tiger}
\end{subfigure}
\caption{Picture of animals}
\label{fig:animals}
\end{figure}
\end{document}
输出:
如果你需要像图片中那样的子标题数字,你必须调整s里面的subfigure
计数器\setcounter{subfigure}{<num>}
subfigure
\documentclass{article}
\usepackage{graphicx}
\usepackage{subcaption}
\begin{document}
\begin{figure}
\centering
\begin{subfigure}[b]{.45\linewidth}
\includegraphics[width=\linewidth]{example-image-c}
\setcounter{subfigure}{2}%
\caption{A mouse}\label{fig:mouse}
\end{subfigure}
\begin{subfigure}[b]{.45\linewidth}
\includegraphics[width=\linewidth]{example-image-a}
\setcounter{subfigure}{0}%
\caption{A gull}\label{fig:gull}
\end{subfigure}
\begin{subfigure}[b]{.45\linewidth}
\includegraphics[width=\linewidth]{example-image-b}
\caption{A tiger}\label{fig:tiger}
\end{subfigure}
\caption{Picture of animals}
\label{fig:animals}
\end{figure}
\end{document}
输出:
答案2
在图形环境中,您可以启动表格环境,以便更好地控制空间分布。用子图填充选项卡。您甚至可以使用该multirow
包进行进一步的调整和控制。
\documentclass{article}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{multirow}
\begin{document}
\begin{figure}[h]
\centering
\begin{tabular}[c]{ccccc}
\multirow{2}{*}[14pt]{
\begin{subfigure}{0.45\textwidth}
\includegraphics[height=2cm, width=\textwidth]{example-image-b}
\caption{CEO fixed / total}
\label{fig:ceoa}
\end{subfigure}
}&
\begin{subfigure}[c]{0.11\textwidth}
\includegraphics[height=1cm, width=\textwidth]{example-image-a}
\label{fig:ceob}
\end{subfigure}&
\begin{subfigure}[c]{0.11\textwidth}
\includegraphics[height=1cm, width=\textwidth]{example-image-a}
\label{fig:ceoc}
\end{subfigure}&
\begin{subfigure}[c]{0.11\textwidth}
\includegraphics[height=1cm, width=\textwidth]{example-image-a}
\label{fig:ceoe}
\end{subfigure}&
\begin{subfigure}[c]{0.11\textwidth}
\includegraphics[height=1cm, width=\textwidth]{example-image-a}
\label{fig:cdfeod}
\end{subfigure}\\
&
\begin{subfigure}[c]{0.11\textwidth}
\includegraphics[height=1cm, width=\textwidth]{example-image-a}
\label{fig:caeob}
\end{subfigure}&
\begin{subfigure}[c]{0.11\textwidth}
\includegraphics[height=1cm, width=\textwidth]{example-image-a}
\label{fig:ceoac}
\end{subfigure}&
\begin{subfigure}[c]{0.11\textwidth}
\includegraphics[height=1cm, width=\textwidth]{example-image-a}
\label{fig:ceose}
\end{subfigure}&
\begin{subfigure}[c]{0.11\textwidth}
\includegraphics[height=1cm, width=\textwidth]{example-image-a}
\label{fig:ceod}
\end{subfigure}\\
\end{tabular}
\caption{Compensation measures}
\label{fig:ceo}
\end{figure}
\end{document}
答案3
使用该floatrow
包及其subfloatrow
环境相对容易:
\documentclass{article}
\usepackage{subcaption}
\usepackage{floatrow}
\usepackage{graphicx}
\usepackage[showframe]{geometry}
\begin{document}
\begin{figure}
\floatsetup{capposition = below, floatrowsep =qquad,}
\centering
\begin{subfloatrow}
\centering
\ffigbox[\textwidth]{\caption{The Death of Procris}}{%
\includegraphics[width=0.8\textwidth]{Piero_di_Cosimo_1}
}
\end{subfloatrow}
\vskip1cm
\begin{subfloatrow}
\ffigbox[0.5\textwidth]{\caption{Portrait of Simonetta Vespucci}}{%
\includegraphics[width=0.4\textwidth]{Piero_di_Cosimo_3}%
}
\ffigbox[0.5\textwidth]{\caption{Portrait of Simonetta Vespucci}}{%
\includegraphics[width=0.4\textwidth]{Piero_di_Cosimo_3}%
}
\end{subfloatrow}
\caption{Three paintings by Piero di Cosimo}
\label{PC}
\end{figure}
\end{document}
答案4
您可以使用 minipages 来指定图像的对齐方式。如果您先将图像放入框中,则可以使用 获取图像的宽度(应该是 minipage 的宽度)\wd
,即:
\documentclass{article}
\usepackage{subcaption}
\usepackage{graphicx}
\begin{document}
\begin{figure}
\newcommand*\FigVSkip{0.5em}
\newcommand*\FigHSkip{0.1em}
\newsavebox\FigBox
\centering
% Top image is centered, so no need to get width
\begin{minipage}{\textwidth}
\centering\includegraphics{a_mouse}
\subcaption{A mouse}
\end{minipage} \\[\FigVSkip]%
% Save first image in a box to get the width
\sbox{\FigBox}{\includegraphics{a_gull}}
\begin{minipage}{\wd\FigBox}
\centering\usebox{\FigBox}
\subcaption{A gull}
\end{minipage}\hspace*{\FigHSkip}
% Save second image
\sbox{\FigBox}{\includegraphics{a_tiger}}
\begin{minipage}{\wd\FigBox}
\centering\usebox{\FigBox}
\subcaption{A tiger}
\end{minipage}
\caption{Pictures of animals}
\end{figure}
\end{document}
我还添加了两个参数\FigHSkip
和\FigVSkip
来设置图像的水平和垂直间距。其余代码几乎都是从 subcaption 文档第 4 页复制粘贴的(CTAN 上的子标题)