I came across this thread recently while solving a variant of Peter's question.
Instead of adding a hyperlink DOI to each of the bibliography items, you may want not to write the DOI explicitly but to make another field of the bibliographic item clickable with an hyperlink to the download location. In some journals, the hyperlink is associated to the group "Journal Name, volume, page number" for instance.
You may find some existing bibliography style files doing that, but sometimes you need to add this feature to a personal bibliography style. In this case, none of the above solutions work. The hack I came up with is to define the following function in the .bst
file:
FUNCTION {doilink}
{ duplicate$ empty$
{ pop$ "" }
{ doi empty$
{ skip$ }
{ "\href{http://dx.doi.org/" doi * "}{" * swap$ * "}" * }
if$
}
if$
}
Here is an example of how to call the function:
FUNCTION {format.vol.num.pages}
{ volume field.or.null
boldface
pages empty$
'skip$
{ duplicate$ empty$
{ pop$ format.pages }
{ ", " * pages first.page.number * }
if$
}
if$
doilink
}
In this case the volume and pages will be hyperlinks. In general the hyperlink will be associated to the item on the top of the stack when the function doilink
is called. You also need to make sure that the doi
is declared as a possible field for bibliographic entries. As a minimal example:
ENTRY
{ author
doi
journal
key
pages
title
volume
year
}
This may not be the most robust solution but it solved my problem. I thought it might be useful to some people here.
EDIT
Following @laclaro 's follow-up question, I add an example of a .tex
file calling the modified .bst
file:
\documentclass{article}
\usepackage{natbib}
\usepackage{color}
\definecolor{darkblue}{rgb}{0.,0.,0.4}
\definecolor{darkred}{rgb}{0.5,0.,0.}
\usepackage[pdftex,colorlinks=true,linkcolor=darkblue,citecolor=darkred,urlcolor=blue]{hyperref}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article{Brune1996,
Author = {Brune, M and Hagley, E and Dreyer, J and Maître, X and Maali, A and Wunderlich, C and Raimond,J.M. and Haroche,S },
Title = {Observing the Progressive Decoherence of the “Meter” in a Quantum Measurement},
Year = {1996},
Journal = {Phys. Rev. Lett.},
volume = {77},
pages = {4887},
doi = {10.1103/PhysRevLett.77.4887}}
\end{filecontents}
\begin{document}
\cite{Brune1996}
\bibliographystyle{mystyle}
\bibliography{\jobname}
\end{document}
and a screenshot of what it looks like:
Here, clicking on the volume or page number opens the doi link. To adapt this so that the hyperlink is on the journal, you would need to modify the function FUNCTION {format.journal}
in the .bst
style file rather than the FUNCTION {format.vol.num.pages}
as was done here.