Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
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 Dec 17 '12 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/… –  Alessandro Cuttin Jul 18 '13 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... –  Axel Sommerfeldt Jul 27 '13 at 7:46

1 Answer 1

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}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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