Wide figure in twocolumn output in Plain TeX
As my comment suggests\pagebody
must be changed. Currently
both columns are too long. The vbox for the columns are created in
\pagebody
and in this box the widetopinserts must be handled. Then
the first column isn't to long anymore. So add:
\def\pagebody{\vbox to\vsize{\boxmaxdepth=\maxdepth
\ifvoid\widetopins \else\unvbox\widetopins\fi \pagecontents}}
Of course, the similar lines in \doubleformat
must be deleted.
The length of the second column must be adjusted. This is best done
in \output
when the first column is built. (The \vsize
is reset
after the second column is output.)
But a widetopinsert cannot be handled if it falls in the right
column. And we cannot split the widetopinsert in a left column as the
float went to the next output element and this would be the right
column. In both cases the left column is already created so to change it needs
\vsplit
and then a completely different approach should be used. See
the macros in Appendix E of the TeXbook, pp. 416--417.
Therefore widetopinserts are only created if \@firstcolumntrue
is
set; otherwise the material is put aside for the next physical page. The
box \nxtpgwtibox
keeps the material. It is filled in
\endwideinsert
if a widetopinsert shall be processed but we are not in the left column or the right column is too
full already. After the page is done the material is placed in a
widetopinsert; see \doubleformat
.
I added two \par
s to the \text
and made some other changes to
clean the code. Note, I have not performed many tests with this code
and there is room for improvement. For example, the code does not
check that the collected widetopinserts need more than a page which is
not allowed as they cannot be split.
Here is the complete code:
\newbox\nxtpgwtibox
\newdimen\orgvsize \orgvsize=\vsize
\newdimen\fullhsize \newdimen\columnsep
\fullhsize\hsize \columnsep 1cm
\raggedbottom
\catcode`@=11
\advance\hsize-\columnsep \divide\hsize\tw@
\def\fullline{\hbox to\fullhsize}
\def\makeheadline{\vbox to\z@{\vskip-22.5\p@
\fullline{\vbox to8.5\p@{}\the\headline}\vss}\nointerlineskip}
\def\makefootline{\baselineskip24\p@\lineskiplimit\z@\fullline{\the\footline}}
\newif\if@firstcolumn \@firstcolumntrue
\newbox\firstcolumn
\output={\if@firstcolumn
\dimen@=\vsize \advance\dimen@ by -\ht\widetopins \advance\dimen@ by -\dp\widetopins
\global\setbox\firstcolumn=\columnbox \global\@firstcolumnfalse
\global\vsize=\dimen@
\else
\doubleformat \global\@firstcolumntrue
\global\vsize=\orgvsize\fi
\ifnum\outputpenalty>-20000 \else\dosupereject\fi}
\def\doubleformat{\shipout\vbox{\makeheadline
\fullline{\box\firstcolumn\hfil\columnbox}%
\makefootline}\advancepageno
\ifvoid\nxtpgwtibox\else
\insert\widetopins{\penalty100 \floatingpenalty=0
\box\nxtpgwtibox\nobreak\bigskip}\fi}
\def\columnbox{\leftline{\pagebody}}
\def\pagebody{\vbox to\vsize{\boxmaxdepth=\maxdepth
\ifvoid\widetopins \else\unvbox\widetopins\fi \pagecontents}}
\newinsert\widetopins
\skip\widetopins\z@skip
\count\widetopins=1000
\dimen\widetopins=\maxdimen
\def\widetopinsert{\par\begingroup\hsize=\fullhsize\setbox\z@\vbox\bgroup}
\def\endwideinsert{\egroup
\if@firstcolumn
\dimen@=\ht\z@ \advance\dimen@ by \dp\z@ \advance\dimen@ by 1\baselineskip
\advance\dimen@ by \pagetotal \advance\dimen@ by -\pageshrink
\else \dimen@=1.1\pagegoal\fi % no widetopinserts in second column
\ifdim\dimen@>\pagegoal % the page is full, no more widetopinserts
\ifvoid\nxtpgwtibox \global\setbox\nxtpgwtibox=\vbox{\box\z@}%
\else \global\setbox\nxtpgwtibox=\vbox{\box\nxtpgwtibox
\nobreak\vskip1\baselineskip\box\z@}\fi
\else \insert\widetopins{\penalty100 \floatingpenalty=0
\box\z@\nobreak\bigskip}\fi\endgroup}
\catcode`@=12
\def\mypicture#1{\vrule height 1#10pt depth 4#1pt width3#1#1pt}
\def\text{Lorem ipsum dolor sit amet, consetetur sadipscing elitr,
sed diam nonumy eirmod tempor invidunt ut labore et dolore magn
a aliquyam erat, sed diam voluptua. At vero eos et accusam et justo
duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata
%sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet,
sanctus est Lorem ipsum dolor sit amet.\par Lorem ipsum dolor sit amet,
consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut
labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos
et accusam et justo duo dolores et ea rebum. Stet clita kasd
%gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.}
gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.\par}
\text\text %\text % one more \text moves the 1st widetopinsert to the next page
\widetopinsert
\centerline{\mypicture0}
\endwideinsert
\text
\widetopinsert
\centerline{\mypicture9}
\endwideinsert
\text\text\text\text\text
\bye