我正在使用 biber 和 biblatex,我想列印 2013 年之前的所有論文。
year = {2010}
.bib 檔案中的條目,每個想法都正常運作。但是,如果我使用
date = {2010-11-25}
我的條目被忽略,而不是年份。我尊重日期格式,對嗎?那麼有什麼問題嗎?這是一個 MWE。
\documentclass{article}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@THESIS{a,
AUTHOR = {Myself},
TITLE = {Me, myself and I},
Institution = {My University},
type = {Ph.D. thesis},
year = {2010}
} % date = {2010-11-25}
\end{filecontents*}
\usepackage[backend=biber,defernumbers=true,sorting=ydnt]{biblatex}
\addbibresource{\jobname.bib}
\DeclareSourcemap{
\maps[datatype=bibtex]{
\map[overwrite=true]{
\step[fieldsource=year, match=\regexp{199([7-9])|200([0-9])|201([0-2])},final]
\step[fieldset=keywords, fieldvalue={,}, append]
\step[fieldset=keywords, fieldvalue={before2013}, append]
}}}
\begin{document}
Hello world.
\nocite{*}
\printbibliography[type=thesis,keyword=before2013,title=Thesis,resetnumbers=true]
\end{document}
答案1
year
您可以將該欄位與biblatex
文件中的欄位進行比較,而不是 Biber 的來源對應。 (year
無論您是否使用year
或 ,我們都可以在此處使用,date
因為date
欄位在寫入 時總是被分割成其組成部分.bbl
。)
我們定義一個 bibcheck
\defbibcheck{before2013}{%
\iffieldint{year}
{\ifnumless{\thefield{year}}{2013}
{}
{\skipentry}}
{\skipentry}}
並使用該檢查而不是關鍵字
\printbibliography[type=thesis,check=before2013,title=Thesis,resetnumbers=true]
答案2
您\maps
只能設定keyword=before2013
1997year
年至 2012 年,但不能date
設定 1997-01-01 至 2012-12-31。僅當 時才列印索引keyword=before2013
。因此,如果使用date
代替,則不會列印該條目year
。
date
您可以為以下內容添加類似的地圖year
:
\documentclass{article}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@THESIS{a,
AUTHOR = {Myself},
TITLE = {Me, myself and I},
Institution = {My University},
type = {Ph.D. thesis},
year = {2010}
}
@THESIS{b,
AUTHOR = {Another},
TITLE = {Another, one and nobody},
Institution = {My University},
type = {Ph.D. thesis},
date = {2010-11-25}
}
@THESIS{c,
AUTHOR= {Never},
TITLE = {I'm to late},
Institution = {My University},
type = {Ph.D. thesis},
date = {2017-01-01}
}
\end{filecontents*}
\usepackage[backend=biber,defernumbers=true,sorting=ydnt]{biblatex}
\addbibresource{\jobname.bib}
\DeclareSourcemap{
\maps[datatype=bibtex]{
\map[overwrite=true]{
\step[fieldsource=year, match=\regexp{199([7-9])|200([0-9])|201([0-2])},final]
\step[fieldset=keywords, fieldvalue={,}, append]
\step[fieldset=keywords, fieldvalue={before2013}, append]
}
\map[overwrite=true]{
\step[fieldsource=date, match=\regexp{199([7-9])|200([0-9])|201([0-2])},final]
\step[fieldset=keywords, fieldvalue={,}, append]
\step[fieldset=keywords, fieldvalue={before2013}, append]
}
}
}
\begin{document}
Hello world.
\nocite{*}
\printbibliography[type=thesis,keyword=before2013,title=Thesis,resetnumbers=true]
\end{document}
另一個解決方案是使用檢查,因為檢查是在日期已經分割時完成的:
\documentclass{article}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@THESIS{a,
AUTHOR = {Myself},
TITLE = {Me, myself and I},
Institution = {My University},
type = {Ph.D. thesis},
year = {2010}
}
@THESIS{b,
AUTHOR = {Another},
TITLE = {Another, one and nobody},
Institution = {My University},
type = {Ph.D. thesis},
date = {2010-11-25}
}
@THESIS{c,
AUTHOR= {Never},
TITLE = {I'm to late},
Institution = {My University},
type = {Ph.D. thesis},
date = {2017-01-01}
}
\end{filecontents*}
\usepackage[backend=biber,defernumbers=true,sorting=ydnt]{biblatex}
\addbibresource{\jobname.bib}
\defbibcheck{before2013}{%
\iffieldint{year}% If an interger field year exists
{
\ifnumless{\thefield{year}}{2013}% and the field value is less than 2013
{}% do nothing
{\skipentry}% otherwise skip the entry
}
{\skipentry}% skip the entrie also if there isn't an integer field year
}
\begin{document}
Hello world.
\nocite{*}
\printbibliography[type=thesis,check=before2013,title=Thesis,resetnumbers=true]
\end{document}
結果是一樣的。