10

I'm using the subcaptionpackage to have figures side-by-side. The problem is that the package aligns the figures to their subcaptions (should I be taking a hint for the package name?) rather than the top of the pictures.

How can I algin the subfigures by the top border?

MWE:

\begin{figure}[h]
\begin{subfigure}[b]{.5\linewidth}
\centering\large A
\caption{A subfigure}\label{fig:1a}
\end{subfigure}%
\begin{subfigure}[b]{.5\linewidth}
\centering\large B
\caption{Another subfigure with a long, long, long, long caption.}\label{fig:1b}
\end{subfigure}
\caption{A figure}\label{fig:1}
\end{figure}

Result: Subcaption example

benregn
  • 6,082

2 Answers2

6

I've tried to solve the problem in a different way, although in the package documentation I don't find any hint on this. Instead of adopting [b] I set [t]:

\documentclass[a4paper,11pt]{article}
\usepackage{subcaption}

\begin{document}
\begin{figure}[h]
\begin{subfigure}[t]{.5\linewidth}
\centering\large A
\caption{A subfigure}\label{fig:1a}
\end{subfigure}%
\begin{subfigure}[t]{.5\linewidth}
\centering\large B
\caption{Another subfigure with a long, long, long, long caption.}\label{fig:1b}
\end{subfigure}
\caption{A figure}\label{fig:1}
\end{figure}    

\end{document}

that leads to:

enter image description here

The reason of my choice was just a parallel with t,b of columns alignment in Beamer.

  • Regarding the missing hint: It's "the new environments subfigure and sub-table are available, which have the same (optional & mandatory) arguments as the minipage environment." in the documentation. Will try to make this more clear in the next version... –  May 18 '12 at 06:17
  • @AxelSommerfeldt: thanks! Now it's clear to me. :) – Claudio Fiandrino May 18 '12 at 07:25
  • @AxelSommerfeldt: I couldn't figure it out for the life of me :) – benregn May 18 '12 at 07:43
  • 1
    @benregn This won't align the subcaptions to each other if the figures have different height. – egreg May 18 '12 at 17:57
  • @egreg: I'll keep that in mind. In the specific case that prompted the question, it is not a problem. – benregn May 19 '12 at 12:08
3

You can use a trick that fools LaTeX into thinking that the first subcaption is as high as the second, but doesn't add to the width:

\subcaption{A subfigure\vspace{\baselineskip}}

Of course, leave this kind of adjustments for the final revision of the document, when you're sure that the text won't change any more.

egreg
  • 1,121,712