我想实现“经过认证的随机数“biblatex(使用 biber)中的作者顺序”。为此,我想指出特定的作者列表已被认证为随机的,在这些情况下,我想使用 ⓡ 符号来分隔名称。我还想使用“ⓡ al.”而不是“et al.”
下面是一个使用 ⓡ 符号替换的示例每一个名称集。但是,我不希望到处都有 ⓡ 符号。相反,我想使用注释表示应添加 ⓡ 符号。一种可能的注释是author+an:order = {random}
,如下例所示。
我想为任何包含字段的条目添加使用 ⓡ 符号的选项author
,但我不想重新定义每种条目类型。
\documentclass{article}
\usepackage[american]{babel}
\usepackage[backend=biber]{biblatex-chicago}
\usepackage{filecontents}
\begin{filecontents}{refs.bib}
@article{two-author-paper,
Author = {Last1, First1 and Last2, First2},
Journal = {Some Journal},
Title = {Old-school title},
Year = {1930}}
@article{four-author-paper,
Author = {LastA, FirstA and LastB, FirstB and LastC, FirstC and LastD, FirstD},
author+an:order = {random},
Journal = {Journal of Future Papers},
Title = {Really Cool Title},
Year = {2025}}
\end{filecontents}
\addbibresource{refs.bib}
\DefineBibliographyStrings{american}{%
andothers = {\textcircled{r} al.}
}
\renewcommand{\finalnamedelim}{\space\textcircled{r}\space}
\renewcommand{\multinamedelim}{\space\textcircled{r}\space}
\begin{document}
\textcite{two-author-paper}
\textcite{four-author-paper}
\printbibliography
\end{document}
(bibtex
不是biblatex
) 实现如下:https://github.com/ShiroTakeda/econ-bst/blob/master/econ.bst#L289
另一个问题类似:如何在 LaTeX 中实现认证随机。但是,它询问如何在编译文档时随机化名称。我不想那样,我只想在适当的位置插入 ⓡ 符号。
答案1
以下解决方案使用标准样式,但也authoryear
可以使用完全相同的代码。biblatex-chicago
可以使用 查询字段注释\iffieldannotation{certrand}
,然后只需根据此测试条件重新定义分隔符即可。不幸的是,如果测试为假,则很难保留分隔符的原始值,因此我只是从 复制了它们biblatex.def
。如果您的样式修改了分隔符,则可能需要从那里复制定义。
\documentclass{article}
\usepackage[american]{babel}
\usepackage{csquotes}
\usepackage[style=authoryear, maxbibnames=999, backend=biber]{biblatex}
\newcommand*{\ifcertrand}{\iffieldannotation{certrand}}
\newcommand*{\certrandorelse}[1]{%
\ifcertrand
{\addspace\textcircled{r}\space}
{#1}}
\DeclareDelimFormat{multinamedelim}{\certrandorelse{\addcomma\space}}
\DeclareDelimFormat{finalnamedelim}{%
\certrandorelse{%
\ifnumgreater{\value{liststop}}{2}{\finalandcomma}{}%
\addspace\bibstring{and}\space}}
\NewBibliographyString{certrandothers}
\DefineBibliographyStrings{american}{%
certrandothers = {\textcircled{r} al\adddot},
}
\renewbibmacro*{name:andothers}{%
\ifboolexpr{
test {\ifnumequal{\value{listcount}}{\value{liststop}}}
and
test \ifmorenames
}
{\ifcertrand
{\printdelim{andothersdelim}\bibstring{certrandothers}}
{\ifnumgreater{\value{liststop}}{1}
{\finalandcomma}
{}%
\printdelim{andothersdelim}\bibstring{andothers}}}
{}}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article{two-author-paper,
author = {Last1, First1 and Last2, First2},
author+an = {=certrand},
journal = {Some Journal},
title = {New-ish title},
year = {2018},
}
@article{four-author-paper,
author = {LastA, FirstA and LastB, FirstB and LastC, FirstC and LastD, FirstD},
author+an = {=certrand},
journal = {Journal of Future Papers},
title = {Really Cool Title},
year = {2019},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\addbibresource{biblatex-examples.bib}
\begin{document}
\textcite{two-author-paper}
\textcite{four-author-paper}
\textcite{sigfridsson}
\textcite{companion}
\printbibliography
\end{document}
请注意,我稍微将注释语法更改为更简单的author+an = {=certrand},
。如果要使用形式的命名注释author+an:order = {=certrand},
,只需将其替换\newcommand*{\ifcertrand}{\iffieldannotation{certrand}}
为\iffieldannotation[][order]{certrand}
。值中的前导=
可能有点尴尬,但这是字段注释语法所必需的。