I came up with a solution based on \DeclareSourcemap and an auxiliary keyword. I observed that keyword= constraints will have \printbibliography, well, not printing (including the section heading) if a required keyword is not present in any of the entries. Exactly the behavior, I was looking for.
Therefore, I refactored my initial year check ("byYear" above) into a \map statement:
\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,}]
}
}
}
(which, here, inserts a keyword "recent" for all entries having a year value between 2008-2099)
The rewritten example of above is:
\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}
Yes, if you just want to get rid of the headings, just use \printbibliography[heading=none]
. You have other options to customize the headings through \defbibheading
(see section 3.6.7 of the biblatex
manual). There are several predefined headings which you can choose by specifying the option [heading=]
to \printbibliography
, none
is one of these.
Note that if you want to add some text between the heading and the list of references, you also have the option prenote
which you can supply to \printbibliography
.
Here is an example using prenote
and title
to change the title of the second reference list.
\documentclass{article}
\usepackage{filecontents}
\usepackage[backend=biber]{biblatex}
\usepackage{lipsum}
\begin{filecontents}{\jobname.bib}
@article{A2012,
author = {Author, A},
title = {An interesting paper},
journal = {Journal},
year = {2012},
volume = {2},
pages = {70--76},
}
@article{B2012,
author = {Buthor, B},
title = {An also interesting paper},
journal = {Journal},
year = {2012},
volume = {2},
pages = {77--79},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
\lipsum[1] \cite{A2012}
\printbibliography
\newrefsection
\lipsum[2] \cite{B2012}
\defbibnote{note}{Here are some additional references for further reading}
\printbibliography[title={Sources},prenote=note]
\end{document}
And the output:
Best Answer
as per @moewe 's comment: there was a
\less
(2 actually) in a bib entry. As soon as I deleted that the error disappeared.with the following files you too can reproduce this error:
main.tex
:and
thesis.bib
: