I am using plainTeX and would like to typeset some (python) code examples.
Switching to \tt gets me partway there, but I (obviously) need
the whitespace respected. Is there a trick for doing this? The last time I needed this I ended up writing a preprocessor that inserted appropriate \ everywhere.
Oh dear, I guess I also need to eliminate paragraph indenting, and force newlines.
|
|
|||||
|
|
I would use
|
|||
|
|
|
In general TH.'s answer is preferable. It also disables other special characters like But here the answer about the spaces, line endings and parindent: This should be done inside a group of course. Make sure to comment all line endings for you code including the trailing
|
|||||||||
|
|
there's a rather elaborate verbatim routine in the tugboat plain macros, in the file
|
|||
|
|
|
I have tried to use plain TeX to typeset source code (in many languages). As it proved to be a hard task, and even harder if you wanted some eye candy like keyword highlighting, nowadays I prefer to use LaTeX to do the job with the listing environment and to include the output as a figure. Ex:
|
|||||||||||||||||||
|
