# referencing subfigures with tufte-book and subfig package

I can't figure out how to correctly reference subfigures with tufte-book class. Apparently it's NOT compatible with the subcaption package.

After a lot of googling, I tried:

• subfigure: all subfigures are correctly referenced, but it messes up the number (and link) of a lot of regular figures when I reference them.
• subfig: all links are correct, but subfigures are correctly referenced only with \subref (which outputs a letter) and not with \ref (it outputs ??).

It seems easier to work with subfig, then. The only workaround I found is to combine \ref and \subref when I want to reference a subfigure.

Is there a less ugly solution?

Here's an example:

    \documentclass{tufte-book}
\usepackage[caption=false]{subfig}
\usepackage[demo]{graphicx}
\begin{document}

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

We have Figure~\ref{fig:results} with a subfigure~\subref{fig:sub1} and~\subref{fig:sub2},
or rather Figure~\ref{fig:sub1} and Figure~\ref{fig:sub2}.

By combining the two, I get Figure~\ref{fig:results}\subref{fig:sub1} and Figure~\ref{fig:results}\subref{fig:sub2}

\end{document}


There is no subfloat environment with subfig, but a \subfloat command. And no, there's no “nice” solution for combining the cross references.

\documentclass{tufte-book}
\usepackage[caption=false]{subfig}
\usepackage[demo]{graphicx}

\begin{document}

\begin{figure}[t]
\phantomsection
\subfloat[Subfigure 1\label{fig:sub1}]
{%
\includegraphics[width=\textwidth]{subfig1.eps}%
}

\subfloat[Subfigure 2\label{fig:sub2}]
{%
\includegraphics[width=\textwidth]{subfig1.eps}%
}

\caption{Results for subfigure\label{fig:results}}

\end{figure}

We have Figure~\ref{fig:results} with a subfigure~\subref{fig:sub1}
and~\subref{fig:sub2},

By combining the two, I get Figure~\ref{fig:results}\subref{fig:sub1} and
Figure~\ref{fig:results}\subref{fig:sub2}

\end{document}


• Thanks! But does anything change with your modifications? The output is the same, isn't it? – Ricky Robinson Apr 3 '16 at 23:06
• @RickyRobinson Well, now the input is correct. ;-) – egreg Apr 3 '16 at 23:08