Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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: output of MWE

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?

share|improve this question
add comment

1 Answer 1

up vote 6 down vote accepted

Here's an idea that borrows from my answer to

Why is picture and matrix not drawn at the same height

and the links within.

screenshot

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}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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