4

Why are the numbers (acually, letters) for the sub-captions missing in the following MWE? note the colon that would follow the letter is printed.

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

output of MWE

mac
  • 311

1 Answers1

6

When I compiled your original code I got the errors

Package caption Warning: \caption will not be redefined since it's already
(caption)                redefined by a document class or package which is
(caption)                unknown to the caption package.
See the caption package documentation for explanation.


! Package caption Error: The `subcaption' package does not work correctly
(caption)                in compatibility mode.

You can read more about this in the documentation, but essentially it means that the current documentclass (in your case tufte-handout) already has its own way of modifying the caption command.

You can get round this by using

\captionsetup{compatibility=false}

as I have done in the following code- your images now have captions!

screenshot

I see that you've asked another question about the vertical alignment of the subfigures, so we'll address that in that question :)

\documentclass{tufte-handout}

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

\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}
David Carlisle
  • 757,742
cmhughes
  • 100,947