[SciPy-user] embedding Python code in LaTeX

Prabhu Ramachandran prabhu_r at users.sf.net
Mon Jan 16 23:01:02 CST 2006


>>>>> "Fernando" == Fernando Perez <Fernando.Perez at colorado.edu> writes:

    Fernando> Ryan Krauss wrote:
    >> Can anyone recommend a good way to embed python code in a LaTeX
    >> document?  Preferably a LaTeX package or Python module that
    >> converts code to LaTeX.  I would like to have the code snippets
    >> look pretty in my thesis.

    Fernando> The listings latex package, combined with this, gives me
    Fernando> results I'm quite happy with (colors optimized so they
    Fernando> read well on print, even if a b/w printer is used):

    Fernando> \usepackage{listings} \lstset{

Yes, I strongly recommend listings as well, fwiw, this is what I use:

\usepackage{listings}
\lstset{language=Python,
  commentstyle=\color{red}\itshape,
  stringstyle=\color{darkgreen},
  showstringspaces=false,
  keywordstyle=\color{blue}\bfseries}


cheers,
prabhu



More information about the SciPy-user mailing list