我在用制作idx包装,使用时\打印索引命令,它将在新页面中开始,
有没有一种方法可以让“索引”名称成为章节样式,就像“第 1 章索引”一样。
我想更改索引定义,但找不到它。
有谁能帮助我吗?
\documentclass[]{book}
\usepackage{makeidx}
\makeindex
\begin{document}
test test test test\index{AAA} test test test test\index{BBB} test test test test test\index{CCC} test test test test test test test test test test test test test test test test test test test\index{DDD} test test test test test test
\printindex
\end{document}
答案1
解决方案 1:
\documentclass[]{book}
\usepackage{makeidx}
\makeindex
\renewcommand{\indexname}{\chaptername\ \thechapter\ Index}
\begin{document}
\chapter{First}
test test test test\index{AAA} test test test test\index{BBB} test test test test test\index{CCC} test test test test test test test test test test test test test test test test test test test\index{DDD} test test test test test test
\stepcounter{chapter}
\printindex
\end{document}
解决方案 2
(重新定义索引环境):
\documentclass[openany]{book}
\usepackage{makeidx}
\makeatletter
\renewenvironment{theindex}
{\if@twocolumn
\@restonecolfalse
\else
\@restonecoltrue
\fi
%\twocolumn[\@makeschapterhead{\indexname}]%NO PAGEBREAK BEFORE INDEX
\@mkboth{\MakeUppercase\indexname}%
{\MakeUppercase\indexname}%
\thispagestyle{plain}\parindent\z@
\parskip\z@ \@plus .3\p@\relax
\columnseprule \z@
\columnsep 35\p@
\let\item\@idxitem}
%{\if@restonecol\onecolumn\else\clearpage\fi} %NO CLEARPAGE AFTER INDEX
\makeatother
\makeindex
\begin{document}
\chapter{First Chapter}
A\index{A}B\index{B}
\chapter{Index}
\printindex
\chapter{Other chapter}
\end{document}
生成: