3

I'm trying to use the caption package to do this and I've used the following code, but it's still not giving me a period as a label separator. How can I go about fixing this? Here's what I have:

    \documentclass[english,dotinlabels,nohyper,notoc]{tufte-handout}
    \usepackage{babel}
    \usepackage{hyperref}
    \usepackage{caption}
    \captionsetup[figure]{labelformat=simple, labelsep = period}
    \captionsetup[marginfigure]{labelformat=simple, labelsep = period}

    \begin{document}

    \section{test}

    \begin{figure}
    \caption{erere}
    \end{figure}

    \vspace{20pt}

    this is a test

    \begin{marginfigure}
    \caption{rerweaere}
    \end{marginfigure}

    \end{document}

As indicated below, it works for figure, but not margin figure: enter image description here

Black Milk
  • 519
  • 4
  • 14

2 Answers2

3

The Tufte-LaTeX classes don't play very nicely with the caption package, currently.

The easiest solution is to redefine the \@caption command that is defined by the Tufte-LaTeX classes. In the preamble of your document, add the following code:

\makeatletter
\long\def\@caption#1[#2]#3{%
  \par
  \addcontentsline{\csname ext@#1\endcsname}{#1}%
    {\protect\numberline{\csname the#1\endcsname}{\ignorespaces #2}}%
  \begingroup
    \@parboxrestore
    \if@minipage
      \@setminipage
    \fi
    \@tufte@caption@font\@tufte@caption@justification
    \noindent\csname fnum@#1\endcsname. \ignorespaces#3\par% changed : to .
  \endgroup}
\makeatother

The example that you provided also has centered captions (as a by-product of using the caption package) instead of the ragged-right captions normally found in Tufte-style documents.

As Gonzalo Medina mentioned, the openany and a5paper options are ignored by the Tufte-LaTeX classes.

godbyk
  • 7,737
  • 2
  • 32
  • 47
  • Thank you. This worked as well. I'll keep this handy in case 'caption' doesn't work right. As for the centered captions, this doesn't occur when I actually have an image embedded. – Black Milk Oct 21 '12 at 06:20
  • It's really nice to know you're around (and sorry for not noticing it before). I really like the the features provided by the Tufte-LaTeX classes! – Gonzalo Medina Oct 21 '12 at 06:26
  • @godbyk I'd like to thank you for maintaining this wonderful class. – Black Milk Oct 21 '12 at 06:30
  • @EdwinMontufar: When I ran a test with images here, the captions were centered. But if it looks okay on your end, then feel free to stick with the caption package. – godbyk Oct 21 '12 at 06:49
  • @GonzaloMedina: Thanks! I'm hoping to do some more development work on the T-L classes over the next few months (as I'll be using it to write my dissertation). – godbyk Oct 21 '12 at 06:52
2

You can redefine marginfigure to include the change in the caption formatting:

\documentclass[english,dotinlabels,nohyper,notoc]{tufte-handout}
\usepackage{babel}
\usepackage{hyperref}
\usepackage{caption}
\captionsetup[figure]{labelformat=simple, labelsep = period}

\makeatletter
\renewenvironment{marginfigure}[1][-1.2ex]%
  {\begin{@tufte@margin@float}[#1]{figure}%
    \captionsetup{labelformat=simple, labelsep = period}}
  {\end{@tufte@margin@float}}
\makeatother

\begin{document}

\section{test}

\begin{figure}
\caption{erere}
\end{figure}
\vspace{20pt}
this is a test

\begin{marginfigure}
\caption{rerweaere}
\end{marginfigure}

\end{document}

enter image description here

As a side note, openany and a5paper are not supported class options with this document class.

Gonzalo Medina
  • 505,128