biblatex-philosophy で参考文献フィールドを交換するにはどうすればいいですか?

biblatex-philosophy で参考文献フィールドを交換するにはどうすればいいですか?

要求された参考文献のスタイルを と一致させるための以前の探求において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挙げます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})。

運が良ければ、交換したい 2 つのフィールドを出力する、比較的短い bibmacro があります。その場合、フィールドの順序を変更するのは、その bibmacro を再定義するのと同じくらい簡単です。たとえば、、およびの順序を変更したい場合は、publisher単に、およびを再定義するだけで済みます。多くの場合、これらのマクロはすべてのエントリ タイプで同様に使用されるため、その点について心配する必要はありません。locationdatepublisher+location+date

しかし、特定のドライバーの異なるマクロによって印刷される 2 つのフィールドを入れ替えたい場合は、基本的にそのドライバーを書き直す必要があります。ドライバー定義をコピーし、フィールドを並べ替えるだけです。これは面倒な作業で、平均的な 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}

ここに画像の説明を入力してください

関連情報