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},
}
4
  • Can you tell us what package and style you use to get your citations and bibliography? Ideally you would show us an MWE/MWEB. A solution will crucially depend on the bibliography package and style you use as well as on other modifications you have made to the style.
    – moewe
    Aug 3, 2017 at 14:26
  • 1
    And: Welcome to TeX.SX! You might want to sign up/register to be able to access your question in a few days and comment on it.
    – moewe
    Aug 3, 2017 at 14:27
  • 1
  • May be, get rid off the first paragraph!
    – hola
    Dec 13, 2018 at 19:36

1 Answer 1

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}          

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.