我想从我的硕士论文的目录中删除索引字母。无论如何,整个索引都在同一页上。
\documentclass[a4paper, 10pt]{report}
\usepackage{hyperref}
\usepackage{doc}
%%%%%% Indexing %%%%%%
\IndexPrologue{\chapter*{Index}\markboth{Index}{Index}}% section heading, no message
\usepackage{makeidx}
\makeindex
%%% Begin document
\begin{document}
\tableofcontents
\setcounter{page}{1}
\index{And}
\index{Book}
\index{Summer}
\index{Latex}
\pagebreak
\addcontentsline{toc}{chapter}{Index}
\printindex
\end{document}
生成此目录
而我希望它只包含索引行,而不包含单独的字母。
我该如何解决这个问题?
答案1
我认为 makeindex 配置为使用特殊样式,
makeindex -s mystyle.ist myfile.idx
像mystyle.ist
这样
% MakeIndex style file
heading_prefix "\\section{ "
heading_suffix "}"
headings_flag 1
解决方案是本地禁用\addcontentsline
\documentclass[a4paper, 10pt]{report}
\usepackage{hyperref}
\usepackage{doc}
%%%%%% Indexing %%%%%%
\IndexPrologue{\chapter*{Index}\markboth{Index}{Index}}% section heading, no message
\usepackage{makeidx}
\makeindex
%%% Begin document
\begin{document}
\tableofcontents
\setcounter{page}{1}
\index{And}
\index{Book}
\index{Summer}
\index{Latex}
\pagebreak
\addcontentsline{toc}{chapter}{Index}
{\def\addcontentsline#1#2#3{} %<---
\printindex} %<---
\end{document}