我正在使用 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
了year
1997 年至 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}
结果是一样的。