title: latex - escape dollar sign inside lstlisting with [mathescape]
body: <p>I have a problem escaping the dollar sign in an mathescaped lstlisting environment</p>
  
  <pre><code>\begin{lstlisting}[mathescape]
    $\delta$(Z, $\varepsilon$, $S) = (R, $\varepsilon$)
                               ^ 
  \end{lstlisting}
  </code></pre>
  
  <p>With the help of an answer of a <a href="https://stackoverflow.com/questions/4448462" title="related question">related question</a> I got the idea to use another sign instead of the dollar sign like this:</p>
  
  <pre><code>\lstset{
    literate={\§}{{\textcolor{black}{\$}}}1
  }
  </code></pre>
  
  <p>But when I used <code>\§</code> inside the listing I got <code>\$</code> instead of <code>$</code>.</p>