LaTeXing python programs
basti.wiesner at gmx.net
Sun May 24 22:37:03 CEST 2009
<Edward Grefenstette – Donnerstag, 21. Mai 2009 00:27>
> On May 20, 10:10 pm, John Reid <j.r... at mail.cryst.bbk.ac.uk> wrote:
>> Alan G Isaac wrote:
>> > The listings package is great and highly configurable.
>> > Note that you can also input entire files of Python code
>> > or pieces of them based on markers. Really quite great.
>> I tried listings. I believe pygments makes better formatted output (at
>> least out of the box).
> I'm trying to figure out how to use pygments. Are there any good usage
> examples out there?
It's not really difficult. First choose a pygments style and create the
latex definitions for it (STYLENAME serves as placeholder here):
pygmentize -S STYLENAME -f latex > pygments_style.tex
Now import the required packages and the style definitions:
These packages are included in Tetex as well as in Texlive, if not, you can
of course install them from CTAN.
To format a snippet of code, run pygmentize and copy the output into your
pygmentize -f latex a_python_file.py
Freedom is always the freedom of dissenters.
More information about the Python-list