Math symbols in listings
27,647
You can use the option mathescape
for your environment which gives you the ability to use the normal latex behavior of the $-signs. Try:
\begin{lstlisting}[mathescape]
...
\end{lstlisting}
For more info, take a look into the listings
package manual.
![Admin](/assets/logo_square_200-5d0d61d6853298bd2a4fe063103715b4daf2819fc21225efa21dfb93e61952ea.png)
Author by
Admin
Updated on July 08, 2022Comments
-
Admin almost 2 years
I have a problem with LaTeX – I don't know how to put mathematical equations and symbols in listings. I use the
listings
package and it's offers great looking listings, but it doesn't allow math symbols in$ ... $
. Another package,algorithms
, allows math, but listings doesn't look as good as withlistings
(the problem is thatalgorithms
demands to get new line after everyif
,then
, etc.)