blob: 9ea91182ca67afe562b07b7366591e49f82f10b7 (
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
|
% copied from TUGboat, Vol.10 (1989) No.3 p.409--415 (B.J.)
% MULTICOLUMN LaTeX environement.
% Author: F. Mittelbach
% Quick adaptation to PLAIN: B. Jackowski (Ver. 0.9); alterations are
% marked by `(B.J.)'
%
% Since I do not understand floats I assume that they are
% not used while multicolumning. Maybe some other day...
%
% ========================================================================
% --------------------- PSEUDO-LaTeX ENVIRONEMENT ------------------------
% ========================================================================
\catcode`\@=11
\newtoks\@uteroutput % (P.P.)
\@uteroutput\output %
% --------------------------
\def\adjust@PLAIN{%
\newlinechar=`\^^J
\columnwidth\hsize \textwidth\hsize
\@colht\vsize \@colroom\vsize % NO FLOATs PLEASE!
\def\makefootline{\baselineskip24\p@\hbox to \textwidth{\the\footline}}
\def\pagebody{\vbox to\@colht{\boxmaxdepth\maxdepth \pagecontents}}
\def\vfootnote##1{\insert\footins\bgroup
\hsize=\textwidth
\interlinepenalty\interfootnotelinepenalty
\splittopskip\ht\strutbox % top baseline for broken footnotes
\splitmaxdepth\dp\strutbox \floatingpenalty\@MM
\leftskip\z@skip \rightskip\z@skip \spaceskip\z@skip \xspaceskip\z@skip
\textindent{##1}\footstrut\futurelet\next\fo@t}
}
% --------------------------
\mathchardef\@Mi=10001
\newcount\@tempcnta % temporary count register
% ------ These four macros differ from their LaTeX twins ------
\def\thepage{\number\pageno}
\def\addvspace#1{\vskip#1\relax}
\def\typeout#1{\immediate\write\z@{#1}}
\def\@warning#1{\typeout{WARNING: #1.}}
% --------------------------
\def\newpage{\par\vfil\penalty -\@M}
\long\def\@ifundefined#1#2#3{\expandafter\ifx\csname
#1\endcsname\relax#2\else#3\fi}
\def\@ifnextchar#1#2#3{\let\@tempe #1\def\@tempa{#2}\def\@tempb{#3}\futurelet
\@tempc\@ifnch}
\def\@ifnch{\ifx \@tempc \@sptoken \let\@tempd\@xifnch
\else \ifx \@tempc \@tempe\let\@tempd\@tempa\else\let\@tempd\@tempb\fi
\fi \@tempd}
\def\:{\let\@sptoken= } \: % this makes \@sptoken a space token
\def\:{\@xifnch} \expandafter\def\: {\futurelet\@tempc\@ifnch}
% --------------------------
\def\@spaces{\space\space\space\space}
\def\@width{width}
\newdimen\@colroom
\newdimen\@colht
\newdimen\columnwidth
\newdimen\textwidth
% --------------------------
\newdimen\columnsep \columnsep=24pt
\newdimen\columnseprule \columnseprule = 0pt
% ========================================================================
% -------------------- MITTELBACH's MACROS -------------------------------
% ========================================================================
\newcount\unbalance \unbalance = 0
\newcount\collectmore \collectmore = 0
\newcount\tracingmulticols \tracingmulticols = 0
\newcount\col@number
\newcount\doublecol@number
\newcount\multicoltolerance \multicoltolerance = 9999
\newdimen\page@free
\newdimen\premulticols \premulticols = 50pt
\newdimen\postmulticols \postmulticols = 20pt
\newskip\multicolsep \multicolsep = 12pt plus 4pt minus 3pt
\newskip\multicolbaselineskip \multicolbaselineskip = 0pt
\newbox\partial@page
\newif\ifshr@nking
%
\@ifundefined{mult@cols}{}{\endinput}
\ifnum\tracingmulticols>\z@ % <--------------------------------- added (B.J.)
\typeout{%
MULTI COLUMN format designed by Frank Mittelbach --- see TUGboat}
\typeout{%
Vol.10 (1989) No.3 pp.407--415> for doc.; PLAIN ver. 0.9 by B. Jackowski}
\fi
%
\def\beginmulticols{\begingroup\multicols}% <--- substitute of LaTeX's phrase
% \begin{...} ... \end{...} (B.J.)
%
\def\multicols#1{\col@number#1\relax
%
\adjust@PLAIN
%
\ifnum\col@number<\@ne
\@warning{Using `number\col@number'
columns doesn't seem a good idea.^^J
\@spaces\@spaces I therefore use two columns instead}%
\col@number\tw@ \fi
\@ifnextchar[\mult@cols{\mult@cols[]}}
%
\def\mult@cols[#1]{\@ifnextchar[%
{\mult@@cols{#1}}%
{\mult@@cols{#1}[\premulticols]}}
%
\def\mult@@cols#1[#2]{%
\ifnum\tracingmulticols>\z@
\typeout{^^J^^JStarting multicolumn
output with \the\col@number
\space columns:^^J}\fi
\enough@room#2%
{#1}\par % <-------------- instead of #1\par---it seems more natural (B.J.)
% the more so, as outer {} braces inside [] brackets are gobbled:
% \multicols{...}[cosik] is equivalent to \multicols{...}[{cosik}]
\addvspace\multicolsep
\begingroup
\prepare@multicols\ignorespaces}
%
\def\enough@room#1{\par \penalty\z@
\page@free \pagegoal
\advance \page@free -\pagetotal
\ifnum \tracingmulticols>\z@
\typeout{Current page:}%
\message{\@spaces goal height=%
\the\pagegoal: used \the\pagetotal
\space -> free\the\page@free}%
\typeout{\@spaces needed \the#1
(for \string#1)}\fi
\ifdim \page@free <#1\newpage \fi}
%
\def\prepare@multicols{%
\output{\global\setbox\partial@page
\vbox{\unvbox\@cclv}}\eject
\vbadness9999 \hbadness5000
\tolerance\multicoltolerance
\doublecol@number\col@number
\multiply\doublecol@number\tw@
\advance\baselineskip\multicolbaselineskip
\advance\@colroom-\ht\partial@page
\vsize\col@number\@colroom
\advance\vsize\collectmore\baselineskip
\hsize\columnwidth \advance\hsize\columnsep
\advance\hsize-\col@number\columnsep
\divide\hsize\col@number
% \linewidth\hsize % <----------------- it seems unnecessary in PLAIN (B.J.)
\output{\multi@columnout}%
\multiply\count\footins\col@number
\multiply\skip \footins\col@number
\reinsert@footnotes}
%
\def\endmulticols{\par\penalty\z@
\output{\balance@columns}\eject
\endgroup \reinsert@footnotes
\global\unbalance\z@
\enough@room\postmulticols
\addvspace\multicolsep
\nointerlineskip % <------------------------------------------ added (B.J.)
\ifnum \tracingmulticols>\z@
\typeout{^^JEnding multicolumn
output.^^J^^J}\fi
\endgroup}
%
\def\process@cols#1#2{\count@#1\relax
\loop #2%
\advance\count@\tw@
\ifnum\count@<\doublecol@number
\repeat}
%
\def\page@sofar{\unvbox\partial@page
\process@cols\z@{\wd\count@\hsize}%
\hbox to \textwidth{%
\process@cols\tw@{\box\count@
\hss\vrule\@width\columnseprule\hss}%
\box\z@}}
%
\def\reinsert@footnotes{\ifvoid\footins\else
\insert\footins{\unvbox\footins}\fi}
%
\def\multi@columnout{%
\ifnum\outputpenalty <-\@Mi
\speci@ls
\else
\splittopskip\topskip
\splitmaxdepth\maxdepth
\dimen@\@colroom
\divide\skip\footins\col@number
\ifvoid\footins \else
\advance\dimen@-\skip\footins
\advance\dimen@-\ht\footins \fi
\process@cols\tw@{\setbox\count@
\vsplit\@cclv to\dimen@}%
\setbox\z@\vsplit\@cclv to\dimen@
\ifvoid\@cclv \else
\unvbox\@cclv
\penalty\outputpenalty
\ifnum \tracingmulticols>\tw@
\hrule\allowbreak \fi
\ifvoid\footins\else % <----------------------------------- added (B.J.)
\@warning{I moved some lines to the next page.^^J
\@spaces\@spaces Footnotes on page \thepage\space
might be wrong}\fi\fi
\setbox\@cclv\vbox{\page@sofar}%
% \plainoutput % <---------------- instead of \@makecol\@outputpage (B.J.)
\the\@uteroutput % <------------- instead of \plainoutput (P.P.)
\global\@colroom\@colht
\process@deferreds
\ifnum\tracingmulticols>\@ne
\typeout{Colroom: \the\@colht\space after float
space removed = \the\@colroom}\fi
\global\vsize\col@number\@colroom
\global\advance\vsize \collectmore\baselineskip
\multiply\skip\footins\col@number
\fi}
%
\def\speci@ls{%
\typeout{Floats and marginpars not allowed inside
`multicols' environement!}%
\unvbox\@cclv\reinsert@footnotes
% \gdef\@currlist{}% <----------------------------- not used in PLAIN (B.J.)
}
%
\def\process@deferreds{}% <---------- instead of the `percented' macro (B.J.)
% (temporarily: until I'll learn what all that
% mumbling means)
%\def\process@deferreds{%
% \@floatplacement
% \begingroup
% \let\@tempb\@deferlist
% \gdef\@deferlist{}%
% \let\@elt\@scoelt
% \@tempb \endgroup}
%
% Originally: <------------------------------------------------------- (B.J.)
%\def\raggedcolumns{\@bsphack\shr@nkingtrue\@esphack}
%\def\flushcolumns{\@bsphack\shr@nkingfalse\@esphack}
%
\def\raggedcolumns{\shr@nkingtrue}
\def\flushcolumns{\shr@nkingfalse}
%
\def\balance@columns{%
\splittopskip\topskip
\splitmaxdepth\maxdepth
\setbox\z@\vbox{\unvbox\@cclv}\dimen@\ht\z@
\advance\dimen@ \col@number\topskip
\advance\dimen@ -\col@number\baselineskip
\divide\dimen@ \col@number
\advance\dimen@ \unbalance\baselineskip
\ifnum\tracingmulticols>\@ne
\typeout{Balance columns: \ifnum\unbalance=\z@\else
(off balance=\number\unbalance)\fi}%
\fi
{\vbadness\@M
\loop
{\process@cols\@ne{\global\setbox\count@\box\voidb@x}}%
\global\setbox\@ne\copy\z@
{\process@cols\thr@@{\global\setbox\count@
\vsplit\@ne to\dimen@}}%
%
% ... After \process@cols has done its job we have the following situation:
% box0 <-- all material
% box3 <-- first column
% box5 <-- second column
% ...
% box1 <-- last column ...
%
\ifnum\tracingmulticols>\@ne
\message{\@spaces First column = \the\ht\thr@@}\fi
\ifshr@nking \global\setbox\thr@@\vbox{\unvbox\thr@@}%
\ifnum\tracingmulticols>\@ne
\message{ after shrinking \the\ht\thr@@}\fi\fi
\ifnum\tracingmulticols>\@ne
\message{<> last column = \the\ht\@ne}%
\typeout{}\fi
\ifdim\ht\@ne > \ht\thr@@
\global\advance\dimen@\p@
\repeat}%
\dimen@\ht\thr@@
\process@cols\z@{\@tempcnta\count@
\advance\@tempcnta\@ne
\setbox\count@\vtop to\dimen@
{\unvbox\@tempcnta
\ifshr@nking\vfill\fi}}%
\global\vsize\@colroom
\global\advance\vsize\ht\partial@page
\page@sofar}
% ========================================================================
\catcode`\@=12 % default PLAIN value
% ========================================================================
\endinput
|