考虑一份作者为“van Beethoven, Ludwig”的文档。我想在正文中将其引用为“van Beethoven”,并在参考文献中将其列为“van Beethoven”。这可以通过 来实现useprefix=true
。但是,我想在参考文献中将该条目列在“B”下而不是“v”下。在德国,这通常被认为是处理带有 von 和 van 前缀的名称的正确方法。我知道我可以通过向相关 BibTeX 条目添加 sortkey 字段来实现此行为,但自动解决方案当然是更好的选择。
答案1
我真的不擅长使用正则表达式,所以我怀疑很多人可以改进这一点。但有两种不同的方法:一种更“手动”的方法,对我来说更容易微调最终的排序方案;另一种更花哨的方法,如果您有许多van
和von
条目,其名称与其他人相同,则可能会造成严重破坏。(最坏的情况是有一个Ludwig Beethoven
、Ludwig van Beethoven
和Ludwig von Beethoven
——不确定它是否会变得那么糟糕,但就是这样。)所以:
手动微调:
\documentclass[12pt]{article}
\usepackage[T1]{fontenc}
\usepackage[backend=biber,useprefix=true,style=authortitle]{biblatex}
\addbibresource{\jobname.bib}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@article{aaa,
author = {Adams, Ludwig},
title = {Title},
journal = {Sort this one under Adams},
date = 1998,
}
@article{ccc,
author = {Curtius, Ludwig},
title = {Title},
journal = {Sort this one under Curtius},
date = 1998,
}
@article{sss,
author = {Smith, Ludwig},
title = {Title},
journal = {Sort this one under Smith},
date = 1998,
}
@article{www,
author = {Williams, Ludwig},
title = {Title},
journal = {Sort this one under Williams},
date = 1998,
}
@article{van,
author = {van Beethoven, Ludwig},
title = {Title},
journal = {Sort this one under Beethoven},
date = 1998,
}
@article{von,
author = {von Beethoven, Ludwig},
title = {Another Title},
journal = {Sort this one under Beethoven},
date = 1999,
}
@article{nosort,
author = {van~Beethoven, Ludwig},
title = {Another Title},
journal = {Don't Sort this One via DeclareSourceMap, thanks to the Tilde},
date = 2001
}
@article{override,
author = {van Beethoven, Ludwig},
title = {Title},
journal = {Sortname is: ZZZ -- Will be Overwritten!},
date = 2000,
sortname = {ZZZ},
}
@article{beethoven,
author = {Beethoven, Ludwig},
title = {Title},
journal = {Sort this one under Beethoven but
before the von/van entries (to pinpoint final sort)},
date = 1998,
}
@article{beZthoven,
author = {Bezthoven, Ludwig},
title = {Title},
journal = {Sort this one under BeZthoven (to pinpoint final sort)},
date = 1998,
}
\end{filecontents*}
\DeclareSourcemap{%
\maps[datatype=bibtex]{
\map[overwrite=true]{
\perdatasource{\jobname.bib}
\step[fieldsource=author, final]
\step[fieldset=sortname, origfieldval]
\step[fieldsource=sortname,
match=\regexp{van\s(Beethoven,)\s(Ludwig)*},
replace={BeethovenY, Ludwig}]
\step[fieldsource=sortname,
match=\regexp{von\s(Beethoven,)\s(Ludwig)*},
replace={BeethovenZ, Ludwig}]
}% The disadvantage is clear: you need to add manual sorting
}% rules for each individual. But the advantage is that it is
}% easier to control the final sorting scheme
\begin{document}
\nocite{*}
\printbibliography
\end{document}
尝试巧妙地利用 REGEXP:
\documentclass[12pt]{article}
\usepackage[T1]{fontenc}
\usepackage[backend=biber,useprefix=true,style=authortitle]{biblatex}
\addbibresource{\jobname.bib}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
% well, just use the same entries as above
\end{filecontents}
\DeclareSourcemap{%
\maps[datatype=bibtex]{
\map[overwrite=true]{
\perdatasource{\jobname.bib}
\step[fieldsource=author, final]
\step[fieldset=sortname, origfieldval]
\step[fieldsource=sortname,
match=\regexp{(v.n)\s(\w+,)\s(\w+)*},
replace={$2}]
}% the problem: 'von' will be sorted before 'van' IFF the title
}% of the 'von' entry is alphabetically prior to the title of
}% the 'van' entry. Worse(?): a regular 'Beethoven, Ludwig' will
% also be sorted among the 'van's and 'von's based solely on their
% titles.
\begin{document}
\nocite{*}
\printbibliography
\end{document}
答案2
这是尝试扩展jon 的精彩回答以允许稍微更多的灵活性。
所有定义的标准排序方案都biblatex.def
包含(在某个时候)以下行
\sort{
\field{sortname}
\field{author}
\field{editor}
\field{translator}
\field{sorttitle}
\field{title}
}
因此,在排序时,对于调用哪个名称字段似乎存在某种层次结构。顺序似乎是sortname
>
author
>
editor
>
translator
。如果我们想完全自动从排序中剥离von
/,van
我们将不得不处理所有这些字段。
为了处理这些微妙的问题,定义一个新的名称字段用于内部排序似乎是一个不错的主意。(可能有更有效的方法来实现这一点,但这个方法似乎很自然,也很容易理解——这是我能想到的唯一方法)。
我们定义新的名称列表tempsortname
。这可以通过以下两行轻松完成(将它们放入biblatex-dm.cfg
或任何其他可以处理数据模型命令的文件中)。
\DeclareDatamodelFields[type=list, datatype=name]{tempsortname}
\DeclareDatamodelEntryfields{tempsortname}
现在,我们将依次将上面层次结构中的名称字段从低到高 ( translator
<
editor
<
author
) 复制到我们的tempsortname
字段中。如果任何字段为空,则不会将其复制。在此映射步骤之后,tempsortname
将保留层次结构中“最高”的非空字段 - 这并非完全巧合,与 biber 用于对条目进行排序的字段完全相同。
然后,我们通过正则表达式从中删除von
/ 。(模式与字符串或匹配,当且仅当它出现在字段的开头 [如] 或前面至少有一个空格 [如] 后面至少有一个空格。)原始字段将不会更改,但会丢失前缀。van
tempsortname
van
von
van Beethoven, Ludwig
Johann Wolfgang von Goethe
tempsortname
如果尚未指定,则最后tempsortname
复制到。因此,在此设置中,始终胜过我们的字段;考虑到实际上是,或(减去前缀),这正是标准排序将执行的操作。sortname
sortname
sortname
tempsortname
tempsortname
author
editor
translator
\DeclareSourcemap{%
\maps[datatype=bibtex]{
\map[overwrite=true]{
\step[fieldsource=translator]
\step[fieldset=tempsortname, origfieldval]
\step[fieldsource=editor]
\step[fieldset=tempsortname, origfieldval]
\step[fieldsource=author]
\step[fieldset=tempsortname, origfieldval]
}
\map[overwrite=true]{
\step[fieldsource=tempsortname, match=\regexp{(^|\s+)\Kv[a|o]n\s+}, replace={$1}]
}
\map[overwrite=false]{
\step[fieldsource=tempsortname]
\step[fieldset=sortname, origfieldval]
}
}
}
需要注意的是,在此解决方案中Ludwig Beethoven
,Ludwig van Beethoven
和Ludwig von Beethoven
将被排序为同一个人,前缀将被完全忽略。这可能会导致(很可能是不希望的)以下情况
范·贝多芬,路德维希。标题 A。2000 年。
贝多芬,路德维希。标题 B。2000 年。
范·贝多芬,路德维希。标题 C。2000 年。
数学家
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[backend=biber,useprefix=true,style=authortitle]{biblatex}
\addbibresource{\jobname.bib}
\usepackage{filecontents}
\begin{filecontents*}{biblatex-dm.cfg}
\DeclareDatamodelFields[type=list,datatype=name]{tempsortname}
\DeclareDatamodelEntryfields{tempsortname}
\end{filecontents*}
\begin{filecontents*}{\jobname.bib}
@InCollection{brandt,
author = {von Brandt, Ahasver and Erich Hoffmann},
editor = {Ferdinand Seibt},
title = {Die nordischen L{\"a}nder von der Mitte des 11.~Jahrhunderts
bis 1448},
date = 1987,
booktitle = {Europa im Hoch- und Sp{\"a}tmittelalter},
series = {Handbuch der europ{\"a}ischen Geschichte},
number = 2,
publisher = {Klett-Cotta},
location = {Stuttgart},
pages = {884-917},
hyphenation = {german},
}
@Book{vangennep,
author = {van Gennep, Arnold},
title = {Les rites de passage},
date = 1909,
publisher = {Nourry},
location = {Paris},
hyphenation = {french},
}
@article{aaa,
author = {Adams, Ludwig},
title = {Title},
journal = {Sort this one under Adams},
date = 1998,
}
@article{ccc,
author = {Curtius, Ludwig},
title = {Title},
journal = {Sort this one under Curtius},
date = 1998,
}
@article{hhhh,
author = {Hoffmann, Bernd},
title = {Title},
journal = {Sort this one under Hoffmann},
date = 1998,
}
@article{sss,
author = {Smith, Ludwig},
title = {Title},
journal = {Sort this one under Smith},
date = 1998,
}
@article{www,
author = {Williams, Ludwig},
title = {Title},
journal = {Sort this one under Williams},
date = 1998,
}
@article{van,
author = {van Beethoven, Ludwig},
title = {Title},
journal = {Sort this one under Beethoven},
date = 1998,
}
@book{vonn,
author = {Johann Wolfgang von Goethe},
editor = {von Beethoven, Ludwig},
subtitle = {Another Title},
title = {Sort this one under Goethe},
date = 1999,
}
@collection{von,
editor = {von Beethoven, Ludwig},
subtitle = {Another Title},
title = {Sort this one under Beethoven},
date = 1999,
}
@article{nosort,
author = {van~Beethoven, Ludwig},
title = {Another Title},
journal = {Don't Sort this One via DeclareSourceMap, thanks to the Tilde},
date = 2001
}
@article{override,
author = {van Beethoven, Ludwig},
title = {Title},
journal = {Sortname is: ZZZ -- Will be Overwritten!},
date = 2000,
sortname = {ZZZ},
}
@book{beeta,
author = {van Beethoven, Ludwig},
title = {Title A},
date = 2000,
}
@book{beetb,
author = {Beethoven, Ludwig},
title = {Title B},
date = 2000,
}
@book{beetc,
author = {van Beethoven, Ludwig},
title = {Title C},
date = 2000,
}
@book{beetd,
author = {van Beethoven, Ludwig},
title = {Title D},
date = 2000,
}
@article{beethoven,
author = {Beethoven, Ludwig},
title = {Title},
journal = {Sort this one under Beethoven but
before the von/van entries (to pinpoint final sort)},
date = 1998,
}
@article{beZthoven,
author = {Bezthoven, Ludwig},
title = {Title},
journal = {Sort this one under BeZthoven (to pinpoint final sort)},
date = 1998,
}
@article{mevon,
author = {Mevon, Peter},
title = {Title},
journal = {Mr Mevon -- just to see that he does not get matched},
date = 1998,
}
@article{vontong,
author = {Vontong, Jane},
title = {Title},
journal = {Mrs Vontong -- just to see that she does not get matched},
date = 1998,
}
@book{somebook,
author = {Arnold von Uthor},
editor = {Edward von Ditor},
translator = {Ted von Ranslator},
title = {Title},
date = 1998,
}
@book{somebooktr,
translator = {Ted von Ranslator},
title = {Title},
date = 1998,
}
@book{uz,
author = {James Uzambara},
title = {Sort under Uzambara},
date = 2000,
}
\end{filecontents*}
\DeclareSourcemap{%
\maps[datatype=bibtex]{
\map[overwrite=true]{
\step[fieldsource=translator]
\step[fieldset=tempsortname, origfieldval]
\step[fieldsource=editor]
\step[fieldset=tempsortname, origfieldval]
\step[fieldsource=author]
\step[fieldset=tempsortname, origfieldval]
}
\map[overwrite=true]{
\step[fieldsource=tempsortname, match=\regexp{(^|\s+)\Kv[a|o]n\s+}, replace={$1}]
}
\map[overwrite=false]{
\step[fieldsource=tempsortname]
\step[fieldset=sortname, origfieldval]
}
}
}
\begin{document}
\nocite{*}
\printbibliography
\end{document}