summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/plain/vertex/twocol.tex
blob: 53a4fecdbc4294f824a86e3c897d25dce3b73761 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                two colume output from TUGboat
%              vol. 6, No. 1 (1985) by Craig Platt
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


\newif\iftitle                %true if this is a titlepage
  \global\titlefalse


\def\titlepage{\global\titletrue} 

\def\onepageout#1{\shipout\vbox{%
 \offinterlineskip%
 \vbox to 3pc{%
   \iftitle \global\titlefalse%
   \else\ifodd\pageno\rightheadline\else\leftheadline\fi\fi \vfill}%
 \vbox to \vsize{#1%
      \ifvoid\footins\else%
      \vskip\skip\footins \kern-3pt%
%     \hrule height\ruleht width\hsize \kern-\ruleht \kern3pt%
      \unvbox\footins\fi%
    \boxmaxdepth=\maxdepth}}%
\advancepageno}

\newdimen\colwidth \newdimen\bigcolheight		%%%1
\colwidth=13pc \bigcolheight=98pc			%%%2 

\output{\onepageout{\unvbox225}}

\newbox\partialpage
\newdimen\savesize					%%%3

\def\begindoublecolumns{\begingroup
	\savesize=\vsize				%%%4
	\output={\global\setbox\partialpage=\vbox{\unvbox255}}\eject
	\output={\doublecolumnout} \hsize=\colwidth \vsize=\bigcolheight
	\advance\vsize by -2\ht\partialpage}		%%%5

\def\enddoublecolumns{\output={\balancecolumns}\eject
	\global\output={\onepageout{\unvbox255}}	%%%6
	\global\vsize=\savesize				%%%7
	\endgroup \pagegoal=\vsize}

\def\doublecolumnout{\dimen0=\pageheight
	\advance\dimen0 by-\ht\partialpage \splittopskip=\topskip
	\setbox0=\vsplit255 to\dimen0
	\setbox2=\vsplit255 to\dimen0
	\onepageout\pagesofar
	\global\vsize=\bigcolheight			%%%8
	\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}
	\global\output={\balancingerror}		%%%9
	\pagesofar}

\newhelp\balerrhelp{Please change the page		%%%10
                       into one that works.} 		%%%11

\def\balancingerror{\errhelp=\balerrhelp		%%%12
	\errmessage{Page can't be balanced}		%%%13
	\onepageout{\unvbox255}}			%%%14