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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Please consider the following MWE

\documentclass{article}

\usepackage[demo]{graphicx}

\begin{document}

  \begin{figure}
    \centering
    \begin{minipage}[c]{0.45\textwidth}
      \centering
     \includegraphics[width=3cm,height=4cm]{mypicture.png}
     \caption{Caption 1}
    \end{minipage}
    \begin{minipage}[c]{0.45\textwidth}
      \centering
     \includegraphics[width=3cm,height=2cm]{mypicture.png}
     \caption{Caption 2}
    \end{minipage}
\end{figure}

\end{document}

which produces

enter image description here

How could I, without moving downward figure 2, align the two captions to obtain

enter image description here

share|improve this question
up vote 5 down vote accepted

You can use a savebox for this kind of thing - the idea is to measure the height of the largest figure, and then use the dimensions of that box in the next figure:

screenshot

% arara: pdflatex
% !arara: indent: {overwrite: yes}
\documentclass{article}

\usepackage{graphicx}
\newsavebox\mybox

\begin{document}

\savebox{\mybox}{\includegraphics[width=3cm,height=4cm]{example-image-a}}
\begin{figure}
    \centering
    \begin{minipage}{0.45\textwidth}
        \centering
        \usebox{\mybox}
        \caption{Caption 1}
    \end{minipage}
    \begin{minipage}{0.45\textwidth}
        \centering
        \vbox to \ht\mybox{%
            \vfill
            \includegraphics[width=3cm,height=2cm]{example-image-b}
            \vfill
        }
        \caption{Caption 2}
    \end{minipage}
\end{figure}

\end{document}
share|improve this answer
    
If "Caption 2", for example, spans two or more lines, the alignment will be lost. – Gonzalo Medina May 8 '14 at 14:36
    
To get a more general solution you can use \subcaptionbox as in \documentclass{article} \usepackage{subcaption} \usepackage{graphicx} \newsavebox\mybox \savebox{\mybox}{\includegraphics[width=3cm,height=4cm]{example-image-a}} \begin{document} \begin{figure} \centering \subcaptionbox{Some text and some more text and some more text}[.48\linewidth]{\usebox{\mybox}}\hfill% \subcaptionbox{Some text }[.48\linewidth]{% \hsize=.48\linewidth\vbox to \ht\mybox{% \vfill \includegraphics[width=3cm,height=2cm]{example-image-b} \vfill }% } \end{figure} \end{document} – Gonzalo Medina May 8 '14 at 14:54
    
I'm sorry for the poor formatting of the code in my previous comment, the % characters are there in the "real" version to suppress blank spaces at the end of the lines. – Gonzalo Medina May 8 '14 at 14:55
    
@GonzaloMedina thanks for the details :) I'll incorporate them into my answer :) – cmhughes May 8 '14 at 16:22

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.