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

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}
  • +1 RTFL. – yo' Dec 6 '12 at 22:39
  • When I try to \ref{fig:circles} I get a undefined reference. Is there a way to fix that? – Rafael S. Calsaverini Dec 17 '12 at 21:04
  • @RafaelS.Calsaverini compile more than once :) – cmhughes Dec 17 '12 at 23:46
  • I did. :( Still no labels. – Rafael S. Calsaverini Dec 18 '12 at 11:04
  • @RafaelS.Calsaverini ah, now I understand why you asked Are there any subfloat package that works with tufte-latex? I'm afraid I don't have an answer at the moment, but will look into it; the author of the caption and subcaption package is an active member of the site, maybe he'll be able to work some magic :) – cmhughes Dec 18 '12 at 17:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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