Follow up question to this one. I would now like to add authors and titles in my primary bibliography to the index, which works, but for the secondary bibliography I would like to index only the authors (editors, translators), not the titles of their books.
\documentclass{memoir}
\usepackage{csquotes}
\makeindex
\usepackage{xpatch}
\usepackage[indexing=true,authordate,backend=biber,language=auto,autolang=other]{biblatex-chicago}
\usepackage{filecontents}
\renewbibmacro*{bibindex}{%
\ifbibindex
{\indexnames{author}%
\indexnames{editor}%
\indexnames{translator}%
\indexnames{commentator}%
\ifkeyword{pri}{\indexfield{indextitle}}{}
}
{}}
\renewbibmacro*{citeindex}{%
\ifciteindex
{\indexnames{author}%
\indexnames{editor}%
\indexnames{translator}%
\indexnames{commentator}%
\ifkeyword{pri}{\indexfield{indextitle}}{}
}
{}}
\begin{filecontents}{pri.bib}
@misc{Kuṭṭanīmata,
entrysubtype = {classical},
author = {Dāmodaragupta},
title = {Kuṭṭanīmata},
related = {DezsoGoodall2012},
relatedoptions = {dataonly,useeditor=false,usetranslator=false}
}
\end{filecontents}
\begin{filecontents}{sec.bib}
@book{DezsoGoodall2012,
title = {Dāmodaraguptaviracitaṃ Kuṭṭanīmatam},
subtitle = {The Bawd’s Counsel, Being an Eighth-century Verse Novel in Sanskrit by Dāmodaragupta, Newly Edited and Translated into English},
editor = {Csaba Dezső and Dominic Goodall},
translator = {Csaba Dezső and Dominic Goodall},
series = {Groningen Oriental Studies},
number = {23},
location = {Groningen},
publisher = {Egbert Forsten},
year = {2012}
}
\end{filecontents}
\addbibresource{pri.bib}
\addbibresource{sec.bib}
\DeclareSourcemap{
\maps{
\map{
\perdatasource{pri.bib}
\step[fieldset=keywords, fieldvalue=pri]
\step[fieldsource=title, final]
\step[fieldset=sortkey, origfieldval]
}
}
}
\DeclareFieldFormat[misc]{title}{\mkbibemph{#1}\isdot}
\newbibmacro*{pri:titleofauthor}{%
\ifentrytype{misc}
{\iffieldequalstr{entrysubtype}{classical}
{\ifbibliography
{\printfield{title}%
\ifnameundef{author}
{}
{\setunit*{\addspace}%
\bibstring{of}%
\setunit*{\addspace}%
\printnames{author}%
\clearname{author}}%
\clearfield{title}}
{\printtext[bibhyperref]{\printfield[citetitle]{title}}%
\ifnameundef{labelname}
{}
{\setunit*{\addspace}%
\bibstring{of}%
\setunit*{\addspace}%
\printnames{labelname}}%
\clearfield{labeltitle}%
\clearname{labelname}}}
{}}
{}}
\xpretobibmacro{cite}
{\usebibmacro{pri:titleofauthor}}
{}
{}
\xpatchbibdriver{misc}
{\usebibmacro{bibindex}}
{\usebibmacro{bibindex}\usebibmacro{pri:titleofauthor}}
{}
{}
\begin{document}
Filler text \autocite{Kuṭṭanīmata}.
Filler text \autocite{DezsoGoodall2012}.
\printbibliography[title=Primary Sources, keyword=pri,heading=subbibliography]
\printbibliography[title=Secondary Sources, notkeyword=pri,heading=subbibliography]
\printindex
\end{document}
EDIT: Added redefinitions of bibindex and citeindex to the example, which unconditionally suppress the indexing of titles. I guess in both cases (or maybe they could also be joined?) one would need to add a condition before the to-be-commented-back-in \indexfield{indextitle}.
EDIT: The command \ifkeyword{}{}{} seems to be doing the required test. Still I am wondering if it is really necessary to have identical definitions of bibindex and citeindex, or if there's a better way of doing this.