0

I would like to create a template for a publication list that can then be used by several people. The idea is that there is one bib-file which contains all of the publications. Peer-reviewed entries are marked with the keyword = pr. Then there is the master-file of the type scriptreport in which everyone can integrate their chapter-file in order to merge the publication lists of everybody into one file. The chapter file is the core of everything and should be reusable. It should filter out the entries for the respective author from the bib file and print them out in two lists (peer-reviewed and non-peer-reviewed). My problem is that I don't really know how to filter by author in this case. Here are the rough codes of the two files:

Master:

\documentclass[a4paper]{scrreprt}

\usepackage{biblatex}

\title{Publication list}

\addbibresource{sample.bib}

\begin{document}
    \maketitle
    
    \tableofcontents
    \newpage
    
    \include{Researcher}
    \newpage
\end{document}

chapter:

\chapter*{Researcher}
\addcontentsline{toc}{chapter}{Researcher}
    
    \nocite{*}
    \printbibliography[keyword={pr}, title={Peer-reviewed}]
    
    \nocite{*}
    \printbibliography[notkeyword={pr}, title={Non-peer-reviewed}]
0

Filtering by name isn't that easy. One way would be to use a sourcemap and regex to match names and add keyowrds (e.g. biblatex: separating publications of a specific author in the bibliography).

Another way using string/macro comparison is shown in biblatex: filter out publications from a specific author in the references dynamically. Similar to Make specific author bold using biblatex I'd prefer using hashes instead of string/macro comparison.

The following is an adaptation of my answer https://tex.stackexchange.com/a/416416/35864 for bold names to name filtering. Most of the code from there can simply be copied over, the new thing is to define two bibchecks to filter the bibliography entries by arbitrary conditions.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[backend=biber,style=authoryear]{biblatex}

\addbibresource{biblatex-examples.bib}

\makeatletter
\def\fnblx@bibfile@name{\jobname -fnblx.bib}
\newwrite\fnblx@bibfile
\immediate\openout\fnblx@bibfile=\fnblx@bibfile@name

\immediate\write\fnblx@bibfile{%
  @comment{Auto-generated file}\blx@nl}

\newcounter{fnblx@name}
\setcounter{fnblx@name}{0}

\newcommand*{\fnblx@writenametobib}[1]{%
  \stepcounter{fnblx@name}%
  \edef\fnblx@tmp@nocite{%
    \noexpand\AfterPreamble{%
      \noexpand\setbox0\noexpand\vbox{%
        \noexpand\fnblx@getmethehash{fnblx@name@\the\value{fnblx@name}}}}%
  }%
  \fnblx@tmp@nocite
  \immediate\write\fnblx@bibfile{%
    @misc{fnblx@name@\the\value{fnblx@name}, author = {\unexpanded{#1}}, %
          options = {dataonly=true},}%
  }%
}

\AtEndDocument{%
  \closeout\fnblx@bibfile}

\addbibresource{\fnblx@bibfile@name}

\newcommand*{\fnblx@namehashes}{}
\DeclareNameFormat{fnblx@hashextract}{%
  \xifinlist{\thefield{hash}}{\fnblx@namehashes}
    {}
    {\listxadd{\fnblx@namehashes}{\thefield{hash}}}}

\DeclareCiteCommand{\fnblx@getmethehash}
  {}
  {\printnames[fnblx@hashextract][1-999]{author}}
  {}
  {}

\newtoggle{fnblx@tempa}
\DeclareIndexNameFormat{fnblx@checkfilternames}{%
  \xifinlist{\thefield{hash}}{\fnblx@namehashes}
    {\global\toggletrue{fnblx@tempa}}
    {}}

\newcommand*{\addbfilternames}{\forcsvlist\fnblx@writenametobib}
\newcommand*{\resetfilternames}{\def\fnblx@namehashes{}}

\defbibcheck{filternames}{%
  \global\togglefalse{fnblx@tempa}
  \indexnames[fnblx@checkfilternames][1-999]{labelname}%
  \iftoggle{fnblx@tempa}
    {}
    {\skipentry}}
    
\defbibcheck{notfilternames}{%
  \global\togglefalse{fnblx@tempa}
  \indexnames[fnblx@checkfilternames][1-999]{labelname}%
  \iftoggle{fnblx@tempa}
    {\skipentry}
    {}}
\makeatother


\begin{document}
\cite{sigfridsson,worman,geer,knuth:ct:a,knuth:ct:b}

\addbfilternames{Emma Sigfridsson}
\printbibliography[check=filternames, title={Works by Emma Sigfridsson}]
\printbibliography[check=notfilternames, title={Works not by Emma Sigfridsson}]

\resetfilternames
\addbfilternames{{Knuth, Donald E.}}
\printbibliography[check=filternames, title={Works by Donald Knuth}]
\printbibliography[check=notfilternames, title={Works not by Donald Knuth}]
\end{document}

Two filtered bibliographies.

The user interface should be self-explanatory with the usage examples above. If you have any questions about the implementation that aren't covered by https://tex.stackexchange.com/a/416416/35864, please ask ahead in the comments.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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