当有两个不同大小的子图时,有没有办法垂直对齐它们?
梅威瑟:
\documentclass{memoir}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{duckuments}
\usepackage{graphicx}
\newsubfloat{figure}
\begin{document}
\begin{figure}
\centerfloat
\subbottom[]{\includegraphics[height = 2cm]{example-image-duck}}~%
\subbottom[]{\includegraphics{example-image-duck}}
\caption{The two figures should be vertically aligned}
\end{figure}
\end{document}
生成:
答案1
答案已更新:
\documentclass{memoir}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\begin{document}
%----------------------------------------------------------------
\begin{figure}
\begin{subfigure}[t]{0.5\textwidth}% Takes half the text width (left to center)
\includegraphics[width=\textwidth, height = 2cm]{example-image-a}
\caption{A long caption of the subcaption of the left subfigure}
\end{subfigure}
\hfill
\begin{subfigure}[t]{0.5\textwidth}% Takes half the text width, (other half center to right)
\includegraphics[width=\textwidth]{example-image-b}
\caption{
A long caption of the subcaption of the right subfigure copied and
pasted twice a long caption of the subcaption of the right subfigure
}
\end{subfigure}
\caption{Overall Overall Overall Overall Overall Overall Overall Overall caption}
\end{figure}
%----------------------------------------------------------------
\begin{figure}
\begin{subfigure}[t]{0.4\textwidth}% Takes half the text width (left to center)
\includegraphics[width=\textwidth, height = 2cm]{example-image-a}
\caption{A long caption of the subcaption of the left subfigure}
\end{subfigure}
\hfill
\begin{subfigure}[t]{0.4\textwidth}% Takes half the text width, (other half center to right)
\includegraphics[width=\textwidth]{example-image-b}
\caption{
A long caption of the subcaption of the right subfigure copied and
pasted twice a long caption of the subcaption of the right subfigure
}
\end{subfigure}
\caption{Overall Overall Overall Overall Overall Overall Overall Overall caption}
\end{figure}
%----------------------------------------------------------------
\begin{figure}
\begin{subfigure}[t]{0.7\textwidth}% Takes half the text width (left to center)
\includegraphics[width=\textwidth, height = 2cm]{example-image-a}
\caption{A long caption of the subcaption of the left subfigure}
\end{subfigure}
\hfill
\begin{subfigure}[t]{0.2\textwidth}% Takes half the text width, (other half center to right)
\includegraphics[width=\textwidth]{example-image-b}
\caption{A long caption of the subcaption of the right subfigure}
\end{subfigure}
\caption{Overall Overall Overall Overall Overall Overall Overall Overall caption}
\end{figure}
\end{document}
上一个答案:
您可以使用graphbox
允许您指定所需对齐类型的包。您可以将其align = t
用于顶部对齐、align = c
居中或align = b
底部对齐。
\documentclass{memoir}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{graphbox} % Need this!
\newsubfloat{figure}
\begin{document}
\begin{figure}
\centerfloat
\subbottom[]{\includegraphics[height = 1cm, align = t]{example-image-a}}
\subbottom[]{\includegraphics[height = 2cm, align = t]{example-image-b}}
\caption{The two figures should be vertically aligned (top)}
\end{figure}
\vspace*{-3cm}
\begin{figure}
\centerfloat
\subbottom[]{\includegraphics[height = 1cm, align = c]{example-image-a}}
\subbottom[]{\includegraphics[height = 2cm, align = c]{example-image-b}}
\caption{The two figures should be vertically aligned (center)}
\end{figure}
\vspace*{-3cm}
\begin{figure}
\centerfloat
\subbottom[]{\includegraphics[height = 1cm, align = b]{example-image-a}}
\subbottom[]{\includegraphics[height = 2cm, align = b]{example-image-b}}
\caption{The two figures should be vertically aligned (bottom)}
\end{figure}
\end{document}