50

I'm using biblatex with the standard bibliography style. How or what should I modify so that the title is turned into a link pointing to a suitable doi url? (of course only if the doi is available)

42

I used the default example bib from the current biblatex documentation which is available on every TeX distribution. The two entries have both a doi entry in the bib file:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[backend=biber]{biblatex} 
\usepackage[colorlinks]{hyperref}
\bibliography{biblatex-examples}
\ExecuteBibliographyOptions{doi=false}
\newbibmacro{string+doi}[1]{%
  \iffieldundef{doi}{#1}{\href{http://dx.doi.org/\thefield{doi}}{#1}}}
\DeclareFieldFormat{title}{\usebibmacro{string+doi}{\mkbibemph{#1}}}
\DeclareFieldFormat[article]{title}{\usebibmacro{string+doi}{\mkbibquote{#1}}}
\begin{document}
A reference to~\cite{kastenholz} and~\cite{sigfridsson}. 
\printbibliography
\end{document}

With the latest biblatex update there is also a star version for \DeclareFieldFormat which refers to all entry types.

enter image description here

4
  • 1
    @Herbert, would it be possible to make the hyperlinks conditional? What I mean is, if both URL and DOI are available, use DOI, if only URL is available, use URL. Also, you mentioned that there must (should?) be a star version for \DeclareFieldFormat to capture all entry types. Do you know the command for that? – Jörg Mar 16 '12 at 14:28
  • 1
    I added a follow up question here: tex.stackexchange.com/questions/48400/… – Jörg Mar 17 '12 at 20:11
  • 1
    Thanks so much! I'm using this: However it appears to not work when the item is a conference paper. Journal papers will have the hyperlinks, but conference papers don't. Is there a way to fix this? – RobertHannah89 Mar 13 '18 at 16:31
  • The MWE is working, I then tried to do the same with the filecontents and my own citation entries, however, the link would not show up. I then downloaded the actual biblatex-examples file here and made a same one with filecontents. But the link still did not appear. – zyy Jan 13 '20 at 5:31

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.
https://tex.stackexchange.com/questions/23832/biblatex-make-title-hyperlink-to-doi-url-if-available
tex.stackexchange.com
crawl=CC-MAIN-2021-31
172007
application/http; msgtype=response
sha1:BMUNKY27THWS56RDRVJDGUMSY6ORB2DG
<urn:uuid:264c3278-81bb-48fb-8927-56ce56b549f4>
2021-08-04T23:25:37Z
151.101.129.69
text/html
sha1:KX3ZYZJUX5FI3GSPWEZKSZZT4BC2N4KJ
<urn:uuid:d908cd82-2372-45c7-b886-abf24500b213>
https://tex.stackexchange.com/questions/23832/biblatex-make-title-hyperlink-to-doi-url-if-available
response
<urn:uuid:fddd1e1e-4d66-4757-88eb-48b0e7acde2b>
isPartOf: CC-MAIN-2021-31
publisher: Common Crawl
description: Wide crawl of the web for July/August 2021
operator: Common Crawl Admin (info@commoncrawl.org)
hostname: ip-10-67-67-190.ec2.internal
software: Apache Nutch 1.18 (modified, https://github.com/commoncrawl/nutch/)
robots: checked via crawler-commons 1.2-SNAPSHOT (https://github.com/crawler-commons/crawler-commons)
format: WARC File Format 1.1
conformsTo: https://iipc.github.io/warc-specifications/specifications/warc-format/warc-1.1/