在我以前尋求將請求的參考書目風格與 相匹配時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}