[Tex/LaTex] Recommended package for making same-height subfigures

subcaptionsubfloats

I've read that the subfigure package has been deprecated in favor of the subcaption package. However, the subcaption package has the unfortunate requirement that you specify the width of each subfigure in advance. But, for the common case of creating a row of same-height subfigures, you don't know their widths in advance, you just know that you want all them to be 5cm tall (for example).

So, what would be a recommended (and not deprecated) package for making strips of subfigures so that they're automatically scaled to a given height?

Note: The easiest syntax, the better (ie: I prefer to avoid manually defined minipages nor custom boxes, and use a package with easy syntax instead, just like subcaption, subfigure, etc…)

Best Answer

There is no requirement to specify the width of the box when you supply the content inside a \subcaptionbox:

enter image description here

\documentclass{article}

\usepackage{subcaption,graphicx}

\begin{document}

\begin{figure}
  \centering
  \subcaptionbox{abc}{\includegraphics[height=5\baselineskip]{example-image-a}} \quad
  \subcaptionbox{def}{\includegraphics[height=5\baselineskip]{example-image-1x1}} \quad
  \subcaptionbox{ghi}{\includegraphics[height=5\baselineskip]{example-image-b}} \quad
\end{figure}

\end{document}

The width of the resulting box is made to fit the contents naturally. You can specify the width if you need to, since \subcaptionbox has the following extended usage/format:

\subcaptionbox[<list entry>]{<heading>}[<width>][<inner-pos>]{<contents>}

Note the optional macro for specifying the <width> of the box.