
%\hoffset=-0.1in
%\voffset=-2pc
%\raggedbottom
%\hsize=39pc  %\vsize=59pc  
%\maxdepth=2.2pt  \parindent=1pc
%\vsize=720pt
%\hsize=6.5in
%\baselineskip12pt
%\parskip0pt
%\parindent1em
%\hfuzz1.5pt
%\tolerance2000

%\hyphenation{Post-Script}
% Page layout
\newdimen\pagewidth \newdimen\pageheight \newdimen\ruleht
\newdimen\colwidth \newdimen\bigcolheight\newdimen\gutter
\gutter=0.3in%better as 0.4in
%\colwidth=3.1in%19pc
\colwidth=\hsize
\advance\colwidth by-\gutter
\divide\colwidth by 2\relax 
%\bigcolheight=1450pt%120pc
\bigcolheight=\vsize
\advance\bigcolheight by\bigcolheight
\advance\bigcolheight by 10pt
\pagewidth=\hsize \pageheight=\vsize \ruleht=.5pt
\abovedisplayskip=6pt plus 3pt minus 1pt
\belowdisplayskip=6pt plus 3pt minus 1pt
\abovedisplayshortskip=0pt plus 3pt
\belowdisplayshortskip=4pt plus 3pt
 
\newinsert\botins
\def\afoot{\strut\egroup}
\def\botpic#1{\par
      \insert\botins\bgroup\hsize=\pagewidth
      \offinterlineskip
      \interlinepenalty100 \let\par=\endgraf
        \leftskip=0pt     \rightskip=0pt      
        \splittopskip=10pt plus 1pt minus 1pt \floatingpenalty=20000
        \medskip{#1}\medskip\egroup}
\skip\botins=12pt plus 2pt minus 4pt % space added when footnote is present
\count\botins=2000 % footnote magnification factor (1 to 1)
\dimen\botins=36pc % maximum footnotes per page
 
\def\toppic#1{\par
      \insert\topins\bgroup\hsize=\pagewidth
      \interlinepenalty100 \let\par=\endgraf
      \offinterlineskip
        \leftskip=0pt     \rightskip=0pt      
        \splittopskip=10pt plus 1pt minus 1pt \floatingpenalty=20000
        \medskip{#1}\medskip\egroup}
\skip\topins=12pt plus 2pt minus 4pt % space added when footnote is present
\count\topins=2000 % footnote magnification factor (1 to 1)
\dimen\topins=36pc % maximum footnotes per page
 
\newinsert\margin
\dimen\margin=\maxdimen
%\count\margin=0 \skip\margin=0pt % marginal inserts take up no space
 
\newif\iftitle
\def\titlepage{\global\titletrue} % for pages without headlines
%\def\rhead{{}}                           
 
\def\leftheadline{\hbox to \pagewidth{%
    \vbox to 10pt{}% strut to position the baseline
    \sl\rhead\hfill\lhead         % running head flush left
    }}
\def\rightheadline{\hbox to \pagewidth{%
    \vbox to 10pt{}% strut to position the baseline
    \sl\rhead\hfill\lhead      % running head flush left  
    }}
 
\def\onepageout#1{\shipout\vbox{ % here we define one page of output
    \offinterlineskip % butt the boxes together
    \vbox to 2pc{ % this part goes on top of the 44pc pages
      \iftitle % the next is used for title pages
        \global\titlefalse % reset the titlepage switch
        \setcornerrules % for camera alignment
      \else\ifodd\pageno \rightheadline\else\leftheadline\fi\fi
      \vfill} % this completes the \vbox to 3pc
    \vbox to \pageheight{
      \ifvoid\margin\else % marginal info is present
        \rlap{\kern31pc\vbox to 0pt{\kern4pt\box\margin \vss}}\fi
      \ifvoid\topins\else % top note info is present
        %\hrule height\ruleht width\pagewidth \kern-\ruleht \kern3pt
        \unvbox\topins
        \vskip\skip\topins \kern-3pt
        %\hrule height\ruleht width\pagewidth \kern-\ruleht \kern3pt
        \vskip\skip\topins \kern-3pt
        \fi
      #1 % now insert the main information
      \vfill
      \ifvoid\botins\else % bot note info is present
        \vskip\skip\botins \kern-3pt
        %\hrule height\ruleht width\pagewidth \kern-\ruleht \kern3pt
        \unvbox\botins
        \vskip\skip\botins \kern-3pt
        %\hrule height\ruleht width\pagewidth \kern-\ruleht \kern3pt
        \fi
      \boxmaxdepth=\maxdepth
      } % this completes the \vbox to \pageheight
    }
  \advancepageno}
 
\def\setcornerrules{\hbox to \pagewidth{\vrule width 1pc height\ruleht
    \hfil \vrule width 1pc}
  \hbox to \pagewidth{\llap{\sevenrm(page \folio)\kern1pc}%
    \vrule height1pc width\ruleht depth 0pt
    \hfil \vrule width\ruleht depth 0pt}}
 
\output{\onepageout{\unvbox255}}
 
\newbox\partialpage
\newdimen\savesize
\def\begindoublecolumns{\begingroup
  \savesize=\vsize
  \output={\global\setbox\partialpage=\vbox{\unvbox255\bigskip}}\eject
  \output={\doublecolumnout} \hsize=\colwidth \vsize=\bigcolheight
  \advance\vsize by -2\ht\partialpage
  \advance\vsize by -2\ht\botins
  \advance\vsize by -2\ht\topins
  \pagegoal=\vsize}
\def\enddoublecolumns{\output={\balancecolumns}\eject
  \global\output={\onepageout{\unvbox255}}
  \global\vsize=\savesize
  \endgroup \pagegoal=\vsize}
 
\def\doublecolumnout{%
% \splitmaxdepth=\maxdepth
  \dimen0=\pageheight
  \advance\dimen0 by-\ht\partialpage
  \advance\dimen0 by-\ht\botins
  \advance\dimen0 by-\ht\topins
  \splittopskip=\topskip
  \setbox0=\vsplit255 to\dimen0
  \setbox2=\vsplit255 to\dimen0
  \onepageout\pagesofar
  \global\vsize=\bigcolheight
  \unvbox255 \penalty\outputpenalty}
\def\pagesofar{\unvbox\partialpage
  \wd0=\hsize \wd2=\hsize \hbox to\pagewidth{\box0\hfil\box2}}
\def\balancecolumns{\setbox0=\vbox{\unvbox255} \dimen0=\ht0
  \advance\dimen0 by\topskip \advance\dimen0 by-\baselineskip
  \divide\dimen0 by2 \splittopskip=\topskip
  {\vbadness=10000 \loop \global\setbox3=\copy0
    \global\setbox1=\vsplit3 to\dimen0
    \ifdim\ht3>\dimen0 \global\advance\dimen0 by1pt \repeat}
  \setbox0=\vbox to\dimen0{\unvbox1}
  \setbox2=\vbox to\dimen0
% {\unvbox3}
  {\dimen2=\dp3 \unvbox3 \kern-\dimen2 \vfil}
  \global\output={\balancingerror}
  \pagesofar}
\newhelp\balerrhelp{Please change the page into one that works.}
\def\balancingerror{\errhelp=\balerrhelp
  \errmessage{Page can't be balanced}
  \onepageout{\unvbox255}}
 
 
 
 
 
 
 
