LaTeX forum ⇒ Text FormattingEscape Character in custom Python Code Block

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

Escape Character in custom Python Code Block

Postby geolykos » Thu Aug 15, 2013 6:43 pm


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:
  1. \begin{python}
  2. % if interface.exists:
  3. ip route ${interface.loopback} ${interface.subnet} ${interface.destination}
  4. \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.
  1. % if interface.exists:
  2. 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.


Return to “Text Formatting”

Who is online

Users browsing this forum: No registered users and 4 guests