% from the TeXbook, p. 257

\newdimen\fullhsize
\fullhsize\hsize

\def\fullline{\hbox to\fullhsize}

\ifx\plainmakeheadline\undefined
% ensure that we do this only once!
\let\plainmakeheadline\makeheadline
\let\plainmakefootline\makefootline
\fi

% the text width spans both columns, as far as
% head- and footlines are concerned

\def\textwideline{\hbox to\fullhsize}

\def\makeheadline{{\let\line\textwideline\plainmakeheadline}}
\def\makefootline{{\let\line\textwideline\plainmakefootline}}

% space between the two columns -- can be changed
% immediately after loading 2col

\def\gutter#1{\hsize\fullhsize
\advance\hsize-#1
\hsize.5\hsize
}

\gutter{1.5pc}

\let\lr=L

\newbox\leftcolumn

\output={\if L\lr
\global\setbox\leftcolumn=\columnbox
\global\let\lr=R\else
\doubleformat
\global\let\lr L\fi
\ifnum\outputpenalty>-20000 \else
\dosupereject\fi}

\def\doubleformat{\shipout\vbox{\makeheadline
\fullline{\box\leftcolumn\hfil\columnbox}%
\makefootline}\advancepageno}

\def\columnbox{\leftline{\pagebody}}

% \bye cleans up.

\outer\def\bye{\vfill\supereject
\if R\lr\null\vfill\eject\fi
\end}
