# Biblatex: Combine filters

I posted the exact same question on comp.text.tex

I wonder if I am missing something or not, but I think the following feature for biblatex would be great: Biblatex offers the possibility to define so-called filters for the bibliography.

1. Is there a way to combine filters by using some syntax like: \defbibfilter{myNewFilter}{filter=AnOldFilter and not ( filter=AnotherFilter )}?

2. [A simpler suggestion] Is there a way to say something like: \printbibliography[notfilter=MyFilter]? I know that \printbibliography[filter=...] and \printbibliography[nottype=...] exist for instance, and I wonder if the "notfilter" option could be implemented.

-
My question was mainly: Is this feature implemented or not? I agree there could be plenty of solutions to write some code doing what I wanted! –  Bruno Oct 28 '11 at 16:32

At the moment a combination of filters isn't implemented. To combine filters you have to create your own algorithm.

I want to present one approach. Therefor I defined the command:

\combinetwobibfilter{Arg 1}{Arg 2}{Arg 3}


with three mandatory arguments. The first argument is the name of the new filter. The second and the third argument are the names of the two predefined filters. Up to now I have no test implemented to check whether the filters are defined or not.

\setcounter{errorcontextlines}{999}
\documentclass{article}
\usepackage[style=authoryear]{biblatex}
\usepackage{biblatex}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@misc{A01,
author = {Author, A.},
year = {2001},
title = {Alpha},
}
@misc{B02,
author = {Buthor, B.},
year = {2002},
title = {Bravo},
}
@misc{C03,
author = {Cuthor, C.},
year = {2003},
title = {Charlie},
}
\end{filecontents}

\DeclareBibliographyCategory{cat1}
\DeclareBibliographyCategory{cat2}
\DeclareBibliographyCategory{cat3}

\makeatletter
\let\defbibfilter@orig\defbibfilter
\renewrobustcmd*{\defbibfilter}[2]{%
\csgdef{save@bibfilter#1}{#2}%
\defbibfilter@orig{#1}{#2}}

\newrobustcmd{\combinetwobibfilter}[3]{%
\csedef{temp@bibfilter}{%
\csuse{save@bibfilter#2}
or
\csuse{save@bibfilter#3}
}%
\defbibfilter{#1}{\csuse{temp@bibfilter}}%
}
\makeatother

\defbibfilter{FilterOne}{category=cat1}
\defbibfilter{FilterTwo}{category=cat2}
\defbibfilter{FilterThree}{category=cat3}
\combinetwobibfilter{FilterFour}{FilterTwo}{FilterThree}

\begin{document}