🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.text
Article #4975

Re: Command environment for TeX?

#4975
From: Brian T. Schellenberger
Date: Tue, 02 Aug 1988 21:26
50 lines
2405 bytes
An environment convenient for writing code in (this is in LaTeX):

    \global\newif\ifatletter
    \ifcat @a \atletterture \else \atletterfalse \fi
    \makeatletter
    
    \newenvironment {definitions}
       {
       \endgroup    % doesn't really nest
       \ifcat @a \atlettertrue \else \atletterfalse \fi
       \catcode`\@=11 \catcode`\ =9 \catcode`\^^M=9
       }%
       {
       \catcode`\@=12 \catcode`\ =10 \catcode`\^^M=5
       \ifatletter \catcode`\@=\letterC \fi
       \def \@currenvir {definitions}
       \begingroup % doesn't really nest
       }
    
    \ifatletter\else \makeatother \fi

To translate into TeX, ignore the \endgroup, \begingroup, and 
\def\@currenvir; define two seperate macros for the two halves
of the environment; and replace \makeatother and \makeatletter with
the obvious \catcode magic.

Due to the difficulty of getting my computers to easily send small things,
I've typed this in by hand from a copy in front of me, so there may be some
very silly typo in this.

Once you've got such an environment, you can write nicely formatted stuff.
The only problem is that *all* spaces are now ignored; you must remember
to use "\ " or \space for spaces that you really want.  For this reason,
I've defined the little environment for doing things like constructing
error messages:

   \newenvironment {userfeedback}
       {\catcode`\ =10}
       {}

(Actually, I define all my things like this with lines like
"\catcode`\@=\otherC \catcode`\ =\spaceC \catcode`\^^M=\nlC," having
defined the necessary \chardefs for all the catagory codes.  I recommend
this heartily; it makes TeX code *much* easier to read.)
-- 
--Brian,                     __________________________________________________
  the man from              |Brian T. Schellenberger   ...!mcnc!rti!sas!bts
  Babble-On                 |104 Willoughby Lane     work: (919) 467-8000 x7783
____________________________|Cary, NC   27513        home: (919) 469-9389 
Technical Details
Message-ID: <584@sas.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!bellcore!rutgers!gatech!mcnc!rti!sas!bts
References: <854@hydra.riacs.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!bellcore!rutgers!gatech!mcnc!rti!sas!bts
From: bts@sas.UUCP (Brian T. Schellenberger)
Newsgroups: comp.text
Subject: Re: Command environment for TeX?
Message-ID: <584@sas.UUCP>
Date: 2 Aug 88 21:26:23 GMT
References: <854@hydra.riacs.edu>
Reply-To: bts@sas.UUCP (Brian T. Schellenberger)
Organization: SAS Institute Inc, Cary NC
Lines: 50