Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question
add comment

3 Answers

up vote 14 down vote accepted

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.)

share|improve this answer
    
Thanks very much! –  thrope Aug 14 '10 at 11:20
    
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? –  thrope Jan 9 '11 at 19:38
2  
@thrope Another user has requested a similar feature here. –  Audrey Aug 31 '11 at 17:27
add comment

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.

share|improve this answer
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/… –  thrope 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
1  
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. –  thrope Jan 11 '11 at 10:22
    
@thrope What kind of citation command are you using (\textcite \parencite etc?) and what version of biblatex and biblatex-apa do you have? \textcite{key} should have both as a link. If you add postnotes, prenotes or things like that \textcite[postnote]{key} then only the year gets linked. –  Seamus Jan 11 '11 at 11:20
add comment

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}}
share|improve this answer
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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