在我以前寻求将所要求的参考书目样式与 相匹配的过程中biblatex
,我想知道如何在 中交换“版本”和“编辑”字段biblatex-philosophy
。
这是我需要的格式:
我大致有以下几点:
\documentclass[11pt, a4paper]{scrartcl}
% Bibliography preamble
\usepackage[giveninits=true, style=philosophy-modern]{biblatex}
\addbibresource{testbib.bib}
% Some tweaks I've already made
\DeclareFieldFormat{postnote}{#1}% no postnote prefix in "normal" citation commands
\DeclareFieldFormat{multipostnote}{#1}% no postnote prefix in "multicite" commands
\DeclareFieldFormat{pages}{#1}% no prefix for the `pages` field in the bibliography
\DeclareFieldFormat[article]{title}{#1} % Remove quotations from Article title
\setlength{\yeartitle}{5.4em} % Set greater spacing between the year and the title
\setlength{\postnamesep}{2.5ex plus 2pt minus 1pt}
\begin{document}
Sentence containing citation \parencite{auerbach2003}.
\printbibliography
\end{document}
和.bib
文件:
@book{auerbach2003,
Author = {Auerbach, Erich},
Publisher = {Princeton University Press},
Title = {Mimesis: the representation of reality in Western literature},
date = {2003},
Editor = {Trask, Willard R.},
editortype = {translator},
Location = {Princeton},
edition = {2nd ed.}}
输出:
我希望这个过程也可以在其他领域重现,因为我真的很想获得这方面的技能。最佳答案这里在提供高层概述方面非常有帮助,但目前细节仍然超出了我的理解。
答案1
biblatex
仅用几行代码更改字段的顺序并不总是那么简单。这是由于biblatex
的参考书目处理结构所致。biblatex
每个条目类型都有一个“驱动程序”,用于定义以何种顺序打印哪些字段。但是,这些驱动程序并不总是\printfield
直接调用,它们通常调用执行打印的辅助 bibmacros。
以@book
from 的驱动程序philosophy-standard.bbx
为例
\DeclareBibliographyDriver{book}{%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\usebibmacro{author/editor+others/translator+others}%
\setunit{\labelnamepunct}\newblock
\usebibmacro{maintitle+title}%
\newunit
\printlist{language}%
\newunit\newblock
\usebibmacro{byauthor}%
\newunit\newblock
\usebibmacro{byeditor+others}%
\newunit\newblock
\printfield{edition}%
\newunit
\printfield{volumes}%
\newunit\newblock
\usebibmacro{series+number}%
\newunit\newblock
\printfield{note}%
\newunit\newblock
\usebibmacro{publisher+location+date}%
\newunit
\iffieldundef{maintitle}
{\printfield{volume}%
\printfield{part}}
{}%
\newunit\newblock
\usebibmacro{chapter+pages}%
\newunit
\printfield{pagetotal}%
\newunit\newblock
\iftoggle{bbx:isbn}
{\printfield{isbn}}
{}%
\newunit\newblock
\usebibmacro{doi+eprint+url}%
\newunit\newblock
\usebibmacro{addendum+pubstate}%
\newblock
\usebibmacro{phil:related}%
\newunit\newblock
\usebibmacro{pageref}%
\usebibmacro{finentry}}
您可以看到,一些字段是直接打印的(\printfield{edition}
),而许多其他内容则通过 bibmacro 打印(\usebibmacro{byeditor+others}
)。
如果您很幸运,有一个相当短的 bibmacro 可以打印您想要交换的两个字段。然后更改字段的顺序就像重新定义该 bibmacro 一样简单。例如,如果您想更改 和 的顺序,您只需重新定义即可publisher
。location
通常,所有条目类型都使用这些宏,因此您甚至不必担心这一点。date
publisher+location+date
但是,如果您想交换特定驱动程序中由不同宏打印的两个字段,那么您必须重写该驱动程序。您可以复制驱动程序定义并简单地重新排列字段。这可能很累人,并且会导致您的前言很快被许多行代码填满,因为您的平均 bibdriver 大约有 40 到 50 行长。而且您必须修改所有受影响的驱动程序。
在这些情况下,使用包会更方便xpatch
。使用\xpatchbibdriver
命令,您可以替换驱动程序定义的某些部分。要从edition
驱动程序中删除,@book
您可以说
\xpatchbibdriver{book}
{\printfield{edition}%
\newunit}
{}
{}
{\typeout{failed to remove edition from driver for 'book'}}
然后你可以将它添加到你真正想要的位置
\xpatchbibdriver{book}
{\printlist{language}%
\newunit\newblock}
{\printlist{language}%
\newunit\newblock
\printfield{edition}%
\newunit}
{}
{\typeout{failed to add edition to bibmacro 'book'}}
结构类似的补丁也必须应用于其他驱动程序和 bibmacros。
为了实现这一点,了解底层驱动程序的结构至关重要。
已对所有条目类型进行完整修补
\documentclass[11pt, a4paper]{scrartcl}
% Bibliography preamble
\usepackage[giveninits=true, style=philosophy-modern]{biblatex}
\addbibresource{biblatex-examples.bib}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@book{auerbach2003,
Author = {Auerbach, Erich},
Publisher = {Princeton University Press},
Title = {Mimesis: the representation of reality in Western literature},
date = {2003},
Editor = {Trask, Willard R.},
editortype = {translator},
Location = {Princeton},
edition = {2}}
\end{filecontents}
\addbibresource{\jobname.bib}
% Some tweaks I've already made
\DeclareFieldFormat{postnote}{#1}% no postnote prefix in "normal" citation commands
\DeclareFieldFormat{multipostnote}{#1}% no postnote prefix in "multicite" commands
\DeclareFieldFormat{pages}{#1}% no prefix for the `pages` field in the bibliography
\DeclareFieldFormat[article]{title}{#1} % Remove quotations from Article title
\setlength{\yeartitle}{5.4em} % Set greater spacing between the year and the title
\setlength{\postnamesep}{2.5ex plus 2pt minus 1pt}
\usepackage{xpatch}
\newcommand*{\removeeditiondriver}[1]{%
\xpatchbibdriver{#1}
{\printfield{edition}%
\newunit}
{}
{}
{\typeout{failed to remove edition from driver for '#1'}}}
\forcsvlist{\removeeditiondriver}{book,collection,manual,jurisdiction}
\newcommand*{\removeeditionbibmacro}[1]{%
\xpatchbibdriver{#1}
{\printfield{edition}%
\newunit}
{}
{}
{\typeout{failed to remove edition from bibmacro '#1'}}}
\forcsvlist{\removeeditionbibmacro}{inbook:full,incollection:full,xrefdata}
\newcommand*{\addeditiondriver}[1]{%
\xpatchbibdriver{#1}
{\printlist{language}%
\newunit\newblock}
{\printlist{language}%
\newunit\newblock
\printfield{edition}%
\newunit}
{}
{\typeout{failed to add edition to driver for '#1'}}}
\forcsvlist{\addeditiondriver}{book,collection,manual,jurisdiction}
\newcommand*{\addeditionbibmacroin}[1]{%
\xpatchbibdriver{#1}
{\usebibmacro{maintitle+booktitle}%
\newunit\newblock}
{\usebibmacro{maintitle+booktitle}%
\newunit\newblock
\printfield{edition}%
\newunit}
{}
{\typeout{failed to add edition to bibmacro '#1'}}}
\forcsvlist{\addeditionbibmacroin}{inbook:full,incollection:full}
\xpretobibmacro{xrefdata}
{\printfield{edition}%
\newunit}
{}
{\typeout{failed to add edition to bibmacro '#1'}}
\begin{document}
Sentence containing citation \parencite{nietzsche:ksa,companion,auerbach2003}.
\printbibliography
\end{document}