我如何将三个浮点数垂直堆叠在一起,使得每个图的高度大约为页面文本高度的三分之一?(即它们都适合,包括标题和子标题)。我不在乎浮点数的宽度,只要比例适合线宽即可。
我更喜欢使用 subcaption 包。
感谢任何支持,
答案1
\documentclass[a4paper]{article}
\usepackage{graphicx}
\usepackage{subcaption}
\begin{document}
\begin{figure}[htbp]
\centering
\subcaptionbox{some caption}[\textwidth]{\includegraphics[height=.3\textheight]{example-image-a}}
\subcaptionbox{some caption}[\textwidth]{\includegraphics[height=.3\textheight]{example-image-b}}
\subcaptionbox{some caption}[\textwidth]{\includegraphics[height=.3\textheight]{example-image-c}}
\caption{This is the main caption}
\end{figure}
\end{document}
答案2
通过这种stackengine
方法,您可以控制从图像底部到子标题顶部的间隙(当前为1.1\baselineskip
)以及从标题底部到下方图像顶部的间隙(当前为8pt
)。
\documentclass{article}
\usepackage[usestackEOL]{stackengine}
\setstackgap{S}{8pt}
\setstackgap{L}{1.1\baselineskip}
\usepackage{graphicx}
\begin{document}
\begin{figure}[p]
\centering\Shortstack
{
\def\stacktype{L}
\stackunder{\includegraphics[height=.27\textheight]{example-image-a}}
{(a) This is subcaption A}
\\
\def\stacktype{L}
\stackunder{\includegraphics[height=.27\textheight]{example-image-a}}
{(b) This is subcaption B}
\\
\def\stacktype{L}
\stackunder{\includegraphics[height=.27\textheight]{example-image-a}}
{(c) This is subcaption C}
}
\caption{This is the figure caption}
\end{figure}
\end{document}