# tufte-latex and subfloat positioning

I'd like to have two rows of top-aligned images, with top-aligned captions below each.

This answer provides a technique using the floatrow package, but something in that package (or one of its dependencies) doesn't play nice with the tufte-latex document classes. It breaks the caption positioning for all other floats (should be in the margin for the tufte-handout class).

\documentclass{tufte-handout}

\usepackage{tikz}
\usepackage{caption}
\usepackage{subcaption}

\begin{document}

\begin{figure}
\begin{subfigure}[b]{0.3\textwidth}
\centering
\begin{tikzpicture}
\draw circle (1.25cm) {};
\end{tikzpicture}%
\caption{A circle, bottom-aligned}
\label{fig:circle}
\end{subfigure}%
~
\begin{subfigure}[b]{0.3\textwidth}
\centering
\begin{tikzpicture}
\draw circle (1cm) {};
\end{tikzpicture}%
\caption{A second, smaller circle}
\label{fig:circle}
\end{subfigure}%
~
\begin{subfigure}[b]{0.3\textwidth}
\centering
\begin{tikzpicture}
\draw circle (1.25cm) {};
\end{tikzpicture}%
\caption{A third circle, with a long caption that will force more
line breaks and mess up the pretty layout}
\label{fig:circle3}
\end{subfigure}%
\\
\begin{subfigure}[b]{0.3\textwidth}
\centering
\begin{tikzpicture}
\draw circle (1.25cm) {};
\end{tikzpicture}%
\caption{another circle, in a new row}
\label{fig:circle4}
\end{subfigure}%
~
\begin{subfigure}[b]{0.3\textwidth}
\centering
\begin{tikzpicture}
\draw circle (1.25cm) {};
\end{tikzpicture}%
\caption{final circle}
\label{fig:circle5}
\end{subfigure}%
\caption{Shapes with no corners. Ugly sub-figure layout. Caption for
the figure is in the margin per the \texttt{tufte-handout}
class}\label{fig:circles}
\end{figure}

\end{document}


produces:

I'd like the tops of the figures to be aligned, and the tops of the captions in each row to be aligned.

Related: Where'd my subfigure letters go?

-

Here's an idea that borrows from my answer to

Why is picture and matrix not drawn at the same height

The idea is to measure the height of the biggest subfigure, and then use \vfill to center the other subfigure vertically.

Notice that I've changed the optional argument to [t] so that each subfigure is 'top aligned'.

\documentclass{tufte-handout}

\usepackage{tikz}
\usepackage{caption}
\usepackage{subcaption}
\captionsetup{compatibility=false}

\newsavebox{\tempbox}
\begin{document}

% store the biggest picture
% store the bigger of the two pictures in a vbox
\sbox{\tempbox}{%
\begin{tikzpicture}
\draw circle (1.25cm) {};
\end{tikzpicture}%
}

\begin{figure}
\begin{subfigure}[t]{0.3\textwidth}
\centering
% use the save box
\usebox{\tempbox}
\caption{A circle, bottom-aligned}
\label{fig:circle}
\end{subfigure}%
\begin{subfigure}[t]{0.3\textwidth}
\centering
% for the other figures, you can use \vfill as follows
\vbox to\ht\tempbox{
\begin{tikzpicture}
\draw circle (1cm) {};
\end{tikzpicture}%
\vfill
}
\caption{A second, smaller circle}
\label{fig:circle}
\end{subfigure}%
\begin{subfigure}[t]{0.3\textwidth}
\centering
\usebox{\tempbox}
\caption{A third circle, with a long caption that will force more
line breaks and mess up the pretty layout}
\label{fig:circle3}
\end{subfigure}%
\\
\begin{subfigure}[t]{0.3\textwidth}
\centering
\begin{tikzpicture}
\draw circle (1.25cm) {};
\end{tikzpicture}%
\caption{another circle, in a new row}
\label{fig:circle4}
\end{subfigure}%
~
\begin{subfigure}[t]{0.3\textwidth}
\centering
\begin{tikzpicture}
\draw circle (1.25cm) {};
\end{tikzpicture}%
\caption{final circle}
\label{fig:circle5}
\end{subfigure}%
\caption{Shapes with no corners. Ugly sub-figure layout. Caption for
the figure is in the margin per the \texttt{tufte-handout}
class}\label{fig:circles}
\end{figure}

\end{document}

-