![biber來源映射問題](https://rvso.com/image/475745/biber%E4%BE%86%E6%BA%90%E6%98%A0%E5%B0%84%E5%95%8F%E9%A1%8C.png)
下面是一個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
欄位。
所以sourcemapping程式碼也應該可以這樣寫。
\DeclareStyleSourcemap{
\maps{
\map{
\pertype{customa}
\step[fieldsource=eventyear]
\step[fieldset=sortyear, origfieldval]
}
}
}
但這第二個解決方案不起作用。為什麼?錯誤是什麼?謝謝。
答案1
來源映射步驟(Biber 將變更套用到資料)在檔案處理過程的早期發生.bib
。特別是它發生在 Biber 將日期欄位拆分為各個組件的步驟之前。
因此,當\DeclareStyleSourcemap
執行時,日期欄位仍然是eventdate
(如文件中給出的.bib
)eventyear
並且朋友尚不可用。