0

I'm using the tufte-book document class and the biblatex package, and would like to add margin notes indicating a near-full reference the "first time" a citation is made. Specifically, I'd like for the in-text citation itself to act as a sort of note call. The closest thing I've been able to achieve is:

enter image description here

Note two undesired things. First, the second margin note shouldn't exist. Second, the margin note's citation information should be exactly the same as the one in the main text. That is, no initials for first names.

I wrote first time between quotes because I'd like to reset the behavior for i) each page, ii) each even-odd pair of pages except the first page of the chapter which is odd (and should include the behavior), and iii) each chapter. Of course, only one case should hold for any complete document.

I tried, unsuccessfully, to adapt code from here, here, and here. I suspect two sources for the problem:

1) citetracker being disabled in all floats (p. 59 of the biblatex manual - version 3.11). I think the marginfix package arranges the margin notes using floats so I tried to set \citetrackertrue in several ways but all failed.

2) The \newbibmacro* section having incorrect syntax. More precisely, inside the \ifciteseen section.

Another strategy I tried was using \AtEveryCitekey to add additional code (\marginnote{}) the first time a key is used, but that didn't bring out the desired result.

Finally, please note I can't prescind from the fixmargin package, that I need to maintain APA style, and that I'm compiling with overleaf.com.

My minimal working example is:

\RequirePackage{filecontents}
\begin{filecontents}{mybib.bib}
@article{acemoglu2001colonial,
  title={The colonial origins of comparative development: An empirical investigation},
  author={Acemoglu, Daron and Johnson, Simon and Robinson, James A},
  journal={American Economic Review},
  volume={91},
  number={5},
  pages={1369--1401},
  year={2001}
}
\end{filecontents}

% ---------------------------------------

\documentclass[nobib]{tufte-book} 
\usepackage[T1]{fontenc}

\usepackage[
    style=apa,
    citestyle=apa,
    backend=biber
]{biblatex}
\addbibresource{mybib.bib}

\ExecuteBibliographyOptions{citetracker,sorting=none}
\DeclareCiteCommand{\fullcite}
  {\usebibmacro{prenote}}
  {\usedriver
     {\DeclareNameAlias{sortname}{default}}
     {\thefield{entrytype}}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\newbibmacro*{fullcite}{%
  \ifciteseen
    {}
    {\fullcite{\thefield{entrykey}}\addperiod}
}

\usepackage{xargs}
\newcommandx{\mytextcite}[3][1={0pt},2={}]{
    \textcite{#3}\marginnote[#1]{\fullcite[#2]{#3}.}
    }

\AtEveryCitekey{\clearfield{pages}}
\AtEveryCitekey{\clearfield{volume}}
\AtEveryCitekey{\clearfield{number}}

% For Apa to work
\DeclareLanguageMapping{english}{english-apa}

\usepackage{marginfix}

\begin{document}

\mytextcite{acemoglu2001colonial} argue that the evidence is not robust.

This new paragraph repeats a citation. We now want to check how repeated in-text citations are treated in the margin. \mytextcite{acemoglu2001colonial} are the only authors that \ldots

\printbibliography

\end{document}
  • Does the style have to be based on biblatex-apa or would a standard style like style=authoryear also be OK? Since biblatex-apa has to work hard to implement all particularities of the APA guidelines it is harder to modify and tweak than the standard styles. – moewe Jul 15 '18 at 19:02
  • I would prefer it be APA. As you say, it does some convenient hard work. I don't know why it's necessary to tweak the APA style file, but a solution that is easy to implement and doesn't go all the way (mainly because the reference in the margin contains first name initials) is also welcome. I would rather not have those initials because a few characters can make a difference when many margin notes are laid out. – Roberto Ferrer Jul 15 '18 at 22:42
1

As far as I can see neither 1 nor 2 are actually problems here.

biblatex's trackers are not disabled in \marginnote and the syntax for \newbibmacro*{fullcite} is actually correct, but there is no bibmacro called fullcite and it is never called, so that definition doesn't do anything.

But there is a problem with the proposed approach. \mytextcite is split into two different and separate cite commands (\textcite and \fullcite). Naturally these two commands have different values for \ifciteseen. If a citation has not been seen before \textcite has \ifciteseen switched to false, but toggles it to true for all subsequent citations. That means no matter what \ifciteseen will be true for the subsequent \fullcite.

The best way to get out of this problem is to define only one cite command with \DeclareCiteCommand that decides whether or not to issue a margin note directly. That way the \ifciteseen has the correct value.

The second change I applied is a matter of taste. Instead of using fullcite and deleting 'superfluous' information with \AtEveryCitekey I found it more elegant to define a macro that only prints the desired information in the first place. nearfullcite shows the labelname (author, editor, etc.), year, title and title of the enclosing work (journaltitle or booktitle) if appropriate.

Because you want to use biblatex-apa the code needed a few dirty hacks. bibaltex-apa has to work really hard to get some of the APA requirements right and it can be a pain to interfere with that.

\RequirePackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article{acemoglu2001colonial,
  title   = {The colonial origins of comparative development: An empirical investigation},
  author  = {Acemoglu, Daron and Johnson, Simon and Robinson, James A},
  journal = {American Economic Review},
  volume  = {91},
  number  = {5},
  pages   = {1369--1401},
  year    = {2001}
}
\end{filecontents}

\documentclass[nobib]{tufte-book} 
\usepackage[T1]{fontenc}

\usepackage[
    style=apa,
    citetracker=true,
    backend=biber,
]{biblatex}

\newcommand*{\bibmarginnote}[2][0pt]{%
  \marginnote[#1]{\protecting{\blxmkbibnote{foot}{#2}}}}

\DeclareCiteCommand{\margtextcite}
  {\usebibmacro{cite:init}%
   \usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{textcite}%
   \ifciteseen
     {}
     {\bibmarginnote{\usebibmacro{nearfullcite}}}}
  {}
  {\usebibmacro{textcite:postnote}%
   \usebibmacro{cite:post}}

\newrobustcmd*{\Margtextcite}{\bibsentence\margtextcite}

\makeatletter
% this macro is specific to biblatex-apa
\newbibmacro*{nearfullcite}{%
  \begingroup
  \let\ifciteseen\@secondoftwo% <- bad hack for biblatex-apa
  \printnames[labelname][-\value{listtotal}]{labelname}%
  \setunit{\addspace}%
  \usebibmacro{cite:paren:labeldate+extradate}%
  \newunit
  \ifbooklikeentrytype
    {\usebibmacro{maintitle+title}} 
    {\usebibmacro{title}}%
  \newunit
  \ifentrytype{article}
    {\usebibmacro{journal}}
    {}%
  \newunit
  \ifinbooklikeentrytype
    {\usebibmacro{maintitle+booktitle}}
    {}%
  \endgroup
}
\makeatother

\providebibmacro*{cite:paren:labeldate+extradate}{%
  \iffieldundef{labelyear}
    {}
    {\printtext[parens]{\printlabeldateextra}}}

\newcommand*{\ifbooklikeentrytype}{%
  \ifboolexpr{   test {\ifentrytype{book}}
              or test {\ifentrytype{collection}}
              or test {\ifentrytype{proceedings}}}}

\newcommand*{\ifinbooklikeentrytype}{%
  \ifboolexpr{   test {\ifentrytype{inbook}}
              or test {\ifentrytype{incollection}}
              or test {\ifentrytype{inproceedings}}}}

\newcommand*{\ifmisclikeentrytype}{%
  \ifboolexpr{   test {\ifentrytype{booklet}}
              or test {\ifentrytype{manual}}
              or test {\ifentrytype{misc}}
              or test {\ifentrytype{online}}
              or test {\ifentrytype{report}}
              or test {\ifentrytype{thesis}}
              or test {\ifentrytype{unpublished}}}}

\usepackage{marginfix}

\addbibresource{\jobname.bib}
\addbibresource{biblatex-examples.bib}

\begin{document}
\Margtextcite{acemoglu2001colonial,sigfridsson,nussbaum} argue that the evidence is not robust.

This new paragraph repeats a citation. We now want to check how repeated in-text citations are treated in the margin. It has been shown by \margtextcite{acemoglu2001colonial,geer,sigfridsson} that \ldots

\printbibliography
\end{document}

enter image description here

The cite tracker can be reset on a per-chapter (if available), per-section, per-subsection basis with the option citereset=chapter etc. etc.

For a per-page reset there is no citereset there you just use \iflastciteonsamepage from https://tex.stackexchange.com/a/275524/35864 instead of \ifciteseen.

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.