|
From: John H. <jdh...@ac...> - 2005-01-15 16:49:36
|
>>>>> "Gary" == Gary <pa...@in...> writes:
Gary> John, I've been meaning to ask you ... how did you produce
Gary> the very fine User Guide? Is that TeXmacs? LyX? raw
Gary> LaTeX? ConTeXt? emacs magic?
I'm using latex with the excellent listings package-
http://www.atscire.de/index.php?nav=products/listings. It knows
python syntax, and can do string, comment, keyword highlighting and
more.
You can see the latex src that created the user's guide by checking
out users_guide from matplotlib CVS, or visiting
http://cvs.sourceforge.net/viewcvs.py/matplotlib/users_guide . The
README file in that directory contains more information.
For much of the user's guide, I keep the python code in external files
and include them in a special verbatim environment that does syntax
highlighting with , eg
\lstinputlisting[linerange=1-12,caption={Wild and wonderful ways to specify colors;
see Figure~\ref{fig:color_demo}},
label=lst:color_demo]{code/color_demo.py}
The linerange is used to leave some boilerplate at the beginning and
end of the file (eg some savefig calls to generate the accompanying
figures in eps and png). This helps insure that the python code in
the manual actually runs, since it is the same code used to generate
the figures for the guide.
Gary> Is there some slick way of getting the listings from the
Gary> command line window into the document, especially with the
Gary> comments colorized? I'm writing a small local guide, and
Gary> was wondering ...
By "the command line window" do you mean the python shell? If so,
you'll have to do some special tweaks to handle the >>> prompt, but
the listings packages is very sophisticated, and can ignore prefixes
or add them, etc.... There is a fairly comprehensive manual. Or did
you mean something else?
JDH
|