
我正在嘗試將文件date
中的一個條目的欄位bib
用於另一個條目。我的想法是,我使用另一個來源來確定條目的日期(其本身未註明日期),並且我想避免重複資料。
bib
Biblatex 提供了一種簡單的方法來透過指令使用檔案中另一個條目中的欄位\entrydata{entry_key}{\thefield{field}}
。
儘管它對於像 和 這樣的字段效果很好,title
儘管使用該\printdate
命令也可以在title
字段 ( \entrydata{entry_key}{\prindate}
) 中使用,但在字段\entrydata{entry_key}{\thefield{date}}
中使用date
不起作用。
我猜測這與該字段的性質有關,date
該字段不是一個簡單的字符串,但是在根據經驗嘗試了 biblatex 手冊中我能想到的每個命令之後,沒有任何效果。
此外,date
我想要使用的欄位將以以下YYYY-MM-DD
形式出現:我希望保留完整日期用於排序目的,但僅列印年份。
任何幫助將非常感激。
微量元素:
\documentclass{article}
\usepackage{biblatex}
\usepackage{filecontents}
\begin{filecontents}{sources.bib}
@article{testart1,
title = {First Article Title},
journaltitle = {Something Times},
date = {1964-02-01},
}
@article{testart2,
title = {\entrydata{testart1}{\thefield{title}}},% using the title of testart1 entry, working
journaltitle = {Another Times},
date = {1975-05-10},
}
@video{testvid,
title = {A Film Title},
editor = {Doe, John},
date = {},% should use date field from testart1 entry, not working with \thefield{date}
}
\end{filecontents}
\addbibresource{sources.bib}
\begin{document}
Lorem.
\nocite{*}
\printbibliography
\end{document}
答案1
找到了一個簡單的解決方案:
若要使用date
另一個號碼布條目的字段,只需向crossref
包含另一個條目(來源條目)的關鍵字的目標條目新增一個欄位。
使用crossref
有一個副作用,如果尚未定義這些字段,它會使用來源條目中不必要的字段填充目標條目(如果來源條目和目標條目屬於不同類型,則通常會發生這種情況)。透過使用可以輕鬆防止這種情況\DeclareDataInheritance
。例如:
\DeclareDataInheritance{article}{music}{% source entry type / destination entry type
\inherit{date}{date}% field we want to use
\noinherit{entrysubtype}% fields we don't want to use
\noinherit{author}
\noinherit{title}
\noinherit{subtitle}
\noinherit{journaltitle}
\noinherit{pages}
}