Subfloats – Subcaption: Two Subfigure Captions on the Same Line

subcaptionsubfloats

In my document, the TikZ pictures have different bounding boxes so the two subfigures have staggered 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}

Since you wont have my two standalones, I will show what is happening:

enter image description here

I would like for the subcaptions to start on the same row.

Best Answer

You can get the desired alignment using the \subcaptionbox command instead of the subfigure environment; the following example shows a comparison between subfigure with default vertical alignment, subfigure with bottom vertical alignment, and \subcaptionbox (the H option from float was only used for the example; I am not recommending using this placement specidier):

\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}

enter image description here