6

I have the following problem trying to align two figures horizontally within the same figure environment. The right image is always put lower than the left image. Here is my code:

\begin{figure} 
    \begin{subfigure}[b]{0.5\textwidth}
    \includegraphics[scale=0.5]{plots/dipfdbs_componentSizeComponentCount.pdf}
    \end{subfigure}
    \begin{subfigure}[a]{0.5\textwidth}
            \includegraphics[scale=0.5]{plots/dipfdbs_averageDegree.pdf}
    \end{subfigure}
    \caption{Degree distribution and component sizes of dipfdbs recommendation graph.}
    \label{fig:dipfdbsgraphplots}
\end{figure}

And here is how it looks like in rendered pdf:

result

Any help would be greatly appreciated.

lockstep
  • 250,273
user16795
  • 61
  • 1
  • 1
  • 2

1 Answers1

14

The optional argument to the subfigure environment defines the vertical alignment of the image within the subfigure, so b will place the images at the bottom of the subfigure, c centers them and t places them on top. You've used b on the first and a in the second, but a doesn't do anything as far as I know. Change a to b to fix it.

(Images are from the mwe package.)

enter image description here

\documentclass{article}
\usepackage{graphicx}
\usepackage{subcaption}
\begin{document}
\begin{figure} 
  \begin{subfigure}[b]{0.5\textwidth}
    \includegraphics[height=4cm]{example-image-a}
  \end{subfigure}
  \begin{subfigure}[b]{0.5\textwidth}
    \includegraphics[height=5cm]{example-image-b}
  \end{subfigure}
  \caption{Degree distribution and component sizes of dipfdbs recommendation graph.}
  \label{fig:dipfdbsgraphplots}
\end{figure}
\end{document}
Torbjørn T.
  • 206,688