Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
    
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
add comment

1 Answer

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}

\addbibresource{\jobname.bib}
\DeclareBibliographyCategory{cat1}
\DeclareBibliographyCategory{cat2}
\DeclareBibliographyCategory{cat3}
\addtocategory{cat1}{A01}
\addtocategory{cat2}{B02}
\addtocategory{cat3}{C03}


\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}

\cite{A01}\quad\cite{B02}\quad\cite{C03}
\printbibliography[title={No filter}]

\printbibliography[title={Filter One},filter=FilterOne]

\printbibliography[title={Filter Two},filter=FilterTwo]

\printbibliography[title={Filter Four=combination of filter two and filter three},filter=FilterFour]
\end{document}

The result is: enter image description here

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.