tufte-latex 和 subfloat 定位

tufte-latex 和 subfloat 定位

我想要两行顶部对齐的图像,每行下方都有顶部对齐的标题。

这个答案提供了一种使用包的技术floatrow,但该包中的某些内容(或其依赖项之一)与文档类不兼容tufte-latex。它破坏了所有其他浮动的标题定位(应该位于类的边距中tufte-handout)。

\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}

生成: MWE 的输出

我希望图形的顶部对齐,并且每行标题的顶部也对齐。

有关的:我的子图字母去哪儿了?

答案1

这个想法借鉴了我的回答

为什么图片和矩阵不绘制在同一高度

以及其中的链接。

截屏

这个想法是测量最大的高度subfigure,然后垂直\vfill应用于center另一个subfigure

请注意,我已将可选参数更改为,[t]以便每个参数subfigure都“顶部对齐”。

\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}

相关内容