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
.)
Using etoolbox
you can patch natbib
's internal author-year citation command so that it hyperlinks only the year whenever both the year and name are included in the citation label. The code below demonstrates patches for natbib.sty
, version 2010/09/13 8.31b
.
\documentclass{article}
\usepackage{natbib}
\usepackage[colorlinks]{hyperref}
\usepackage{etoolbox}
\makeatletter
% Patch case where name and year are separated by aysep
\patchcmd{\NAT@citex}
{\@citea\NAT@hyper@{%
\NAT@nmfmt{\NAT@nm}%
\hyper@natlinkbreak{\NAT@aysep\NAT@spacechar}{\@citeb\@extra@b@citeb}%
\NAT@date}}
{\@citea\NAT@nmfmt{\NAT@nm}%
\NAT@aysep\NAT@spacechar\NAT@hyper@{\NAT@date}}{}{}
% Patch case where name and year are separated by opening bracket
\patchcmd{\NAT@citex}
{\@citea\NAT@hyper@{%
\NAT@nmfmt{\NAT@nm}%
\hyper@natlinkbreak{\NAT@spacechar\NAT@@open\if*#1*\else#1\NAT@spacechar\fi}%
{\@citeb\@extra@b@citeb}%
\NAT@date}}
{\@citea\NAT@nmfmt{\NAT@nm}%
\NAT@spacechar\NAT@@open\if*#1*\else#1\NAT@spacechar\fi\NAT@hyper@{\NAT@date}}
{}{}
\makeatother
\begin{filecontents}{\jobname.bib}
@book{companion,
author = {Goossens, Michel and Mittelbach, Frank and Samarin, Alexander},
title = {The LaTeX Companion},
edition = {1},
publisher = {Addison-Wesley},
location = {Reading, Mass.},
year = {1994}}
@book{adams:life,
title = {Life, the Universe and Everything},
author = {Adams, Douglas},
series = {The Hitchhiker's Guide to the Galaxy},
publisher = {Pan Macmillan},
year = {1980}}
@book{adams:rest,
title = {The Restaurant at the End of the Universe},
author = {Douglas Adams},
series = {The Hitchhiker's Guide to the Galaxy},
publisher = {Pan Macmillan},
year = {1980}}
\end{filecontents}
\newcommand{\cmd}[1]{\textbackslash\texttt{#1}}
\defcitealias{companion}{GMS}
\begin{document}
\noindent
\cmd{citet}: \citet[1--10]{companion,adams:rest,adams:life} \\
\cmd{cite}: \cite[e.g.][100]{adams:life}; \cite{adams:rest} \\
\cmd{citep}: \citep[e.g.][1--10]{adams:rest,adams:life} \\
\cmd{citetext}; \cmd{citealp}:
\citetext{see \citealp[10]{adams:rest}; or even better \citealp{adams:life}} \\
\cmd{citeauthor}, \cmd{citeauthor*}: \citeauthor{adams:life}; \citeauthor*{companion} \\
\cmd{citeyear}, \cmd{citeyearpar}: \citeyear{adams:life}; \citeyearpar{adams:rest} \\
\cmd{citetalias}, \cmd{citepalias}: \citetalias{companion}; \citepalias{companion} \\
\cmd{citenum}: \citenum{adams:life,adams:rest}
\bibliographystyle{plainnat}
\bibliography{\jobname}
\end{document}
Best Answer
The code below hyperlinks the entire citation label for most citation commands. For
\textcite
the hyperlink includes the brackets aroundlabelyear
+extrayear
, unless there are pre- or postnotes. In this case the link is applied only tolabelyear
+extrayear
.Here is the output you should obtain with biblatex 2.6 or earlier. The solution also works for later releases, where
\textcite
and friends use theand
string as a final citation delimiter.