使用 imakeidx 进行多重索引:仅限作者姓名

使用 imakeidx 进行多重索引:仅限作者姓名

我在课堂上写论文yathesis,想用imakeindex软件包生成多个索引。我已经能够生成两个索引:一个包含标题子条目的名称索引,以及一个按年份组织的标题索引。从那里,我无法生成作者姓名的索引(删除标题)。

有人知道我怎样才能获得姓名索引吗?

如果可能的话,在括号中写上作者的姓氏,后面跟着他名字的首字母。就像这样:斯科切波尔(T.)

非常感谢 !

以下是 MWE:

\documentclass[12pt]{yathesis}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{hyperref}
\usepackage{lipsum}

\usepackage{imakeidx}
\usepackage[main=french]{babel}
\usepackage{csquotes}

\usepackage[indexing=cite,style=authortitle,autolang=hyphen,backend=biber]{biblatex}
\addbibresource{biblatex-examples.bib}


\makeindex
\makeindex[name=name-title,title={Name and Title Index}]
\makeindex[name=year-title,title={Year and Title Index}]

\makeatletter
\@ifpackageloaded{biblatex_legacy}
{\DeclareIndexNameFormat{name:title}{%
    \iffieldundef{title}
    {\usebibmacro{index:name}{\index[name-title]}{#1}{#3}{#5}{#7}}
    {\usebibmacro{index:name:title}{\index[name-title]}{#1}{#3}{#5}{#7}}}}
{\DeclareIndexNameFormat{name:title}{%
        \iffieldundef{title}
        {\usebibmacro{index:name}{\index[name-title]}
            {\namepartfamily}
        {\namepartgiven}
        {\namepartprefix}
        {\namepartsuffix}}
    {\usebibmacro{index:name:title}{\index[name-title]}
        {\namepartfamily}
        {\namepartgiven}
        {\namepartprefix}
        {\namepartsuffix}}}}
\makeatother

\DeclareIndexFieldFormat{with:year}{%
\iffieldundef{year}
{\usebibmacro{index:entry}{\index[year-title]}{%
        \mkbibindexentry{0}{Not dated}%
        \subentryoperator%
        \mkbibindexfield{\thefield{indexsorttitle}}{\emph{#1}}}}
{\usebibmacro{index:entry}{\index[year-title]}{%
        \thefield{year}\subentryoperator%
        \mkbibindexfield{\thefield{indexsorttitle}}{\emph{#1}}}}}

\renewbibmacro*{citeindex}{%
\ifciteindex
{\indexnames[name:title]{labelname}%
    \indexfield[with:year]{indextitle}}
{}}

\begin{document}

\mainmatter

Here is some text avec un ballon\index{ballon}
\autocite{knuth:ct,knuth:ct:a,knuth:ct:c,knuth:ct:d}
\autocite{aristotle:anima,aristotle:poetics,aristotle:physics}

 \backmatter 

 \clearpage

 \printbibliography

 \raggedright
 \printindex
 \printindex[name-title] % the name-title index
 \printindex[year-title] % the year-title index

 \end{document}

答案1

以下创建一个仅包含名称的额外索引,并以biblatex“Family (G.)”格式格式化索引中生成的所有名称。

要更改名称格式,我们重新定义\mkbibindexname。对于仅名称索引,我们主要可以从其他索引复制内容,但使用name:indexindex:name不是index:name:title

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[main=french]{babel}
\usepackage{imakeidx}
\usepackage{csquotes}
\usepackage[indexing=cite,style=authortitle,autolang=hyphen,backend=biber]{biblatex}
\usepackage{hyperref}

\addbibresource{biblatex-examples.bib}

\makeindex
\makeindex[name=name-only,title={Name Index}]
\makeindex[name=name-title,title={Name and Title Index}]
\makeindex[name=year-title,title={Year and Title Index}]


\DeclareIndexNameFormat{name:title}{%
  \iffieldundef{title}
    {\usebibmacro{index:name}{\index[name-title]}
       {\namepartfamily}
       {\namepartgiveni}
       {\namepartprefix}
       {\namepartsuffix}}
    {\usebibmacro{index:name:title}{\index[name-title]}
       {\namepartfamily}
       {\namepartgiveni}
       {\namepartprefix}
       {\namepartsuffix}}}

\DeclareIndexNameFormat{name:only}{%
  \usebibmacro{index:name}{\index[name-only]}
    {\namepartfamily}
    {\namepartgiveni}
    {\namepartprefix}
    {\namepartsuffix}}

\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 #1% remove spurious braces
     \ifdefvoid{#4}{}{ #4}%
     \ifdefvoid{#2}{}{ (#2)}%
     \ifdefvoid{#3}{}{ #3}}}
\makeatother

\DeclareIndexFieldFormat{with:year}{%
  \iffieldundef{year}
    {\usebibmacro{index:entry}{\index[year-title]}{%
       \mkbibindexentry{0}{Not dated}%
       \subentryoperator%
       \mkbibindexfield{\thefield{indexsorttitle}}{\emph{#1}}}}
    {\usebibmacro{index:entry}{\index[year-title]}{%
       \thefield{year}\subentryoperator%
       \mkbibindexfield{\thefield{indexsorttitle}}{\emph{#1}}}}}

\renewbibmacro*{citeindex}{%
  \ifciteindex
    {\indexnames[name:only]{labelname}%
     \indexnames[name:title]{labelname}%
     \indexfield[with:year]{indextitle}}
    {}}

\begin{document}
  Here is some text avec un ballon\index{ballon}
  \autocite{knuth:ct,knuth:ct:a,knuth:ct:c,knuth:ct:d}
  \autocite{aristotle:anima,aristotle:poetics,aristotle:physics}

 \printindex
 \printindex[name-title] % the name-title index
 \printindex[year-title] % the year-title index
 \printindex[name-only] % the name index
 \end{document}

在此处输入图片描述

相关内容