7

I want to have mixed persons index and cited works authors index. Authors which appears only in citations must be italicized in the index. Other persons (and authors which appears also in main text) are normal.

\documentclass{article}

\usepackage[backend=biber,natbib=true,indexing=cite]{biblatex} %for digital version 
\bibliography{\jobname}

\usepackage[truexindy,splitindex]{imakeidx}
\makeindex[name=persons,program=truexindy,options=-M texindy]

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@book{book1,
    author  = "Greenwild, Dirk",
    title   = "Yellow pages",
    year    = "1998",
}
@book{book2,
    author    = "Jordan, Peter",
    title     = "Math in the world",
    year      = "1996",
}
\end{filecontents}

\DeclareIndexNameFormat{default}{%
  \nameparts{#1}
  \usebibmacro{index:name}
    {\index[persons]}
    {\itshape\namepartfamily\normalfont} 
    {\namepartgiven}
    {\namepartprefix} 
    {\namepartsuffix}%
    }

\begin{document}

Foo\index[persons]{Smith, Joe}. Foo\cite{book1}. Jordan\index[persons]{Jordan, Peter} foo\cite{book2}.

\printindex[persons]

\end{document}

index

There are some problems. First - I can't italicize first name. {\itshape\namepartfamily\normalfont} italizes last name, but {\itshape\namepartgiven\normalfont} leads to errors. The only way to italicize both is

{\itshape\namepartfamily} 
{\namepartgiven}
{\normalfont\namepartprefix} 

But now author who is not only cited but also indexed manually from text in the index appears twice (Jordan Peter). index2

How can I merge them and make both first and last name italic?

Solution (?):

Finally I get it worked by redefining \mkbibindexname command:

\makeatletter
\renewcommand*{\mkbibindexname}[4]{%
  \ifuseprefix
    {\ifdefvoid{#3}{}{#3 }%
     \@firstofone #1% remove spurious braces
     \ifdefvoid{#4}{}{ #4}%
     \ifdefvoid{#2}{}{, #2}%
     \actualoperator
     \ifdefvoid{#3}{}{\MakeCapital{#3} }%
     #1%
     \ifdefvoid{#4}{}{ #4}%
     \ifdefvoid{#2}{}{, #2}}
    {\@firstofone \textit{#1}% here added \textit
     \ifdefvoid{#4}{}{ #4}%
     \ifboolexpe{%
       test {\ifdefvoid{#2}}
       and
       test {\ifdefvoid{#3}}}
       {}
       {\ }%removes comma between first and last name
     \ifdefvoid{#2}{}{ \textit{#2}}% here added \textit
     \ifdefvoid{#3}{}{ #3}}}
\makeatother

Result:

good one

This solution works (Greenwild Dirk is italicized because he appears only in the citation, Smith Joe is not italicized because he appears only in the main text, Jordan Peter is not italicized because he appears in both text and citation). Perhaps there is some more elegant solution?

Your Answer

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

Browse other questions tagged or ask your own question.