代码:

代码:

在“姓名索引”中,只有很少可能的类别:在此示例中为“动物”、“艺术家”、“矿物”和“植物”。

对于这个“姓名索引”,我该如何消除“A”、“M”和“P”字母类别——尤其是在书签中?我不希望这会改变其他索引。

在此处输入图片描述

我希望书签看起来像:

Name Index
    Animal
    Artists
    Mineral
    Plant

Main Index
    C
    D
    T

相关问题

代码:

\documentclass{article}
\usepackage{imakeidx}
\usepackage{xparse}
\usepackage{xcolor}
\usepackage{hyperref}

\newcommand*\lettergroup[1]{\subsection{#1}}

\newcommand*{\IndexWithName}[2]{%
    % #1 = word to index
    % #2 = index name
    \index[#2]{#1}%
}

\NewDocumentCommand{\FormatIndexEntry}{mm}{%
    \textcolor{blue}{#1} #2%
}

\NewDocumentCommand{\AddIndexEntry}{%
    O{}% #1 = index name
      m% #2 = word to index this under
      m% #3 = indexed term
      m% #4 = symbol (not used in this MWE)
}{%
    \expandafter\IndexWithName\expandafter{%
        #2!#3@\FormatIndexEntry{#3}{\unexpanded{\unexpanded{#4}}}%
    }{#1}%
}

\makeindex[title={Main Index},columns=1,program=texindy,name=Main]
\makeindex[title={Name Index},columns=1,program=texindy,name=Name]
\indexsetup{level=\section}

\begin{document}
some text

\AddIndexEntry[Main]{tree}{leaf}{}
\AddIndexEntry[Main]{tree}{trunk}{}
\AddIndexEntry[Main]{dog}{labrador retriever}{}
\AddIndexEntry[Main]{dog}{german shpherd}{}
\AddIndexEntry[Main]{cat}{siamese}{}
\AddIndexEntry[Main]{cat}{persian}{}
\AddIndexEntry[Main]{cat}{bengal}{}

\AddIndexEntry[Name]{artists}{Picasso}{}
\AddIndexEntry[Name]{artists}{van Gogh}{}
\AddIndexEntry[Name]{artists}{da Vinci}{}
\AddIndexEntry[Name]{plant}{tree}{}
\AddIndexEntry[Name]{plant}{shrub}{}
\AddIndexEntry[Name]{animal}{fox}{}
\AddIndexEntry[Name]{animal}{cat}{}
\AddIndexEntry[Name]{mineral}{quartz}{}
\AddIndexEntry[Name]{mineral}{marble}{}

\clearpage 
\setcounter{secnumdepth}{0}
\printindex[Name]
\printindex[Main]
\end{document}

相关内容