2

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

Torbjørn T.
  • 206,688
  • See also https://tex.stackexchange.com/questions/152818/top-aligned-subfigure-with-bottom-aligned-caption and https://tex.stackexchange.com/questions/80172/align-captions-of-subfigures?s=7|0.0000 – John Kormylo Oct 30 '17 at 14:51

1 Answers1

3

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}
Torbjørn T.
  • 206,688
  • 1
    Exactly what I wanted! :-) It is also possible to add a normal caption to both images (not part of the question, but good to know) – Toke Faurby Oct 31 '17 at 07:39
  • @TokeFaurby Do you mean what you get by adding \caption{ ... } after the second \subcaptionbox? – Torbjørn T. Oct 31 '17 at 09:03