3

In this day and age, if I grab an electronic version of a paper and stumble across a reference, I'd rather be able to access that reference's webpage directly instead of being redirected to the PDF reference page first and then click on the DOI link (if there are any).

So I would like to know how I could make biblatex/hyperref link to the DOI upon \cite{} (if available) instead of disrupting my readers' reading by sending them to another place in the PDF.

Currently, I am using that preamble:

\documentclass{scrartcl}
\usepackage[
    bibencoding=utf8,
    backend=biber,
    firstinits=true,
    style=numeric-comp,
    sorting=none,
    natbib=true,
    url=false,
    doi=true,
]{biblatex}
\usepackage[
    colorlinks=false,
    hidelinks=true,
    unicode
]{hyperref}
\addbibresource{bib.bib}
\begin{document}
    Blah\cite{foo}
    \printbibliography
\end{document}

And bib.bib:

@article{Foo,
    author = {Foo and Bar},
    title = {Foobar},
    journal = {{Foo society}},
    volume = {42},
    number = {42},
    pages = {42},
    year = {2017},
    doi = {10.1021/foo.bar},
}
Henry
  • 33

1 Answers1

2
\DeclareFieldFormat{bibhyperref}{%
  \iffieldundef{doi}
    {\bibhyperref{#1}}
    {\href{https://doi.org/\thefield{doi}}{#1}}}

Will send you to the DOI if available. If there is no DOI it goes to the bibliography/references at the end.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[british]{babel}
\usepackage{csquotes}
\usepackage[
    backend=biber,
    firstinits=true,
    style=numeric-comp,
    sorting=none,
]{biblatex}
\usepackage{hyperref}                   
 \addbibresource{biblatex-examples.bib}     

\DeclareFieldFormat{bibhyperref}{%
  \iffieldundef{doi}
    {\bibhyperref{#1}}
    {\href{https://doi.org/\thefield{doi}}{#1}}}

\begin{document}
  \cite{sigfridsson}

  \printbibliography
\end{document}          
moewe
  • 175,683