How can I vertically align subfigures of different size without affecting subcaptions?

\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

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

-

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:

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

-
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