[Tex/LaTex] Biblatex style with hyperlinks using url in bib file

biblatexhyperref

I am using biblatex with the href option for my bibliography.

I would like to use the url field of my bib file to add a hyperlink to the online version of the article. However I don't want the whole url link to be printed in the bibliography but, if that's possible the link to appear when clicking on the volume / page of the cited journal (or on the journal name would also be fine) – as it is the case in a lot of scientific journals.

I am using the nature citation style and have tried to modify the .bbx according to my needs – but my knowledge of the .bbx structure and LaTeX macros is very sparse.

Best Answer

The way the nature style is setup it is easiest to replace the pages with the link (or the volume) but getting the pages and volume is difficult since they are printed at different times. You would have to do a major overhaul of the style. The meat of the solution is

\newbibmacro*{myurl}{\printfield[myurl]{url}}
\DeclareFieldFormat{myurl}{\href{#1}{\printfield{pages}}}

\newbibmacro*{note+pages}{%
  \printfield{note}%
  \setunit{\bibpagespunct}%
  \usebibmacro{myurl}%
  \newunit}

combining it to form a complete MWE gives:

\documentclass{article}
\usepackage{filecontents}
\usepackage[style=nature, url=true]{biblatex}
\usepackage{hyperref}
\begin{filecontents}{\jobname.bib}
@article{aksin,
  author = {Aks{\i}n, {\"O}zge and T{\"u}rkmen, Hayati and Artok, Levent
    and {\k{C}}etinkaya, Bekir and Ni, Chaoying
    and B{\"u}y{\"u}kg{\"u}ng{\"o}r, Orhan and {\"O}zkal, Erhan},
  indextitle = {Effect of immobilization on catalytic characteristics},
  title = {Effect of immobilization on catalytic characteristics of saturated
    Pd-N-heterocyclic carbenes in Mizoroki-Heck reactions},
  journaltitle = jomch,
  volume = {691},
  number = {13},
  date = {2006},
  pages = {3027--3036},
  url = {http://www.google.com}
}
\end{filecontents}
\addbibresource{\jobname.bib}

\newbibmacro*{myurl}{\printfield[myurl]{url}}
\DeclareFieldFormat{myurl}{\href{#1}{\printfield{pages}}}

\newbibmacro*{note+pages}{%
  \printfield{note}%
  \setunit{\bibpagespunct}%
  \usebibmacro{myurl}%
  \newunit}

\begin{document}
\cite{aksin}
\printbibliography
\end{document}