5

I have two images of different heights and widths sat next to eachother on the page, and I'd like their captions to align. As it is currently, one caption is displaced vertically from the other. My code goes as follows:

\begin{figure}[h]  
 \begin{minipage}[c]{0.49\textwidth}    
  \centering    
  \includegraphics[width=\textwidth]{image1}    
  \caption{Caption 1 with citation 1.}    
  \label{fig:label1}    
 \end{minipage}    
\hspace*{0.1cm}    
 \begin{minipage}[c]{0.49\textwidth}    
  \centering    
  \includegraphics[width=\textwidth]{image2}    
  \caption{Caption 2 with citation 2.}    
  \label{fig:label2}    
 \end{minipage}    
\end{figure}

I've tried a couple of things, but none seem to work very well for me. Does anyone have any suggestions?

Edit: I've tried using [heightadjust=all]{floatrow} and the minipage[b] solution, but it does not seem to work. I've tried using both methods in a seperate document, but for the [heightadjust=all]{floatrow} I get an hbox error and the minipage[b] only works on some of my images.

3
  • Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. Feb 18 '14 at 16:31
  • Does any of the answers below solve your problem? If yes, please consider accepting it. See How do you accept an answer? Feb 19 '14 at 17:09
  • Sadly, this solution did not work for me. I just received an hbox overfull error, and it didn't include the images. Just a blank page with captions.
    – Asbjørn
    Mar 5 '14 at 11:53
4

Surely your images have different heights and that's why you notice that behavior.

I'll show you two options.

  1. Use the floatrow package

    The floatrow package loaded with the option heightadjust=all automatically adjusts side by side figures and their captions.

    MWE:

    \documentclass{article}
    \usepackage{graphicx}
    \usepackage[heightadjust=all]{floatrow}
    
    \begin{document}
    
    \begin{figure}[!h]
       \begin{floatrow}
         \ffigbox{\includegraphics[width=.48\textwidth]{example-image-a}}
             {\caption{Caption 1 with citation 1.}\label{fig:label1}}
         \ffigbox{\includegraphics[width=.48\textwidth,height=1cm]{example-image-b}}
             {\caption{Caption 2 with citation 2.}\label{fig:label2}}
       \end{floatrow}
    \end{figure}
    
    \end{document} 
    

    Output:

    enter image description here

  2. Use minipages with manual adjusting

    Use the [b] specifier for minipages instead of [c] and manually adjust the positioning of the images through some vertical space.

    MWE:

    \documentclass{article}
    \usepackage{graphicx}
    
    \begin{document}
    \begin{figure}[h]
    
    \begin{minipage}[b]{0.49\textwidth}
    
    \centering
    
    \includegraphics[width=\textwidth]{example-image-a}
    
    \caption{Caption 1 with citation 1.}
    
    \label{fig:label1}
    
    \end{minipage}%
    \hspace*{0.1cm}
    \begin{minipage}[b]{0.49\textwidth}
    
    \centering
    
    \includegraphics[width=\textwidth,height=1cm]{example-image-b}
    
    \vspace*{48pt}
    
    \caption{Caption 2 with citation 2.}
    
    \label{fig:label2}
    
    \end{minipage}
    
    \end{figure}
    \end{document} 
    

    Output:

    enter image description here

2

Things look better with subcaptionbox from subcaption package:

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

\begin{document}

\begin{figure}[htb]
\centering
\subcaptionbox{first subfigure\label{fig:label1}}{\includegraphics[width=.48\textwidth]{example-image-a}}\hfill
\subcaptionbox{second subfigure\label{fig:label2}}{\includegraphics[width=0.48\textwidth,height=1cm]{example-image-b}}
\end{figure}

\end{document}

enter image description here

2
  • Probably the OP wants two figures side by side, not two sub figures... Feb 19 '14 at 5:58
  • @karlkoeller That may be one possibility.
    – user11232
    Feb 19 '14 at 7:35
0

I can't see the exact results you get because I don't have the exact dimensions of your images. I suspect that the two images have unequal aspect ratios. Your minipages, including the captions, are horizontally centered. If you change that [c] for a [b], they become bottom-aligned. Like this:

 \begin{minipage}[b]{0.49\textwidth}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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