From amgreene@ATHENA.MIT.EDU Mon Feb  5 00:40:22 1990
From: amgreene@ATHENA.MIT.EDU
Date: Sun, 4 Feb 90 20:24:46 -0500
To: tex-hackers@ATHENA.MIT.EDU
Subject: margin-setting hack


Some of you may have seen the LaTeX margin-setting hack that Jon Kamens
has installed in the SIPB locker.  I would like to submit for your
entertainment a similar file for plain TeX that I wrote a while ago.
In addition to being somewhat useful, this file provides a wonderful
example of \afterassignment.

The file is not commented, but it should be fairly self-explanatory.
The strange way of setting the catcode of @ ensures that @ will have
the same catcode at the end of this file as at the beginning.

Once this file has been \input, you simply say \leftmargin=3in and
the Right Thing happens, instantly.  \leftmargin, \rightmargin,
\topmargin and \bottommargin can be treated as TeX dimen registers
as far as setting goes.  (However, \the\leftmargin will, of course,
fail.  I'm assuming we want to set as easily as possible, and almost
never want to read the values.)

---cut here---
\expandafter\xdef\csname c@tcode\endcsname{\the\catcode`\@}
\catcode`\@=11
%
\newdimen\leftm@rgin   \leftm@rgin=1.5in
\newdimen\rightm@rgin  \rightm@rgin=1n
\newdimen\topm@rgin    \topm@rgin=1in
\newdimen\bottomm@rgin \bottomm@rgin=1in
%
\def\leftmargin{\afterassignment\setmargins\leftm@rgin}
\def\rightmargin{\afterassignment\setmargins\rightm@rgin}
\def\topmargin{\afterassignment\setmargins\topm@rgin}
\def\bottommargin{\afterassignment\setmargins\bottomm@rgin}
%
\def\setmargins{
\dimen255=\leftm@rgin \advance\dimen255 by -1in \hoffset=\dimen255
\dimen255=8.5in \advance\dimen255 by -\rightm@rgin 
\advance\dimen255 by -\leftm@rgin \hsize=\dimen255
\dimen255=\topm@rgin \advance\dimen255 by -1in \voffset=\dimen255
\dimen255=11in \advance\dimen255 by -\bottomm@rgin 
\advance\dimen255 by -\topm@rgin \vsize=\dimen255}
%
\catcode`\@=\c@tcode

