I am using the nomencl package, and so far it has worked out flawlessly. However, today I decided to introduce some notation that includes an exclamation mark, and it failed.
There is a minimal example here:
\documentclass{article}
\usepackage{nomencl}
\makenomenclature
\begin{document}
\nomenclature{$n!$}{factorial of $n$}
\[
n! = \prod_{i=1}^n i
\]
\printnomenclature
\end{document}
pdflatex text.texruns OKmakeindex test.nlo -s nomencl.ist -o test.nlsruns OK, and reports "1 entries accepted, 0 rejected)", etc (no problem).pdflatex text.tex, ran for the second time aftermakeindex, fails.
The error is this:
Writing nomenclature file test.nlo
(./test.aux) (./test.nls
! Missing $ inserted.
<inserted text>
$
l.6 \subitem
[{$n
?
If I remove the exclamation mark, like this:
\nomenclature{$n$}{factorial of $n$}
then the document compiles and produces the correct output.
I have tried using $n{!}$ and $n\!$, but that didn't fix the problem.
What would be the right way to include $n!$, or $!n$, or other expressions with exclamation marks in nomenclature?
nomencl.istnow has%as the quote character. See edited answer. – egreg Aug 08 '23 at 19:09