biblatex filter on arbitrary field
Note that annote
is an alias for annotation
, so the answer uses annotation
instead.
You can create bibcheck
s 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}
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}