# tufte-latex: biblatex citations in captions

How can biblatex citations used in captions of the tufte-book document class?

The following MWE does not work since the \autocite command in the image caption does not properly handled by tufte-book. I assume the marginnote needs to be queued somewhere in tufte-common.def.

% !TeX program = pdflatex
% !TeX encoding = UTF-8
% !TeX spellcheck = en-US
% !BIB program = biber
\documentclass[a4paper,twoside,justified,marginals=raggedright,nobib]{tufte-book}
\usepackage{graphicx}

\usepackage[%
backend=biber,
bibstyle=authoryear,
citestyle=authortitle-icomp,
]{biblatex}%

\begin{document}
Citation in text.\autocite{westfahl:space}
\begin{figure}
\includegraphics{example-grid-100x100pt}
\caption{Citation in caption.\autocite{westfahl:space}}
\end{figure}
\end{document}

• The problem is that biblatex's footnote detection does not work with the tufte classes (with the tufte classes one should probably consider a caption to be a footnote as well). So \autocite (which branches depending on whether we're in a footnote or not) goes miss, just use \cite and everything is tickety-boo. Feb 13, 2016 at 18:54

By default, the Tufte classes are not too fond of you using a \footnote from within a \caption. Since biblatex doesn't know we are using \autocite from within a \caption it defaults to \footcite; indeed since patching the \footnote command failed, biblatex can't even detect it is in a footnote and use \parencite there.

With

\makeatletter
\long\def\@caption#1[#2]#3{%
\expandafter\ifx\csname if@capstart\expandafter\endcsname
\csname iftrue\endcsname
\global\let\@currentHref\hc@currentHref
\else
\hyper@makecurrent{\@captype}%
\fi
\@ifundefined{NR@gettitle}{%
\def\@currentlabelname{#2}%
}{%
\NR@gettitle{#2}%
}%
\protect\numberline{\csname the#1\endcsname}{\ignorespaces #2}%
}%
\begingroup
\toggletrue{blx@footnote}%
\@parboxrestore
\if@minipage
\@setminipage
\fi
\@tufte@caption@font\@tufte@caption@justification%
\expandafter\ifx\csname if@capstart\expandafter\endcsname
\csname iftrue\endcsname
\global\@capstartfalse
%\@makecaption{\csname fnum@#1\endcsname}{\ignorespaces#3}%
\noindent\csname fnum@#1\endcsname: \ignorespaces#3%
\else
%\@makecaption{\csname fnum@#1\endcsname}{%
\noindent\csname fnum@#1\endcsname:
\ignorespaces
\ifHy@nesting
\expandafter\hyper@@anchor\expandafter{\@currentHref}{#3}%
\else
\expandafter\hyper@@anchor\expandafter{%
\@currentHref
}{\relax}%
}%
#3%
\fi
%}%
\fi
\par
\endgroup
}

\renewcommand\@footnotetext[2][0pt]{%
\marginpar{%
\hbox{}\vspace*{#1}%
\def\baselinestretch {\setspace@singlespace}%
\reset@font\footnotesize%
\@tufte@margin@par% use parindent and parskip settings for marginal text
\vspace*{-1\baselineskip}\noindent%
\protected@edef\@currentlabel{%
\csname p@footnote\endcsname\@thefnmark%
}%
\color@begingroup%
\toggletrue{blx@footnote}%
\@makefntext{%
\ignorespaces#2%
}%
\color@endgroup%
}%
}%
\makeatother


a bastardisation of tufte-common.def's definitions, bits of what hyperref.sty does and patching done by biblatex, footnote detection will work and \captions will be treated as if they were sidenotes by biblatex's tracker.

MWE

\documentclass[a4paper,twoside,justified,marginals=raggedright,nobib]{tufte-book}
\usepackage{graphicx}
\usepackage{mwe}

\usepackage[%
backend=biber,
bibstyle=authoryear,
citestyle=authortitle-icomp,
]{biblatex}%

\makeatletter
\long\def\@caption#1[#2]#3{%
\expandafter\ifx\csname if@capstart\expandafter\endcsname
\csname iftrue\endcsname
\global\let\@currentHref\hc@currentHref
\else
\hyper@makecurrent{\@captype}%
\fi
\@ifundefined{NR@gettitle}{%
\def\@currentlabelname{#2}%
}{%
\NR@gettitle{#2}%
}%
\protect\numberline{\csname the#1\endcsname}{\ignorespaces #2}%
}%
\begingroup
\toggletrue{blx@footnote}%
\@parboxrestore
\if@minipage
\@setminipage
\fi
\@tufte@caption@font\@tufte@caption@justification%
\expandafter\ifx\csname if@capstart\expandafter\endcsname
\csname iftrue\endcsname
\global\@capstartfalse
%\@makecaption{\csname fnum@#1\endcsname}{\ignorespaces#3}%
\noindent\csname fnum@#1\endcsname: \ignorespaces#3%
\else
%\@makecaption{\csname fnum@#1\endcsname}{%
\noindent\csname fnum@#1\endcsname:
\ignorespaces
\ifHy@nesting
\expandafter\hyper@@anchor\expandafter{\@currentHref}{#3}%
\else
\expandafter\hyper@@anchor\expandafter{%
\@currentHref
}{\relax}%
}%
#3%
\fi
%}%
\fi
\par
\endgroup
}

\renewcommand\@footnotetext[2][0pt]{%
\marginpar{%
\hbox{}\vspace*{#1}%
\def\baselinestretch {\setspace@singlespace}%
\reset@font\footnotesize%
\@tufte@margin@par% use parindent and parskip settings for marginal text
\vspace*{-1\baselineskip}\noindent%
\protected@edef\@currentlabel{%
\csname p@footnote\endcsname\@thefnmark%
}%
\color@begingroup%
\toggletrue{blx@footnote}%
\@makefntext{%
\ignorespaces#2%
}%
\color@endgroup%
}%
}%
\makeatother

\begin{document}
Citation in text.\autocite{westfahl:space}
\begin{figure}
\includegraphics{example-grid-100x100pt}
\caption{Citation in caption. \autocite{westfahl:space}}
\end{figure}
\end{document}


• Dark magick indeed. Feb 24, 2019 at 19:13
• This worked for me. However, I have an issue. I am using style=verbose in biblatex and I am using the citecounter=true and citecounter=true options so that biblatex abbreviates in the margin of the tufte-book class subsequent citations of the same source. However, using your solution, in the case where the citation of the source is not the first occurrence when it appears in the caption, biblatex is still treating it as the very first occurrance by not abbreviating it. Is there a workaround or easy fix for this particular situation? Sep 10, 2022 at 5:20
• @Steven Citation tracking is disabled inside floats since they are "outside the normal flow of text". Maybe tex.stackexchange.com/q/506161/35864 and linked issues help. If not, please open a new question with suitable example document. Sep 10, 2022 at 5:42
• @moewe Brilliant! That did the trick. Thank you! Sep 11, 2022 at 5:44
• @moewe I have another issue that I have posted here: tex.stackexchange.com/questions/657138/… Perhaps you may be able to offer some guidance? Sep 14, 2022 at 9:06

I found a manual workaround based on Using \footnote in a figure's \caption, but I would prefer an automated solution.

% !TeX program = pdflatex
% !TeX encoding = UTF-8
% !TeX spellcheck = en-US
% !BIB program = biber
\documentclass[a4paper,twoside,justified,marginals=raggedright,nobib]{tufte-book}
\usepackage{graphicx,lipsum}

\usepackage[%
backend=biber,
bibstyle=authoryear,
citestyle=authortitle-icomp,
]{biblatex}%