子标题:同一行有两个子图标题

子标题:同一行有两个子图标题

在我的文档中,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底部垂直对齐方式和\subcaptionboxH选项来自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}

在此处输入图片描述

相关内容