0

How can I hyperref only the year part of a \citet entry?

I am using \citet and the result is the author and year appear with hyperref blue link. I only wan the year to show like that.

enter image description here

example of the code is:

\documentclass[onecolumn]{svjour3}       % onecolumn (second format)
\usepackage[authoryear]{natbib}
\setcitestyle{aysep={}}
\usepackage[colorlinks,citecolor=blue,urlcolor=blue,bookmarks=false,hypertexnames=true]{hyperref} 
\usepackage{url}
\def\urlprefix{}
\urlstyle{rm}
\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{document}

\title{title title title
}

... and marine environmental monitoring programs \citep{GuptaandSingh2011}. \citet{ElderCollins} pointed out the convenience of using introduced species as monitoring organisms because of their physiological tolerance range and their wide... 

\renewcommand*{\bibfont}{\footnotesize}
\bibliographystyle{spbasic}
\bibliography{RefLimnoBECT}

\end{document}

also the bibtex is:

@incollection{ElderCollins,
  title={Freshwater molluscs as indicators of bioavailability and toxicity of metals in surface-water systems},
  author={Elder, John F and Collins, Jerilyn J},
  booktitle={Reviews of Environmental Contamination and Toxicology},
  editor={Ware, GW},  
  pages={37--79},
  year={1991},
  publisher={Springer}, 
  address={New York},
}

Thank you so much in advance for the help!

  • 1
    I've voted to close this question as a duplicate, as the patch code you posted appears to be a verbatim copy of the patch code contained in Audrey B.'s answer posted back in September 2011. If you believe that this is not the case, i.e., if you believe that your patch code differs materially from what Audrey wrote back in 2011, please point out how your code differs materially from that in the earlier query and associated answer. – Mico Feb 28 at 9:53
0

I just worked it out, there was a mistake in the patch code when separated by opening bracket. I decided to leave this question with my answer in case it helps someone else.

the correct patch would be:

% 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}}
  {}{} 
| improve this answer | |
  • 1
    The use of the if*#1*\ instead of \if#1 was already suggested back in 2011 in this answer by @Audrey. – Mico Feb 29 at 9:08

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