tags:

views:

467

answers:

3

I am using LaTeX to write a document about Python. This document will contain code snippets (examples).

I could use the verbatim environment, but before I embark onto it, I'd like to know if you are aware of any LaTeX style file which provides an environment for Python code. Syntax highlight would be a plus.

Thanks.

Edit:

I must point out that the package minted is exactly what I was looking for. It has beautiful syntax highlighting and it is very simple to use. Check this question to know more about it.

+2  A: 

Use Docutils and RST for this. It has Latex with Syntax highlighting.

http://docutils.sourceforge.net/docs/user/latex.html

S.Lott
+2  A: 

Hi

The LaTeX Listings package seems to know about Python. Worth taking a look at.

Mark

High Performance Mark
+3  A: 

Take a look at this question http://stackoverflow.com/questions/1966425/source-code-highlighting-in-latex for more information.

You should also look at the pygments program for source code highlighting.

I personally use Emacs org-mode with #+BEGIN_SRC python and let htmlize.el take care of the highlighting during export. You can see a sample here (This is an HTML export but with the latest version of org-mode, it can use the listings LaTeX package to colourise exported PDFs too).

Noufal Ibrahim
Thank you. I am sorry about having repeated the question unknowingly. The package minted is the solution I was looking for.
Arrieta