[Tex/LaTex] Are there any subfloat package that works with tufte-latex

captionssubcaptionsubfloatstufte

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{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.

Best Answer

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}