# [Tex/LaTex] Vertically center two side by side figures, leaving captions on the same line

floatspositioning

I would like to place two independent figures (no subfigures) besides each other. Each figure should have its own caption. This approach uses two minipages inside a figure environment and is nearly what I'm looking for. But my figures don't have the same height, so I want to center them vertically, whereas the captions should stay on the same line.

Here is an example:

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{caption}

\begin{document}

\begin{figure}
\centering
\begin{minipage}{.5\textwidth}
\centering
\includegraphics[width=.4\linewidth, height=.8\linewidth]{image1}
\captionof{figure}{A figure}
\label{fig:test1}
\end{minipage}%
\begin{minipage}{.5\textwidth}
\centering
\includegraphics[width=.4\linewidth, height=.4\linewidth]{image1}
\captionof{figure}{Another figure}
\label{fig:test2}
\end{minipage}
\end{figure}

\end{document}


This shows how the output looks vs. how I would like it to look:

A layman's solution is to use four minipages - two for figures and two for captionof.

\documentclass{article}
\usepackage{graphicx}
\usepackage{caption,showframe}

\begin{document}

\begin{figure}
\centering
\begin{minipage}{.5\textwidth}
\centering
\includegraphics[width=.4\linewidth, height=.8\linewidth]{example-image-a}
\end{minipage}%
\begin{minipage}{.5\textwidth}
\centering
\includegraphics[width=.4\linewidth, height=.4\linewidth]{example-image-b}
\end{minipage}
\par
\medskip
\noindent
\begin{minipage}[t]{.49\textwidth}
\centering
\captionof{figure}{A figure}
\label{fig:test1}
\end{minipage}%
\hfill
\begin{minipage}[t]{.49\textwidth}
\centering
\captionof{figure}{Another figure Another figure Another figure Another figure Another figure Another figure Another figure}
\label{fig:test2}
\end{minipage}
\end{figure}

\end{document}