Debian Codegraph @

texmf-dist/tex/latex-dev/tools/multicol.sty

raw
1 %%
2 %% This is file `multicol.sty',
3 %% generated with the docstrip utility.
4 %%
5 %% The original source files were:
6 %%
7 %% multicol.dtx (with options: `package,badness,check,marktrace,nobalance')
8 %%
9 %% This is a generated file.
10 %%
11 %% The source is maintained by the LaTeX Project team and bug
12 %% reports for it can be opened at https://latex-project.org/bugs/
13 %% (but please observe conditions on bug reports sent to that address!)
14 %%
15 %% Copyright (C) 1993-2026
16 %% The LaTeX Project and any individual authors listed elsewhere
17 %% in this file.
18 %%
19 %% This file was generated from file(s) of the Standard LaTeX `Tools Bundle'.
20 %% --------------------------------------------------------------------------
21 %%
22 %% It may be distributed and/or modified under the
23 %% conditions of the LaTeX Project Public License, either version 1.3c
24 %% of this license or (at your option) any later version.
25 %% The latest version of this license is in
26 %% https://www.latex-project.org/lppl.txt
27 %% and version 1.3c or later is part of all distributions of LaTeX
28 %% version 2005/12/01 or later.
29 %%
30 %% This file may only be distributed together with a copy of the LaTeX
31 %% `Tools Bundle'. You may however distribute the LaTeX `Tools Bundle'
32 %% without such generated files.
33 %%
34 %% The list of all files belonging to the LaTeX `Tools Bundle' is
35 %% given in the file `manifest.txt'.
36 %%
37 %% Package `multicol' to use with LaTeX2e
38 %% Copyright 1989-2025 Frank Mittelbach
39 %%
40 %% In addition to the terms of LPPL any distributed version
41 %% (unchanged or modified) of multicol has to keep the statement
42 %% about the moral obligation for using multicol. In case of major
43 %% changes where this would not be appropriate the author of the
44 %% changed version should contact the copyright holder.
45 %%
46 %%
47 %% Moral obligation for using multicol:
48 %% ------------------------------------
49 %%
50 %% Users of multicol who wish to include or use multicol or a modified
51 %% version in a proprietary and commercially market product are asked
52 %% under certain conditions (see below) for the payment of a license
53 %% fee. The size of this fee is to be determined, in each instance,
54 %% by the commercial user, depending on his/her judgment of the value of
55 %% multicol for his/her product.
56 %%
57 %%
58 %% The conditions for this are as follows:
59 %%
60 %% The producer of a proprietary and commercially market product
61 %% that involves typesetting using multicol is asked to determine
62 %% the value of a license fee for using multicol if
63 %%
64 %% - the product is a document and the producer has decided to
65 %% include multicol to typeset (parts of) the document or has
66 %% directed the author of the document to include multicol (for
67 %% example, by providing a class file to be used by the author)
68 %%
69 %% - the product is a LaTeX class or package that includes multicol
70 %%
71 %%
72 %% There is no moral obligation in case
73 %%
74 %% - the product is a document but producer has not directed
75 %% the author to include multicol (in that case the moral obligation
76 %% lies with the author of the document)
77 %%
78 %% - the product does not involve typesetting, e.g., consists, for
79 %% example, of distributing multicol and its documentation.
80 %%
81 %% - the product is not proprietary, i.e., is made available as free
82 %% software itself (which doesn't prohibit its commercial marketing)
83 %%
84 %% - multicol is used for non-commercial purposes
85 %%
86 %%
87 %% Determining a license fee might result in a license fee of zero
88 %% (i.e., no payment) in case a producer has determined that the use
89 %% of multicol has no enhancing effect on the product. This is a
90 %% plausible scenario, i.e., in the above two cases the producer is
91 %% only asked to evaluate the value of multicol for the product
92 %% not for the payment of a license fee per se (which might or might
93 %% not follow from this evaluation).
94 %%
95 %% The license fee, if any, can be paid either to the LaTeX fund
96 %% (see ltx3info.txt in the base LaTeX distribution) or to the author of
97 %% the program who can be contacted at
98 %%
99 %% [email protected]
100 %%
101
102 \DeclareRelease{}{1994-06-01}{multicol-2017-04-11.sty}
103 \DeclareRelease{}{2017-04-11}{multicol-2017-04-11.sty}
104 \DeclareRelease{v1.8}{2019-10-01}{multicol-2019-10-01.sty}
105 \DeclareRelease{v1.9}{2021-11-15}{multicol-2024-05-23.sty}
106 \DeclareCurrentRelease{}{2021-11-15}
107
108 \ProvidesPackage{multicol}
109 [2025/10/21 v2.0b multicolumn formatting (FMi)]
110
111 \DeclareOption{twocolumn}
112 {\PackageWarning{multicol}{May not work
113 with the twocolumn option}}
114 \newcount\c@tracingmulticols
115 \DeclareOption{errorshow}
116 {\c@tracingmulticols\z@}
117 \DeclareOption{infoshow}
118 {\c@tracingmulticols\@ne}
119 \DeclareOption{balancingshow}
120 {\c@tracingmulticols\tw@}
121 \DeclareOption{markshow}
122 {\c@tracingmulticols\thr@@
123 \DebugMarksOn
124 }
125 \DeclareOption{debugshow}
126 {\c@tracingmulticols5\relax
127 \DebugMarksOn
128 }
129 \let\mc@gridwarn\maxdimen
130 \DeclareOption{grid}
131 {\def\mc@gridwarn{\@maxdepth}}
132 \DeclareOption{colaction}{%
133 \def\mc@col@status@write{%
134 \protected@write\@auxout{}%
135 {\string\mc@col@status
136 {\ifmc@firstcol 1\else 2\fi}}%
137 \mc@firstcolfalse}%
138 \def\mc@lastcol@status@write{%
139 \protected@write\@auxout{}%
140 {\string\mc@col@status{3}}}%
141 }
142 \let\mc@col@status@write\relax
143 \let\mc@lastcol@status@write\relax
144 \ProcessOptions
145 \def\multicols#1{\col@number#1\relax
146 \ifnum\col@number<\tw@
147 \PackageWarning{multicol}%
148 {Using `\number\col@number'
149 columns doesn't seem a good idea.^^J
150 I therefore use two columns instead}%
151 \col@number\tw@ \fi
152 \ifnum\col@number>20
153 \PackageError{multicol}%
154 {Too many columns}%
155 {Current implementation doesn't
156 support more than 20 columns.%
157 \MessageBreak
158 I therefore use 20 columns instead}%
159 \col@number20 \fi
160 \ifx\@footnotetext\mult@footnotetext
161 \else
162 \let\orig@footnotetext\@footnotetext
163 \let\@footnotetext\mult@footnotetext
164 \fi
165 \@ifnextchar[\mult@cols{\mult@cols[]}}
166 \long\def\mult@footnotetext#1{\begingroup
167 \columnwidth\textwidth
168 \orig@footnotetext{#1}\endgroup}
169 \def\mult@cols[#1]{\@ifnextchar[%
170 {\mult@@cols{#1}}%
171 {\mult@@cols{#1}[\premulticols]}}
172 \def\mult@@cols#1[#2]{%
173 \par
174 \ifinner \@boxedmulticolstrue
175 \else
176 \ifnum \doublecol@number>\z@
177 \@boxedmulticolstrue
178 \fi
179 \fi
180 \mult@info\z@
181 {Starting environment with
182 \the\col@number\space columns%
183 \if@boxedmulticols\MessageBreak
184 (boxed mode)\fi
185 }%
186 \enough@room{#2}%
187 #1\par\addvspace\multicolsep
188 \ifdim \prevdepth = -\@m\p@
189 \else
190 \@tempcnta\prevdepth
191 \@tempcntb\baselineskip
192 \divide\@tempcnta\@tempcntb
193 \advance\@tempcnta\@ne
194 \dimen@\prevdepth
195 \advance\dimen@ -\@tempcnta\baselineskip
196 \advance\dimen@ \topskip
197 \kern-\dimen@
198 \fi
199 \begingroup
200 \prepare@multicols
201 \if@boxedmulticols
202 \setbox\mult@box\vbox\bgroup
203 \color@setgroup
204 \fi
205 \ignorespaces}
206 \newif\if@boxedmulticols
207 \@boxedmulticolsfalse
208 \newbox\mult@box
209 \def\enough@room#1{%
210 \if@boxedmulticols\else
211 \par
212 \bgroup\@nobreakfalse\addpenalty\z@\egroup
213 \page@free \pagegoal
214 \advance \page@free -\pagetotal
215 \@tempskipa#1\relax
216 \mult@info\z@
217 {Current page:\MessageBreak
218 height=%
219 \the\pagegoal: used \the\pagetotal
220 \space -> free=\the\page@free
221 \MessageBreak
222 needed \the\@tempskipa
223 \space(for #1)}%
224 \ifdim \page@free <#1\newpage \fi
225 \fi}
226 \def\prepare@multicols{%
227 \multicol@leftmargin\@totalleftmargin
228 \@totalleftmargin\z@
229 \parshape\z@
230 \doublecol@number\col@number
231 \multiply\doublecol@number\tw@
232 \advance\doublecol@number\mult@rightbox
233 \mc@prepare@mark@regions
234 \if@boxedmulticols
235 \else
236 \nointerlineskip {\topskip\z@\null}%
237 \output{%
238 \global\setbox\partial@page\vbox
239 {%
240 \ifvoid\partial@page\else
241 \PackageError{multicol}%
242 {Error saving partial page}%
243 {The part of the page before
244 the multicols environment was
245 nearly full with^^Jthe result
246 that starting the environment
247 will produce an overfull
248 page. Some^^Jtext may be lost!
249 Please increase \premulticols
250 either generally or for this%
251 ^^Jenvironment by specifying a
252 suitable value in the second
253 optional argument to^^Jthe
254 multicols environment.}
255 \unvbox\partial@page
256 \box\last@line
257 \fi
258 \unvbox\@cclv
259 \global\setbox\last@line\lastbox
260 }%
261 }\eject
262 \advance\@colroom-\ht\partial@page
263 \set@mult@vsize\relax
264 \output{\multi@column@out}%
265 \init@mult@footins
266 \reinsert@footnotes
267 \def\clearpage{%
268 \ifx\@deferlist\@empty\else
269 \PackageError{multicol}%
270 {Deferred floats not cleared}%
271 {A \string\clearpage\space inside
272 multicols acts like
273 \string\newpage\space and doesn't
274 clear floats.\MessageBreak
275 Move it before the multicols
276 environment if you need it.}%
277 \fi
278 \newpage}%
279 \fi
280 \vbadness\@Mi \hbadness5000
281 \tolerance\multicoltolerance
282 \pretolerance\multicolpretolerance
283 \setemergencystretch\col@number\hsize
284 \set@floatcmds
285 \advance\baselineskip\multicolbaselineskip
286 \hsize\linewidth \advance\hsize\columnsep
287 \advance\hsize-\col@number\columnsep
288 \divide\hsize\col@number
289 \full@width\linewidth
290 \linewidth\hsize
291 \columnwidth\hsize
292 }
293 \def\init@mult@footins{%
294 \multiply\count\footins\col@number
295 \multiply\skip \footins\col@number
296 }
297 \def\set@mult@vsize#1{%
298 \vsize\@colroom
299 \@tempdima\baselineskip
300 \advance\@tempdima-\topskip
301 \advance\vsize\@tempdima
302 \vsize\col@number\vsize
303 \advance\vsize-\@tempdima
304 \advance\vsize\col@number\baselineskip
305 #1\advance\vsize
306 \c@collectmore\baselineskip}
307 \newdimen\multicol@leftmargin
308 \mathchardef\@Mvi=10006 % 10005 is
309 % \columnbreak
310 \def\endmulticols{\par
311 \if@boxedmulticols
312 \remove@discardable@items
313 \color@endgroup\egroup
314 \balance@columns
315 \global\setbox\mc@boxedresult\vbox{%
316 \mc@handle@marks@and@reinserts
317 {in multicol (boxed mode)}%
318 \page@sofar
319 \mc@reinsert@marks
320 }%
321 \else
322 \ifdim\pagegoal=\maxdimen
323 \ifvoid\colbreak@box\else
324 \mult@info\@ne{Re-adding forced
325 break(s) for splitting}%
326 \unvbox\colbreak@box\fi
327 \fi
328 \penalty\z@
329 \penalty-\@Mvi
330 \ifvbox\partial@page
331 \unvbox\partial@page\fi
332 \fi
333 \@checkend{multicols}%
334 \endgroup
335 \global\c@unbalance\z@
336 \if@boxedmulticols
337 \unvbox\mc@boxedresult
338 \mc@col@status@write
339 \else
340 \reinsert@footnotes
341 \ifdim \pagegoal=\maxdimen
342 \global\vsize\@colroom
343 \else
344 \enough@room\postmulticols
345 \fi
346 \fi
347 \addvspace\multicolsep
348 \prevdepth\z@
349 \mult@info\z@
350 {Ending environment
351 \if@boxedmulticols
352 \space(boxed mode)\fi
353 }}
354 \newcount\c@unbalance
355 \newcount\c@collectmore
356 \newcount\doublecol@number
357 \newcount\multicoltolerance
358 \newcount\multicolpretolerance
359 \newdimen\full@width
360 \newdimen\page@free
361 \newdimen\premulticols
362 \newdimen\postmulticols
363 \newskip\multicolsep
364 \newskip\multicolbaselineskip
365 \newbox\partial@page
366 \newbox\last@line
367 \newbox\mc@boxedresult
368 \c@unbalance = 0
369 \c@collectmore = 0
370 \multicoltolerance = 9999
371 \multicolpretolerance = -1
372 \premulticols = 50pt
373 \postmulticols= 20pt
374 \multicolsep = 12pt plus 4pt minus 3pt
375 \multicolbaselineskip=0pt
376 \def\process@cols#1#2{\count@#1\relax
377 \loop
378 #2%
379 \advance\count@\tw@
380 \ifnum\count@<\doublecol@number
381 \repeat}
382 \def\page@sofar{%
383 \process@cols\mult@rightbox
384 {\ifvoid\count@
385 \setbox\count@\hbox to\hsize{}%
386 \else
387 \wd\count@\hsize
388 \fi}%
389 \count@\col@number \advance\count@\m@ne
390 \mult@info\z@
391 {Column spec: \the\full@width\space = indent
392 + columns + sep =\MessageBreak
393 \the\multicol@leftmargin\space
394 + \the\col@number\space
395 x \the\hsize\space
396 + \the\count@\space
397 x \the\columnsep
398 }%
399 \ifvmode\else\errmessage{Multicol Error}\fi
400 \nointerlineskip
401 \setbox\z@\hbox{\multicolmindepthstring}\global\dimen\tw@\dp\z@
402 \UseTaggingSocket{page@sofar}%
403 \moveright\multicol@leftmargin
404 \hbox to\full@width{%
405 \mc@align@columns
406 \rlap{\phantom \multicolmindepthstring}%
407 }%
408 \prevdepth\z@
409 \kern-\dimen\tw@
410 \ifdim\dimen\tw@ > \mc@gridwarn
411 \PackageWarning{multicol}%
412 {Very deep columns!\MessageBreak
413 Grid alignment might be broken}%
414 \fi
415 }
416 \def\multicolmindepthstring{p}
417 \def\columnseprulecolor{\normalcolor}
418 \def\reinsert@footnotes{\ifvoid\footins\else
419 \insert\footins{}\fi}
420 \def\vfilmaxdepth{\vskip \z@ \@plus .0001fil
421 \@minus \@maxdepth}
422 \def\multi@column@out{%
423 \ifnum\outputpenalty <-\@M
424 \speci@ls \else
425 \ifvoid\colbreak@box\else
426 \mult@info\@ne{Re-adding forced
427 break(s) for splitting}%
428 \setbox\@cclv\vbox{%
429 \unvbox\colbreak@box
430 \penalty-\@Mv
431 \unvbox\@cclv}%
432 \fi
433 \splittopskip\topskip
434 \splitmaxdepth\@maxdepth
435 \boxmaxdepth\@maxdepth
436 \dimen@\@colroom
437 \divide\skip\footins\col@number
438 \ifvoid\footins \else
439 \leave@mult@footins
440 \fi
441 \ifvbox \@kludgeins
442 \advance \dimen@ -\ht\@kludgeins
443 \ifdim \wd\@kludgeins>\z@
444 \shr@nkingtrue
445 \fi
446 \fi
447 \process@cols\mult@firstbox{%
448 \setbox\count@
449 \vsplit\@cclv to\dimen@
450 \setbox\count@
451 \vbox to\dimen@
452 {\unvbox\count@
453 \ifshr@nking
454 \vfilmaxdepth\fi}%
455 }%
456 \setbox\mult@rightbox
457 \vsplit\@cclv to\dimen@
458 \setbox\mult@rightbox\vbox to\dimen@
459 {\unvbox\mult@rightbox
460 \ifshr@nking\vfilmaxdepth\fi}%
461 \ifvoid\@cclv \else
462 \unvbox\@cclv
463 \ifnum\outputpenalty=\@M
464 \else
465 \penalty\outputpenalty
466 \fi
467 \ifvoid\footins\else
468 \PackageWarning{multicol}%
469 {I moved some lines to
470 the next page.\MessageBreak
471 Footnotes on page
472 \thepage\space might be wrong}%
473 \fi
474 \ifnum \c@tracingmulticols>\thr@@
475 \hrule\allowbreak \fi
476 \fi
477 \boxmaxdepth\maxdimen
478 \setbox\@cclv\vbox
479 {%
480 \mc@handle@col@andpage@marks
481 {in multicol OR (full page)}%
482 \unvbox\partial@page
483 \page@sofar
484 }%
485 \@makecol\@outputpage
486 \global\@colroom\@colht
487 \global \@mparbottom \z@
488 \global \@textfloatsheight \z@
489 \process@deferreds
490 \@whilesw\if@fcolmade\fi{\@outputpage
491 \global\@colroom\@colht
492 \process@deferreds}%
493 \mult@info\@ne
494 {Colroom:\MessageBreak
495 \the\@colht\space
496 after float space removed
497 = \the\@colroom \@gobble}%
498 \set@mult@vsize \global
499 \fi}
500 \def\leave@mult@footins{%
501 \advance\dimen@-\skip\footins
502 \advance\dimen@-\ht\footins
503 }
504 \def\speci@ls{%
505 \ifnum\outputpenalty <-\@Mi
506 \ifnum \outputpenalty<-\@MM
507 \PackageError{multicol}{Document end
508 inside multicols environment}\@ehd
509 \@specialoutput
510 \else
511 \ifnum\outputpenalty = -\@Mv
512 \mult@info\@ne{Forced column
513 break seen}%
514 \global\advance\vsize-\pagetotal
515 \global\setbox\colbreak@box
516 \vbox{%
517 \ifvoid\colbreak@box
518 \else
519 \unvbox\colbreak@box
520 \penalty-\@Mv
521 \fi
522 \boxmaxdepth\@maxdepth
523 \setbox\@cclv\vbox{%
524 \unvbox\@cclv
525 \remove@discardable@items}%
526 \dimen@\dp\@cclv
527 \unvbox\@cclv
528 \kern-\dimen@
529 }%
530 \reinsert@footnotes
531 \else
532 \ifnum\outputpenalty = -\@Mvi
533 \mult@info\@ne{End penalty of
534 multicols seen}%
535 \outputpenalty\@M % pretend we had
536 % a natural
537 % forced break
538 \balance@columns@out
539 \else
540 \PackageWarningNoLine{multicol}%
541 {Floats and marginpars not
542 allowed inside `multicols'
543 environment!}%
544 \unvbox\@cclv\reinsert@footnotes
545 \xdef\@freelist{\@freelist
546 \@currlist}%
547 \gdef\@currlist{}%
548 \fi
549 \fi
550 \fi
551 \else \@doclearpage \fi
552 }
553 \def\process@deferreds{%
554 \@floatplacement
555 \@tryfcolumn\@deferlist
556 \if@fcolmade\else
557 \begingroup
558 \let\@tempb\@deferlist
559 \gdef\@deferlist{}%
560 \let\@elt\@scolelt
561 \@tempb \endgroup
562 \fi}
563 \newif\ifshr@nking
564 \def\raggedcolumns{%
565 \@bsphack\shr@nkingtrue\@esphack}
566 \def\flushcolumns{%
567 \@bsphack\shr@nkingfalse\@esphack}
568 \def\balance@columns@out{%
569 \setbox\mult@box\vbox{%
570 \ifvoid\colbreak@box\else
571 \unvbox\colbreak@box
572 \penalty-\@Mv
573 \mult@info\@ne{Re-adding
574 forced break(s) in balancing}%
575 \fi
576 \unvbox\@cclv
577 \remove@discardable@items
578 }%
579 \balance@columns
580 \iftoo@bad
581 \mult@info\@ne
582 {Balancing failed ...
583 cut a normal page}%
584 \setbox\@cclv\vbox
585 {\vskip\topskip
586 \vskip-\splittopskip
587 \unvbox\mult@box
588 \penalty-\@Mvi
589 }%
590 \multi@column@out
591 \else
592 \global\vsize\@colroom
593 \global\advance\vsize\ht\partial@page
594 \ifvbox\@kludgeins
595 \insert\@kludgeins
596 {\unvbox\@kludgeins}\fi
597 \unvbox\partial@page
598 % \begin{macrocode}
599 \mc@handle@marks@and@reinserts
600 {in multicol OR (balancing)}%
601 \page@sofar
602 \mc@reinsert@marks
603 \penalty\z@
604 \fi
605 }
606 \def\balance@columns{%
607 \setbox\mult@box\vbox{%
608 \penalty-\@M
609 \unvbox\mult@box
610 }%
611 \@tempdima\topskip
612 \splittopskip\@tempdima
613 \@plus\multicolundershoot
614 \@minus\multicolovershoot
615 \splitmaxdepth\@maxdepth
616 \boxmaxdepth\@maxdepth
617 \setbox\@tempboxa\vsplit\mult@box to\z@
618 \@tempdima\ht\mult@box
619 \advance\@tempdima\dp\mult@box
620 \divide\@tempdima\col@number
621 \count@\@tempdima
622 \divide\count@\baselineskip
623 \dimen@\count@\baselineskip
624 \advance\dimen@\topskip
625 \ifdim \dimen@ >\@tempdima
626 \advance\dimen@-\baselineskip
627 \fi
628 \@tempdima\dimexpr
629 \topskip +\c@minrows\baselineskip
630 -\baselineskip\relax
631 \ifnum\dimen@<\@tempdima
632 \mult@info\@ne
633 {Start value
634 \the\dimen@ \space ->
635 \the\@tempdima \space
636 (corrected for minrows)}%
637 \dimen@\@tempdima
638 \fi
639 \advance\dimen@\c@unbalance\baselineskip
640 \mult@info\@ne
641 {Balance columns\on@line:
642 \ifnum\c@unbalance=\z@\else
643 (off balance=\number\c@unbalance)\fi
644 \@gobbletwo}%
645 \ifnum\dimen@<\topskip
646 \mult@info\@ne
647 {Start value
648 \the\dimen@ \space ->
649 \the\topskip \space (corrected)}%
650 \dimen@\topskip
651 \fi
652 \vbadness\@M
653 \vfuzz \maxdimen
654 \last@try-\p@
655 \loop
656 {\process@cols\mult@grightbox
657 {\global\setbox\count@
658 \box\voidb@x}}%
659 \global\setbox\mult@grightbox
660 \copy\mult@box
661 \too@badfalse
662 \forcedbreak@leftoverfalse
663 {\process@cols\mult@gfirstbox{%
664 \global\setbox\count@
665 \vsplit\mult@grightbox to\dimen@
666 \global\setbox\count@
667 \vbox to\dimen@
668 {\unvbox\count@}%
669 \ifnum\c@tracingmulticols>\@ne
670 \@tempcnta\count@
671 \advance\@tempcnta-\mult@grightbox
672 \divide\@tempcnta \tw@
673 \message{^^JColumn
674 \number\@tempcnta\space
675 badness: \the\badness\space}%
676 \fi
677 \ifnum\badness>\c@columnbadness
678 \ifnum\c@tracingmulticols>\@ne
679 \message{too bad
680 (>\the\c@columnbadness)}%
681 \fi
682 \too@badtrue
683 \fi
684 }}%
685 \global\setbox\mult@grightbox
686 \vbox{\unvbox\mult@grightbox}%
687 \setbox\mult@nat@firstbox
688 \vbox{\unvcopy\mult@gfirstbox}%
689 \ifnum\c@tracingmulticols>\@ne
690 \message{^^JFirst column
691 = \the\dimen@\space
692 (\the\ht\mult@nat@firstbox)}\fi
693 \ifnum\c@tracingmulticols>\@ne
694 \message{<> last column =
695 \the\ht\mult@grightbox^^J}%
696 \fi
697 \ifdim\ht\mult@grightbox >\dimen@
698 \too@badtrue
699 \ifnum\c@tracingmulticols>\@ne
700 \typeout{Rejected: last
701 column too large!}%
702 \fi
703 \else
704 \setbox\@tempboxa
705 \copy\mult@grightbox
706 \setbox\z@\vsplit\@tempboxa to\maxdimen
707 \ifvoid\@tempboxa
708 \global\setbox\mult@grightbox
709 \vbox to\dimen@
710 {\unvbox\mult@grightbox}%
711 \ifnum\c@tracingmulticols>\@ne
712 \message{Final badness:
713 \the\badness}%
714 \fi
715 \ifnum\badness>\c@finalcolumnbadness
716 \global\setbox\mult@grightbox
717 \vbox to\dimen@
718 {\unvbox\mult@grightbox\vfil}%
719 \ifnum\c@tracingmulticols>\@ne
720 \message{ setting natural
721 (> \the\c@finalcolumnbadness)}%
722 \fi
723 \fi
724 \else
725 \@tempdima\@colroom
726 \advance\@tempdima \maxbalancingoverflow
727 \ifdim \dimen@ < \@tempdima
728 \too@badtrue
729 \ifnum\c@tracingmulticols>\@ne
730 \typeout{Rejected: unprocessed
731 forced break(s) in last column!}%
732 \fi
733 \else
734 \forcedbreak@leftovertrue
735 \ifnum\c@tracingmulticols>\@ne
736 \typeout{Failed: columns too large
737 with unprocessed forced break(s)!}%
738 \fi
739 \fi
740 \fi
741 \fi
742 \ifdim\ht\mult@nat@firstbox<\dimen@
743 \ifdim\ht\mult@nat@firstbox>\last@try
744 \too@badtrue
745 \ifnum\c@tracingmulticols>\@ne
746 \typeout{Retry: using natural
747 height of first column!}%
748 \fi
749 \dimen@\ht\mult@nat@firstbox
750 \last@try\dimen@
751 \advance\dimen@-\p@
752 \fi
753 \fi
754 \iftoo@bad
755 \advance\dimen@\p@
756 \repeat
757 \ifforcedbreak@leftover
758 \too@badtrue
759 \else
760 \if@boxedmulticols\else
761 \ifdim\dimen@>\@colroom
762 \dimen@\@colroom
763 \fi
764 \fi
765 \process@cols\mult@rightbox
766 {\@tempcnta\count@
767 \advance\@tempcnta\@ne
768 \vfuzz\z@
769 \setbox\count@\vbox to\dimen@
770 {%
771 \vskip \z@
772 \@plus-\multicolundershoot
773 \@minus-\multicolovershoot
774 \unvbox\@tempcnta
775 \ifshr@nking\vfilmaxdepth\fi
776 }%
777 \ifnum\badness>\@M
778 \vfuzz\maxdimen % no overfull warning
779 \setbox\@tempboxa \vbox to\dimen@
780 {\vskip-\maxbalancingoverflow
781 \unvcopy\count@}%
782 \ifnum\badness>\@M
783 \mult@info\@ne
784 {Balanced column more than
785 \the\maxbalancingoverflow\space
786 too large}%
787 \too@badtrue
788 \else
789 \mult@info\@ne
790 {Balanced column
791 too large, but less than
792 \the\maxbalancingoverflow}%
793 \fi
794 \fi
795 }%
796 \fi
797 }
798 \newdimen\maxbalancingoverflow
799 \maxbalancingoverflow=12pt
800
801 \ifnum\numexpr
802 \count20-\count14-1<40
803 % this is = 2 * 20
804 \count14=\@cclv
805 \fi
806 \newbox\mult@rightbox
807 \newbox\mult@grightbox
808 \newbox\mult@firstbox
809 \newbox\mult@gfirstbox
810 \newbox\@tempa\newbox\@tempa
811 \newbox\@tempa\newbox\@tempa
812 \newbox\@tempa\newbox\@tempa
813 \newbox\@tempa\newbox\@tempa
814 \newbox\@tempa\newbox\@tempa
815 \newbox\@tempa\newbox\@tempa
816 \newbox\@tempa\newbox\@tempa
817 \newbox\@tempa\newbox\@tempa
818 \newbox\@tempa\newbox\@tempa
819 \newbox\@tempa\newbox\@tempa
820 \newbox\@tempa\newbox\@tempa
821 \newbox\@tempa\newbox\@tempa
822 \newbox\@tempa\newbox\@tempa
823 \newbox\@tempa\newbox\@tempa
824 \newbox\@tempa\newbox\@tempa
825 \newbox\@tempa\newbox\@tempa
826 \newbox\@tempa\newbox\@tempa
827 \newbox\@tempa\newbox\@tempa
828 \let\@tempa\relax
829 \@ifundefined{emergencystretch}
830 {\newdimen\emergencystretch}{}
831 \def\setemergencystretch#1#2{%
832 \emergencystretch 4pt
833 \multiply\emergencystretch#1}
834
835 \def\set@floatcmds{%
836 \let\@dblfloat\@dbflt
837 \def\end@dblfloat{\@endfloatbox
838 \UseTaggingSocket{float/end}%
839 \@largefloatcheck
840 \outer@nobreak
841 \ifnum\@floatpenalty<\z@
842 \@cons\@deferlist\@currbox
843 \fi
844 \ifnum\@floatpenalty=-\@Mii
845 \@Esphack
846 \UseTaggingSocket{float/hmode/end}%
847 \fi}}
848 \skip0=0pt
849 \edef\the@zero@skip{\the\skip0}
850 \def\remove@discardable@items{%
851 \unpenalty
852 \edef\@tempa{\the\lastskip}%
853 \unskip
854 \ifx\@tempa\the@zero@skip
855 \edef\@tempb{\the\lastskip}%
856 \ifx\@tempb\the@zero@skip
857 \else
858 \unskip
859 \ifnum \lastpenalty=\@M
860 \vskip\@tempb\vskip\@tempa\relax
861 \else
862 \remove@discardable@items
863 \fi
864 \fi
865 \else
866 \remove@discardable@items
867 \fi
868 }
869 \newif\iftoo@bad
870 \def\too@badtrue{\global\let\iftoo@bad\iftrue}
871 \def\too@badfalse{\global\let\iftoo@bad\iffalse}
872 \newif\ifforcedbreak@leftover
873 \newcount\c@minrows
874 \c@minrows=1
875 \newcount\c@columnbadness
876 \c@columnbadness=10000
877 \newcount\c@finalcolumnbadness
878 \c@finalcolumnbadness=9999
879
880 \newdimen\last@try
881
882 \newdimen\multicolovershoot
883 \newdimen\multicolundershoot
884 \multicolovershoot=0pt
885 \multicolundershoot=2pt
886 \newbox\mult@nat@firstbox
887 \def\mult@info#1#2{%
888 \ifnum\c@tracingmulticols>#1%
889 \GenericWarning
890 {(multicol)\@spaces\@spaces}%
891 {Package multicol: #2}%
892 \fi
893 }
894 \@namedef{multicols*}{%
895 \ifinner
896 \PackageWarning{multicol}%
897 {multicols* inside a box does
898 not make sense.\MessageBreak
899 Going to balance anyway}%
900 \else
901 \def\balance@columns@out
902 {\multi@column@out \penalty-\@Mvi }%
903 \fi
904 \begin{multicols}
905 }
906 \@namedef{endmulticols*}{%
907 \par
908 \ifdim\lastskip>\z@ \vskip-\lastskip \fi
909 \ifdim \prevdepth>\z@
910 \vskip-\ifdim\prevdepth>\boxmaxdepth
911 \boxmaxdepth
912 \else \prevdepth \fi
913 \fi
914 \ifshr@nking\else
915 \vfil
916 \fi
917 \end{multicols}}
918 \mathchardef\@Mv=10005
919 \newcommand\columnbreak[1][4]{%
920 \ifnum\col@number<\tw@
921 \PackageError{multicol}%
922 {\noexpand\columnbreak outside multicols}%
923 {This command can only be used within
924 a multicols or multicols* environment.}%
925 \else
926 \edef\mc@break@pen
927 {-\ifcase#1\@m\or 3333\or 6666\or 9999\else\@Mv\fi\relax}%
928 \ifvmode
929 \penalty \mc@break@pen
930 \else
931 \@bsphack
932 \vadjust{\penalty \mc@break@pen}%
933 \@esphack
934 \fi
935 \fi}
936 \newcommand\newcolumn{%
937 \ifnum\col@number<\tw@
938 \PackageError{multicol}%
939 {\noexpand\newcolumn outside multicols}%
940 {This command can only be used within
941 a multicols or multicols* environment.}%
942 \else
943 \ifvmode
944 \nobreak\vfill\kern\z@\penalty -\@Mv\relax
945 \else
946 \@bsphack
947 \vadjust{\nobreak\vfill\kern\z@\penalty -\@Mv\relax}%
948 \@esphack
949 \fi
950 \fi}
951 \newbox\colbreak@box
952 \def\LR@column@boxes{%
953 \process@cols\mult@firstbox{%
954 \ifdim\dp\count@>\dimen\tw@
955 \global\dimen\tw@\dp\count@ \fi
956 \mc@col@status@write
957 \box\count@
958 \hss{\columnseprulecolor\vrule
959 \@width\columnseprule}\hss}%
960 \ifdim\dp\mult@rightbox>\dimen\tw@
961 \global\dimen\tw@\dp\mult@rightbox \fi
962 \mc@lastcol@status@write
963 \box\mult@rightbox
964 }
965
966 \def\RL@column@boxes{%
967 \process@cols\mult@firstbox{%
968 \hskip\hsize
969 \hss{\columnseprulecolor\vrule
970 \@width\columnseprule}\hss
971 }%
972 \hskip\hsize
973 \process@cols\mult@firstbox{%
974 \ifdim\dp\count@>\dimen\tw@
975 \global\dimen\tw@\dp\count@ \fi
976 \hskip-\hsize
977 \mc@col@status@write
978 \box\count@
979 \hskip-\hsize
980 \hskip-\columnsep
981 }%
982 \ifdim\dp\mult@rightbox>\dimen\tw@
983 \global\dimen\tw@\dp\mult@rightbox \fi
984 \hskip-\hsize
985 \mc@lastcol@status@write
986 \box\mult@rightbox
987 \hskip-\hsize
988 \hskip\full@width
989 }
990 \newcommand\RLmulticolcolumns
991 {\let\mc@align@columns
992 \RL@column@boxes}
993 \newcommand\LRmulticolcolumns
994 {\let\mc@align@columns
995 \LR@column@boxes}
996 \LRmulticolcolumns
997 \newcount\mc@col@check@num
998
999 \newcommand\docolaction{%
1000 \ifx\mc@col@status@write\relax
1001 \PackageError{multicol}%
1002 {Option 'colaction' not selected}%
1003 {\string\docolaction\space
1004 requires the use of the 'colaction'
1005 option on the package}%
1006 \fi
1007 \global\advance\mc@col@check@num\@ne
1008 \edef\mc@col@type{\expandafter\ifx
1009 \csname mc@col-\the\mc@col@check@num
1010 \endcsname\relax
1011 0\else
1012 \csname mc@col-\the\mc@col@check@num
1013 \endcsname
1014 \fi}%
1015 \@ifstar
1016 {\@docolactionstartrue \@docolaction}%
1017 {\@docolactionstarfalse\@docolaction}%
1018 }
1019 \newcommand\@docolaction[4][1]{%
1020 \edef\@docolactioncheck{\write\@auxout
1021 {\string\mc@set@col@status
1022 {mc@col-\the\mc@col@check@num}%
1023 {\mc@col@type}}}%
1024 \if@docolactionstar \@docolactioncheck \fi
1025 \ifcase \mc@col@type\relax
1026 \ifcase #1\or #2\or#3\or#4\fi
1027 \or
1028 #2% % 1 First col
1029 \or
1030 #3% % 2 any middle col
1031 \or
1032 #4% % 3 last col
1033 \else
1034 \ERRORwrongdefaultgiven
1035 \fi
1036 \if@docolactionstar \else \@docolactioncheck \fi
1037 }
1038 \newif\if@docolactionstar
1039 \def\mc@col@status#1{%
1040 \gdef\mc@curr@col@status{#1}}
1041 \def\mc@set@col@status#1#2{%
1042 \global\expandafter\let\csname #1\endcsname
1043 \mc@curr@col@status}
1044 \AtEndDocument{\def\mc@set@col@status#1#2{%
1045 \ifnum #2=\mc@curr@col@status\else
1046 \@tempswatrue
1047 \fi}%
1048 }
1049 \newif\ifmc@firstcol
1050 \mc@firstcoltrue
1051 \ExplSyntaxOn
1052 \int_new:N \g__mc_curr_col_int
1053 \cs_new:Npn \__mc_debug_marks:n #1 { \__mark_debug:n {#1} }
1054 \cs_new_protected:Npn \__mc_update_mcol_structures: {
1055 \__mc_debug_marks:n
1056 { \typeout{Marks:~ update~ mcol~ structures~ (multicol)} }
1057 \int_step_inline:nnn {\col@number + 1} { \g__mc_curr_col_int }
1058 { \mark_set_structure_to_err:n { mcol - ##1 } }
1059 \int_gset:Nn \g__mc_curr_col_int {1}
1060 \process@cols\mult@firstbox
1061 {
1062 \mark_update_structure_from_material:nn
1063 {column}
1064 {\unvcopy\count@}
1065 \mark_copy_structure:nn
1066 {mcol - \int_use:N\g__mc_curr_col_int }
1067 {column}
1068 \int_gincr:N \g__mc_curr_col_int
1069 }
1070 \mark_update_structure_from_material:nn
1071 {column}
1072 {\unvcopy\mult@rightbox}
1073 \mark_copy_structure:nn
1074 { mcol - \int_use:N\g__mc_curr_col_int }
1075 {column}
1076 \mark_copy_structure:nn{first-column}{mcol-1}
1077 \mark_copy_structure:nn{last-column} {column}
1078 }
1079
1080 \cs_new_protected:Npn \__mc_update_page_structures: {
1081 \__mc_debug_marks:n
1082 {
1083 \typeout{Marks:~ update~ page~ structure~ (multicol)}
1084 }
1085 \mark_update_structure_from_material:nn
1086 {page}
1087 {
1088 \unvcopy\partial@page
1089 \process@cols \mult@firstbox { \unvcopy\count@ }
1090 \unvcopy\mult@rightbox
1091 }
1092 }
1093
1094 \cs_new_protected:Npn \__mc_prepare_mark_reinserts: {
1095 \__mc_debug_marks:n
1096 { \typeout{Marks:~ prepare~ for~ reinserting~ marks~ (multicol)} }
1097 \mark_get_marks_for_reinsertion:nNN
1098 {
1099 \process@cols \mult@firstbox { \unvcopy\count@ }
1100 \unvcopy\mult@rightbox
1101 }
1102 \l__mc_first_marks_tl
1103 \l__mc_last_marks_tl
1104 }
1105 \tl_new:N \l__mc_first_marks_tl
1106 \tl_new:N \l__mc_last_marks_tl
1107 \cs_new_protected:Npn \mc@reinsert@marks{
1108 \__mc_debug_marks:n
1109 { \typeout{Marks:~ --~ reinsert~ marks~ (multicol)} }
1110 \l__mc_first_marks_tl \l__mc_last_marks_tl
1111 \__mc_debug_marks:n
1112 { \typeout{Marks:~ --~ finished~ reinserting~ marks~ (multicol)} }
1113 }
1114 \cs_new_protected:Npn \mc@prepare@mark@regions {
1115 \legacy_if:nT { @boxedmulticols }
1116 { \mark_copy_structure:nn{saved-column}{column} }
1117 \__mc_debug_marks:n
1118 { \typeout{Marks:~ empty~ mcol~ regions~ (multicol)} }
1119 \mark_clear_structure:n {column}
1120 }
1121 \cs_new_protected:Npn \mc@handle@marks@and@reinserts #1 {
1122 \__mc_update_mcol_structures:
1123 \__mc_debug_marks:n { \__mark_status:nn {#1} {\the\col@number} }
1124 \__mc_prepare_mark_reinserts:
1125 \legacy_if:nT { @boxedmulticols }
1126 { \mark_copy_structure:nn {column}{saved-column} }
1127 }
1128
1129 \cs_new_protected:Npn \mc@handle@col@andpage@marks #1 {
1130 \__mc_update_mcol_structures:
1131 \__mc_update_page_structures:
1132 \__mc_debug_marks:n { \__mark_status:nn {#1} {\the\col@number} }
1133 }
1134 \NewSocket{tagsupport/page@sofar}{0}
1135 \NewSocketPlug {tagsupport/page@sofar}{default}
1136 {
1137 \process@cols\mult@firstbox
1138 { \tag_mc_add_missing_to_stream:Nn \count@ {multicol} }
1139 \tag_mc_add_missing_to_stream:Nn \mult@rightbox {multicol}
1140 }
1141 \sys_if_engine_luatex:TF
1142 { \AssignSocketPlug{tagsupport/page@sofar}{noop} }
1143 { \AssignSocketPlug{tagsupport/page@sofar}{default} }
1144 \ExplSyntaxOff
1145 \endinput
1146 %%
1147 %% End of file `multicol.sty'.