[Tex/LaTex] biblatex filter on arbitrary field

biblatex

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?

Best Answer

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}