[comp.text.tex] LaTeX verbatim

leipold@eplrx7.uucp (Walt Leipold) (04/11/91)

I'm writing a report (using LaTeX) which has to include a *lot* of short
(1 to 40 line) code fragments.  How the heck do I get each of these
fragments displayed as an indented block of verbatim code?  That is, how
can I do it from a LaTeX \newcommand or \newenvironment?  I can't figure
out how to embed the \begin{verbatim}..\end{verbatim} into a LaTeX
\newcommand or \newenvironment.  I'm looking for something like

    \source{
    linear(x,xmin,xmax,smin,smax) = 
        if xmin=xmax then
            error "Linear interpolation with zero range."
        else
            (x-xmin)/(xmax-xmin)*(smax-smin)
    }

I tried the \listing macro from the TeXbook, but it seems to work only
for material that's \input (maybe because the EOF on the \input file
puts all the character codes back where they belong?).  Creating a
hundred little source files just to get LaTeX to display 'em properly
doesn't appeal to me...


-- 
--------------------------------------------------------------------------
"Never attribute to malice that which                         Walt Leipold
is adequately explained by stupidity."          (leipolw%esvax@dupont.com)
--------------------------------------------------------------------------
--
The UUCP Mailer