Text FormattingEscape Character in custom Python Code Block

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
geolykos
Posts: 1
Joined: Thu Aug 15, 2013 6:33 pm

Escape Character in custom Python Code Block

Post by geolykos »

Hello,

I wanted to put some Python code in my text so I found a custom made Python highlighting file from here. It works great and I even changed most colors etc. but I have a problem with the escape character ($). Some code I need in my report is a template code which means I use Python for reference plus other commands. An example:

Code: Select all

\begin{python}
% if interface.exists:
ip route ${interface.loopback} ${interface.subnet} ${interface.destination}
\end{python}
In this code the % and $ symbols declare Python references but the problem is that the $ are 3 so the rest of my text from there on becomes green like in escape mode. I tried \$ but this custom file is like verbatim and everything you type is shown as normal. It should ore look like this.

Code: Select all

% if interface.exists:
ip route ${interface.loopback} ${interface.subnet} ${interface.destination}
Last edited by cgnieder on Fri Aug 16, 2013 5:08 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Post Reply