使用 babel 和 memoir 与 makeindex 冲突吗?

使用 babel 和 memoir 与 makeindex 冲突吗?

修改后的问题(我已经能够从我的原始源项目中删除所有无关的定义,但仍然可以使用 MWE 重现此错误。)

在下面的文档源中,memoir我运行了(带有指示 样式文件的选项),然后再次运行。在最后一次运行中,我得到了错误。具体来说,日志显示:pdflatexmakeindex-s.istpdflatexpdflatexExtra }, or forgotten \endgroup

Redoing nameref's sectioning
Redoing nameref's label
(./indexerr.out) (./indexerr.out) [1{/Users/murray/Library/texlive/2019/texmf-v
ar/fonts/map/pdftex/updmap/pdftex.map}] [2] [3] (./indexerr.ind
(/usr/local/texlive/2019/texmf-dist/tex/latex/base/t1cmss.fd) [4] [5]
! Extra }, or forgotten \endgroup.
<argument> ...entry@wrap {\@nameuse {indexeheadr}}
                                                  \@nameuse {indexpsheadstru...
l.110 \end{theindex}

错误确实不是如果我省略babel序言中的命令就会发生!

错误来源可能是什么?

%% INDEXERR.TEX
\begin{filecontents}{indexerr.ist}
% MakeIndex style file
% output main entry <entry> as: \item \idxmark{<entry>}, 
item_0  "\n\\item \\idxmark{"
delim_0 "}, "
% not forgetting the subitem case
item_x1 "} \n \\subitem "
%%headings_flag 1
%%heading_prefix "{\\textsf{\\textbf{"
%%heading_suffix "}}}\\nopagebreak\n"
headings_flag 1
heading_prefix "{\\medskip\\hfill\\large\\textsf{\\textbf{"
heading_suffix "}}\\hfill}\\medskip\\nopagebreak\n"
\end{filecontents}

\documentclass{memoir}

%% BABEL (actually used with multiple languages)
\RequirePackage[T1]{fontenc}%
\RequirePackage[main=english]{babel}%

%% HEADINGS
\makeheadrule {headings}{\textwidth}{\normalrulethickness}   
\makepagestyle{index}
\makeheadrule{index}{\textwidth}{\normalrulethickness}
\makeevenhead{index}%
{\sffamily\bfseries\rightmark}%
{\sffamily\bfseries\MakeTextUppercase{\indexname}}%
{\sffamily\bfseries\leftmark}
\makeoddhead{index}%
{\sffamily\bfseries\rightmark}%
{\sffamily\bfseries\MakeTextUppercase{\indexname}}%
{\sffamily\bfseries\leftmark}
\makeevenfoot{index}{}{\sffamily\thepage}{}
\makeoddfoot{index}{}{\sffamily\thepage}{}         

%% INDEXING
\newcommand\gobbleone[1]{}
\newcommand{\seeonly}[2]{\, (\emph{\seename} #1)}
\newcommand{\also}[2]{\unskip(\emph{\alsoname} #1)}
\newcommand{\Also}[2]{\unskip\emph{See also} #1}
\let\oldindex\index
\renewcommand{\index}[1]{\def\exptoindex{#1}\expandafter\oldindex\expandafter{\exptoindex}}
\makeatletter
\newcommand{\indexsee}[2]{\index{#1\protect\gobbleone|seeonly{#2}}}
\newcommand{\indexalso}[2]{\index{#1!zzzz@\protect\gobbleone|also{#2}}}
\newcommand{\indexAlso}[2]{\index{#1!zzzz@\protect\gobbleone|Also{#2}}}
\makeatother
\newcommand{\indexnamesee}[2]{\index[names]{#1\protect\gobbleone|seeonly{#2}}}
% fix for memoir to put hyperlink on mainref, too:
\newcommand{\mainref}[1]{\textbf{\emph{\hyperpage{#1}}}}
\newcommand{\idxmark}[1]{{\let\gobbleone\relax\markboth{\sffamily\bfseries#1}{\sffamily\bfseries#1}}#1}

%% CROSS-REFERENCING
\RequirePackage[pdftex]{hyperref}
\hypersetup{colorlinks, citecolor=red, linkcolor=blue}

\makeindex

\begin{document}

\frontmatter
\mainmatter

\chapter{The chapter}

This is a short book about zero. Therefore, it's also about nothing.
Which means null (or nil).
%
\index{nothing}
\index{nothing!nil}
\index{nothing!nil!and zero}
\index{nothing!null}
\indexalso{nothing!nil}{null elements}
\indexsee{nothing!nada}{nothing!nil}
\indexsee{zero}{zero elements}
\indexAlso{nothing}{zero elements}
\indexsee{thing}{something}
\index{null elements}

\newpage
More.
\index{nothing}
\index{nothing!nil}
\index{nothing!nil!and zero}
\index{null elements}
\index{zero elements}

\newpage
Still more.
\index{closed interval}
\index{continuous function!and bounded function}
\index{cover!and open cover}
\index{open cover|mainref}
\index{open cover|(}

\newpage
Yet more
\index{znothing}
\index{znothing!nil}
\index{znothing!nil!and zero}
\index{znothing!null}
\indexalso{znothing!nil}{null elements}
\indexsee{zzero}{zero elements}
\indexAlso{znothing}{zero elements}
\indexsee{zthing}{something}
\index{znull elements}

Something.
\index{ynothing}
\index{ynothing!nil}
\index{ynothing!nil!and zero}
\index{ynothing!null}
\indexalso{ynothing!nil}{null elements}
\indexsee{yzero}{zero elements}
\indexAlso{ynothing}{zero elements}
\indexsee{ything}{something}
\index{ynull elements}
Really nothing,
\index{xnothing}
\index{xnothing!nil}
\index{nothing!nil!and zero}
\index{xnothing!null}
\indexalso{xnothing!nil}{xnull elements}
\indexsee{xzero}{xzero elements}
\indexAlso{xnothing}{xzero elements}
\indexsee{xthing}{xsomething}
\index{xnull elements}
Getting repetitous!
\index{wnothing}
\index{wnothing!nil}
\index{wnothing!nil!and zero}
\index{wnothing!null}
\indexalso{wnothing!nil}{wnull elements}
\indexsee{wzero}{wzero elements}
\indexAlso{wnothing}{wzero elements}
\indexsee{wthing}{wsomething}
\index{wnull elements}
Still is.
\index{vnothing}
\index{vnothing!nil}
\index{vnothing!nil!and zero}
\index{vnothing!null}
\indexalso{vnothing!nil}{vnull elements}
\indexsee{vzero}{vzero elements}
\indexAlso{vnothing}{vzero elements}
\indexsee{vthing}{vsomething}
\index{vnull elements}

Hope this is enough.
\index{unothing}
\index{unothing!nil}
\index{unothing!nil!and zero}
\index{unothing!null}
\indexalso{unothing!nil}{unull elements}
\indexsee{uzero}{uzero elements}
\indexAlso{unothing}{uzero elements}
\indexsee{uthing}{usomething}
\index{unull elements}

\pagestyle{index}
\printindex

\end{document}

笔记:索引命令的定义\seeonly,\also , etc., and the auxiliary\gobbleone come from https://tex.stackexchange.com/questions/318472/change-index-see-also-and-see-format. The definitions of\indexsee and\idxmark` 来自索引页标题、回忆录类条目有误

答案1

这似乎有帮助(添加了四次)。它与使用as重新定义\let\gobbleone\relax有关。老实说,我不太明白为什么在两个地方都需要。对于标题来说,似乎是因为实际上保留在标题中而不是变成空。但这并不能解释为什么在定义中仍然需要它babelbabel\markboth\let...\gobbleone\idxmark

\makeevenhead{index}%
{\let\gobbleone\relax\sffamily\bfseries\rightmark}%
{\sffamily\bfseries\MakeTextUppercase{\indexname}}%
{\let\gobbleone\relax\sffamily\bfseries\leftmark}
\makeoddhead{index}%
{\let\gobbleone\relax\sffamily\bfseries\rightmark}%
{\sffamily\bfseries\MakeTextUppercase{\indexname}}%
{\let\gobbleone\relax\sffamily\bfseries\leftmark}
\makeevenfoot{index}{}{\sffamily\thepage}{}
\makeoddfoot{index}{}{\sffamily\thepage}{}         

顺便说一句:makeindex 不喜欢这个:\indexsee{nothing!nada}{nothing!nil}请参阅.ilg文件。


对于注释来说太长了。这是一个更短的 MWE(错误与 类似memoir,这只是为了表明这并不memoir具体)

\documentclass{book}
%\usepackage[english]{babel} % dies if babel is used
\newcommand\gobbleone[1]{}
\newcommand{\idxmark}[1]{{\let\gobbleone\relax\markboth{\sffamily\bfseries#1}{\sffamily\bfseries#1}}#1}
\begin{document}
\idxmark{thing\gobbleone }, 
\end{document}

只要babel没有运行,它就会按预期工作。babel重新定义\markboth并且它的参数不再像“正常”那样工作。

相关内容