Nomenclature+amsart: compile error if PDF output is long but not if it is short

Using the nomenclature package with amsart, I get a compiling error if the PDF output is long but not if it is short. Here is the shortest example of the problem I could make.

\immediate\write18{makeindex "\jobname.nlo" -s nomencl.ist -o "\jobname.nls"}
\documentclass{amsart}
\usepackage{nomencl}
\usepackage{lipsum}

\makenomenclature

\begin{document}
\title{Nomenclature error}
\maketitle
\tableofcontents

\nomenclature[Lx]{L}{The distribution of random variable $X$.}
We write $\mathcal{L}_X$ for the distribution of $X$.

\lipsum
\lipsum
\printnomenclature
\end{document}


Using the "Typset" command in TeXShop 4.42, with a fresh MacTeX install (from mactex-20190508.pkg, downloaded just this morning). The second time I run "Typset" the console gives me the following.

LaTeX2e <2018-12-01>
(/usr/local/texlive/2019/texmf-dist/tex/latex/amscls/amsart.cls
Document Class: amsart 2017/10/31 v2.20.4
(/usr/local/texlive/2019/texmf-dist/tex/latex/amsmath/amsmath.sty
For additional information on amsmath, use the ?' option.
(/usr/local/texlive/2019/texmf-dist/tex/latex/amsmath/amstext.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/amsmath/amsgen.sty))
(/usr/local/texlive/2019/texmf-dist/tex/latex/amsmath/amsbsy.sty)
(/usr/local/texlive/2019/texmf-dist/tex/latex/amsmath/amsopn.sty))
(/usr/local/texlive/2019/texmf-dist/tex/latex/amsfonts/umsa.fd)
(/usr/local/texlive/2019/texmf-dist/tex/latex/amsfonts/amsfonts.sty))
(/usr/local/texlive/2019/texmf-dist/tex/latex/nomencl/nomencl.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/xkeyval/xkeyval.sty
(/usr/local/texlive/2019/texmf-dist/tex/generic/xkeyval/xkeyval.tex
(/usr/local/texlive/2019/texmf-dist/tex/generic/xkeyval/xkvutils.tex
(/usr/local/texlive/2019/texmf-dist/tex/generic/xkeyval/keyval.tex))))
(/usr/local/texlive/2019/texmf-dist/tex/latex/base/ifthen.sty)
(/usr/local/texlive/2019/texmf-dist/tex/latex/koma-script/tocbasic.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/koma-script/scrbase.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/koma-script/scrlfile.sty))))
(/usr/local/texlive/2019/texmf-dist/tex/latex/lipsum/lipsum.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/l3kernel/expl3.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/l3kernel/expl3-code.tex)
(/usr/local/texlive/2019/texmf-dist/tex/latex/l3kernel/l3pdfmode.def))
(/usr/local/texlive/2019/texmf-dist/tex/latex/l3packages/xparse/xparse.sty)
(/usr/local/texlive/2019/texmf-dist/tex/latex/lipsum/lipsum.ltd.tex))
(./mwe.aux) (/usr/local/texlive/2019/texmf-dist/tex/latex/amsfonts/umsa.fd)
(/usr/local/texlive/2019/texmf-dist/tex/latex/amsfonts/umsb.fd) (./mwe.toc)
[1{/usr/local/texlive/2019/texmf-var/fonts/map/pdftex/updmap/pdftex.map}]
Underfull \vbox (badness 10000) has occurred while \output is active [2]
(./mwe.nls)
./mwe.tex:21: Undefined control sequence.
<argument> \list@fname

l.21 \end{document}

?


If I hit return to ignore the error the compile completes with correct output.

The same error occurs if I replace \printnomenclature with the content of the file mwe.nls, which is the following:

\begin{thenomenclature}
\nomgroup{L}
\item [{L}]\begingroup The distribution of random variable $X$.\nomeqref {0}\nompageref{1}

\end{thenomenclature}


However, if in the main TeX file I include the \lipsum command just one time rather than two times, the error does not occur.

The error also doesn't occur if I use article rather than amsart.

• can't reproduce your problem. your code works fine for me. I get the same underful warning, but that can be ignored (but it's best to deal with warnings the same way as with errors). have you run an update on your packages? Oct 2 '19 at 17:54

The difference between the short and long version is that on page 3 the code tries to write the name of the nomenclature in the header. And as amsart does a number of unusual things something clashes.

Possible workarounds:

\usepackage[notocbasic]{nomencl}


or

\makeatletter\let\list@fname\nomname \makeatother

• The main problem seems to be that amsart redefines \@starttoc to take two arguments instead of one, while tocbasic expects the standard definition. I'd go with notocbasic`. Oct 2 '19 at 20:02
• notocbasic solved the problem for me. I tried to read the doc of package nomencl but I do not understand what are the implications of switching off this option. In fact I do not see why toc stuff is involved in the default mode notintoc. Oct 21 '20 at 9:41