This is a follow-up to an earlier question regarding left-aligning subfigure captions.
Having achieved the left-alignment goal, I would now like the caption of the subfigure to be bottom-aligned, while having the subfigure itself be top-aligned. As an example, in the figure below, subfigures (a) and (b) would share an uppermost edge, and their captions would share a lowermost edge, and similarly for subfigures (c) and (d). This is most appropriate for the overall layout style of my document and also the content of the subfigures themselves.
\documentclass{article}
\usepackage[font=footnotesize]{subcaption}
\usepackage[draft]{graphicx}
\begin{document}
\begin{figure}[!ht]
\captionsetup[subfigure]{justification=justified,singlelinecheck=false}
\centering
\begin{subfigure}[b]{0.3\textwidth}
\includegraphics[scale=0.8]{fig/workflow-S}
\caption{workflow $S$}
\end{subfigure}
\begin{subfigure}[b]{0.5\textwidth}
\includegraphics[scale=0.8]{fig/workflow-S-run}
\caption{run of $S$}
\end{subfigure}
\vskip 8pt
\begin{subfigure}[b]{0.3\textwidth}
\includegraphics[scale=0.8]{fig/workflow-S'}
\caption{workflow $S'$}
\end{subfigure}
\begin{subfigure}[b]{0.5\textwidth}
\includegraphics[scale=0.8]{fig/workflow-S'-run}
\caption{run of $S'$}
\end{subfigure}
\caption{Here's a figure}
\end{figure}
\end{document}
I've experimented with the minipage
settings for subfigure
, specifically using [t]
instead of [b]
, but it seems to have no effect. I'm unsure as to whether a position of [t]
would produce the right effect anyway, or whether it would shift the captions up as well.
Why is [t]
not working here, and what's the right way to produce the layout I need?
The solution should generalise to an arbitrary number of subfigures per row, subfigures which are text or tables rather than images, and should not require any hard-coded sizes.
Best Answer
Here's a flexible solution; in a
figure
environment you define with\xsubfigure
the objects you need and then arrange them as you like. Each command has as a first argument a symbolic key to be used in\makerow
; the second argument defines the objects via a key-value syntax (add\label
in the body ofcaption
, if needed).Note that if you're not satisfied with the arrangement, you can rearrange the subfigures by saying, for instance,
In the example I set height and width for every
\includegraphics
, as I don't have your images, but you can use the keys you prefer.