I am trying to combine to use mathescape together with the Erlang syntax highlighting in the package lstlisting, as described in Section 4.14 of its manual:




This fails with:

! Extra }, or forgotten \endgroup.
<recently read> \egroup 

l.10 \lstinline{$n_1$.lookup(k)}

The code works fine for other languages, e.g. C. Does the style for Erlang miss something to allow this?

  • 1
    \lstinline|$n_1$.lookup(k)| seems to work. – egreg Feb 13 '13 at 14:36
  • Yes, it works. You might want to put that up as an answer. – evnu Feb 13 '13 at 14:42

The listings package allows the syntax


but marks it as “experimental”, see p. 26 of the manual, section 4.2. Section 5.1 talks about using \lstinline in the argument of another command; the end of section 5.1 tells, however, that this is not safe.

In particular, mathescape turns out not be compatible with the experimental syntax, so you should use something like


(use, as a delimiter, a character that doesn't appear in the string to be typeset, just like for the \verb command).

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.