I'm trying to index the tokens in a listing, but they always get rejected if they are followed by a comma.
Here's mwe.tex
:
\documentclass{article}
\usepackage{listings}
\lstset{index={foobar}}
\makeindex
\begin{document}
\begin{lstlisting}
foobar, baz
\end{lstlisting}
\end{document}
pdflatex mwe
produces mwe.idx
:
\indexentry{{\ttfamily foobar\unhbox \voidb@x \kern \z@ }}{1}
makeindex mwe
however rejects the entry, as seen in mwe.ilg
:
This is makeindex, version 2.15 [TeX Live 2018] (kpathsea + Thai support).
Scanning input file mwe.idx...
!! Input index error (file = mwe.idx, line = 1):
-- Extra `@' at position 44 of first argument.
done (0 entries accepted, 1 rejected).
Nothing written in mwe.ind.
Transcript written in mwe.ilg.
I feel like \unhbox \voidb@x \kern \z@
shouldn't be there.
I figured out that's the expansion of \lst@nolig
.
I located \lst@nolig
's definition in listings.sty
but its purpose is not clear to me and I'm not sure why this happens only when a token preceeds a comma.
\let\lst@nolig\@empty
is a solution, but of course that's not satisfactory.
What's the proper solution to the problem?
Also, what's going on with the \lst@nolig
?