解决方案 (?):

解决方案 (?):

我想要混合人物索引和引用作品作者索引。出现的作者仅有的索引中引用的人员必须用斜体表示。其他人员(以及在正文中出现的作者)则正常。

\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}

指数

存在一些问题。首先 - 我无法将名字斜体化。 {\itshape\namepartfamily\normalfont}将姓氏斜体化,但{\itshape\namepartgiven\normalfont}会导致错误。将两者斜体化的唯一方法是

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

但是现在,在索引中不仅被引用而且从文本中手动索引的作者出现了两次(Jordan Peter)。 索引2

我怎样才能合并它们并使名字和姓氏都变为斜体?

解决方案 (?):

最后我通过重新定义命令使其工作\mkbibindexname

\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

结果:

好

此解决方案有效(Greenwild Dirk 用斜体表示,因为他只出现在引文中;Smith Joe 不用斜体表示,因为他只出现在正文中;Jordan Peter 不用斜体表示,因为他同时出现在正文和引文中)。也许还有其他更优雅的解决方案?

相关内容