# Hyperlink each bib entry to its DOI page

Can I have each bib entry hyper-linked to its DOI page? i.e. clicking anywhere on the bib entry (preferably anywhere, but if not possible, at least on the title of the paper) in the PDF should open the link to its DOI page. I am willing to ensure that each entry in the bib file has a DOI/URL.

I'm using TexShop on Mac OS X Snow Leopard, and use pdflatex/bibtex to compile my dissertation.

• Welcome to TeX.sx! Usually, we don't put a greeting or a "thank you" in our posts. While this might seem strange at first, it is not a sign of lack of politeness, but rather part of our trying to keep everything very concise. Upvoting is the preferred way here to say "thank you" to users who helped you. Nov 25, 2012 at 8:10
• Just to note, revtex4-1 bibstyle generates links according to DOIs. (However, the style itself is extremely concise, e.g., omitting the title). Nov 25, 2012 at 8:23
• Do you use biblatex? You can activate the display of dois for each entry (if available) with doi=true. Then you can click on the doi information in a bib entry to open the web site. Why must it be the title? Nov 25, 2012 at 11:21
– Alex
Nov 25, 2012 at 11:39
• If you are not using biblatex then this question is relevant. Some of the answers apply to non natbib styles. Nov 25, 2012 at 12:50

With respect, it doesn't make much sense to have the ENTIRE bib entry link to the DOI page, since, an individual bibliography record may have BOTH URL and DOI's, either, or neither.

I use the following command, along with the hyperref package, which gives a blue colored hyperlink to the DOI webpage for the bibliography entries that have DOI records.

In the preamble, put the following:

\usepackage[hidelinks]{hyperref} %boxes hidden, remove hidelinks if boxes are desired.


Then before the bibliography is called:

\def\mybibdoicolor{\color{blue!75!black}} %change color to suit.
\newcommand*{\doi}[1]{\href{http://dx.doi.org/\detokenize{#1} {\raggedright\mybibdoicolor{DOI: \detokenize{#1}}}}


Finally, the bibliography can be called:

\bibliography{BIBDATAFILE}


An exerpt from my output is displayed below, noting the blue DOI record/s held in references [41-43], each can be clicked from inside PDF, in such event, the user would be redirected to the relevant site. In this case, as an example, should the user click on the DOI record inside [41], he/she would be redirected to http://dx.doi.org/10.1098/rspa.1925.0147, which in turn redirects the user to the publication.

Since I could not get the solutions here working with the latest biblatex, I am posting here two alternate approaches that worked for me. Both were posted by others for other questions. I just reproduce and link them here for reference since they are quite hard to find (at least it took me half a day finding them).

A lot of other solutions to make individual parts of the citation clickable exist, but actually making the whole thing into a link is tricky. Most solutions I found make it necessary to rebuild the citation style manually and are therefore not portable from one document to the next. These two seem to not touch the appearance but just wrap the item into a hyperlink.

## 1 In Document Solution

Moewe posted the following solution:

\newbibmacro{string+doiurl}[1]{%
\iffieldundef{doi}
{\iffieldundef{url}
{#1}
{\href{\thefield{url}}{#1}}}
{\href{https://doi.org/\thefield{doi}}{#1}}}

\makeatletter
\def\blx@driver#1{%
\ifcsdef{blx@bbx@#1}
{\usebibmacro{string+doiurl}{\csuse{blx@bbx@#1}}}
{\ifcsdef{blx@bbx@*}
{\blx@warning{%
No driver for entry type '#1'.\MessageBreak
Using fallback driver}%
\usebibmacro{string+doiurl}{\csuse{blx@bbx@*}}}
{\blx@error
{No driver found}
{I can't find a driver for the entry type
'\abx@field@entrytype'\MessageBreak
and there is no fallback driver either}}}}
\makeatother


## 2 Biblatex Config File

Carlos Lanziano's answer number two contains a config file, that makes the entire entry into a hyperlink.

Save the following as biblatex-dm.cfg next to your document:

\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}}}


There is the urlbst package. It provides a perl script to modify existing .bst files with url and enclose the whole citation in an hyperlink.

To make a whole reference an hyperlink (with biblatex) using url (it is to do the same using doi)

\AtEveryBibitem{%
\iffieldundef{url}
{}
{\href{\thefield{url}}{\usedriver{\thefield{article}}}
\csdef{blx@bbx@\thefield{entrytype}}{}}%
}

• I am currently using the authoryear style with biblatex, and have added this line. It successfully produces entries with hyperlinked author, year and title fields, but removes the other fields. Is there an alternative command to redefine rather than blx@bbx@\thefield{entrytype}? Nov 14, 2013 at 20:29
• I was facing the exact same problem. See my answer for two possible solutions. May 20, 2020 at 14:36

Small correction to the solution by Guido:

\AtEveryBibitem{%
\iffieldundef{url}
{}
{\href{\thefield{url}}{\usedriver{\thefield{article}}\thefield{entrytype}}}
\csdef{blx@bbx@\thefield{entrytype}}{}}%
}


That yields the expected result for me.