我试图定位 3 个图像,一个大图像在左边,两个较小的图像在右边彼此叠放,如下所示:
我有以下代码,虽然它可以工作,但它看起来并不是实现此目的的最佳方法:
\begin{figure}% \minipage[b]{0.49\linewidth}
\centering
\subfloat[cap]{{\includegraphics[width=1.2\textwidth]{A.jpg}
}}
\endminipage\hfill
\qquad\qquad\qquad
\minipage[b]{0.49\linewidth}
\subfloat[cap2]{{\includegraphics[width=.5\textwidth]{B.jpg}}}\\
\subfloat[cap3]{{\includegraphics[width=.5\textwidth]{C.jpg}
}}%
\endminipage
\caption{Some general caption}%
\label{fig:example}% \end{figure}
答案1
我建议修改我的答案
\documentclass{article}
\usepackage{graphicx,subfig}
\usepackage{showframe,lipsum} % just for the example
\newlength{\subcolumnwidth}
\newenvironment{subcolumns}[1][0.45\columnwidth]
{\valign\bgroup\hsize=#1\setlength{\subcolumnwidth}{\hsize}\vfil##\vfil\cr}
{\crcr\egroup}
\newcommand{\nextsubcolumn}[1][]{%
\cr\noalign{\hfill}
\if\relax\detokenize{#1}\relax\else\hsize=#1\setlength{\subcolumnwidth}{\hsize}\fi
}
\newcommand{\nextsubfigure}{\vfill}
\begin{document}
\lipsum[1]
\begin{figure}[htp]
\begin{subcolumns}
\subfloat[Caption 1]{\includegraphics[width=\subcolumnwidth]{example-image-9x16}}
\nextsubcolumn
\subfloat[Caption 2]{\includegraphics[width=\subcolumnwidth]{example-image-a}}
\nextsubfigure
\subfloat[Caption 3]{\includegraphics[width=\subcolumnwidth]{example-image-b}}
\end{subcolumns}
\caption{Global caption}
\end{figure}
\lipsum[2]
\begin{figure}[!htp]
\begin{subcolumns}[0.6\textwidth]
\subfloat[Caption 1]{\includegraphics[width=\subcolumnwidth]{example-image-1x1}}
\nextsubcolumn[0.35\textwidth]
\subfloat[Caption 2]{\includegraphics[width=\subcolumnwidth]{example-image-a}}
\nextsubfigure
\subfloat[Caption 3]{\includegraphics[width=\subcolumnwidth]{example-image-b}}
\end{subcolumns}
\caption{Global caption}
\end{figure}
\begin{figure}[!htp]
\centering
\begin{minipage}{0.7\textwidth}
\begin{subcolumns}[0.62\textwidth]
\subfloat[Caption 1]{\includegraphics[width=\subcolumnwidth]{example-image-1x1}}
\nextsubcolumn[0.33\textwidth]
\subfloat[Caption 2]{\includegraphics[width=\subcolumnwidth]{example-image-a}}
\nextsubfigure
\subfloat[Caption 3]{\includegraphics[width=\subcolumnwidth]{example-image-b}}
\end{subcolumns}
\end{minipage}
\caption{Global caption}
\end{figure}
\lipsum[3-5]
\end{document}
可选参数确定第一列(默认值,适用于两列相等)和所有其他列\begin{subcolumns}
的宽度;但是,可以指定可选参数来设置下一列的宽度。我提供了三个示例来说明其工作原理;最后一个示例说明如何减小默认情况下占据整个列宽的整体尺寸。0.45\textwidth
\newsubcolumn
您可以拥有任意数量的列。
\begin{figure}[!htp]
\begin{subcolumns}[0.3\textwidth]
\subfloat[Caption 1]{\includegraphics[width=\subcolumnwidth]{example-image-9x16}}
\nextsubcolumn
\subfloat[Caption 2]{\includegraphics[width=\subcolumnwidth]{example-image-a}}
\nextsubfigure
\subfloat[Caption 3]{\includegraphics[width=\subcolumnwidth]{example-image-b}}
\nextsubcolumn
\subfloat[Caption 4]{\includegraphics[width=\subcolumnwidth]{example-image-a}}
\nextsubfigure
\subfloat[Caption 5]{\includegraphics[width=\subcolumnwidth]{example-image-b}}
\end{subcolumns}
\caption{Global caption}
\end{figure}
除了建议
避免使用诸如 之类的外来语法\minipage...\endminipage
。对于特定情况来说,这不是什么大问题,但\flushleft...\endflushleft
会带来灾难性的后果。
答案2
下面使用该subcaption
包并使用环境堆叠右侧的两幅图像tabular
。
\documentclass[]{article}
\usepackage[]{graphicx}
\usepackage{subcaption}
\begin{document}
\begin{figure}
\begin{subfigure}[c]{.48\linewidth}
\centering
\includegraphics[width=\linewidth]{example-image-duck-portrait}%
\caption
{%
the big one%
\label{fig:big}%
}%
\end{subfigure}\hfill
\begin{tabular}[c]{@{}c@{}}
\begin{subfigure}[c]{.48\linewidth}
\centering
\includegraphics[width=\linewidth]{example-image-duck}%
\caption
{%
the upper small one%
\label{fig:upper}%
}%
\end{subfigure}\\
\noalign{\bigskip}%
\begin{subfigure}[c]{.48\linewidth}
\centering
\includegraphics[width=\linewidth,page=2]{example-image-duck}%
\caption
{%
the lower small one%
\label{fig:lower}%
}%
\end{subfigure}
\end{tabular}
\caption
{%
The big caption for everyone%
\label{fig:every}%
}
\end{figure}
\end{document}