以下はmweです:
\begin{filecontents}[overwrite]{\jobname.bib}
@customa{a,
author = {Author},
eventdate = {1000-01-01},
title = {Title},
journaltitle = {Journaltitle},
date = {3000},
}
@customa{b,
author = {Author},
eventdate = {2000-01-01},
title = {Title},
journaltitle = {Journaltitle},
date = {1000},
}
@customa{c,
author = {Author},
eventdate = {3000-01-01},
title = {Title},
journaltitle = {Journaltitle},
date = {2000},
}
@article{article,
author = {Author},
title = {Title},
journaltitle = {Journaltitle},
date = {2000},
}
\end{filecontents}
\documentclass{article}
\usepackage[style=authortitle]{biblatex}
\addbibresource{\jobname.bib}
\DeclareStyleSourcemap{
\maps{
\map{
\pertype{customa}
\step[fieldsource=eventdate, match=\regexp{\A(\d+)}]
\step[fieldset=sortyear, fieldvalue={$1}]
}
}
}
\DeclareBibliographyDriver{customa}{%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\printnames{author}%
\newunit
\printeventdate
\newunit
\usebibmacro{title}%
\newunit\newblock
\bibstring{in}%
\printunit{\intitlepunct}
\usebibmacro{journal+issuetitle}%
\usebibmacro{finentry}}
\begin{document}
\nocite{*}
\printbibliography
\end{document}
mwe は正常に動作します。
私の理解では、<datetype>date
が定義されている場合、biber/biblatex は<datetype>year
、、、<datetype>month
および<datetype>day
フィールドを自動的に生成します。
したがって、ソースマッピング コードも次のように記述できるはずです。
\DeclareStyleSourcemap{
\maps{
\map{
\pertype{customa}
\step[fieldsource=eventyear]
\step[fieldset=sortyear, origfieldval]
}
}
}
しかし、この 2 番目の解決策は機能しません。なぜでしょうか? エラーは何ですか? ありがとうございます。
答え1
Biber がデータに変更を適用するソースマッピング ステップは、.bib
ファイルの処理の非常に早い段階で行われます。特に、Biber が日付フィールドをコンポーネントに分割するステップの前に行われます。
したがって\DeclareStyleSourcemap
、 が実行されると、日付フィールドはまだeventdate
(ファイルに指定されているとおり.bib
) であり、eventyear
と 友人はまだ利用できません。