当我将 imakeidx 包与 amsbook 文档类一起使用时,索引的最后一页上出现了错误的标题“INDEX”,而不是指定的标题(在下面的示例中为“SUBJECT INDEX”)。有没有办法修复这个问题,让索引中每一页的标题都是相同的“SUBJECT INDEX”?
梅威瑟:
\documentclass{amsbook}
\usepackage{imakeidx}
\makeindex[title=Subject Index,columns=1]
\begin{document}
\mainmatter
The issue occurs when the index has multiple pages. The last page of the index has a header INDEX which is incorrect/different from the header of all other index pages.
\index{a1} \index{a2} \index{a3} \index{a4} \index{a5} \index{a6} \index{a6} \index{a7}\index{a8} \index{a9} \index{a0}
\index{b1} \index{b2} \index{b3} \index{b4} \index{b5} \index{b6} \index{b6} \index{b7}\index{b8} \index{b9} \index{b0}
\index{c1} \index{c2} \index{c3} \index{c4} \index{c5} \index{c6} \index{c6} \index{c7}\index{c8} \index{c9} \index{c0}
\index{d1} \index{d2} \index{d3} \index{d4} \index{d5} \index{d6} \index{d6} \index{d7}\index{d8} \index{d9} \index{d0}
\index{e1} \index{e2} \index{e3} \index{e4} \index{e5} \index{e6} \index{e6} \index{e7}\index{e8} \index{e9} \index{e0}
\index{f1} \index{f2} \index{f3} \index{f4} \index{f5} \index{f6} \index{f6} \index{f7}\index{f8} \index{f9} \index{f0}
\index{g1} \index{g2} \index{g3} \index{g4} \index{g5} \index{g6} \index{g6} \index{g7}\index{g8} \index{g9} \index{g0}
\index{h1} \index{h2} \index{h3} \index{h4} \index{h5} \index{h6} \index{h6} \index{h7}\index{h8} \index{h9} \index{h0}
\index{k1} \index{k2} \index{k3} \index{k4} \index{k5} \index{k6} \index{k6} \index{k7}\index{k8} \index{k9} \index{k0}
\backmatter
\printindex
\end{document}
答案1
这是一个时间问题,似乎仅发生在amsbook
(具有非标准标题管理)中。
解决方法如下代码中。
\documentclass{amsbook}
\usepackage{imakeidx}
\makeindex[
title=Subject Index,
columns=1
]
\makeatletter
\def\imki@indexheaders{%
\begingroup\edef\x{\endgroup
\noexpand\@mkboth{\MakeUppercase{\indexname}}{\MakeUppercase{\indexname}}%
}\x
}
\makeatother
\begin{document}
\frontmatter
\tableofcontents
\mainmatter
The issue occurs when the index has multiple pages. The last page of the index has a header INDEX which is incorrect/different from the header of all other index pages.
\index{a1} \index{a2} \index{a3} \index{a4} \index{a5} \index{a6} \index{a6} \index{a7}\index{a8} \index{a9} \index{a0}
\index{b1} \index{b2} \index{b3} \index{b4} \index{b5} \index{b6} \index{b6} \index{b7}\index{b8} \index{b9} \index{b0}
\index{c1} \index{c2} \index{c3} \index{c4} \index{c5} \index{c6} \index{c6} \index{c7}\index{c8} \index{c9} \index{c0}
\index{d1} \index{d2} \index{d3} \index{d4} \index{d5} \index{d6} \index{d6} \index{d7}\index{d8} \index{d9} \index{d0}
\index{e1} \index{e2} \index{e3} \index{e4} \index{e5} \index{e6} \index{e6} \index{e7}\index{e8} \index{e9} \index{e0}
\index{f1} \index{f2} \index{f3} \index{f4} \index{f5} \index{f6} \index{f6} \index{f7}\index{f8} \index{f9} \index{f0}
\index{g1} \index{g2} \index{g3} \index{g4} \index{g5} \index{g6} \index{g6} \index{g7}\index{g8} \index{g9} \index{g0}
\index{h1} \index{h2} \index{h3} \index{h4} \index{h5} \index{h6} \index{h6} \index{h7}\index{h8} \index{h9} \index{h0}
\index{k1} \index{k2} \index{k3} \index{k4} \index{k5} \index{k6} \index{k6} \index{k7}\index{k8} \index{k9} \index{k0}
\index{l1} \index{l2} \index{l3} \index{l4} \index{l5} \index{l6} \index{l6} \index{l7}\index{l8} \index{l9} \index{l0}
\index{m1} \index{m2} \index{m3} \index{m4} \index{m5} \index{m6} \index{m6} \index{m7}\index{m8} \index{m9} \index{m0}
\index{n1} \index{n2} \index{n3} \index{n4} \index{n5} \index{n6} \index{n6} \index{n7}\index{n8} \index{n9} \index{n0}
\index{o1} \index{o2} \index{o3} \index{o4} \index{o5} \index{o6} \index{o6} \index{o7}\index{o8} \index{o9} \index{o0}
\backmatter
\printindex
\chapter{xxx}
\end{document}
对于较旧的 TeX 发行版(TL 2022 之前),代码应该是
\makeatletter
\def\imki@indexheaders{%
\begingroup\edef\x{\endgroup
\noexpand\@mkboth{\noexpand\MakeUppercase{\indexname}}{\noexpand\MakeUppercase{\indexname}}%
}\x
}
\makeatother
答案2
警告:以下只是一种解决方法,而不是真正的解决方案!
一个不太好但可行的解决方案是,\indexname
在 之前重命名\printindex
。如果您只有一个索引,您可以在文档序言中执行以下操作:
\documentclass{amsbook}
\usepackage{imakeidx}
\makeindex[title=Subject Index,columns=1]
\renewcommand*{\indexname}{Subject Index}
\begin{document}
\mainmatter
The issue occurs when the index has multiple pages. The last page of the index has a header INDEX which is incorrect/different from the header of all other index pages.
\index{a1} \index{a2} \index{a3} \index{a4} \index{a5} \index{a6} \index{a6} \index{a7}\index{a8} \index{a9} \index{a0}
\index{b1} \index{b2} \index{b3} \index{b4} \index{b5} \index{b6} \index{b6} \index{b7}\index{b8} \index{b9} \index{b0}
\index{c1} \index{c2} \index{c3} \index{c4} \index{c5} \index{c6} \index{c6} \index{c7}\index{c8} \index{c9} \index{c0}
\index{d1} \index{d2} \index{d3} \index{d4} \index{d5} \index{d6} \index{d6} \index{d7}\index{d8} \index{d9} \index{d0}
\index{e1} \index{e2} \index{e3} \index{e4} \index{e5} \index{e6} \index{e6} \index{e7}\index{e8} \index{e9} \index{e0}
\index{f1} \index{f2} \index{f3} \index{f4} \index{f5} \index{f6} \index{f6} \index{f7}\index{f8} \index{f9} \index{f0}
\index{g1} \index{g2} \index{g3} \index{g4} \index{g5} \index{g6} \index{g6} \index{g7}\index{g8} \index{g9} \index{g0}
\index{h1} \index{h2} \index{h3} \index{h4} \index{h5} \index{h6} \index{h6} \index{h7}\index{h8} \index{h9} \index{h0}
\index{k1} \index{k2} \index{k3} \index{k4} \index{k5} \index{k6} \index{k6} \index{k7}\index{k8} \index{k9} \index{k0}
\backmatter
\printindex
\end{document}
注意:如果您正在使用babel
,则必须使用babel
用户界面来更改与语言相关的术语。
如果您有多个索引,则需要移动\renewcommand
每个索引前的(并根据单个索引进行更改)。