# biblatex filter on arbitrary field

We maintain a bibtex file with all publications from our group. We use the annote field to separate the publications into several groups, e.g. Journal Papers or Other Papers. This makes the entries look like this:

@article{something_2011,
Author = {Author, Some and Other, An},
Title = {Here be dragons},
Journal = {Whatever journal},
Pages = {123-234},
Volume = {1},
Year = {2000},
Annote = {Other Peer Reviewed Paper}
}


We then have a tex file that looks something like this:

\documentclass{article}
\usepackage{fontspec}
\usepackage{biblatex}

\addbibresource{author1_Books.bib}
\addbibresource{author1_OtherPeerReviewedPapers.bib}
\addbibresource{author1_OtherPapers.bib}
\addbibresource{author1_JournalPapers.bib}

\begin{document}
\nocite{*}
\printbibliography[title={Books}]
\printbibliography[title={Other Peer Reviewed Papers}]
\printbibliography[title={Other Papers}]
\printbibliography[title={Journal Papers}]
\end{document}


The above tex files prints all publications into all four bibliographies. So we want to use the content of the annote field to group the entries. But biblatex only filters on segment, type, subtype, category, keyword or a combination of those, but not on arbitrary fields. Is it possible to have biblatex filter on the annote field?

## 2 Answers

Note that annote is an alias for annotation, so the answer uses annotation instead.

You can create bibchecks with almost arbitrary logic. See §3.7.9 Bibliography Filters and Checks of the biblatex manual. A bibcheck will contain the special directive \skipentry to discard a particular entry, all entries that do not get to \skipentry will be displayed. (So in a way you don't explicitly tell biblatex which entries you want, you mark those that you don't want.)

With \iffieldequalstr you can check for field contents. Putting that together you can use

\defbibcheck{annotebar}{\iffieldequalstr{annotation}{bar}{}{\skipentry}}
\defbibcheck{annotefoo}{\iffieldequalstr{annotation}{foo}{}{\skipentry}}


to obtain only those entries with an annotation equal to bar and foo, respectively.

\documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{csquotes}
\usepackage[bibencoding=auto,backend=biber,babel=other]{biblatex}

\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@book{Bara2006,
address = {New York},
author = {Bara, Judith},
publisher = {Routledge},
title = {English Citation entry},
year = {2006},
annote = {foo},
}
@book{Bara2007,
address = {New York},
author = {Bara, Judith},
publisher = {Routledge},
title = {Another English Citation entry},
year = {2007},
annote = {bar},
}
\end{filecontents*}

\addbibresource{\jobname.bib}

\defbibcheck{annotebar}{\iffieldequalstr{annotation}{bar}{}{\skipentry}}
\defbibcheck{annotefoo}{\iffieldequalstr{annotation}{foo}{}{\skipentry}}

\begin{document}
\parencite{Bara2006,Bara2007}
\printbibliography[check=annotebar]
\printbibliography[check=annotefoo]
\end{document}

• Thanks for this detailed answer. I actually missed the part to define arbitrary filters in the biblatex documentation. I read the beginning of the referenced chapter §3.7.9, but I somehow overlook it. I'll give it a try – PVitt Oct 11 '16 at 16:25

Here is a solution using filters and categories from biblatex:

\documentclass{article}

\usepackage{filecontents}

\begin{filecontents*}{\jobname.bib}
@article{aaa,
Author = {Aaa, John and Other, An},
Title = {Here be dragons},
Journal = {Whatever journal},
Pages = {123-234},
Volume = {1},
Year = {2000},
Annote = {Journal Papers}
}
@article{bbb,
Author = {Bbb, Alexandra},
Title = {Dunjeon \& Dragons},
Journal = {A journal},
Pages = {12-24},
Volume = {1},
Year = {2001},
Annote = {Other Papers}
}
@article{ccc,
Author = {Ccc, Jules},
Title = {A small title},
Journal = {A book},
Pages = {1023-1026},
Volume = {2},
Year = {2016},
Annote = {Books}
}
\end{filecontents*}

\usepackage{biblatex}
\addbibresource{\jobname.bib}

\DeclareBibliographyCategory{Books}
\DeclareBibliographyCategory{JournalPapers}
\DeclareBibliographyCategory{OtherPapers}
\DeclareIndexFieldFormat{Books}{%
\ifstrequal{Books}{#1}
{\addtocategory{Books}{\thefield{entrykey}}}
{
\ifstrequal{Journal Papers}{#1}
{\addtocategory{JournalPapers}{\thefield{entrykey}}}
{
\ifstrequal{Other Papers}{#1}
{\addtocategory{OtherPapers}{\thefield{entrykey}}}
{}
}
}
}
\AtDataInput{\indexfield[Books]{annotation}}

\begin{document}
\nocite{*}
\printbibliography[category=Books,title={Books}]
\printbibliography[category=JournalPapers,title={Journal Papers}]
\printbibliography[category=OtherPapers,title={Other Papers}]
\end{document}