# How to hyperlink only the year part when using natbib and hyperref

I am using the natbib and hyperref packages:

\usepackage{natbib}

\usepackage[pagebackref=true, plainpages=false, bookmarks, bookmarksnumbered,
urlcolor=blue]{hyperref}


With my current settings (above) both the name and the year are hyperlinked.

My question is, whether there is a way to hyperlink (or color) only the year-not the author(s).

I have the impression reading this post hyperlink name with biblatex authoryear that biblatex does it by default. However changing to biblatex is not an option for me at this point.

-

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{etoolbox}

\makeatletter

% Patch case where name and year are separated by aysep
\patchcmd{\NAT@citex}
{\@citea\NAT@hyper@{%
\NAT@nmfmt{\NAT@nm}%
\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}%
{\@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},
year = {1994}}
title = {Life, the Universe and Everything},
series = {The Hitchhiker's Guide to the Galaxy},
publisher = {Pan Macmillan},
year = {1980}}
title = {The Restaurant at the End of the Universe},
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