在我的文档中,TikZ
图片有不同的边界框,所以两者subfigures
交错captions
。
\documentclass{article}
\usepackage{standalone}
\usepackage{subcaption}
\begin{document}
\begin{figure}
\centering
\begin{subfigure}{.4\linewidth}
\centering
\includestandalone{one}
\caption[short]{long}
\end{subfigure}
\begin{subfigure}{.4\linewidth}
\centering
\includestandalone{two}
\caption[short]{long}
\end{subfigure}
\end{figure}
\end{document}
由于您没有我的两个独立设备,我将展示正在发生的事情:
我希望从subcaptions
同一行开始。
答案1
\subcaptionbox
您可以使用命令而不是环境来获得所需的对齐方式subfigure
;以下示例显示了subfigure
默认垂直对齐方式、subfigure
底部垂直对齐方式和\subcaptionbox
(H
选项来自float
仅用于示例;我是不是建议使用此放置说明符):
\documentclass{article}
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage{float}% just for the example
\begin{document}
Using \texttt{subfigure} with default vertical alignment (undesired result):
\begin{figure}[H]
\centering
\begin{subfigure}{.4\linewidth}
\centering
\includegraphics[height=2cm]{example-image-a}
\caption[short]{The left subfigure with a long caption spanning several lines and some more text}
\end{subfigure}
\begin{subfigure}{.4\linewidth}
\centering
\includegraphics[height=1cm]{example-image-b}
\caption[short]{The right subfigure}
\end{subfigure}
\end{figure}
Using \texttt{subfigure} with bottom alignment (undesired result):
\begin{figure}[H]
\centering
\begin{subfigure}[b]{.4\linewidth}
\centering
\includegraphics[height=2cm]{example-image-a}
\caption[short]{The left subfigure with a long caption spanning several lines and some more text}
\end{subfigure}
\begin{subfigure}[b]{.4\linewidth}
\centering
\includegraphics[height=1cm]{example-image-b}
\caption[short]{The right subfigure}
\end{subfigure}
\end{figure}
Using \texttt{subcaptionbox} (desired result):
\begin{figure}[H]
\centering
\subcaptionbox{The left subfigure with a long caption spanning several lines and some more text}%
[.4\linewidth]{\includegraphics[height=2cm]{example-image-a}}
\subcaptionbox{The right subfigure}
[.4\linewidth]{\includegraphics[height=1cm]{example-image-b}}
\end{figure}
\end{document}