13

I am trying to put two figures side-by-side in beamer environment. Figures are placed properly using the following lines:

\usepackage{subcaption}
 ....

\begin{figure}
\centering
\begin{subfigure}{.5\textwidth}\centering
  \includegraphics[width=\columnwidth]{a.pdf}
  \caption{Figure a}
\end{subfigure}%
\begin{subfigure}{.5\textwidth}\centering
  \includegraphics[width=\columnwidth]{b.pdf}
  \caption{Figure b}
\end{subfigure}
\end{figure}

but the captions are not aligned. The caption for the left figure is nicely placed, but the caption for the right figure shows up a few cm below the figure:

|------------------|           |------------------|
|------------------|           |------------------|
|------------------|           |------------------|
    (a) Figure a                   


                                  (b) Figure b

1 Answer 1

25

Just use the optional [t] argument from subcaption:

\documentclass{article}
\usepackage{graphicx,subcaption}

\begin{document}
\begin{figure}
%\centering -> This is irrelevant because of the '.5\textwidth' as Mico advised below.
\begin{subfigure}[t]{.5\textwidth}\centering
  \includegraphics[width=.8\columnwidth]{example-image-a.pdf}
  \caption{Figure a}
\end{subfigure}%
\begin{subfigure}[t]{.5\textwidth}\centering
  \includegraphics[width=\columnwidth]{example-image-b.pdf}
  \caption{Figure b}
\end{subfigure}
\end{figure}
\end{document}

enter image description here

4
  • 1
    What if I want the A and B images to be aligned center and the captions to be aligned on the same line?
    – S P Sharan
    May 17, 2022 at 14:59
  • 2
    I don’t think there is an “official” way to do so. I can think of several hacky ones, like altering the bounding boxes. Although if you haven't found an answer for that, you should really ask a new question and link it here. May 19, 2022 at 1:10
  • 2
    @GuilhermeZanotelli Can you explain what t option does? The documentation just says that it defines the outer-pos but doesn't explain what this outer-pos is.
    – ado sar
    Nov 26, 2023 at 23:57
  • 1
    @adosar, that very same question is answered under the package documentation FAQ section (page 13, section 2.5, item 1): [...] use the environment options ‘[t]’ or ‘[b]’ to move the baseline to the top or bottom rather than the center. So there you go, it moves the baseline to the desired position. Dec 4, 2023 at 12:57

You must log in to answer this question.

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