2

Revised question (I've been able to eliminate all extraneous definitions from my original source project and yet still reproduce this error with a MWE.)

On the memoir document source below, I've run pdflatex, makeindex (with the -s option for the indicated .ist style file), and then pdflatex again. On that final run of pdflatex I get the error Extra }, or forgotten \endgroup. Specifically, the log shows:

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}

The error does not occur if I omit the babel commands from the preamble!

What could the error source be?

%% 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}

Notes: The definitions of indexing commands \seeonly,\also, etc., and the auxiliary\gobbleonecome from https://tex.stackexchange.com/questions/318472/change-index-see-also-and-see-format. The definitions of\indexseeand\idxmark` come from Error with entries in index page header, memoir class.

murray
  • 7,944
  • search your code for \@nameuse {indexoheadl} as that is followed by one extra bracket (it doesn't mean the error is there tex probably got lost earlier but find that and work backwards.... – David Carlisle Jul 23 '19 at 20:20
  • also it might be \@nameuse {i#1} where #1 is indexoheadl so you need to be fairly open in your search queries – David Carlisle Jul 23 '19 at 20:21
  • I searched all files used in my project, including those generated up to and including the point where I get the error. But I don't find \@nameuse at all, anywhere! – murray Jul 23 '19 at 21:46
  • What I find in .log is: ./topologybook.ind:1152: Extra }, or forgotten \endgroup. <argument> ...entry@wrap {\@nameuse {indexeheadr}} \@nameuse {indexpsheadstru... l.1152 \subitem of a relation, \hyperpage{12} – murray Jul 23 '19 at 21:53
  • grep for pshead across the tex input tree suggests it's in memoir /usr/local/texlive/2019/texmf-dist/tex/latex/memoir/memoir.cls: \@namedef{#1psheadstrut}{\@nameuse{#2psheadstrut}} – David Carlisle Jul 23 '19 at 22:00
  • I didn't look into texlive-distro files. What do I do about this? memoir.cls does not seem to have changed since 2018/12/12, and I've certainly successfully processed the index between that date and now (up to 6 to 8 weeks ago). – murray Jul 23 '19 at 22:09
  • if it was my document (or you made a small example available) I'd start from a copy of memoir to add some \show or \tracingall around where I think the problem is to trace what it's doing but as it is, i can't help much, sorry. – David Carlisle Jul 23 '19 at 22:37
  • (off topic, and apologies for nitpicking) Since this theorem is attributed to three different people, the hyphens in "Heine-Borel-Lebesgue" should really be en-dashes. Reason? There are theorems that are attributed to two people, one of whom has a hyphenated name. The en-dash serves to distinguish the difference. – barbara beeton Jul 24 '19 at 01:46
  • These are the way the memoir headers are build. But you really need to boil this down to something we can test. Where is idxmark defined? Also why thst redefinition of the index command? Also what is that gobbleone doing there in the indexentry? – daleif Jul 24 '19 at 06:02
  • @barbarabeeton: Thnaks for catching the incorrect hyphens; I do know the distinction and that en-dashes are the appropriated separators. (I haven't proofread the index yet, just using its production to guide additional index entries as I write.) – murray Jul 24 '19 at 13:55
  • @daleif : I now include the code showing use of \gobbleone and \idxmark. Believe me, I would dearly love to be able to boil my complex preamble specifications down and prune my hundreds of output pages of material down down to a MWE to post. I do understand that the errors seem to be originating in building headers, as an index page is being completed before being shipped out. – murray Jul 24 '19 at 13:59
  • Otherwise, zip everything together, and email it to my obvious gmail, then I'll see if I get the same issues when I get back home tonight – daleif Jul 24 '19 at 14:05
  • Also I still do not see why you are using gobbleone – daleif Jul 24 '19 at 14:07
  • Is there any particular reason for wanting to define \C in that weird way? Just use a different name for the complex numbers. Anyway, we can't debug code we don't see. – egreg Jul 24 '19 at 16:08
  • @egreg: I want to use \C for complex number just as I use \R for reals, \Q for rationals, \Z for integers, and \N for natural numbers: shorter to type, easier to read as I'm writing and revising, closer to notation we use on paper or blackboard. (Note similarity of that usage to that in package mismath.sty, sec. 2.4.) – murray Jul 24 '19 at 16:54
  • @daleif: For origin of my using \gobbleone, see https://tex.stackexchange.com/questions/318472/change-index-see-also-and-see-format. – murray Jul 24 '19 at 17:00
  • @murray I understand it's simpler; but if it forces you to do macro somersaults… – egreg Jul 24 '19 at 17:31
  • The problem (as I expected) is your \idxmark command in connection with that \gobbleone hackery. I'll take a a look. It is actually not related to memoir at all, I kan get a similar error with book + makeidx (minus the memoir index header definitions) – daleif Jul 25 '19 at 21:11
  • @daleif: Like you, I get successful result using latexmk -norc -pdf indexerr.tex. But I get the same error with pdflatex indexerr, pdflatex indexerr, makeindex -s indexerr.ist indexerr, pdflatex indexerr (and I'm not finding a .latexmkrc or latexmkrc in the directory of my source or in my $HOME (which is ~). And how would inclusion/exclusion of the babel stuff change things for me? – murray Jul 25 '19 at 21:30
  • I forgot the .ist file. I'm getting the same error and a similar one with book. So it does not have to do with memoir. It is something to do with then \gobbleone is reset, it sees to be doing so too late or something when it comes to the \markboth – daleif Jul 25 '19 at 21:31
  • @daleif: Do you get the error if you comment-out the fontenc and babel lines? If not and the trouble is caused by \gobbleone, why would babel cause the error, but without the babel code no error? – murray Jul 25 '19 at 21:49
  • I think I got it working. Add \let\gobbleone\relax to the \leftmark and \rightmark lines as well. It is strange, because it still needs the one in the \idxmark definition as well. – daleif Jul 25 '19 at 21:55
  • What the FÅK, there seems to be something with/without babel. (not 100% confirmed yet) – daleif Jul 25 '19 at 22:16
  • If you mean to use \gobbleone\relax\sffamily\bfseries\leftmark and similary for \rightmark (on both evenhead and oddhead for index, then the headers on the index pages after the first become simply: INDEX INDEX INDEX (with the starting & ending entries now misssing from the left and right sides of the headers. (Or did I unintenionally omit something from my MWE preamble?) – murray Jul 25 '19 at 22:22
  • Remember the \let – daleif Jul 25 '19 at 22:25

1 Answers1

4

This seems to help (\let\gobbleone\relax added four times). It is related to using babel as babel redefines \markboth. Honestly, I do not quite understand why the \let... is needed in both places. For the headers it seems to be because \gobbleone actually survives into the header instead of just becoming nothing. But that does not explain why it is still needed in the definition of \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}{}         

BTW: makeindex does not like this one: \indexsee{nothing!nada}{nothing!nil} see the .ilg file.


Too long for a comment. This is a much shorter MWE (the error is similar to that of memoir, this is just to show that this is not memoir specific)

\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}

As long as babel is not running, it works as expected. babel redefines \markboth and this its arguments no longer works as "normal".

daleif
  • 54,450
  • As to \indexsee{nothing!nada}{nothing!nil}, see: https://tex.stackexchange.com/questions/502427/get-see-index-cross-references-with-subitems. – murray Aug 01 '19 at 17:16
  • @murray I don't think it makes any sense to have sublevels in the see part – daleif Aug 01 '19 at 18:00
  • Right, something like \indexsee{nothing!nada}{nothing!nil} is likely useless; but something like \indexsee{nothing!nada}{nothing} referring to a top-level item from another items' subentry would be useful -- and suffice for the likely-useless form. – murray Aug 02 '19 at 00:25
  • @murray and that ought to work without makeindex complaining – daleif Aug 02 '19 at 05:16