我重复前面的例子一个图形有两列子图:左列有一个图像,右列有两个图像 ,但使用了 subcaption 包。
最后,我得到了一个失败的版本和一个成功的版本。我的问题是,为什么第一个版本会失败(获取了错误的高度minipage
和subfigure
内部环境)?
% The failed version
\documentclass{article}
\usepackage{subcaption}
\usepackage[demo]{graphicx}
\newsavebox{\measurebox}
\begin{document}
\begin{figure}
\centering
\sbox{\measurebox}{%
\begin{minipage}[b]{.33\textwidth}
\begin{subfigure}{\textwidth}
{\includegraphics[width=\textwidth,height=5cm]{figA}\caption{caption A}}
\end{subfigure}
\end{minipage}}
\fbox{\usebox{\measurebox}}\qquad
\fbox{%
\begin{minipage}[b][\ht\measurebox][s]{.33\textwidth}
\centering
\begin{subfigure}{\textwidth}
\includegraphics[width=\textwidth,height=2cm]{figB}\caption{caption B}
\end{subfigure}
\vfill
\begin{subfigure}{\textwidth}
\includegraphics[width=\textwidth,height=2cm]{figC}\caption{caption C}
\end{subfigure}
\end{minipage}%
}
\caption{my caption}
\end{figure}
\end{document}
% The successful version
\documentclass{article}
\usepackage{subcaption}
\usepackage[demo]{graphicx}
\newsavebox{\measurebox}
\begin{document}
\begin{figure}
\centering
\sbox{\measurebox}{%
\begin{minipage}[b]{.33\textwidth}
\includegraphics[width=\textwidth,height=5cm]{figA}\subcaption{caption A}
\end{minipage}}
\fbox{\usebox{\measurebox}}\qquad
\fbox{%
\begin{minipage}[b][\ht\measurebox][s]{.33\textwidth}
\centering
\includegraphics[width=\textwidth,height=2cm]{figB}\subcaption{caption B}
\vfill
\includegraphics[width=\textwidth,height=2cm]{figC}\subcaption{caption C}
\end{minipage}%
}
\caption{my caption}
\end{figure}
\end{document}