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)
[Tex/LaTex] biblatex: Make title hyperlink to doi url (if available)
biblatexdoihyperref
Related Solutions
One possibility is to extend Herbert's bibmacro to several nested conditions. (The following example contains only placeholder links for the ISBN/ISSN fields because I don't know how this links must be formatted.)
With regard to your further issues:
I'm not sure if the
url
field allows to specify several URLs separated by white spaces; if it does, I don't know how to retain only the first URL.Herbert's code actually first covers all entry types, then specifies a special title format (quotes instead of emphasis) for articles.
\documentclass{article}
\usepackage[doi=false,url=false,isbn=false]{biblatex}
\usepackage[colorlinks]{hyperref}
\newbibmacro{string+doiurlisbn}[1]{%
\iffieldundef{doi}{%
\iffieldundef{url}{%
\iffieldundef{isbn}{%
\iffieldundef{issn}{%
#1%
}{%
\href{http://books.google.com/books?vid=ISSN\thefield{issn}}{#1}%
}%
}{%
\href{http://books.google.com/books?vid=ISBN\thefield{isbn}}{#1}%
}%
}{%
\href{\thefield{url}}{#1}%
}%
}{%
\href{http://dx.doi.org/\thefield{doi}}{#1}%
}%
}
\DeclareFieldFormat{title}{\usebibmacro{string+doiurlisbn}{\mkbibemph{#1}}}
\DeclareFieldFormat[article,incollection]{title}%
{\usebibmacro{string+doiurlisbn}{\mkbibquote{#1}}}
\begin{filecontents}{\jobname.bib}
@article{A01,
author = {Author, A.},
year = {2001},
title = {Alpha},
doi = {doi},
url = {url},
issn = {isbn-issn},
}
@book{B02,
author = {Buthor, B.},
year = {2002},
title = {Bravo},
url = {http://tex.stackexchange.com/},
isbn = {isbn-issn},
}
@incollection{C03,
author = {Cuthor, C.},
year = {2003},
title = {Charlie},
isbn = {9780521867016},
}
@misc{D04,
author = {Duthor, D.},
year = {2004},
title = {Delta},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\nocite{*}
\begin{document}
\printbibliography
\end{document}
If you use biber, this might be best handled with the related entries feature supported by biblatex 2.0+.
The preamble below defines a new type of related entry: prelim
. This key specifies the localization string, formatting directive and bibliography macro used to set the entries given in the related
field.
\documentclass{article}
\usepackage[american]{babel}
\usepackage{csquotes}
\usepackage[backend=biber]{biblatex}
\usepackage[colorlinks]{hyperref}
\renewcommand*{\relatedpunct}{\addcolon\space}
\renewcommand*{\relateddelim}{\addcomma\space}
\newbibmacro*{related:prelim}[1]{%
\renewcommand*{\newunitpunct}{\addcomma\space}%
\entrydata{#1}{\usebibmacro{doi+eprint+url}}}
\NewBibliographyString{prelim,prelims}
\DefineBibliographyStrings{american}{%
prelim = {Preliminary version},
prelims = {Preliminary versions}}
\begin{filecontents}{\jobname.bib}
@article{v008a021,
author = {Roy Kasher and Julia Kempe},
title = {Two-Source Extractors Secure Against Quantum Adversaries},
year = {2012},
pages = {461-486},
doi = {10.4086/toc.2012.v008a021},
journal = {Theory of Computing},
volume = {8},
number = {1},
related = {kasher/arxiv,kasher/approx},
relatedtype = {prelim}}
@online{kasher/arxiv,
author = {Kasher, Roy and Kempe, Julia},
title = {Two-Source Extractors Secure Against Quantum Adversaries},
eprinttype = {arxiv},
eprintclass = {quant-ph},
eprint = {1005.0512},
month = may,
year = {2010}}
@inproceedings{kasher/approx,
author = {Kasher, Roy and Kempe, Julia},
title = {Two-source extractors secure against quantum adversaries},
booktitle = {Proceedings of the 13th international conference on Approximation,
and the 14th International conference on Randomization, and combinatorial
optimization: algorithms and techniques},
series = {APPROX/RANDOM'10},
year = {2010},
venue = {Barcelona, Spain},
pages = {656--669},
url = {http://dl.acm.org/citation.cfm?id=1886521.1886572},
publisher = {Springer-Verlag},
location = {Berlin, Heidelberg}}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
\cite{v008a021}
\printbibliography
\end{document}
Here biber accesses data for every entry indicated in the related
field. Each related entry is assigned a hash key and is marked dataonly
. This avoids extraneous entries in the bibliography. It also allows you to cite related works directly and create "circular" relationships between entries.
Since you probably won't be citing preliminary works you could get by without biber, using some additional code to access related entry data and a few more LaTeX/BibTeX runs.
\documentclass{article}
\usepackage[american]{babel}
\usepackage{csquotes}
\usepackage[backend=bibtex,defernumbers]{biblatex}
\usepackage[colorlinks]{hyperref}
\DeclareBibliographyCategory{related}
\newrobustcmd*{\getrelated}[1]{%
\nocite{#1}\addtocategory{related}{#1}}
\AtDataInput{%
\iffieldundef{usera}{}{\forcsvfield{\getrelated}{usera}}}
\AtEveryBibitem{%
\iffieldundef{usera}{}{%
\edef\bbxusera{\thefield{usera}}%
\edef\bbxuserb{\thefield{userb}}%
\restorefield{related}{\bbxusera}%
\restorefield{relatedtype}{\bbxuserb}}}
\renewcommand*{\relatedpunct}{\addcolon\space}
\renewcommand*{\relateddelim}{\addcomma\space}
\newbibmacro*{related:prelim}[1]{%
\renewcommand*{\newunitpunct}{\addcomma\space}%
\entrydata{#1}{\usebibmacro{doi+eprint+url}}}
\NewBibliographyString{prelim,prelims}
\DefineBibliographyStrings{american}{%
prelim = {Preliminary version},
prelims = {Preliminary versions}}
\begin{filecontents}{\jobname.bib}
@article{v008a021,
author = {Roy Kasher and Julia Kempe},
title = {Two-Source Extractors Secure Against Quantum Adversaries},
year = {2012},
pages = {461-486},
doi = {10.4086/toc.2012.v008a021},
journal = {Theory of Computing},
volume = {8},
number = {1},
usera = {kasher/arxiv,kasher/approx},
userb = {prelim}}
@online{kasher/arxiv,
author = {Kasher, Roy and Kempe, Julia},
title = {Two-Source Extractors Secure Against Quantum Adversaries},
eprinttype = {arxiv},
eprintclass = {quant-ph},
eprint = {1005.0512},
month = may,
year = {2010}}
@inproceedings{kasher/approx,
author = {Kasher, Roy and Kempe, Julia},
title = {Two-source extractors secure against quantum adversaries},
booktitle = {Proceedings of the 13th international conference on Approximation,
and the 14th International conference on Randomization, and combinatorial
optimization: algorithms and techniques},
series = {APPROX/RANDOM'10},
year = {2010},
venue = {Barcelona, Spain},
pages = {656--669},
url = {http://dl.acm.org/citation.cfm?id=1886521.1886572},
publisher = {Springer-Verlag},
address = {Berlin, Heidelberg}}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
\cite{v008a021}
\printbibliography[notcategory=related]
\end{document}
Related Question
- [Tex/LaTex] Biblatex: Convert doi-url into doi field
- [Tex/LaTex] biblatex: make “authors” hyperlink to DOIs, URL or ISBN and url breaklink issue in hyperref
- [Tex/LaTex] Hyperlink in DOI in IEEEtran Bibliography
- Biblatex bibliography – how to output DOI/URL differently based on digital copy/to-be printed copy
Best Answer
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:
With the latest biblatex update there is also a star version for
\DeclareFieldFormat
which refers to all entry types.