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}
Best Answer
\setunit
is an alternative to\newunit
that allows you to set punctuation instead of\newunitpunct
(which is typically a period plus a space). The really neat thing about\newunit
and\setunit
is that you don't need to worry about generating excessive punctuation, particularly when some fields are missing.The code below defines a new bibliography macro
bbx:parunit
. It issues\setunit
to generate line breaks only in the bibliography. With the option settingbackref=true
,bbx:parunit
also prints the back reference immediately before the first line break. Edits are applied to generic bibliography macros frombiblatex.def
so that the solution should work with most styles.