46

I am using biblatex with the authoryear styles.

So far I've been able to find everything I need easily in the excellent documentation, but I'm stuck on one thing.

With my current settings (below) citations only have the year hyperlinked to the bibliography entry. I think prior to using biblatex I would have the whole citation (authors + year) as a reference - I think this is easier to click etc. when browsing.

Is there an easy way to get this (or does it involve creating a new style).

\usepackage[style=authoryear,
            bibstyle=authoryear,
            citestyle=authoryear,
            natbib=true,
            hyperref=true,
            backref=true,
            abbreviate=true]{biblatex}
30

Add the following to you preamble:

\DeclareCiteCommand{\cite}
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \printtext[bibhyperref]{\usebibmacro{cite}}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand*{\cite}
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \printtext[bibhyperref]{\usebibmacro{citeyear}}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand{\parencite}[\mkbibparens]
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
    \printtext[bibhyperref]{\usebibmacro{cite}}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand*{\parencite}[\mkbibparens]
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
    \printtext[bibhyperref]{\usebibmacro{citeyear}}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand{\footcite}[\mkbibfootnote]
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
  \printtext[bibhyperref]{ \usebibmacro{cite}}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand{\footcitetext}[\mkbibfootnotetext]
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \printtext[bibhyperref]{\usebibmacro{cite}}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand{\textcite}
  {\boolfalse{cbx:parens}}
  {\usebibmacro{citeindex}%
   \printtext[bibhyperref]{\usebibmacro{textcite}}}
  {\ifbool{cbx:parens}
     {\bibcloseparen\global\boolfalse{cbx:parens}}
     {}%
   \multicitedelim}
  {\usebibmacro{textcite:postnote}}

Note that this code snipped is basically taken from here and adapted to biblatex v0.9b, i.e. the definitions for \footcitetext and \textcite are added resp. changed. (I also decided not to add hyperlinks for \citeauthor and \citeyear.)

  • 2
    One thing I noticed with this is that for in text citations the closing bracket is not part of the hyperlink (although the rest of the text is) - so this looks a bit messy. Is there any way around that? – robince Jan 9 '11 at 19:38
  • 2
    @thrope Another user has requested a similar feature here. – Audrey Aug 31 '11 at 17:27
  • @robince Check out this answer. – Luke Davis Feb 20 '18 at 21:40
8

The biblatex style apa (which is a modified authoryear style) does this for you. For example:

\usepackage[american]{babel}
\usepackage[style=apa]{biblatex}
\DeclareLanguageMapping{american}{american-apa}

Note it is also recommended that you load the csquotes package.

It needs a relatively up to date version of biblatex to work.

  • 2
    I updated to MacTex / TexLive 2010 to try this but the apa style appears to be broken - my document wont compile with "Undefined control sequence. <argument> \mkbibdateapalongextra {year}{month}{day}" - same problem as here: developpez.net/forums/d984595/autres-langages/autres-langages/… – robince Jan 9 '11 at 19:39
  • 2
    Have you included the \DeclareLanguageMapping line? it is necessary... – Seamus Jan 9 '11 at 20:58
  • 2
    @thrope and, of course, got the right babel settings? This sounds like a localisation issue. – Seamus Jan 9 '11 at 21:04
  • 3
    I'm using babel with [english] so I put the mapping as {english}{english-apa}... I had another go being more careful to delete all the intermediate files and it seemed to compile successfully (using bibstyle=authoryear, citestyle=apa) - but it doesn't link the names... only the years of the citation are linked. – robince Jan 11 '11 at 10:22
  • 1
    @Seamus I am using \parencite with loaded option style=apa. Is there any recent solution to hyperlink both author and year? – Diaa Dec 7 '16 at 14:02
3

As an addition to the answer provided by lockstep, the following code for \textcite includes the closing parenthesis in the link too, and, unfortunately, the space afterwards.

\DeclareCiteCommand{\textcite}
 {\boolfalse{cbx:parens}}
  {\usebibmacro{citeindex}%
    \printtext[bibhyperref]{\printnames{labelname}%
      \printtext{ (\printfield{year}\printtext{)}}}}
 {\ifbool{cbx:parens}
  {\bibcloseparen\global\boolfalse{cbx:parens}}
  {}%
 \multicitedelim}
{\usebibmacro{textcite:postnote}}
  • 1
    This appears to give the desired output only for \textcite{<entrykey>}, but doesn't handle notes properly. prenote gets ignored entirely. postnote is enclosed in a second set of parentheses. For example \textcite[postnote]{key} gives labelname (labelyear) (postnote), not labelname (labelyear, postnote). – Audrey Sep 1 '11 at 0:06

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.