1

I would like

  1. my citation style to be a footnote Author (Year)
  2. for the entire Author (Year) to be a hyperlink to the bibliography
  3. for repeated citations to be Ibid

So far I can almost do it all.

The code below compiles to give the correct hyperlink and the correct ibidem, but the citation is Author Year (no parentheses). If I change each autocite to footcite I get the correct hyperlink and the correct citation, but the wrong ibidem: Author (ibid.).

If I make the first autocite a footcite, I get the intended result ... but that means I have to keep track of autocite and footcite, which defeats the purpose of automatic ibidem.

\documentclass{article}
\usepackage{varioref}
\usepackage{hyperref}
\usepackage{cleveref}
\usepackage[utf8]{inputenc}
\usepackage[backend=biber,style=authoryear-ibid,ibidtracker=constrict, autocite=footnote]{biblatex}

\DeclareFieldFormat{citehyperref}{%
  \DeclareFieldAlias{bibhyperref}{noformat}% Avoid nested links
  \bibhyperref{#1}}

\DeclareFieldFormat{textcitehyperref}{%
  \DeclareFieldAlias{bibhyperref}{noformat}% Avoid nested links
  \bibhyperref{%
    #1%
    \ifbool{cbx:parens}
      {\bibcloseparen\global\boolfalse{cbx:parens}}
      {}}}

\savebibmacro{cite}
\savebibmacro{textcite}

\renewbibmacro*{cite}{%
  \printtext[citehyperref]{%
    \restorebibmacro{cite}%
    \usebibmacro{cite}}}

\renewbibmacro*{textcite}{%
  \ifboolexpr{
    ( not test {\iffieldundef{prenote}} and
      test {\ifnumequal{\value{citecount}}{1}} )
    or
    ( not test {\iffieldundef{postnote}} and
      test {\ifnumequal{\value{citecount}}{\value{citetotal}}} )
  }
    {\DeclareFieldAlias{textcitehyperref}{noformat}}
    {}%
  \printtext[textcitehyperref]{%
    \restorebibmacro{textcite}%
    \usebibmacro{textcite}}}

% The following lines give the correct footcite Author (Year) but make the ibid erroneous
% Author (ibid)
\DeclareCiteCommand{\footcite}[\mkbibfootnote]
  {\boolfalse{cbx:parens}}
  {\usebibmacro{citeindex}%
   \iffirstcitekey
     {\setcounter{textcitetotal}{1}}
     {\stepcounter{textcitetotal}%
      \textcitedelim}%
   \usebibmacro{textcite}}
  {\ifbool{cbx:parens}
     {\bibcloseparen\global\boolfalse{cbx:parens}}
     {}}
  {\usebibmacro{textcite:postnote}}


\begin{filecontents}{\jobname.bib}

@book{Chomsky1986,
    Address = {Cambridge Mass.},
    Author = {Noam Chomsky},
    Publisher = {{MIT} Press},
    Title = {Barriers},
    Year = {1986}}

@book{Chomsky1981,
    Address = {Dordrecht},
    Author = {Noam Chomsky},
    Publisher = {Foris Publications},
    Title = {Lectures on Government and Binding},
    Year = {1981}}
\end{filecontents}

\addbibresource{\jobname.bib}

\begin{document}
\section{}
% switching between \autocite and \footcite solves some problems but 
% exposes others
\autocite{Chomsky1981} and \autocite{Chomsky1981}
\printbibliography
\end{document}

1 Answer 1

1

We can just redefine the normal cite macro to wrap the year in parentheses, in order to avoid problems with other cite commands we choose a new name for the changed macro cite:paren:labelyear+extrayear

\renewbibmacro*{cite}{\printtext[citehyperref]{%
  \global\boolfalse{cbx:loccit}%
  \iffieldundef{shorthand}
    {\ifthenelse{\ifciteibid\AND\NOT\iffirstonpage}
       {\usebibmacro{cite:ibid}}
       {\ifthenelse{\ifnameundef{labelname}\OR\iffieldundef{labelyear}}
          {\usebibmacro{cite:label}%
           \setunit{\addspace}}
          {\printnames{labelname}%
           \setunit{\nameyeardelim}}%
        \usebibmacro{cite:paren:labelyear+extrayear}}}
    {\usebibmacro{cite:shorthand}}}}

\renewbibmacro*{cite:paren:labelyear+extrayear}{%
  \iffieldundef{labelyear}
    {}
    {\printtext[parens]{%
       \printfield{labelyear}%
       \printfield{extrayear}}}}

There is no need to change the \footcite command

MWE

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[backend=biber,style=authoryear-ibid,ibidtracker=constrict, autocite=footnote]{biblatex}
\usepackage{hyperref}

\DeclareFieldFormat{citehyperref}{%
  \DeclareFieldAlias{bibhyperref}{noformat}% Avoid nested links
  \bibhyperref{#1}}

\renewbibmacro*{cite}{\printtext[citehyperref]{%
  \global\boolfalse{cbx:loccit}%
  \iffieldundef{shorthand}
    {\ifthenelse{\ifciteibid\AND\NOT\iffirstonpage}
       {\usebibmacro{cite:ibid}}
       {\ifthenelse{\ifnameundef{labelname}\OR\iffieldundef{labelyear}}
          {\usebibmacro{cite:label}%
           \setunit{\addspace}}
          {\printnames{labelname}%
           \setunit{\nameyeardelim}}%
        \usebibmacro{cite:paren:labelyear+extrayear}}}
    {\usebibmacro{cite:shorthand}}}}

\renewbibmacro*{cite:paren:labelyear+extrayear}{%
  \iffieldundef{labelyear}
    {}
    {\printtext[parens]{%
       \printfield{labelyear}%
       \printfield{extrayear}}}}

\addbibresource{biblatex-examples.bib}

\begin{document}
Lorem \autocite{sigfridsson} ipsum\autocite{sigfridsson}. Dolor\autocite{knuth:ct:a,knuth:ct:b}.
\end{document}

footnotes of the example document

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .