🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.text
Article #724

Re: code bursts in LaTeX

#724
From: pallas
Date: Mon, 13 Jan 1986 19:43
30 lines
1759 bytes
This little bit of trickiness shoud do the desired file inclusion,
although the way it's called is a little weird.  You have to say

\verbatimfile{filename}
\end{verbatim}

I tried to make the \end{verbatim} implicit, but I couldn't manage to
do it.  Can someone more TeXnical than I tell me why (or better yet,
how to do it right)?  I know it has to do with the way TeX scans
arguments, and the way \verbatim is defined.

Anyway, here's the magic:

\newcommand{\beginverb}{\begin{verbatim}}
\newcommand{\inputfile}[1]{\input{#1}}
\newcommand{\verbatimfile}[1]{\expandafter\beginverb\inputfile{#1}}

Here's the explanation:

\expandafter is a TeX primitive that causes the second following macro
to be expanded before the first (that is, \expandafter\a\b means expand
\a after expanding \b).  Since \a has to be a single token, we define
a single-token alias for \begin{verbatim}.  The alias for
\input{filename} is required because \input is funny about it's
arguments, so \expandafter doesn't do the right thing.  So, the end
result is that \input{filename} is expanded before \begin{verbatim} is
expanded, so the file's contents are inserted inside the verbatim
environment.

joe
Technical Details
Message-ID: <298@Navajo.ARPA>
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!decvax!decwrl!glacier!Navajo!pallas
References: <552@ukc.UUCP>

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.2 9/18/84; site Navajo.ARPA
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!decvax!decwrl!glacier!Navajo!pallas
From: pallas@Navajo.ARPA
Newsgroups: net.text
Subject: Re: code bursts in LaTeX
Message-ID: <298@Navajo.ARPA>
Date: Mon, 13-Jan-86 14:43:14 EST
Article-I.D.: Navajo.298
Posted: Mon Jan 13 14:43:14 1986
Date-Received: Wed, 15-Jan-86 01:36:39 EST
References: <552@ukc.UUCP>
Organization: Stanford University
Lines: 30