5

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...)

  • Try to use subfig package: \subfloat[<sub caption> \label{...}]{\includegraphics[height=...]{<picture name>}}. – Zarko Oct 21 '15 at 19:12
  • You can use the subfloatrow environment, from the floatrow package. – Bernard Oct 21 '15 at 20:20
8

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.

  • Choose this one because the subcaption package is the one that fits best in my current scenario. – user2811963 Oct 21 '15 at 21:15
4

The \subfloat command from the subfig package can also be used:

\documentclass{article}
\usepackage{subfig}
\usepackage{graphicx}

\begin{document}

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

\end{document}

enter image description here

  • +1 for showing how to do it with subfig. Thanks a lot! – user2811963 Oct 21 '15 at 21:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.