![删除索引第一级的页码](https://linux22.com/image/300278/%E5%88%A0%E9%99%A4%E7%B4%A2%E5%BC%95%E7%AC%AC%E4%B8%80%E7%BA%A7%E7%9A%84%E9%A1%B5%E7%A0%81.png)
我正在使用 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}