# Is it possible to make a reference clickable without showing its DOI or URL field?

I'm using biblatex with the following options

\usepackage[backend=biber,style=numeric-comp,sorting=none,%
isbn=false,url=false,doi=false,firstinits=true]{biblatex}


Thus, my bibliography contains neither url nor doi fields, making it nice and short. However, this comes with the disadvantage that references no longer contain clickable links leading to the download location of that particular source.

Is there a way to change this?

• Have you considered the possibilities offered by eprint and eprinttype? – cfr Oct 13 '14 at 23:13
• you can edit the format of url and doi and only print the words url or doi with the hyperlink to the download location (And using doi=true and url=true, of course). – Carlos Lanziano Oct 13 '14 at 23:48
• Where's a person supposed to click on if the doi and url fields aren't shown? – Mico Oct 14 '14 at 3:33
• Preferably on the publication title but the author name or the whole reference would work just fine as well. – Casimir Oct 14 '14 at 8:55
• – moewe Jan 25 '19 at 13:00

EDIT: Added Title clickable (1. just the title cickable and 2. the whole reference clickable)

# 1. Just the Title reference clickable

You can redefine the title macro and add the \href to the title using the DeclareFieldFormat. I edited the default definitions in the biblatex.def file.

\DeclareFieldFormat{title}{\myhref{\mkbibemph{#1}}}
\DeclareFieldFormat
[article,inbook,incollection,inproceedings,patent,thesis,unpublished]
{title}{\myhref{\mkbibquote{#1\isdot}}}


And the macros are:

\newcommand{\doiorurl}{%
\iffieldundef{doi}
{\iffieldundef{url}
{}
{\strfield{url}}}
{http://dx.doi.org/\strfield{doi}}%
}

\newcommand{\myhref}[1]{%
\ifboolexpr{%
test {\ifhyperref}
and
not test {\iftoggle{bbx:url}}
and
not test {\iftoggle{bbx:doi}}
}
{\href{\doiorurl}{#1}}
{#1}%
}


MWE

\documentclass{article}
\usepackage[backend=biber,style=numeric-comp,sorting=none,%
isbn=false,url=false,doi=false,firstinits=true]{biblatex}
\usepackage{filecontents}
\usepackage{hyperref}

\begin{filecontents}{\jobname.bib}
@Article{usingdoi,
author={The First Author},
title={Using DOI},
year={2014},
journal={J. Med. Sc.},
publisher={Springer},
doi={10.1103/PhysRevLett.77.3865},
pages={1-2},
}

@Article{usingurl,
author={The Other Authors},
title={Using URL},
number={2},
year={1998},
month={4},
journal={ACM Trans. Inf. Sys.},
publisher={Springer},
volume={16},
pages={127-160},
}

@Article{nodoiurl,
author={The Author},
title={Neither doi or url},
number={2},
year={1998},
month={4},
journal={ACM Trans. Inf. Sys.},
publisher={Springer},
volume={16},
pages={127-160},
}

\end{filecontents}

\newcommand{\doiorurl}{%
\iffieldundef{doi}
{\iffieldundef{url}
{}
{\strfield{url}}}
{http://dx.doi.org/\strfield{doi}}%
}

\newcommand{\myhref}[1]{%
\ifboolexpr{%
test {\ifhyperref}
and
not test {\iftoggle{bbx:url}}
and
not test {\iftoggle{bbx:doi}}
}
{\href{\doiorurl}{#1}}
{#1}%
}

\DeclareFieldFormat{title}{\myhref{\mkbibemph{#1}}}
\DeclareFieldFormat
[article,inbook,incollection,inproceedings,patent,thesis,unpublished]
{title}{\myhref{\mkbibquote{#1\isdot}}}

\begin{document}
\nocite{*}
\printbibliography
\end{document}%XXIII


# 2. The whole reference clickable

I found a way that allow to make a reference clickable (The whole text of the reference is clickable)

For this I Modified the definition of DeclareBibliographyDriver to add a \href to the full reference.

This is necessary before biblatex load the bibliography style.

By default, before load the style files, biblatex try load the file biblatex-dm.cfg (biblatex custom data model), then it is possible modify the DeclareBibliographyDriver using this file.

I created the file (biblatex-dm.cfg) in the work directory with the content:

\newcommand{\doiorurl}{%
\iffieldundef{doi}
{\iffieldundef{url}
{}
{\strfield{url}}}
{http://dx.doi.org/\strfield{doi}}%
}

\newcommand{\bibdrivercontent}[1]{%
\ifboolexpr{%
test {\ifhyperref}
and
not test {\iftoggle{bbx:url}}
and
not test {\iftoggle{bbx:doi}}
}
{\href{\doiorurl}{#1}}
{#1}%
}

\let\OldDeclareBibliographyDriver\DeclareBibliographyDriver
\renewcommand{\DeclareBibliographyDriver}[2]{\OldDeclareBibliographyDriver{#1}{\bibdrivercontent{#2}}}


This code use \href only if hyperref is loaded and doi and url options are false.

The MWE:

\documentclass{article}
\usepackage[backend=biber,style=numeric-comp,sorting=none,%
isbn=false,url=false,doi=false,firstinits=true]{biblatex}
\usepackage{filecontents}
\usepackage{hyperref}

\begin{filecontents}{\jobname.bib}
@Article{usingdoi,
author={The First Author},
title={Using DOI},
year={2014},
journal={J. Med. Sc.},
publisher={Springer},
doi={10.1007/0000-0xz},
pages={1-2},
}

@Article{usingurl,
author={The Other Authors},
title={Using URL},
number={2},
year={1998},
month={4},
journal={ACM Trans. Inf. Sys.},
publisher={Springer},
volume={16},
pages={127-160},
}

@Article{nodoiurl,
author={The Author},
title={Neither doi or url},
number={2},
year={1998},
month={4},
journal={ACM Trans. Inf. Sys.},
publisher={Springer},
volume={16},
pages={127-160},
}

\end{filecontents}

\begin{document}
\nocite{*}
\printbibliography
\end{document}


And the result:

• Thanks for your answer. I added the biblatex-dm.cfg file to my working directory and it indeed made all those references clickable that contain url or doi fields. However, if I click on one, doi.org says page not found, as in this case. I'm not very familiar with this stuff. Do you know what could be causing the problem? – Casimir Oct 14 '14 at 8:11
• It is my mistake. In the doiorurl macro change the www by dx. It means: the line {http://www.doi.org/\strfield{doi}} is replaced by {http://dx.doi.org/\strfield{doi}}. I'm going to edit my answer. – Carlos Lanziano Oct 14 '14 at 11:07
• @PacificOrion You're welcome. I edited my answer and I added how to make only the title clickable. – Carlos Lanziano Oct 14 '14 at 11:57
• That's even better. Tested it and works as well. Perhaps you edit your answer so that instructions on on how to add the link to just the reference title come first, as it is simpler and probably what most others would be looking for. – Casimir Oct 14 '14 at 13:48
• A similar approach without the need for another document is posted here. Thanks for your solution anyhow, made me find this one. – patrickmelix May 20 '20 at 14:42