删除索引第一级的页码

删除索引第一级的页码

我正在使用 imakeidx 为我的食谱书创建索引。

我希望索引按级别显示以下内容:

开胃菜

食谱 1,页码

食谱 2,页码

我想要的是索引显示没有页码的主类别,但实际的食谱有页码。这是我到目前为止的测试代码:

\documentclass[12pt, letterpaper]{book}
\usepackage{imakeidx}

\makeindex[name=cat, title=Category, columns=1]
\makeindex[name=type, title=Type of Dish]

\begin{document}
    \index[type]{Casual}    %Want this in bold and no page number
    \index[type]{Quick}     %Want this in bold and no page number
    \index[type]{Formal}    %Want this in bold and no page number
    Appetizers \index[cat]{Appetizers}  %Want this in bold and no page number

    \newpage
    Cauliflower soup \index[cat]{Appetizers!Cauliflower Soup}   \index[type]{Casual!Cauliflower Soup}   %Want this to show as usual with page number

    \newpage
    Drinks  \index[cat]{Drinks} %Want this in bold and no page number

    \newpage
    Lemon Drop \index[cat]{Drinks!Lemon Drop}   %Want this to show as usual with page number


    \printindex[cat]

    \printindex[type]
\end{document}

答案1

在此处输入图片描述

\documentclass[12pt, letterpaper]{book}
\usepackage{imakeidx}

\makeindex[name=cat, title=Category, columns=1]
\makeindex[name=type, title=Type of Dish]

\newcommand\foo[1]{}
\newcommand\textbfz[2]{\textbf{#1}}
\begin{document}
    \index[type]{Casual@\textbfz{Casual}|foo}    %Want this in bold and no page number
    \index[type]{Quick@\textbfz{Quick}|foo}     %Want this in bold and no page number
    \index[type]{Formal@\textbfz{Formal}|foo}    %Want this in bold and no page number
    Appetizers \index[cat]{Apetizers@\textbfz{Appetizers}|foo}  %Want this in bold and no page number

    \newpage
    Cauliflower soup \index[cat]{Apetizers@\textbfz{Appetizers}!Cauliflower Soup} 
   \index[type]{Casual@\textbfz{Casual}|!Cauliflower Soup}   %Want this to show as usual with page number

    \newpage
    Drinks  \index[cat]{Drinks@\textbfz{Drinks}|foo} %Want this in bold and no page number

    \newpage
    Lemon Drop \index[cat]{Drinks@\textbfz{Drinks}!Lemon Drop}   %Want this to show as usual with page number


    \printindex[cat]

    \printindex[type]
\end{document}

相关内容