12

I have a little lstlisting to show a snippet of code but since the code has % in it for modulo calculation the listing breaks down. How can I escape it?

I have tried the backslash, verbatim and \text commands

\begin{lstlisting}
int RSAEncrypt(char m)
{
    return (int)pow(charToNumber(m), e) % n;
}
\end{lstlisting}
2
  • 2
    You shouldn't need to escape a % inside lstlisting... It works perfectly for me...
    – Seamus
    Mar 6, 2011 at 13:04
  • 2
    Could it be that you are using the lstlisting inside another macro or pseudo-environment like tabularx? Otherwise it should work fine as Seamus said. Please add a complete minimal example that illustrates your problem. Mar 6, 2011 at 13:15

1 Answer 1

11

I found it, in the lstset definition I had

escapeinside={\%}{)}

I remove it and it works now. Thanks :)

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .