 
27-Jul-88 06:54:04-PDT,11115;000000000000
Return-Path: <CGL%HGRRUG5.BITNET@Forsythe.Stanford.EDU>
Date:     Wed, 27 Jul 88 15:50 B
From: <CGL%HGRRUG5.BITNET@Forsythe.Stanford.EDU>
Subject:  Improved `Page Layout in LaTeX' program

In Groningen Jan Luyten and myself have
improved the program

***Page Layout in LaTeX***
from Kent McPherson published in TUGBoat, 9, 1.

We consider it a useful program and therefor
offer the program machine readable.
We welcome comments.

%
\newcommand{\bs}{\char'134}
%
\newcommand{\fd}[2]{
   #1=#2
   \divide#1 by65536
   }
%
%
%
\newcount\hofset
\newcount\vofset
\newcount\hofref
\newcount\vofref
\newcount\omargin
\newcount\omarginref
\newcount\emargin
\newcount\emarginref
\newcount\marginref
\newcount\tmargin
\newcount\hheight
\newcount\hsep
\newcount\theight
\newcount\twidth
\newcount\mparsep
\newcount\mparwidth
\newcount\fskip
\newcount\fheight
\newcount\headref
\newcount\bodyref
\newcount\footref
\newcount\margnoteref
\newcount\xp
\newcount\yp
\newcount\oneinch
\newcount\ypm
\newcount\xb
\newcount\xe
\newcount\yb
\newcount\ye
\newcount\la
%
%x:=a+b*tel/noem
% #1=#2+#3*#4/#5
%
\newcommand{\pyl}[5]{
   #1=#3
   \multiply#1 by #4
   \divide#1   by #5
   \advance#1  by #2
   }
%
%
% xbegin,ybegin,lengte,xend,text
%
\newcommand{\hdpyl}[5]{
   \put(#1,#2){\vector(1,0){#3}}
   \put(#1,#2){\makebox(#3,40){\mbox{#5}}}
   #4=#1
   \advance#4 by #3
   \put(#4,#2){\vector(-1,0){#3}}
   }
%
\newcommand{\hxpyl}[5]{
   \la=#1
   \advance\la by -40
   \put(\la,#2){\vector(1,0){40}}
   #4=#1
   \advance#4 by #3
   \put(\#4,#2){\vector(-1,0){40}}
   }
%
% xbegin,ybegin,lengte,yend,text
% yend = ybegin - lengte
%
\newcommand{\vdpyl}[5]{
   \put(#1,#2){\vector(0,-1){#3}}
   #4=#2
   \advance#4 by -#3
   \put(#1,#4){\vector(0,1){#3}}
   \put(#1,#4){\makebox(40,#3){\mbox{#5}}}
   }
\newcommand{\layout}{
%
\xp=598
\yp=846
\oneinch=72
\ypm=\yp
   \advance\ypm by -\oneinch
%
%                                       Op papier wordt een rand van
%                                       ca. 5 mm niet geprint.
%
\fd{\hofset}{\hoffset}
   \hofref=\hofset
   \advance\hofset by \oneinch
%
\fd{\vofset}{\voffset}
   \vofref=\vofset
   \vofset=\ypm
   \advance\vofset by -\vofref
%
\fd{\tmargin}{\topmargin}
%
\fd{\hheight}{\headheight}
%
\headref=\ypm
   \advance\headref by -\vofref
   \advance\headref by -\tmargin
   \advance\headref by -\hheight
%
\fd{\hsep}{\headsep}
%
\fd{\theight}{\textheight}
%
\bodyref=\headref
   \advance\bodyref by -\hsep
   \advance\bodyref by -\theight
%
\fd{\fskip}{\footskip}
%
\fd{\fheight}{\footheight}
   \footref=\bodyref
   \advance\footref by -\fskip
%
\fd{\omargin}{\oddsidemargin}
   \omarginref=\omargin
   \advance\omarginref by \oneinch
   \advance\omarginref by \hofref
%
\fd{\emargin}{\evensidemargin}
   \emarginref=\emargin
   \advance\emarginref by \hofset
%
\fd{\twidth}{\textwidth}
%
\fd{\mparsep}{\marginparsep}
%
\fd{\mparwidth}{\marginparwidth}
%
%                                       Odd page
\margnoteref=\oneinch
   \advance\margnoteref by \hofref
   \advance\margnoteref by \omargin
   \marginref=\margnoteref
   \advance\margnoteref by \twidth
   \advance\margnoteref by  \mparsep
%
\typeout{Begin oneven blz.}
%
Streepjeslijnen geven
{\tt\bs hoffset} en
{\tt\bs voffset}\newline
Oneven pagina; diagram is 0.4 van werkelijke grootte.\newline
\setlength{\unitlength}{0.4pt}
\begin{picture}(\xp,\yp)
%                                       Page
\put(0,0){\framebox(\xp,\yp){}}
%                                       dashed lines
\put(0,\vofset){\dashbox{10}(\xp,0){}}
\put(\hofset,0){\dashbox{10}(0,\yp){}}
%                                       header
\put(\marginref,\headref){\framebox(\twidth,
   \hheight){\footnotesize Kopregel}}
%                                       body
\put(\marginref,\bodyref){\framebox(\twidth,
   \theight){Tekst}}
%                                       footer
\put(\marginref,\footref){\framebox(\twidth,
   \fheight){\footnotesize Voetregel}}
%                                       margin
\put(\margnoteref,\bodyref){\framebox(\mparwidth,
    \theight){\footnotesize\shortstack{Kantlijn\\opmerkingen}}}
%                                       Hor. arrows
%
%                                       #1
   \xb=0
   \pyl{\yb}{\bodyref}{\theight}{1}{2}
   \hdpyl{\xb}{\yb}{\hofset}{\xe}{1}
%
%                                       #2
%
   \pyl{\yb}{\bodyref}{\theight}{5}{6}
   \xb=\xe
   \hdpyl{\xb}{\yb}{\omargin}{\xe}{2}
%
%                                       #3
%
   \xb=\xe
   \pyl{\yb}{\bodyref}{\theight}{1}{6}
   \hdpyl{\xb}{\yb}{\twidth}{\xe}{3}
%
%                                       #4
%
   \pyl{\yb}{\bodyref}{\theight}{11}{12}
   \xb=\xe
   \hdpyl{\xb}{\yb}{\mparsep}{\xe}{4}
%
%                                       #5
%
   \pyl{\yb}{\bodyref}{\theight}{5}{6}
   \xb=\xe
   \hdpyl{\xb}{\yb}{\mparwidth}{\xe}{5}
%
%  indicate how much space is left?
%
%                                       vertical arrows
%
%
%                                       #6
%
   \yb=\yp
   \la=\yp
   \advance\la by -\vofset
   \pyl{\xb}{\marginref}{\twidth}{1}{2}
   \vdpyl{\xb}{\yp}{\la}{\ye}{6}
%
%                                       #7
%
   \pyl{\xb}{\marginref}{\twidth}{1}{8}
   \yb=\ye
   \vdpyl{\xb}{\yb}{\tmargin}{\ye}{7}
%
%                                       #8
%
   \pyl{\xb}{\marginref}{\twidth}{1}{4}
   \yb=\ye
   \vdpyl{\xb}{\yb}{\hheight}{\ye}{8}
%
%                                       #9
%
   \pyl{\xb}{\marginref}{\twidth}{3}{8}
   \yb=\ye
   \vdpyl{\xb}{\yb}{\hsep}{\ye}{9}
%
%                                       #10
%
   \pyl{\xb}{\marginref}{\twidth}{3}{4}
   \yb=\ye
   \vdpyl{\xb}{\yb}{\theight}{\ye}{10}
%
%                                       #11
%
   \pyl{\xb}{\marginref}{\twidth}{1}{8}
   \yb=\ye
   \vdpyl{\xb}{\yb}{\fskip}{\ye}{11}
%
%                                       #12
%
   \pyl{\xb}{\marginref}{\twidth}{1}{4}
   \yb=\ye
   \advance\yb by \fheight
   \vdpyl{\xb}{\yb}{\fheight}{\ye}{12}
%
\end{picture}
\newline
%
{\tt
\begin{tabular}{l@{\hspace{20pt}}l}
1\ \ \bs{}hoffset       = \number\hofref pt&
2\ \ \bs{}oddsidemargin = \number\omargin pt\\
3\ \ \bs{}textwidth     = \number\twidth pt&
4\ \ \bs{}marginparsep  = \number\mparsep pt\\
5\ \ \bs{}marginparwidth= \number\mparwidth pt&
6\ \ \bs{}voffset       = \number\vofref pt\\
7\ \ \bs{}topmargin     = \number\tmargin pt&
8\ \ \bs{}headheight    = \number\hheight pt\\
9\ \ \bs{}headsep       = \number\hsep pt&
10\ \bs{}textheight     = \number\theight pt\\
11\ \bs{}footskip       = \number\fskip pt&
12\ \bs{}footheight     = \number\fheight\\
\multicolumn{2}{c}{72pt $\approx$ 1 inch}
\end{tabular}
   }
%
\typeout{Oneven klaar, nu even.}
\if@twoside
\newpage
%
%                                       Even page
%
\margnoteref=\oneinch
   \advance\margnoteref by \hofref
   \advance\margnoteref by \emargin
   \marginref=\margnoteref
   \advance\margnoteref by -\mparsep
   \advance\margnoteref by -\mparwidth

Streepjeslijnen duiden op
{\tt\bs hoffset} en
{\tt\bs voffset}.\newline
Even page; diagram 0.4 actual size.\newline
\begin{picture}(\xp,\yp)
%                                       Page
\put(0,0){\framebox(\xp,\yp){}}
%                                       dashed lines
\put(0,\vofset){\dashbox{10}(\xp,0){}}
\put(\hofset,0){\dashbox{10}(0,\yp){}}
%                                       header
\put(\marginref,\headref){\framebox(\twidth,
   \hheight){\footnotesize Kopregel}}
%                                       body
\put(\marginref,\bodyref){\framebox(\twidth,
   \theight){Tekst}}
%                                       footer
\put(\marginref,\footref){\framebox(\twidth,
   \fheight){\footnotesize Voetregel}}
%                                       margin
\put(\margnoteref,\bodyref){\framebox(\mparwidth,
    \theight){\footnotesize\shortstack{Kantlijn\\opmerkingen}}}
%                                       Hor. arrows
%
%                                       #1
   \xb=0
   \pyl{\yb}{\bodyref}{\theight}{1}{2}
   \hdpyl{\xb}{\yb}{\hofset}{\xe}{1}
%
%                                       #2
%
   \pyl{\yb}{\bodyref}{\theight}{5}{6}
   \xb=\xe
   \hdpyl{\xb}{\yb}{\emargin}{\xe}{2}
%
%                                       #3
%
   \xb=\xe
   \pyl{\yb}{\bodyref}{\theight}{1}{6}
   \hdpyl{\xb}{\yb}{\twidth}{\xe}{3}
%
%                                       #5
%
   \pyl{\yb}{\bodyref}{\theight}{2}{3}
   \xb=\xe
   \hdpyl{\margnoteref}{\yb}{\mparwidth}{\xe}{5}
%
%                                       #4
%
   \pyl{\yb}{\bodyref}{\theight}{11}{12}
   \xb=\xe
   \hdpyl{\xb}{\yb}{\mparsep}{\xe}{4}
%
%
%  indicate how much space is left?
%
%                                       vertical arrows
%
%
%                                       #6
%
   \yb=\yp
   \la=\yp
   \advance\la by -\vofset
   \pyl{\xb}{\marginref}{\twidth}{1}{2}
   \vdpyl{\xb}{\yp}{\la}{\ye}{6}
%
%                                       #7
%
   \pyl{\xb}{\marginref}{\twidth}{1}{8}
   \yb=\ye
   \vdpyl{\xb}{\yb}{\tmargin}{\ye}{7}
%
%                                       #8
%
   \pyl{\xb}{\marginref}{\twidth}{1}{4}
   \yb=\ye
   \vdpyl{\xb}{\yb}{\hheight}{\ye}{8}
%
%                                       #9
%
   \pyl{\xb}{\marginref}{\twidth}{3}{8}
   \yb=\ye
   \vdpyl{\xb}{\yb}{\hsep}{\ye}{9}
%
%                                       #10
%
   \pyl{\xb}{\marginref}{\twidth}{3}{4}
   \yb=\ye
   \vdpyl{\xb}{\yb}{\theight}{\ye}{10}
%
%                                       #11
%
   \pyl{\xb}{\marginref}{\twidth}{1}{8}
   \yb=\ye
   \vdpyl{\xb}{\yb}{\fskip}{\ye}{11}
%
%                                       #12
%
   \pyl{\xb}{\marginref}{\twidth}{1}{4}
   \yb=\ye
   \advance\yb by \fheight
   \vdpyl{\xb}{\yb}{\fheight}{\ye}{12}
\end{picture}
\newline
%
{\tt
\begin{tabular}{l@{\hspace{20pt}}l}
1\ \ \bs{}hoffset        = \number\hofref pt&
2\ \ \bs{}evensidemargin = \number\emargin pt\\
3\ \ \bs{}textwidth      = \number\twidth pt&
4\ \ \bs{}marginparsep   = \number\mparsep pt\\
5\ \ \bs{}marginparwidth = \number\mparwidth pt&
6\ \ \bs{}voffset        = \number\vofref pt\\
7\ \ \bs{}topmargin      = \number\tmargin pt&
8\ \ \bs{}headheight     = \number\hheight pt\\
9\ \ \bs{}headsep        = \number\hsep pt&
10\ \bs{}textheight      = \number\theight pt\\
11\ \bs{}footskip        = \number\fskip pt&
12\ \bs{}footheight      = \number\fheight\\
\multicolumn{2}{c}{72pt $\approx$ 1 inch}
\end{tabular}
   }
\else
\fi
\typeout{Even ook klaar}
   }


