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?

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


%% BABEL (actually used with multiple languages)

\makeheadrule {headings}{\textwidth}{\normalrulethickness}   

\newcommand{\seeonly}[2]{\, (\emph{\seename} #1)}
\newcommand{\also}[2]{\unskip(\emph{\alsoname} #1)}
\newcommand{\Also}[2]{\unskip\emph{See also} #1}
% fix for memoir to put hyperlink on mainref, too:

\hypersetup{colorlinks, citecolor=red, linkcolor=blue}




\chapter{The chapter}

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

\index{nothing!nil!and zero}
\index{null elements}
\index{zero elements}

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

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

\index{ynothing!nil!and zero}
\indexalso{ynothing!nil}{null elements}
\indexsee{yzero}{zero elements}
\indexAlso{ynothing}{zero elements}
\index{ynull elements}
Really nothing,
\index{nothing!nil!and zero}
\indexalso{xnothing!nil}{xnull elements}
\indexsee{xzero}{xzero elements}
\indexAlso{xnothing}{xzero elements}
\index{xnull elements}
Getting repetitous!
\index{wnothing!nil!and zero}
\indexalso{wnothing!nil}{wnull elements}
\indexsee{wzero}{wzero elements}
\indexAlso{wnothing}{wzero elements}
\index{wnull elements}
Still is.
\index{vnothing!nil!and zero}
\indexalso{vnothing!nil}{vnull elements}
\indexsee{vzero}{vzero elements}
\indexAlso{vnothing}{vzero elements}
\index{vnull elements}

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



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.

  • 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

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


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)

%\usepackage[english]{babel} % dies if babel is used
\idxmark{thing\gobbleone }, 

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

| improve this answer | |
  • As to \indexsee{nothing!nada}{nothing!nil}, see: tex.stackexchange.com/questions/502427/…. – murray Aug 1 '19 at 17:16
  • @murray I don't think it makes any sense to have sublevels in the see part – daleif Aug 1 '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 2 '19 at 0:25
  • @murray and that ought to work without makeindex complaining – daleif Aug 2 '19 at 5:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.