16

The question I want to ask is related to the answer of this question: biblatex: filter out publications from a specific author in the references dynamically .

My aim is to separate my bibliography into two parts : one part for a personnal bibliography, and a second one for the regular bibliography.

To do that, I use the technique of the post I cited :

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[french]{babel}
\usepackage[style=alphabetic,maxnames=6,natbib=true]{biblatex}
\bibliography{biblatex-examples}

% Variants of each could be added
\newcommand{\firstname}{Donald~E.}
\newcommand{\lastname}{Knuth}

\DeclareBibliographyCategory{byname}

\DeclareIndexNameFormat{byname}{% Test could be refined
  \ifboolexpr{ test {\ifdefstring{\lastname}{#1}}
           and test {\ifdefstring{\firstname}{#3}}
              }
{\addtocategory{byname}{\thefield{entrykey}}}
{}}

\AtDataInput{%
  \indexnames[byname]{author}}

\begin{document}
 \section{Knuth's books}
 \begin{refsection}
 \nocite{*}
 \printbibliography[category=byname,heading=none]
 \end{refsection}
 \section{Not Knuth's books}
 \printbibliography[notcategory=byname,heading=none]
\end{document}

The problem is that only the second bibliography appears, and when I remove the refsection, then all the bibtex entries of my input files are printed, separated as they should.

EDIT: the aim is to have all publications (even the ones not cited) by author knuth in the first section and all the other cited publications in the second one.

2 Answers 2

31

If you want to do this using biber, I'd recommend using the sourcemap feature, it's cleaner than adding a category via an index format. This alters the input stream (without altering the .bib file) so that the keyword "knuth" is added to all works with matching "Knuth" as the author, which you can then filter on:

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map{
      \step[fieldsource=author,
            match=Knuth,
            final]
      \step[fieldset=keywords, fieldvalue=knuth]
    }
  }
}

\printbibliography[keyword=knuth]
\printbibliography[notkeyword=knuth]
6
  • I must learn this kind of source. Awesome. Commented Jul 29, 2012 at 17:25
  • This seems neat, but the \DeclareSourcemap command does not seem available on my tex distribution yet, I'll test it then.
    – Pascal
    Commented Jul 30, 2012 at 14:40
  • You need to update to biblatex 2.0 and biber 1.0
    – PLK
    Commented Jul 30, 2012 at 14:50
  • Works like a charm now!
    – Pascal
    Commented Jan 7, 2015 at 9:23
  • Is it possible to get hold of the number of references, printbibliography renders? Commented Dec 2, 2021 at 13:14
11

Here a small modification of your example. The example works only with backend=biber.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[french]{babel}
\usepackage[style=alphabetic,maxnames=6,natbib=true,backend=biber]{biblatex}
%\bibliography{biblatex-examples}
\addbibresource{biblatex-examples.bib}


\DeclareBibliographyCategory{byname}
\newcommand*{\mknamesignature}[5]{\def#1{#2|||}}
\mknamesignature{\highlightname}{Knuth}{}{}{}

\DeclareIndexNameFormat{byname}%
 {%
  \mknamesignature{\currentsignature}{#1}{#3}{#5}{#7}%
  \ifdefequal{\highlightname}{\currentsignature}%
    {\addtocategory{byname}{\thefield{entrykey}}}%
    {}%
}

\AtDataInput{%
  \indexnames[byname]{author}}

\begin{document}
 \section{Knuth's books}
 \begin{refsection}
 \nocite{*}
 \printbibliography[category=byname,heading=none]
 \end{refsection}

 \section{Not Knuth's books}
 \nocite{*}
 \printbibliography[notcategory=byname,heading=none]
\end{document}

enter image description here

10
  • This does not work for me: there is still no citation in the first category.
    – Pascal
    Commented Jul 29, 2012 at 11:19
  • really? Did you run with biber? Commented Jul 29, 2012 at 11:26
  • @Pascal: Which version of biblatex do you use? Commented Jul 29, 2012 at 11:33
  • Ah sorry, I had not seen that it should be ran with biber. Biber doesn't work currently on my distro, I would prefer a solution without it, if you have one.
    – Pascal
    Commented Jul 29, 2012 at 11:41
  • @Pascal: I don't know a way with bibtex? Which problems do you have with biber? Commented Jul 29, 2012 at 11:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .