13

I'm trying a lot of subfloat-like packages with tufte-latex and all of them seem to interact badly with tufte-latex in the matter of labels, refs and captions. To captions I could find solutions thanks to you guys, but refs are still elusive.

Originally no numbering was appearing in the figures, but now the numbers appear but can't be referenced by the labels.

The following minimal examples show what's wrong. Both results in undefined references for the tufte-handout class and work perfectly with article.

\documentclass{tufte-handout}

\usepackage[demo]{graphicx}
\usepackage[caption=false]{subfig}

\begin{document}
\begin{figure}
\centering
  \subfloat[Subfigure 1] % caption for subfigure 1
  {
    \label{fig:sub1}
    \includegraphics[scale=0.5]{subfig1.eps}
  }
  \subfloat[Subfigure 2] % caption for subfigure 2
  {
    \label{fig:sub2}
    \includegraphics[scale=0.5]{subfig2.eps}
  }
  \caption{Results for subfigure}
  \label{fig:results}
  \end{figure}
  In the text, you can refer to subfigures of figure \ref{fig:results} as \ref{fig:sub1}, \ref{fig:sub2}, \subref{fig:sub1}, \subref{fig:sub2}.
\end{document}

This one also works ok with captions but mess up references (gives undefined references with tufte-handout, but works ok with article).

\documentclass{tufte-handout}

\usepackage{caption}
\usepackage{subcaption}
\usepackage[demo]{graphicx}
\captionsetup{compatibility=false}

\begin{document}
\begin{figure}
\centering
  \begin{subfigure}[b]{0.5\textwidth}
    \includegraphics{subfig1.eps}
    \caption{Subfigure 1}
    \label{fig:sub1}   
  \end{subfigure}
  ~
  \begin{subfigure}[b]{0.5\textwidth}
    \includegraphics{subfig2.eps}
    \caption{Subfigure 2}
    \label{fig:sub2}   
  \end{subfigure}
  \caption{Results for subfigure}
  \label{fig:results}
\end{figure}

In the text, you can refer to subfigures of figure \ref{fig:results} as \ref{fig:sub1}, \ref{fig:sub2}, \subref{fig:sub1}, \subref{fig:sub2}.
\end{document}

Are there any other subfloat packages that would work with tufte-latex? Or maybe a way to make the above packages work.

3
  • 6
    The code of tufte-common.def suggests it is compatible with the subfigure package. However, thesubfigure package is often considered to be obsolete. I believe a feature request to the tufte-latex developers (=> compatibility with the subcaption package) seems reasonable...
    – cgnieder
    Commented Dec 17, 2012 at 22:36
  • 1
    "The subfigure and subfig packages redefine the caption and label commands. Unfortunately, the TL classes also need to redefine these commands. In the new version, I'm going go add some code to detect the use of the subfigure/subfig package and try to work together with them." groups.google.com/forum/#!searchin/tufte-latex/subfig/… Commented Jul 18, 2013 at 13:22
  • IMHO "going to add some code to detect the use..." is the totally wrong approach. Contacting the author (=me) with the goal to implement a proper interface between tufte and caption would IMHO be a much better idea because AFAIK in the current situation neither the maintainer of tufte nor me (the maintainer of caption) is able to build a proper solution without relying on internals of the other class/package which could (of course) change in future versions...
    – user2574
    Commented Jul 27, 2013 at 7:46

1 Answer 1

3

Unfortunately, as explained in the comments neither the cited subfigure package seem completely compatible. In the example this package allow correct references to the subcaptions, but hides the reference to the main caption.

However, luckily this can be solved if the main label is protected and included in the caption (not below the caption).

MWE

\documentclass{tufte-handout}
\usepackage{subfigure}
\usepackage[demo]{graphicx}

\begin{document}

\begin{figure}
\subfigure[\label{fig:sub1}Subfigure 1]
{ \includegraphics{subfig1.eps}}
\subfigure[\label{fig:sub2}Subfigure 2]
{ \includegraphics{subfig1.eps}}
\caption{\protect\label{fig:results}Results for subfigure}
\end{figure}

\noindent In the text, you can refer to subfigures of
figure \ref{fig:results} as \ref{fig:sub1}, \ref{fig:sub2},
\subref{fig:sub1}, \subref{fig:sub2}.

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .