[Tex/LaTex] How to vertically align ‘subcaption’ subfigures

floatssubcaptionsubfloatsvertical alignment

I am using the \usepackage{subcaption} library (inspired by this) to create a figure with two images, like so:

\begin{figure}[H]
\centering
\begin{subfigure}{0.45 \linewidth}
    \centering
    \vfill
    \includegraphics{2020.jpg}
    \caption{A a $20\times 20$ image in original size.}
\end{subfigure} \hfill
\begin{subfigure}{0.54 \linewidth}
    \centering
    \includegraphics[height=6cm]{2020.jpg}
    \caption{The same images with increased resolution, for illustrative purposes.}
\end{subfigure}

Giving me the following:

enter image description here

How do I vertically align the two images? I.e. I want something like this:

enter image description here

Best Answer

Use \subcaptionbox{<caption>}[<width>]{<image>} instead the subfigure environments, then you get the desired result, no trickery needed.

output of code

\documentclass{article}
\usepackage{graphicx}

\usepackage{subcaption}
\begin{document}
\begin{figure}
\centering
\subcaptionbox{%
    A a $20\times 20$ image in original size.
  }[0.45\linewidth]
  {\includegraphics[width=1cm]{example-image-1x1}}
\hfill
\subcaptionbox{%
    The same images with increased resolution, for illustrative purposes.
  }[0.54 \linewidth]
  {\includegraphics[width=5cm]{example-image-1x1}}
\end{figure}
\end{document}