5

I'm using tufte-latex in combination with BibLaTeX, as described in Can I use biblatex with Tufte classes? and I have tried the variants suggested both in the question and in the answer. Using the variant based on biblatex's option autocite=footnote, I get nicer results, with shorter version of the citation when it's used more than once, but I don't have the ability to fine-tune the position of the sidenote with the citation, as in the case of redefining the cite command. On the other hand, the redefined cite command always provides me the full version of citation, and the margins quickly become overflooded with citations.

MWE

\documentclass[nobib]{tufte-handout}

\usepackage{hyphenat}

\usepackage[backend=biber,
autocite=footnote,
citecounter=true, 
style=verbose,
citetracker=true
]{biblatex}

%redefinition of cite command
\renewcommand{\cite}[2][0pt]{\sidenote[][#1]{\fullcite{#2}}}


\addbibresource{biblatex-examples.bib}

\begin{document}

This,\autocite{springer} should be a side note and this\autocite{springer} should too.

This,\cite{springer} should be a side note and this\cite[2cm]{springer} should be a shifted down side note.

\printbibliography 

\end{document}

Output: MWE output

So my question is: is it possible somehow to get controllable position for the sidenotes generated with the autocite command?

  • Can you provide a MWE that shows both how you use \cite and \autocite? – moewe Apr 15 '15 at 8:32
  • Also: Welcome to TeX.SX! – moewe Apr 15 '15 at 8:32
  • Yes, I've just added it – Oleg Soloviev Apr 15 '15 at 10:49
4

One (at least I find) elegant and quite usable way would be a new command, say \sidecite.

It will use the same syntax as all the \cite command, but features an optional offset argument enclosed in <> at the beginning.

We will use xparse to implement it.

First we copy the definition of \footcite from the relevant .cbx style file (in your case verbose.cbx), rename it to \sidecitehelper and replace \mkbibfootnote by \bibfootnotewrapper (so we don't actually get a footnote, but consistent output).

\DeclareCiteCommand{\sidecitehelper}[\bibfootnotewrapper]
  {\usebibmacro{prenote}%
   \toggletrue{blx@footnote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {\multicitedelim}
  {\usebibmacro{cite:postnote}}

Then we define \sidecite

\ExplSyntaxOn
\NewDocumentCommand\sidecite{D<>{}O{}om}{%
  \iftoggle{blx@footnote}
    {\cs_set_protected_nopar:Npn \__sct_wrapper:nn ##1 ##2 {\mkbibparens{##2}}}
    {\cs_set_protected_nopar:Npn \__sct_wrapper:nn ##1 ##2 {\sidenote[][##1]{##2}}}
    {\IfNoValueTF{#3}
      {\__sct_wrapper:nn{#1}{\sidecitehelper[#2]{#4}}}
      {\__sct_wrapper:nn{#1}{\sidecitehelper[#2][#3]{#4}}}}
}
\ExplSyntaxOff

With this updated definition of \sidecite we now check if we are in a side note (footnote) and if so only wrap the citation in parentheses instead of creating nested foot/side notes. We have a dummy command \__sct_wrapper:nn that in footnotes just wraps things in parentheses and outside of footnotes creates a side note. In biblatex the command \mkbibfootnote takes care of that, and if we hadn't wanted \sidenote to be able to take its optional argument, an approach with a wrapper command mirroring \mkbibfootnote would have been easier; but since we need the optional argument, all this handling has been moved to \sidecite.

There is one problem left with that: tufte-latex's \footnote command can by default not be patched by biblatex, so we need to do that ourselves. We use xpatch for that

\makeatletter
\xpatchcmd{\@footnotetext}%
      {\color@begingroup}
      {\color@begingroup\toggletrue{blx@footnote}}
      {}
      {}
\makeatother

MWE

\documentclass[nobib]{tufte-handout}
\usepackage{xparse}
\usepackage{xpatch}
\usepackage[
  style=verbose,
  autocite=footnote,
  backend=biber
]{biblatex}
\addbibresource{biblatex-examples.bib}

\makeatletter
\xpatchcmd{\@footnotetext}%
      {\color@begingroup}
      {\color@begingroup\toggletrue{blx@footnote}}
      {}
      {}
\makeatother

\DeclareCiteCommand{\sidecitehelper}[\bibfootnotewrapper]
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {\multicitedelim}
  {\usebibmacro{cite:postnote}}

\ExplSyntaxOn
\NewDocumentCommand\sidecite{D<>{}O{}om}{%
  \iftoggle{blx@footnote}
    {\cs_set_protected_nopar:Npn \__sct_wrapper:nn ##1 ##2 {\mkbibparens{##2}}}
    {\cs_set_protected_nopar:Npn \__sct_wrapper:nn ##1 ##2 {\sidenote[][##1]{##2}}}
    {\IfNoValueTF{#3}
      {\__sct_wrapper:nn{#1}{\sidecitehelper[#2]{#4}}}
      {\__sct_wrapper:nn{#1}{\sidecitehelper[#2][#3]{#4}}}}
}
\ExplSyntaxOff

\begin{document}

This,\sidecite[8]{springer} should\autocite{springer} be a side note and this\sidecite[see][8]{springer} should too.

Lorem ipsum\sidecite<2cm>[9]{geer} dolor\sidecite[cf.][]{springer}.

Sit\sidenote{amet \sidecite{geer}}.

\printbibliography 

\end{document}

enter image description here

Note the 2cm offset of footnote 3 (\sidecite<2cm>[9]{geer}), as well as the natural "if there is only one optional argument, it is the postnote" behaviour standard biblatex cite commands in footnote 1 (\sidecite[8]{springer}). The \sidecite in footnote 6 (\sidenote{amet \sidecite{geer}}) becomes a citation in parentheses to avoid nested footnotes.

  • I have only one remark -- actually, I wanted to use this special command only on a couple of difficult pages; and to leave autocite elsewhere, but I noticed that than autocite do not correlate with sidecite. Try to change the first sidecite in your MWE This,\autocite[8]{springer} should be a side note and this\sidecite[see][8]{springer} should too. – Oleg Soloviev Apr 15 '15 at 10:47
  • I'm not entirely sure what you mean by "they do not correlate". I have, however, made an edit that should make citation tracking more "smooth", maybe that is what you are after. – moewe Apr 15 '15 at 14:14
  • Sorry, I wasn't clear -- I meant the sidecite doesn't see that the citation has been already called by autocite and produces full citation instead of abbreviated one. What have you edited? --I cannot spot the difference – Oleg Soloviev Apr 15 '15 at 14:21
  • @OlegSoloviev I had inserted a \toggletrue{blx@footnote} into the pre-code of \sidecitehelper. I have, however, just edited a slightly greater change to the code, you might want to try that. – moewe Apr 16 '15 at 5:28
  • 1
    Fantastic! It would be great if this becomes part of the tufte classes. – Manuel Schmidt May 26 '16 at 10:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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