TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to include some Python code into LaTex document, so I "imported" the listings package with



 keywords={typeof, null, catch, switch, in, int, str, float, self},
 ndkeywords={boolean, throw, import},
 ndkeywords={return, class, if ,elif, endif, while, do, else, True, False , catch, def},

when compiling, I get:

 Illegal parameter number in definition oof \lstlang@python$ }

I googled, but I didn't understood how to work the problem out. it speaks about a command or something similar.

share|improve this question

migrated from stackoverflow.com Jun 12 '12 at 13:48

This question came from our site for professional and enthusiast programmers.

Welcome to TeX.sx! Your question was migrated here from Stack Overflow. Please register on this site, too, and make sure that both accounts are associated with each other (by using the same OpenID), otherwise you won't be able to comment on or accept answers or edit your question. – Werner Jun 12 '12 at 14:05
up vote 14 down vote accepted

In the LaTeX source you posted, you have an error at:


Change this to:


and it compiles for me.

share|improve this answer
Yes, it works to me too. Last question, I indicated keywords. How to get them colored? I just see black line of code, without no color – FrankBr Jun 11 '12 at 15:18

I found the following in the Reference Guide of the listings package documentation:

4.1 How to read the reference


Regarding the parameters, please keep in mind the following:


5.If you want to enter one of the special characters {}#%\, this character must be escaped with a backslash. This means that you must write } for the single character ‘right brace’—but of course not for the closing paramater character.

and also in the following section there is a note

4.18 Language definitions


... Note: If you want to enter \, {, }, %, # or & as (part of ) an argument to the keywords below, you must do it with a preceding backslash!

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.