1 % Save file as: MULTICOLS.STY Source: FILESERV@SHSU.BITNET
2 % multicols.sty version 1.0
3 % Allows for multiple column typesetting
4 % From TUGboat, voulme 10 (1989), No. 3
5 %
6 % Frank Mittelback
7 % Electronic Data Systems
8 % (Deutschland) GmbH
9 % Eisenstrasse 56
10 % D-6090 Russelsheim
11 % Federal Republic of Germany
12 % Bitnet: pzf5hz@drueds2
13 %
14 % Variables:
15 % \premulticols - If the space left on the page is less than this, a new
16 % page is started before the multiple columns. Otherwise, a \vskip
17 % of \multicolsep is added.
18 % \postmulticols - analogous to \premulticols
19 % \columnseprule - the width of the rule separating the columns.
20 %
21 % Commands:
22 % \raggedcolumns - don't align bottom lines of columns
23 % \flushcolumns - align bottom lines (default)
24 %
25 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
26 \@ifundefined{mult@cols}{}{\endinput}
27
28 \def\multicols#1{\col@number#1\relax
29 \ifnum\col@number<\@ne
30 \@warning{Using '\number\col@number' columns doesn't seem a good idea.^^J
31 I therefore use two columns instead}%
32 \col@number\tw@ \fi
33 \@ifnextchar[\mult@cols{\mult@cols[]}}
34
35 \def\mult@cols[#1]{\@ifnextchar[%
36 {\mult@@cols{#1}}%
37 {\mult@@cols{#1}[\premulticols]}}
38
39 \def\mult@@cols#1[#2]{%
40 \enough@room#2%
41 #1\par\addvspace\multicolsep
42 \begingroup
43 \prepare@multicols\ignorespaces}
44
45 \def\enough@room#1{\par \penalty\z@
46 \page@free \pagegoal
47 \advance \page@free -\pagetotal
48 \ifdim \page@free <#1\newpage \fi}
49
50 \def\prepare@multicols{%
51 \output{\global\setbox\partial@page
52 \vbox{\unvbox\@cclv}}\eject
53 \vbadness9999 \hbadness5000
54 \tolerance\multicoltolerance
55 \doublecol@number\col@number
56 \multiply\doublecol@number\tw@
57 \advance\baselineskip\multicolbaselineskip
58 \advance\@colroom-\ht\partial@page
59 \vsize\col@number\@colroom
60 \advance\vsize\c@collectmore\baselineskip
61 \hsize\columnwidth \advance\hsize\columnsep
62 \advance\hsize-\col@number\columnsep
63 \divide\hsize\col@number
64 \linewidth\hsize
65 \output{\multi@columnout}%
66 \multiply\count\footins\col@number
67 \multiply\skip \footins\col@number
68 \reinsert@footnotes}
69
70 \def\endmulticols{\par\penalty\z@
71 \output{\balance@columns}\eject
72 \endgroup \reinsert@footnotes
73 \global\c@unbalance\z@
74 \enough@room\postmulticols
75 \addvspace\multicolsep}
76
77 \newcount\c@unbalance \c@unbalance = 0
78 \newcount\c@collectmore \c@collectmore = 0
79 \newcount\col@number
80 \newcount\doublecol@number
81 \newcount\multicoltolerance \multicoltolerance = 9999
82 \newdimen\page@free
83 \newdimen\premulticols \premulticols = 50pt
84 \newdimen\postmulticols \postmulticols = 20pt
85 \newskip\multicolsep \multicolsep = 12pt plus 4pt minus 3pt
86 \newskip\multicolbaselineskip \multicolbaselineskip=0pt
87 \newbox\partial@page
88
89 \def\process@cols#1#2{\count@#1\relax
90 \loop #2%
91 \advance\count@\tw@
92 \ifnum\count@<\doublecol@number
93 \repeat}
94
95 \def\page@sofar{\unvbox\partial@page
96 \process@cols\z@{\wd\count@\hsize}%
97 \hbox to\textwidth{%
98 \process@cols\tw@{\box\count@
99 \hss\vrule\@width\columnseprule\hss}%
100 \box\z@}}
101
102 \def\reinsert@footnotes{\ifvoid\footins\else
103 \insert\footins{\unvbox\footins}\fi}
104
105 \def\multi@columnout{%
106 \ifnum\outputpenalty <-\@Mi
107 \speci@ls \else
108 \splittopskip\topskip
109 \splitmaxdepth\maxdepth
110 \dimen@\@colroom
111 \divide\skip\footins\col@number
112 \ifvoid\footins \else
113 \advance\dimen@-\skip\footins
114 \advance\dimen@-\ht\footins \fi
115 \process@cols\tw@{\setbox\count@
116 \vsplit\@cclv to\dimen@}%
117 \setbox\z@\vsplit\@cclv to\dimen@
118 \ifvoid\@cclv \else
119 \unvbox\@cclv
120 \penalty\outputpenalty
121 \fi
122 \setbox\@cclv\vbox{\page@sofar}%
123 \@makecol\@outputpage
124 \global\@colroom\@colht
125 \process@deferreds
126 \global\vsize\col@number\@colroom
127 \global\advance\vsize
128 \c@collectmore\baselineskip
129 \multiply\skip\footins\col@number\fi}
130
131 \def\speci@ls{%
132 \typeout{floats and marginpars not allowed inside `multicols' environment}%
133 \unvbox\@cclv\reinsert@footnotes
134 \gdef\@currlist{}}
135
136 \def\process@deferreds{%
137 \@floatplacement
138 \begingroup
139 \let\@tempb\@deferlist
140 \gdef\@deferlist{}%
141 \let\@elt\@scolelt
142 \@tempb \endgroup}
143
144 \newif\ifshr@nking
145
146 \def\raggedcolumns{%
147 \@bsphack\shr@nkingtrue\@esphack}
148 \def\flushcolumns{%
149 \@bsphack\shr@nkingfale\@esphack}
150
151 \def\balance@columns{%
152 \splittopskip\topskip
153 \splitmaxdepth\maxdepth
154 \setbox\z@\vbox{\unvbox\@cclv}\dimen@\ht\z@
155 \advance\dimen@\col@number\topskip
156 \advance\dimen@-\col@number\baselineskip
157 \divide\dimen@\col@number
158 \advance\dimen@\c@unbalance\baselineskip
159 {\vbadness\@M \loop
160 {\process@cols\@ne{\global\setbox\count@\box\voidb@x}}%
161 \global\setbox\@ne\copy\z@
162 {\process@cols\thr@@{\global\setbox\count@\vsplit\@ne to\dimen@}}%
163 \ifshr@nking \global\setbox\thr@@\vbox{\unvbox\thr@@}%
164 \fi
165 \ifdim\ht\@ne >\ht\thr@@
166 \global\advance\dimen@\p@
167 \repeat}%
168 \dimen@\ht\thr@@
169 \process@cols\z@{\@tempcnta\count@
170 \advance\@tempcnta\@ne
171 \setbox\count@\vtop to\dimen@
172 {\unvbox\@tempcnta
173 \ifshr@nking\vfill\fi}}%
174 \global\vsize\@colroom
175 \global\advance\vsize\ht\partial@page
176 \page@sofar}
177