5

I am using natbib and unsrtnat style for numerical citation with hyperref package.

\documentclass{article}  
\usepackage[square, super, sort]{natbib} 
 \usepackage[dvips,
             bookmarks,
             bookmarksopen = true,
             bookmarksnumbered = true,
             breaklinks = true,
             linktocpage,
             pagebackref,
             colorlinks = true,
             linkcolor = blue,
             urlcolor  = blue,
             citecolor = red,
             anchorcolor = green,
             hyperindex = true,
             hyperfigures]{hyperref}

 \begin{document}
 \bibliographystyle{unsrtnat}
  some text...\citet{ref1}
   other text
   \end{document}

  % some bibliography file
  % test.bib
  @Article {ref1, author = Author1, title = Title1, year = 2010}

\citet{ref1} results in Author1 et al. [1] where only [1] is hyperlinked to the reference. I would like that name part of citation (Author1 et al.) is also hyperlinked. How to make that work?

6

Under numeric citation labels natbib sets names with the \NAT@test command, defined in natbib.sty. Using etoolbox you can patch \NAT@test to mark the name list with an additional hyperlink.

\documentclass{article}
\usepackage[square,super,sort]{natbib}
\usepackage[colorlinks]{hyperref}
\usepackage{etoolbox}

\makeatletter
\patchcmd{\NAT@test}{\else \NAT@nm}{\else \NAT@hyper@{\NAT@nm}}{}{}
\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,
  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}

\begin{document}
\citet{adams}, \citet{companion}, \citet{adams,companion}
\bibliographystyle{unsrtnat}
\bibliography{\jobname}
\end{document}

enter image description here

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.