2

I know one can use bibfilters and bibchecks to exclude entries from a bibliography, but is it possible to do something equivalent for indexing? I've looked at the examples of multiple indexes, but as far as I understand them, they put all the entries, or all the cited entries, into the index, or into an author and a title index. But I'd like to exclude all entries, cited or not, of a single author from any index generated by biblatex. The reason is simple: I would like not to index myself, even though I do cite my papers.

  • This is not the most automatic, but you could use indexing=false as an bibentry option (that is, in your bib file) for your own papers. – gusbrs Mar 21 '18 at 0:51
  • @gusbrs Do you mean adding indexing={false}, to the bib file? This suggests maybe one could use \DeclareSourceMap somehow to add this field to any set of bib entries which one want to exclude? – ss1789 Mar 21 '18 at 3:22
  • No, it should be used as options = {indexing=false}, as mentioned in moewe's answer. But in their answer, you have already a good set of possibilities, I suppose. – gusbrs Mar 21 '18 at 10:12
2

We can filter what goes to the index by checking for the name hash. You can learn more about the name hash in my answer to "Highlight an author in bibliography using biblatex allowing bibliography style to format it". Suffice it to say that Biber creates a unique hash for each name it encounters, you can find the hash for each name in the .bbl. That hash is a convenient way to check if two names are the same without having to expand all name parts and comparing the strings separately.

So you need to find our "your" hash first. Then replace Sir Humphrey's hash with yours in the code below

\documentclass[british]{report}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{csquotes}

\usepackage[style=authoryear, backend=biber, indexing=true]{biblatex}

\DeclareIndexNameFormat{default}{%
  \iffieldequalstr{hash}{dd90e644e3018ab2c6a7ffa2a58522d0}
    {}
    {\usebibmacro{index:name}
       {\index}
       {\namepartfamily}
       {\namepartgiven}
       {\namepartprefix}
       {\namepartsuffix}}}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@book{appleby,
  author  = {Humphrey Appleby},
  title   = {On the Importance of the Civil Service},
  date    = {1980},
}
@book{applebywoolley,
  author  = {Humphrey Appleby and Bernard Woolley},
  title   = {On the Ablative in Greek},
  date    = {1980},
}
\end{filecontents}

\addbibresource{\jobname.bib}
\addbibresource{biblatex-examples.bib}

\usepackage{imakeidx}
\makeindex

\begin{document}
\cite{sigfridsson,appleby,applebywoolley}
\printbibliography
\printindex
\end{document}

The index does not list Sir Humphrey. It does, however, list his co-author Bernard Woolley. This is different from putting options = {indexing=false} in the bibliography where the entire entry would not be indexed.

enter image description here


If you don't like the fact that you have to look up the hash in the .bbl file, you can try the following approach based on my automatic solution to Highlight an author in bibliography using biblatex allowing bibliography style to format it. Using this you can give the names you want to exclude to \addnamehash as you would input them in the .bib file. The code then writes the names to a temporary .bib file and extracts the name hashes automatically.

\documentclass[british]{report}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{csquotes}

\usepackage[style=authoryear, backend=biber, indexing=true]{biblatex}

\makeatletter
\def\nhblx@bibfile@name{\jobname -namehashes.bib}
\newwrite\nhblx@bibfile
\immediate\openout\nhblx@bibfile=\nhblx@bibfile@name
\newcounter{nhblx@name}
\setcounter{nhblx@name}{0}
\newcommand*{\nhblx@writenametobib}[1]{%
  \stepcounter{nhblx@name}%
  \edef\nhblx@tmp@nocite{%
    \noexpand\AfterPreamble{%
      \noexpand\setbox0\noexpand\vbox{%
        \noexpand\nhblx@getmethehash{nhblx@name@\the\value{nhblx@name}}}}%
  }%
  \nhblx@tmp@nocite
  \immediate\write\nhblx@bibfile{%
    @misc{nhblx@name@\the\value{nhblx@name}, author = {\unexpanded{#1}}, %
          options = {dataonly=true},}%
  }%
}

\AtEndDocument{%
  \closeout\nhblx@bibfile}

\addbibresource{\nhblx@bibfile@name}

\newcommand*{\nhblx@hashes}{}
\DeclareNameFormat{nhblx@hashextract}{%
  \xifinlist{\thefield{hash}}{\nhblx@hashes}
    {}
    {\listxadd{\nhblx@hashes}{\thefield{fullhash}}}}

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

\newcommand*{\addnamehash}{\forcsvlist\nhblx@writenametobib}
\newcommand*{\resetnamehashes}{\def\nhblx@hashes{}}

\DeclareIndexNameFormat{default}{%
  \savefield*{hash}{\nhblx@currentnamehash}%
  \xifinlist{\nhblx@currentnamehash}{\nhblx@hashes}
    {}
    {\usebibmacro{index:name}
       {\index}
       {\namepartfamily}
       {\namepartgiven}
       {\namepartprefix}
       {\namepartsuffix}}}
\makeatother

\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@book{appleby,
  author  = {Humphrey Appleby},
  title   = {On the Importance of the Civil Service},
  date    = {1980},
}
@book{applebywoolley,
  author  = {Humphrey Appleby and Bernard Woolley},
  title   = {On the Ablative in Greek},
  date    = {1980},
}
\end{filecontents}

\addbibresource{\jobname.bib}
\addbibresource{biblatex-examples.bib}

\usepackage{imakeidx}
\makeindex

\addnamehash{Humphrey Appleby}

\begin{document}
\cite{sigfridsson,appleby,applebywoolley}
\printbibliography
\printindex
\end{document}

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.