我正在编写biblatex
样式文件来支持在线期刊计算理论。该期刊多年来一直使用 BibTeX,我期待它biblatex
提供的灵活性。
困难:我们的书目条目通常需要参考多种的dois、url 或 eprint 条目。(为什么?我们经常链接到文章的“初步”版本,通常是会议文章或论文集预印本。)我的第一个问题有点像元问题:最好的方法是什么?
我想到两种方法;我没有足够的经验来biblatex
决定采用哪一种。
方法 1
安排 biblatex“本地”处理多个 dois、url、eprint 等。具体来说,最好允许一条记录有多个字段,格式如下
doi = {first-doi},
doi = {second-doi},
...
和
url = {first-url},
url = {second-url},
...
我们的想法是,每个组件都会产生自己的输出:DOI:第一-doi, 多伊:第二 doi等。这容易实现吗?
当然,处理多个 eprint 条目的想法似乎是有问题的,因为一个eprint
字段通常与其他“辅助”字段(如)相结合eprinttype
。(顺便说一句,支持两个 eprint 字段似乎是在许多其他自然情况下人们可能希望做的事情,例如一篇论文同时具有 MathSciNet 条目和DOI)。
方法 2
考虑到解析多个 eprint 字段的问题,另一种可能性是添加一些新字段:
prelim-doi
prelim-eprint
prelim-url
prelim-manuscript
这些将在常规doi
、eprint
和url
条目之后立即打印(例如,对于日记帐)。具体来说,我希望输出以下内容:
Preliminary versions: DOI: ..., eprint: ..., URL: ..., Manuscript: ... .
DOI、电子版和 URL 的处理方式应与相应的“常规”字段相同(特别是,我希望prelim-eprint
继承 的相同电子版处理程序eprint
)。手稿也应以相同的方式处理eprint
(再次使用相同的处理程序)。(如果您想知道为什么我们需要 和prelim-eprint
,prelim-manuscript
这是因为我们经常需要引用使用电子版的初步会议版本和初步 arXiv 版本。)
我的第一次尝试(方法 2)
为了熟悉情况,我尝试了以下内容(在文件中.bbx
):
\DeclareFieldFormat{prelim-doi}{%
\mkbibacro{DOI}\addcolon\space
\ifhyperref
{\href{http://dx.doi.org/#1}{\nolinkurl{#1}}}
{\nolinkurl{#1}}}
\newbibmacro*{prelim-doi+eprint+manuscript+url}{%
\iftoggle{bbx:doi}
{\printfield{prelim-doi}}
{}}
\renewbibmacro*{doi+eprint+url}{%
\iftoggle{bbx:doi}
{\printfield{doi}}
{}%
\newunit\newblock
\iftoggle{bbx:eprint}
{\usebibmacro{eprint}}
{}%
\newunit\newblock
\iftoggle{bbx:url}
{\usebibmacro{url+urldate}}
{}%
\iftoggle{bbx:preliminary}
{\usebibmacro{prelim-doi+eprint+manuscript+url}}
{}}
这使用了一个名为的切换按钮bbx:preliminary
,它原本只是用来处理打印初步的 dois(开始)。但是,它似乎从来没有打印任何东西(即使是带有字段的记录)。我需要做一些花哨的事情来告诉大家新字段的情况prelim-doi
吗?(顺便说一句,这个小文件基本上只是通过 Marco Daniel 的传统纯文本样式加载的(参见biblatex
.bbx
如何使用 biblatex 尽可能地模拟传统的 BibTeX 样式(plain、abbrv、unsrt、alpha)?),因为我们的传统参考书目风格与 BibTeX 的风格相差不远plain
。
答案1
如果您使用 biber,最好使用 biblatex 2.0+ 支持的相关条目功能来处理。
下面的序言定义了一种新类型的相关条目:prelim
。该键指定用于设置字段中给定related
条目的本地化字符串、格式指令和参考书目宏。
\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}
在这里,biber 访问related
字段中指示的每个条目的数据。每个相关条目都分配有一个哈希键并标记为dataonly
。这避免了参考书目中出现无关条目。它还允许您直接引用相关作品并在条目之间创建“循环”关系。
由于您可能不会引用初步作品,因此您可以不用 biber,使用一些额外的代码来访问相关的条目数据,并进行一些 LaTeX/BibTeX 运行。
\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}