Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer

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}
share|improve this answer
    
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.