使用如下所示的设置,我最终会生成一个章节标题“书籍章节”,尽管没有要打印的 bib 条目。这给我(在我的完整设置中)留下了一堆空白 bib 章节的空白标题。
示例文档:
\documentclass[a4paper]{article}
\pagestyle{empty}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{textcomp}
\usepackage[autostyle]{csquotes}
\usepackage{filecontents}
\usepackage[style=alphabetic,%
backend=biber,%
language=english,%
isbn=false,%
url=true,%
maxbibnames=99%
]{biblatex}
\begin{filecontents*}{test.bib}
@inbook{my:key,
author = {AAA BBB and CCC DDD},
title = {An Introduction},
year = {2012},
booktitle = {YYY},
pages = {111-222},
publisher = {LePub},
series = {The Series},
keywords = {authored}
}
\end{filecontents*}
\defbibfilter{bookChapters}{%
type=inbook or type=incollection
}
\defbibcheck{byYear}{%
\iffieldint{year}
{\ifnumless{\thefield{year}}{2013}
{\skipentry}
{}}
{\skipentry}
}
\bibliography{test}
\begin{document}
\nocite{*}
\printbibliography[title={Book Chapters},%
heading=subbibliography,%
check=byYear,%
keyword=authored,%
sorting=ydnt,%
filter=bookChapters]
\end{document}
我抓取了 biblatex 参考资料,但它没有为我提供解决方案。我正在运行 biber 1.1 和 biblatex 2.1。
我将非常感激你的帮助。
答案1
我想出了一个基于 \DeclareSourcemap 和辅助关键字的解决方案。我观察到 keyword= 约束将具有 \printbibliography,如果任何条目中不存在必需的关键字,则不会打印(包括部分标题)。这正是我所寻找的行为。
因此,我将最初的年份检查(上面的“byYear”)重构为 \map 语句:
\DeclareSourcemap{
\maps[datatype=bibtex]{
\map[overwrite=true]{
\step[fieldsource=year,
match=\regexp{^20(0[8-9]|[1-9][0-9])$},
final]
\step[fieldsource=keywords, match=\regexp{^}, replace=\regexp{recent,}]
}
}
}
(此处为年份在 2008 至 2099 之间的所有条目插入关键字“最近”)
上述示例重写如下:
\documentclass[a4paper]{article}
\pagestyle{empty}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{textcomp}
\usepackage[autostyle]{csquotes}
\usepackage{filecontents}
\usepackage[style=alphabetic,%
backend=biber,%
language=english,%
isbn=false,%
url=true,%
maxbibnames=99%
]{biblatex}
\begin{filecontents*}{test.bib}
@inbook{my:key,
author = {AAA BBB and CCC DDD},
title = {An Introduction},
year = {2007},
booktitle = {YYY},
pages = {111-222},
publisher = {LePub},
series = {The Series},
keywords = {authored}
}
\end{filecontents*}
\DeclareSourcemap{
\maps[datatype=bibtex]{
\map[overwrite=true]{
\step[fieldsource=year,
match=\regexp{^20(0[8-9]|[1-9][0-9])$},
final]
\step[fieldsource=keywords, match=\regexp{^}, replace=\regexp{recent,}]
}
}
}
\defbibfilter{bookChapters}{%
type=inbook or type=incollection
}
\bibliography{test}
\begin{document}
\nocite{*}
\printbibliography[title={Book Chapters since 2008},%
heading=subbibliography,%
keyword=authored,%
keyword=recent,%
sorting=ydnt,%
filter=bookChapters]
\end{document}