# How to prevent offset in subcaption / subfigure

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:

Any help would be greatly appreciated.

-

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.)

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

-
Apparently the OP thought a and b would appear in subcaptions. –  lhf Jul 20 '12 at 13:38
@lhf That could explain it. –  Torbjørn T. Jul 20 '12 at 13:44
Thanx a lot... a and b had been set due to a previous usage of an old package for getting the subcaptions. Saved my day! –  user16795 Jul 20 '12 at 21:13