Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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:

\documentclass{article}

\usepackage{listings}
\lstset{
    language=Erlang,
    mathescape=true
}

\begin{document}
\lstinline{$n_1$.lookup(k)}
\end{document}

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?

share|improve this question
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

1 Answer 1

up vote 3 down vote accepted

The listings package allows the syntax

\lstinline{...}

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

\lstinline|$n_1$.lookup(k)|

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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