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.

When one want to do a manual hyperlink to a \label target one can use \hyperref[label]{text}.

But what if one want to create a link pointing to an item in the bibliography, with a user defined text and the same color as \cite

I would rather not have to use \citealias all over the place (which might be the right answer, but we are a bit late for that in this project)

Any ideas?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

The hyperref anchor for key is named cite.key. It is an anchor, not a label, so you have to use \hyperlink instead of \hyperref, but that doesn't use the correct link border color etc. In the following, I have instead provided \hyperlinkcite for that, for which you just supply the cite key and the link text as arguments:

\documentclass{article}

\usepackage{natbib}
\usepackage{hyperref}
\begin{filecontents}{\jobname.bib}
@Book{test1,
  author    = {Goossens, Michel and Mittelbach,
               Frank and Samarin, Alexander},
  title     = {The LaTeX Companion},
  publisher = {Addison-Wesley},
  location  = {Reading, Mass.},
  year      = {1994},
}
\end{filecontents}
\bibliographystyle{plainnat}

\makeatletter
\newcommand*{\hyperlinkcite}[1]{\hyper@link{cite}{cite.#1}}%\hyperlinkcite takes 2 arguments: #1<- cite-key, #2<- link-text
\makeatother


\begin{document}
\citep{test1}, \hyperlinkcite{test1}{test!}

\bibliography{\jobname}
\end{document}

(example bib file borrowed from elsewhere!)

Be sure that the citation actually gets \cited properly somewhere (or \nocited etc), or it may not show up in the bibliography.

share|improve this answer
    
Slight modification, then it works: \newcommand*{\hyperlinkcite}[1]{\hyper@link{cite}{cite.#1\@extra@b@citeb}}, thanks. Without the \@extra@b@citeb, I did get the color right, but the target was wrong –  daleif Dec 12 '12 at 14:51
1  
Thanks @daleif. As you say, it does seem to be needed if using certain styles, but I am not entirely confident about the appropriate time to expand \@extra@b@citeb (to ensure it expands to the same thing as it did when the anchor was set). Therefore, I will not yet incorporate it into the answer, but assume that anyone for whom the above doesn't work will see your comment! –  cyberSingularity Dec 12 '12 at 15:05

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.