# [Twisted-Python] Lore question/ latex output question

stephen at thorne.id.au stephen at thorne.id.au
Wed May 26 20:07:54 EDT 2004

On Wed, 26 May 2004 15:33:59 -0400, "Schneider, Michael" <michael.l.schneider at ugsplm.com> wrote:
>
> Hello All,
>
> I have been using lore for a project that I have been working
> on, and it is a great tool.
>
> I have a quick question.  Does anyone know how
> to get the <pre>...</pre> tags to appear as shaded
> on the latex/pdf output?
>
> The generated latex looks like
>
> \\begin{verbatim}   is being output at the start of the pre
>
> and=20
>
> \\end{verbatim} is being output at the end of the pre.
>
> I am trying to get the same output format as html output.

I hacked up the latex spitter to allow me to change the latex, I recommend
reading the 'extending lore' part of the howtos if this doesn't provide you
enough context. What this following code (that I use) does is puts a box
around the verbatim text:

in my spitters.py:

class LivewiresLatexSpitter(latex.ChapterLatexSpitter):
def visitNode_pre(self, node):
self.writer('\n\n\\begin{fmpage}\n\\begin{verbatim}\n')
buf = StringIO()
latex.getLatexText(node, buf.write)
s = buf.getvalue()
self.writer('\\end{verbatim}\n\\end{fmpage}\n\n\n')

in my book.tex:

\newlength{\fmwidth}
\setlength{\fmwidth}{\textwidth}

\newsavebox{\fmbox}
\newenvironment{fmpage}[0]
{ \begin{lrbox}{\fmbox}\begin{minipage}{\fmwidth}}
{\end{minipage}\end{lrbox}\vspace{1em}\fbox{\usebox{\fmbox}}\vspace{1em}}

I'll be happy to tarball up my documentation tree and send it to you off-list
if you want a working example.

Stephen.