16

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.

2
  • 1
    This should be supported out-of-the-box by supcaption. See, for example, the visual on p 6 of the subcaption documentation when using \subcaptionbox. If you replace your \includestandalone by something like \includegraphics[height=3\baselineskip]{example-image-a} and \includegraphics[height=2\baselineskip]{example-image-b}, do you still have mis-alignment vertically?
    – Werner
    Aug 7, 2013 at 22:42
  • Another solution to this question, using a table, can be found in tex.stackexchange.com/questions/276288/…. May 3, 2021 at 8:55

1 Answer 1

15

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

3
  • Hi there, how would I expand this to have as many boxes I want in one line? Aug 18, 2016 at 15:12
  • @DhruvGhulati Use 3 or subcaptionboxes of course. Don't forget to set the correct width to the subfigures. May 12, 2021 at 7:30
  • Is it possible to have captions of two side-by-side figures to have captions that start on the same row? eg.: Fig. 1: caption1 ...... Fig. 2: caption 2 May 12, 2021 at 7:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .