Debian Codegraph @

texmf-dist/source/latex/sttools/cuted.dtx

raw
1 % \iffalse meta-comment/*% \end{macrocode}*/
2 %
3 % Copyright (C) 2021 by Sigitas Tolu\v{s}is <[email protected]>
4 % ---------------------------------------------------------------------------
5 % This work may be distributed and/or modified under the
6 % conditions of the LaTeX Project Public License, either version 1.3
7 % of this license or (at your option) any later version.
8 % The latest version of this license is in
9 % http://www.latex-project.org/lppl.txt
10 % and version 1.3 or later is part of all distributions of LaTeX
11 % version 2005/12/01 or later.
12 %
13 % This work has the LPPL maintenance status `maintained'.
14 %
15 % The Current Maintainer of this work is Sigitas Tolu\v{s}is.
16 %
17 % This work consists of the files cuted.dtx and cuted.ins
18 % and the derived filebase cuted.sty.
19 %
20 % \fi
21 %
22 % \iffalse
23 %<*internal>
24 \begingroup
25 %</internal>
26 %<*batchfile>
27 \input docstrip.tex
28 \keepsilent\askforoverwritefalse
29 \preamble
30 %%
31 %% This is file `cuted.sty',
32 %% generated with the docstrip utility.
33 %%
34 %% The original source files were:
35 %%
36 %% cuted.dtx (with options: `package')
37 %%
38 \endpreamble
39 \generate{\file{cuted.sty}{\from{cuted.dtx}{package}}}
40 %</batchfile>
41 %<batchfile>\endbatchfile
42 %<*internal>
43 \generate{\file{cuted.ins}{\from{cuted.dtx}{batchfile}}}
44 \endgroup
45 %</internal>
46 %<*driver>
47 \ProvidesFile{cuted.dtx}
48 %</driver>
49 %<*package>
50 %% Copyright (C) 1997-2025 by Sigitas Tolu\v{s}is <[email protected]>
51 %% UAB VTeX, Mokslininkų 2A, LT-08412 Vilnius, Lithuania
52 %% --------------------------------------------------------------------------
53 %% This work may be distributed and/or modified under the
54 %% conditions of the LaTeX Project Public License, either version 1.3
55 %% of this license or (at your option) any later version.
56 %% The latest version of this license is in
57 %% http://www.latex-project.org/lppl.txt
58 %% and version 1.3 or later is part of all distributions of LaTeX
59 %% version 2005/12/01 or later.
60 %%
61 %% PURPOSE: Insert some onecolumn material in full-width on double-column page.
62 %%
63 %</package>
64 %<package>\NeedsTeXFormat{LaTeX2e}[2020/10/01]
65 %<package>\ProvidesPackage{cuted}
66 %<*package>
67 [2025/12/15 v2.10 Mixing onecolumn and twocolumn modes (ST)]
68 %</package>
69 %
70 %<*driver>
71 \documentclass{ltxdoc}
72 \usepackage{cuted}[2025/07/14]
73 \EnableCrossrefs
74 \CodelineIndex
75 \RecordChanges
76 \OnlyDescription
77 \begin{document}
78 \DocInput{cuted.dtx}
79 \PrintChanges
80 \PrintIndex
81 \end{document}
82 %</driver>
83 % \fi
84 %
85 % \CheckSum{1136}
86 %
87 % \CharacterTable
88 % {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
89 % Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
90 % Digits \0\1\2\3\4\5\6\7\8\9
91 % Exclamation \! Double quote \" Hash (number) \#
92 % Dollar \$ Percent \% Ampersand \&
93 % Acute accent \' Left paren \( Right paren \)
94 % Asterisk \* Plus \+ Comma \,
95 % Minus \- Point \. Solidus \/
96 % Colon \: Semicolon \; Less than \<
97 % Equals \= Greater than \> Question mark \?
98 % Commercial at \@ Left bracket \[ Backslash \\
99 % Right bracket \] Circumflex \^ Underscore \_
100 % Grave accent \` Left brace \{ Vertical bar \|
101 % Right brace \} Tilde \~}
102 %
103 %
104 % \changes{}{1997/09/02}{improved column balancing}
105 % \changes{}{1997/09/03}{float control for \cs{@colroom} setting}
106 % \changes{}{1997/09/04}{improved \cs{@colroom} setting}
107 % \changes{}{1997/09/05}{checking for \cs{@viper} and \cs{hold@viper}}
108 % \changes{}{1997/09/09}{compatibility with flushend.sty}
109 % \changes{}{1997/09/22}{improved \cs{output} ir \cs{@specialoutput}}
110 % \changes{}{1997/10/01}{improved \cs{output} ir \cs{@addviper}}
111 % \changes{}{1998/10/23}{pakeistas koloneliu sujungimas}
112 % \changes{}{2000/01/18}{pakeistas \cs{@outputdblcol}}
113 % \changes{}{2002/06/11}{added options unskipbreak and autobase}
114 % \changes{v1.4}{2012/05/29}{Converted to DTX file}
115 % \changes{v2.0}{2021/10/04}{rewrite with new balance algorithm and options}
116 % \changes{v2.4}{2025/01/29}{bugfix version with improved funcionality}
117 % \changes{v2.5}{2025/06/18}{adapt to the latest latex kernel}
118 % \changes{v2.6}{2025/07/14}{fix compatibility with the latest LaTeX kernel}
119 % \changes{v2.7}{2025/10/13}{bugfix version}
120 %
121 % \DoNotIndex{\newcommand,\newenvironment}
122 %
123 % \providecommand*{\url}{\texttt}
124 % \GetFileInfo{cuted.dtx}
125 % \title{The \textsf{cuted} package}
126 % \author{Sigitas Tolu\v{s}is\\ \url{[email protected]}}
127 % \date{\fileversion~from \filedate}
128 %
129 % \maketitle
130 %
131 % \section{Introduction}
132 %
133 % It is denoted to place some material in full-width at any place
134 % on double column page (|\twocolumn| mode) The part of material
135 % can be placed on the next page. The existing text is placed
136 % under inserted material in two columns (it is reformatted).
137 %
138 % Another usage is to combine the |onecolumn| and |twocolumn|
139 % typesetting in the same document using commands:
140 % \cs{switchonecolumn} and \cs{switchtwocolumn}.
141 %
142 % \section{Usage}
143 %
144 % \DescribeMacro{strip}
145 % Provides new environment:
146 % \begin{verbatim}
147 % \begin{strip}
148 % <wide onecolumn material>
149 % \end{strip}
150 % \end{verbatim}
151 % Puts |\vbox|\marg{wide onecolumn material} in full-width on
152 % double-column page.
153 %
154 % \medskip
155 % It can be problems with floats and footnotes. In the case of
156 % problems with footnotes it is possible to correct the situation
157 % using commands |\footnotemark| and |\footnotetext|.
158 %
159 % \medskip
160 % \DescribeMacro{preCutedStrip}\marg{tokens}
161 % \\\noindent Before the strip |\stripsep| glue and |\the\preCutedStrip| token list \meta{tokens} are added.
162 %
163 % \medskip
164 % \DescribeMacro{postCutedStrip}\marg{tokens}
165 % \\\noindent After the strip |\the\postCutedStrip| token list \meta{tokens} and |\stripsep| glue are added.
166 %
167 % \medskip
168 % \DescribeMacro{stripsep}
169 % By default: |\stripsep=15pt plus2pt minus 2pt|.
170 %
171 % \medskip
172 % \DescribeMacro{\oldcolsbreak}
173 % \marg{adds}
174 % \\\noindent Adds \meta{adds} in place of original column break if strip is placed
175 % on the right column. Seems, it should be unnecessary as current version
176 % uses |pagediscards| dimensions to restore original vertical skip.
177 %
178 % \newpage
179 %
180 % \DescribeMacro{\switchonecolumn}
181 % \\\noindent It starts with onecolumn typesetting from the current spot on the page.
182 %
183 % \DescribeMacro{\switchtwocolumn}
184 % \\\noindent It starts with twocolumn typesetting from the current spot on the page
185 %
186 % \subsection{Package options}
187 %
188 % \begin{description}
189 %
190 % \item[\meta{|spread|}]
191 % \texttt{[default]} It enables columns spreading trying to balance.
192 %
193 % \item[\meta{|nospread|}]
194 % It disables columns spreading trying to balance.
195 %
196 % \item[\meta{|shrink|}]
197 % \texttt{[default]} It enables columns shrinking trying to balance.
198 %
199 % \item[\meta{|noshrink|}]
200 % It disables columns shrinking trying to balance.
201 %
202 % \medskip
203 % \textit{Similiar options exist for single column separatly}:
204 %
205 % |lspread|, |nolspread|, |lshrink|, |nolshrink| -- for left column
206 %
207 % |rspread|, |norspread|, |rshrink|, |norshrink| -- for right column
208 %
209 % \item[\meta{|debug|}]
210 % Adds rules to the bottom of columns (just for debugging)
211 % and some additional log info.
212 %
213 % \item[\meta{|nodebug|}]
214 % \texttt{[default]} Skips putting debuging lines and additional info.
215 %
216 % \end{description}
217 %
218 % \StopEventually{}
219 %
220 % \section{Implementation}
221 %
222 % \iffalse
223 %<*package>
224 % \fi
225 %
226 %/*% \begin{macrocode}*/
227 % \begin{macrocode}
228 %
229
230 \newif\if@kernel@version@MMXXV
231 \@ifundefined{@makespecialcolbox}{\@kernel@version@MMXXVtrue}{}
232
233 \newif\if@right@column@spread \@right@column@spreadtrue
234 \newif\if@right@column@shrink \@right@column@shrinktrue
235 \newif\if@left@column@spread \@left@column@spreadtrue
236 \newif\if@left@column@shrink \@left@column@shrinktrue
237 \newif\ifcuted@@debug \cuted@@debugfalse
238
239 \DeclareOption{spread}{%
240 \global\@left@column@spreadtrue
241 \global\@right@column@spreadtrue
242 }
243 \DeclareOption{nospread}{%
244 \global\@left@column@spreadfalse
245 \global\@right@column@spreadfalse
246 }
247 \DeclareOption{lspread}{\global\@left@column@spreadtrue}
248 \DeclareOption{nolspread}{\global\@left@column@spreadfalse}
249 \DeclareOption{rspread}{\global\@right@column@spreadtrue}
250 \DeclareOption{norspread}{\global\@right@column@spreadfalse}
251 \DeclareOption{shrink}{%
252 \global\@left@column@shrinktrue
253 \global\@right@column@shrinktrue
254 }
255 \DeclareOption{noshrink}{%
256 \global\@left@column@shrinkfalse
257 \global\@right@column@shrinkfalse
258 }
259 \DeclareOption{lshrink}{\global\@left@column@shrinktrue}
260 \DeclareOption{nolshrink}{\global\@left@column@shrinkfalse}
261 \DeclareOption{rshrink}{\global\@right@column@shrinktrue}
262 \DeclareOption{norshrink}{\global\@right@column@shrinkfalse}
263 \DeclareOption{debug}{\global\cuted@@debugtrue}
264 \DeclareOption{nodebug}{\global\cutted@@debugfalse}
265 \ProcessOptions
266
267 \newif\if@lastviper \@lastviperfalse
268 \newtoks\At@ViperColsBreak \At@ViperColsBreak{}
269 \newtoks\preCutedStrip \preCutedStrip{}
270 \newtoks\postCutedStrip \postCutedStrip{}
271 \newbox\cuted@@tempbox@a
272 \newbox\cuted@@tempbox@c
273 \newbox\cuted@@tempbox@var
274 \@ifundefined{hold@viper}{\newbox\hold@viper}{}
275 \@ifundefined{@viper}{\newbox\@viper}{}
276 \newbox\cuted@@varbox@a
277 \newbox\cuted@@varbox@c
278 \newdimen\cuted@@tempdim@spread
279 \newdimen\cuted@@tempdim@a
280 \newdimen\cuted@@tempdim@b
281 \newdimen\ht@hold@viper
282 \newdimen\ht@viper
283 \newdimen\var@@pagediscards@ht \var@@pagediscards@ht=\z@
284 \@ifundefined{stripsep}{\newskip\stripsep \stripsep 15\p@ plus 2\p@ minus 2\p@}{}
285 \newcount\viper@penalty
286 \mathchardef\@Mv=10005
287 \def\cuted@@column@badness{101}
288 \def\cuted@@page@rule{\z@}
289 \savingvdiscards=\@ne
290
291 \def\cuted@@wlog@debug#1{\ifcuted@@debug \wlog{#1}\fi}
292
293 \def\set@split@topskip@to#1{%
294 \splittopskip=#1\relax
295 \vfuzz=\maxdimen
296 \vbadness=\maxdimen
297 }
298
299 \def\oldcolsbreak#1{\global\At@ViperColsBreak{#1}}
300
301 \def\on@stripcols@break{%
302 %% adds original vertical page break skip
303 %%
304 \ifdim\strip@page@discards=\z@
305 \else
306 \vskip\strip@page@discards
307 \fi
308 }
309 \gdef\cuted@makecol{%
310 \if@kernel@version@MMXXV
311 \UseHook {build/column/before}%
312 \fi
313 \ifvoid\footins
314 \setbox\@outputbox \box\@cclv
315 \if@kernel@version@MMXXV
316 \@outputbox@removebskip
317 \fi
318 \else
319 \setbox\@outputbox \vbox {%
320 \boxmaxdepth \@maxdepth
321 \unvbox \@cclv
322 \vskip \skip\footins
323 \color@begingroup
324 \normalcolor
325 \footnoterule
326 \unvbox \footins
327 \color@endgroup
328 }%
329 \fi
330 \let\@elt\relax
331 \xdef\@freelist{\@freelist\@midlist}%
332 \global \let \@midlist \@empty
333 \if@kernel@version@MMXXV
334 \UseSocket {build/column/outputbox}%
335 \else
336 \@combinefloats
337 \fi
338 \ifvbox\@kludgeins
339 \if@kernel@version@MMXXV
340 \@make@specialcolbox
341 \else
342 \@makespecialcolbox
343 \fi
344 \else
345 \setbox\@outputbox \vbox to\@colht{%
346 \@texttop
347 \if@kernel@version@MMXXV
348 \@outputbox@depth \dp\@outputbox
349 \unvbox \@outputbox
350 \vskip -\@outputbox@depth
351 \else
352 \dimen@ \dp\@outputbox
353 \unvbox \@outputbox
354 \vskip -\dimen@
355 \fi
356 \@textbottom
357 }%
358 \fi
359 \global \maxdepth \@maxdepth
360 \if@kernel@version@MMXXV
361 \UseHook {build/column/after}%
362 \fi
363 }
364 \@ifundefined{normal@makecol}
365 {\let\@makecol\cuted@makecol}
366 {\let\normal@makecol\cuted@makecol}
367
368 \def\@outputdblcol{%
369 \if@firstcolumn
370 \global\@firstcolumnfalse
371 \global\setbox\@leftcolumn\copy\@outputbox
372 \if@kernel@version@MMXXV
373 \splitmaxdepth\maxdimen
374 \vbadness\maxdimen
375 \setbox\@outputbox\vbox{\unvbox\@outputbox\unskip}%
376 \setbox\@outputbox\vsplit\@outputbox to\maxdimen
377 \toks@\expandafter{\topmark}%
378 \xdef\@firstcoltopmark{\the\toks@}%
379 \toks@\expandafter{\splitfirstmark}%
380 \xdef\@firstcolfirstmark{\the\toks@}%
381 \ifx\@firstcolfirstmark\@empty
382 \global\let\@setmarks\relax
383 \else
384 \gdef\@setmarks{%
385 \let\firstmark\@firstcolfirstmark
386 \let\topmark\@firstcoltopmark
387 }%
388 \fi
389 \fi
390 \else
391 \global\@firstcolumntrue
392 \setbox\@outputbox\vbox{%
393 \hb@xt@\textwidth{%
394 \hb@xt@\columnwidth{\box\@leftcolumn \hss}%
395 \hfil
396 {\normalcolor\vrule \@width\columnseprule}%
397 \hfil
398 \hb@xt@\columnwidth{\box\@outputbox \hss}%
399 }%
400 }%
401 \ifvoid\hold@viper
402 \else
403 \setbox\@outputbox\vbox to\textheight{%
404 \box\hold@viper
405 \ifvoid\@viper
406 \box\@outputbox
407 \fi
408 \vss
409 }%
410 \fi
411 \@combinedblfloats
412 \if@kernel@version@MMXXV
413 \@setmarks
414 \fi
415 \@outputpage
416 \begingroup
417 \@dblfloatplacement
418 \@startdblcolumn
419 \@whilesw\if@fcolmade \fi
420 {\@outputpage \@startdblcolumn}%
421 \ifvoid\@viper
422 \else
423 \global\setbox\@viper\vbox{%
424 \vskip-\stripsep
425 \unvbox\@viper
426 }%
427 \@viperoutput
428 \fi
429 \endgroup
430 \fi
431 }
432 \newdimen\strip@page@discards \strip@page@discards=\z@
433 \def\strip{%
434 \if@twocolumn
435 \ifinner
436 \@parmoderr
437 \viper@penalty\z@
438 \else
439 \viper@penalty=-\@Mv
440 \fi
441 \bgroup
442 \expandafter\setbox\expandafter\z@\expandafter\vbox\expandafter{\pagediscards}%
443 \global\strip@page@discards=\dimexpr\ht\z@+\dp\z@\relax
444 \egroup
445 \global\setbox\@viper\vbox\bgroup
446 \hsize\textwidth
447 \@parboxrestore
448 \col@number=\@ne
449 \vrule height\topskip width\z@ depth\z@
450 \else
451 \@latex@error{strip used only in twocolumn mode!}\@ehb
452 \fi
453 }
454 \def\endstrip{%
455 \if@twocolumn
456 \egroup
457 \ifnum\viper@penalty<-\@Mii
458 \penalty-\@Miv
459 \ifvmode
460 \@tempdima\prevdepth
461 \vbox{}%
462 \prevdepth\@tempdima
463 \penalty-\@Mv\relax
464 \else
465 \par
466 \penalty-\@Mv
467 \ifnum\pagetotal>\z@
468 \quitvmode
469 \fi
470 \fi
471 \fi
472 \else
473 \@latex@error{strip used only in twocolumn mode!}\@ehb
474 \fi
475 }
476 \gdef\@viperoutput{%
477 \global\setbox\@holdpg\vbox{%
478 \unvbox\@holdpg
479 \unvbox\@cclv
480 \setbox\@tempboxa\lastbox
481 \unskip
482 }%
483 \@pagedp=\dp\@holdpg
484 \@pageht=\ht\@holdpg
485 \ifvoid\@viper
486 \else
487 \advance\@pageht by\@pagedp
488 \ifvoid\footins
489 \else
490 \advance\@pageht by\ht\footins
491 \advance\@pageht by\skip\footins
492 \advance\@pageht by\dp\footins
493 \fi
494 \ifvbox\@kludgeins
495 \ifdim\wd\@kludgeins=\z@
496 \advance\@pageht by\ht\@kludgeins
497 \fi
498 \fi
499 \@reinserts
500 \@addviper
501 \fi
502 }
503 \g@addto@macro\@kernel@after@enddocument{%
504 \ifvoid\hold@viper
505 \else
506 \ifdim\pagetotal>\z@
507 \else
508 \null
509 \fi
510 \fi
511 }
512 \def\@doclearpage{%
513 \ifvoid\footins
514 \ifvbox\@kludgeins
515 {\setbox \@tempboxa \box \@kludgeins}%
516 \fi
517 \setbox\@tempboxa\vsplit\@cclv to\z@ \unvbox\@tempboxa
518 \setbox\@tempboxa\box\@cclv
519 \xdef\@deferlist{\@toplist\@botlist\@deferlist}%
520 \global \let \@toplist \@empty
521 \global \let \@botlist \@empty
522 \global \@colroom \@colht
523 \ifx \@currlist\@empty
524 \else
525 \@latex@error{Float(s) lost}\@ehb
526 \global \let \@currlist \@empty
527 \fi
528 \@makefcolumn\@deferlist
529 \@whilesw\if@fcolmade \fi{\@opcol\@makefcolumn\@deferlist}%
530 \if@twocolumn
531 \if@firstcolumn
532 \@ifundefined{@dblbotlist}{%
533 \xdef\@deferlist{\@dbltoplist\@deferlist}%
534 \global \let \@dbltoplist \@empty
535 }{%
536 \xdef\@deferlist{\@dbltoplist\@dblbotlist\@deferlist}%
537 \global \let \@dbltoplist \@empty
538 \global \let \@dblbotlist \@empty
539 }%
540 \global \@colht \textheight
541 \begingroup
542 \@dblfloatplacement
543 \@makefcolumn\@deferlist
544 \if@fcolmade
545 \@whilesw\if@fcolmade\fi{\@outputpage\@makefcolumn\@deferlist}%
546 \else
547 \ifvoid\hold@viper
548 \else
549 \setbox\@cclv\vbox{\box\hold@viper\box\@cclv\vfil}%
550 \@makecol\@opcol
551 \clearpage
552 \fi
553 \fi
554 \endgroup
555 \else
556 \vbox{}\clearpage
557 \fi
558 \fi
559 \ifx\@deferlist\@empty \else\clearpage \fi
560 \else
561 \setbox\@cclv\vbox{\box\@cclv\vfil}%
562 \@makecol\@opcol
563 \clearpage
564 \fi
565 }%
566 \def\dbl@xtryfc #1{%
567 \@tempcnta \count #1%
568 \divide\@tempcnta\@xxxii
569 \multiply\@tempcnta\@xxxii
570 \@bitor \@tempcnta \@failedlist
571 \@testfalse
572 \def\f@depth{1sp}%
573 \@testwrongwidth #1%
574 \if@test
575 \else
576 \ifdim \ht #1>\@colht
577 \@testtrue
578 \fi
579 \fi
580 \if@test
581 \@cons\@failedlist #1%
582 \else
583 \@tempcnta \count#1%
584 \divide \@tempcnta \tw@\relax
585 \ifodd \@tempcnta
586 \@cons\@flsucceed #1%
587 \else
588 \@ifundefined{@dblbotlist}{}{%
589 \@tempcnta \count#1%
590 \divide \@tempcnta 4\relax
591 \ifodd \@tempcnta
592 \@cons\@dblbotlist #1%
593 \else
594 \@cons\@failedlist #1%
595 \fi
596 }%
597 \fi
598 \fi}%
599 \gdef\@specialoutput{%
600 \ifnum\outputpenalty>-\@Mii
601 \@doclearpage
602 \else
603 \ifnum\outputpenalty<-\@Miii
604 \ifnum\outputpenalty<-\@MM \deadcycles \z@ \fi
605 \ifnum\outputpenalty=-\@Mv
606 \if@twocolumn
607 \@viperoutput
608 \ifnum\outputpenalty<\z@
609 \if@nobreak
610 \else
611 \addpenalty \interlinepenalty
612 \fi
613 \fi
614 \else
615 \@next\@currbox\@freelist{}{}%
616 \global\setbox\@currbox\vbox{}%
617 \ifx\@toplist\@empty
618 \global\setbox\@currbox\vbox{%
619 \unvbox\@cclv
620 \vskip-\dbltextfloatsep
621 }%
622 \else
623 \begingroup
624 \def\@elt##1{%
625 \global\setbox\@currbox\vbox{%
626 \unvbox\@currbox
627 \unvbox##1\vskip\floatsep
628 }%
629 }\@toplist
630 \global\setbox\@currbox\vbox{%
631 \unvbox\@currbox
632 \unskip
633 }%
634 \endgroup
635 \begingroup\let\@elt\relax\xdef\@freelist{\@freelist\@toplist}\endgroup
636 \global\setbox\@currbox\vbox{%
637 \unvbox\@currbox
638 \vskip\textfloatsep
639 \unvbox\@cclv
640 \vskip-\dbltextfloatsep
641 }%
642 \fi
643 \global\dp\@currbox1sp %
644 \global \count\@currbox \tw@
645 \global \advance \@dbltopnum \m@ne
646 \@cons \@dbltoplist \@currbox
647 \@inserttrue
648 \global\let\@toplist\@empty
649 \global\vsize\textheight
650 \dbl@floats@ht\@dbltoplist
651 \global\@colht\vsize
652 \global\@colroom\@colht
653 \ifx\@deferlist\@empty
654 \else
655 \xdef\@trylist{\@deferlist}%
656 \global \let \@failedlist \@empty
657 \global \let \@flsucceed \@empty
658 \begingroup
659 \let \@elt \dbl@xtryfc \@trylist
660 \endgroup
661 \ifx\@flsucceed\@empty
662 \else
663 \let\@elt\relax
664 \xdef\@dbltoplist{\@flsucceed\@dbltoplist}%
665 \fi
666 \xdef\@deferlist{\@failedlist}%
667 \fi
668 \global\vsize\textheight
669 \ifx\@dbltoplist\@empty
670 \else
671 \dbl@floats@ht\@dbltoplist
672 \fi
673 \@ifundefined{@dblbotlist}{}{%
674 \ifx\@dblbotlist\@empty
675 \else
676 \ifx\@dblbotlist\@empty
677 \else
678 \dbl@floats@ht\@dblbotlist
679 \fi
680 \fi
681 }%
682 \global\@colht\vsize
683 \global\@colroom\@colht
684 \fi
685 \else
686 \global\setbox\@holdpg\vbox{\unvbox\@cclv}%
687 \fi
688 \else
689 \global\setbox\@holdpg\vbox{%
690 \unvbox\@holdpg
691 \unvbox\@cclv
692 \setbox\@tempboxa\lastbox
693 \unskip
694 }%
695 \@pagedp=\dp\@holdpg
696 \@pageht=\ht\@holdpg
697 \unvbox\@holdpg
698 \@next\@currbox\@currlist{%
699 \ifnum\count\@currbox>\z@
700 \advance \@pageht \@pagedp
701 \ifvoid\footins
702 \else
703 \advance\@pageht by\ht\footins
704 \advance\@pageht by\skip\footins
705 \advance\@pageht by\dp\footins
706 \fi
707 \ifvbox\@kludgeins
708 \ifdim\wd\@kludgeins=\z@
709 \advance\@pageht by\ht\@kludgeins
710 \fi
711 \fi
712 \@reinserts
713 \@addtocurcol
714 \else
715 \@reinserts
716 \@addmarginpar
717 \fi
718 }\@latexbug
719 \ifnum\outputpenalty<\z@
720 \if@nobreak
721 \else
722 \addpenalty \interlinepenalty
723 \fi
724 \fi
725 \fi
726 \fi
727 }
728 \def\@addviper{%
729 \@insertfalse
730 \def\var@@thecol@num{2}%
731 \if@firstcolumn
732 \def\var@@thecol@num{1}%
733 \@reqcolroom=.5\@pageht
734 \ht@viper=\@reqcolroom
735 \advance\@reqcolroom by\ht\@viper
736 \advance\@reqcolroom by\stripsep
737 \else
738 \@reqcolroom=\@colht
739 \advance\@reqcolroom by\@pageht
740 \[email protected]\@reqcolroom
741 \@reqcolroom=\ht@viper
742 \advance\@reqcolroom by\ht\@viper
743 \advance\@reqcolroom by\stripsep
744 \global\setbox\@holdpg\vbox{%
745 \setbox\cuted@@tempbox@a\vbox{%
746 \aftergroup\unvbox
747 \unvcopy\@leftcolumn
748 \unskip\unkern\unpenalty
749 \setbox\@tempboxa\lastbox
750 \ifdim\dimexpr\ht\@tempboxa+\wd\@tempboxa+\dp\@tempboxa>\z@
751 %% keeps lastbox
752 \aftergroup\@leftcolumn
753 \else
754 %% removes lastbox
755 \aftergroup\cuted@@tempbox@a
756 \fi
757 }%
758 \unskip\unkern\unpenalty
759 \on@stripcols@break
760 \the\At@ViperColsBreak
761 \setbox\@tempboxa\vbox{\null\unvbox\@holdpg}%
762 \set@split@topskip@to\z@
763 \setbox\z@\vsplit\@tempboxa to\p@ \unvbox\@tempboxa %% removes topskip
764 }%
765 \global\At@ViperColsBreak{}%
766 \ht@viper=.5\ht\@holdpg
767 \ifdim\ht@viper>\@colht
768 \ht@viper=\@colht
769 \fi
770 \fi
771 %%
772 %% calculations for breaking
773 %%
774 \ifvoid\hold@viper
775 \ht@hold@viper=\z@
776 \else
777 \ht@hold@viper=\ht\hold@viper
778 \fi
779 \cuted@@tempdim@b\ht@viper
780 \set@split@topskip@to\topskip
781 \loop
782 \xdef\saved@tempdimb{\the\cuted@@tempdim@b}%
783 \setbox\cuted@@varbox@a\copy\@holdpg
784 \setbox\cuted@@tempbox@a\vsplit\cuted@@varbox@a to\cuted@@tempdim@b
785 %% set leftcolumn boxes
786 \setbox\cuted@@tempbox@c\vbox{\unvbox\cuted@@tempbox@a}%
787 \setbox\cuted@@tempbox@a\vbox to\cuted@@tempdim@b{\unvcopy\cuted@@tempbox@c}%
788 \xdef\var@@leftcolumn@badness{\the\badness}%
789 %% set rightcolumn boxes
790 \setbox\cuted@@varbox@c\vbox{\unvbox\cuted@@varbox@a}%
791 \setbox\cuted@@varbox@a\vbox to\cuted@@tempdim@b{\unvcopy\cuted@@varbox@c}%
792 \xdef\var@@rightcolumn@badness{\the\badness}%
793 %% analyzing split goodness
794 \cuted@@tempdim@spread=\ht\cuted@@tempbox@c
795 \advance\cuted@@tempdim@spread by\dp\cuted@@tempbox@c
796 \advance\cuted@@tempdim@spread by-\ht\cuted@@varbox@c
797 \advance\cuted@@tempdim@spread by-\dp\cuted@@varbox@c
798 \cuted@@wlog@debug{CUTED [-----]%
799 ^^JLeft: \the\ht\cuted@@tempbox@c
800 +\the\dp\cuted@@tempbox@c\space/\var@@leftcolumn@badness
801 ^^JRight: \the\ht\cuted@@varbox@c
802 +\the\dp\cuted@@varbox@c\space/\var@@rightcolumn@badness
803 ^^JSplit: \the\cuted@@tempdim@b
804 ^^JExtra height: \the\cuted@@tempdim@spread
805 }%
806 \ifnum\var@@leftcolumn@badness<\cuted@@column@badness
807 \ifnum\var@@rightcolumn@badness<\cuted@@column@badness
808 \cuted@@tempdim@spread=\z@
809 \fi
810 \fi
811 \ifdim\cuted@@tempdim@spread<\z@
812 \if@left@column@spread
813 \if@right@column@shrink
814 \ifdim\dimexpr\cuted@@tempdim@spread+\pageshrink>\z@
815 \cuted@@tempdim@a=\dimexpr\ht\cuted@@[email protected]\cuted@@tempdim@spread\relax
816 \else
817 \cuted@@tempdim@a=-\dimexpr\cuted@@tempdim@spread+.5\pageshrink\relax
818 \fi
819 \setbox\cuted@@varbox@a\vbox to\cuted@@tempdim@a{\unvcopy\cuted@@tempbox@c}%
820 \ifnum\badness<\cuted@@column@badness
821 \cuted@@tempdim@b=\cuted@@tempdim@a
822 \cuted@@tempdim@spread=\z@
823 \fi
824 \cuted@@wlog@debug{CUTED [leftcolumn badness]: \number\badness\space on \the\cuted@@tempdim@a}%
825 \setbox\cuted@@varbox@a\vbox to\cuted@@tempdim@a{\unvcopy\cuted@@varbox@c}%
826 \cuted@@wlog@debug{CUTED [rightcolumn badness]: \number\badness\space on \the\cuted@@tempdim@a}%
827 \else
828 \setbox\cuted@@varbox@a\vbox to\ht\cuted@@varbox@c{%
829 \unvcopy\cuted@@tempbox@c
830 }%
831 \ifnum\badness<\cuted@@column@badness
832 \@tempdimb=\ht\cuted@@varbox@c
833 \cuted@@tempdim@spread=\z@
834 \fi
835 \cuted@@wlog@debug{CUTED [leftcolumn badness]: \number\badness on \the\ht\cuted@@varbox@c}%
836 \setbox\cuted@@varbox@a\vbox to\ht\cuted@@varbox@c{%
837 \unvcopy\cuted@@varbox@c
838 }%
839 \cuted@@wlog@debug{CUTED [rightcolumn badness]: \number\badness on \the\ht\cuted@@varbox@c}%
840 \fi
841 \else
842 \if@right@column@shrink
843 \ifdim\dimexpr\cuted@@tempdim@spread+\pageshrink<\z@
844 \else
845 \cuted@@tempdim@b=\ht\cuted@@tempbox@c
846 \cuted@@tempdim@spread=\z@
847 \fi
848 \fi
849 \fi
850 \else
851 \ifdim\cuted@@tempdim@spread>\z@
852 \ifdim\dimexpr\@tempdimb+\p@\relax>\@colht
853 \cuted@@tempdim@b=\@colht
854 \cuted@@tempdim@spread=\z@
855 \fi
856 \fi
857 \fi
858 \ifdim\cuted@@tempdim@spread<\z@
859 \advance\cuted@@tempdim@b 1\p@
860 \repeat
861 \wlog{CUTED [- LAST -]%
862 ^^JExtra skip:\the\cuted@@tempdim@spread
863 ^^JLeft:\the\ht\cuted@@tempbox@c/\the\dp\cuted@@tempbox@c
864 ^^JRight:\the\ht\cuted@@varbox@c/\the\dp\cuted@@varbox@c
865 ^^JSplit: \saved@tempdimb
866 ^^JOutput:\the\cuted@@tempdim@b
867 ^^JPageshrink: \the\pageshrink
868 ^^JPagestretch: \the\pagestretch
869 ^^J@colht:\the\@colht
870 }%
871 %%
872 %% final construction of the cuted page above strip
873 %%
874 \setbox\cuted@@tempbox@c\vsplit\@holdpg to\saved@tempdimb
875 \setbox\cuted@@tempbox@a\vbox to\cuted@@tempdim@b{%
876 \cuted@@tempdim@a=\dimexpr
877 \cuted@@tempdim@b-\ht\cuted@@tempbox@c
878 \relax
879 \cuted@@tempdim@spread=\dp\cuted@@tempbox@c
880 \unvbox\cuted@@tempbox@c
881 \ifdim\cuted@@tempdim@spread>\dp\strutbox
882 \else
883 \vskip-\cuted@@tempdim@spread
884 \fi
885 \prevdepth\z@
886 \hrule\@height\cuted@@page@rule width\textwidth
887 \vskip-\cuted@@page@rule
888 \ifdim\cuted@@tempdim@a>\z@
889 \if@left@column@spread
890 \else
891 \vss
892 \fi
893 \else
894 \ifdim\cuted@@tempdim@a<\z@
895 \if@left@column@shrink
896 \else
897 \vss
898 \fi
899 \fi
900 \fi
901 }%
902 \wlog{CUTED [output]: \the\cuted@@tempdim@b
903 ^^JCUTED [leftcolumn badness]: \number\badness
904 }%
905 \setbox\cuted@@varbox@a\vbox to\cuted@@tempdim@b{%
906 \cuted@@tempdim@a=\dimexpr
907 \cuted@@tempdim@b-\ht\@holdpg
908 \relax
909 \unvbox\@holdpg
910 \ifdim\cuted@@tempdim@a>\z@
911 \if@right@column@spread
912 \else
913 \vss
914 \fi
915 \else
916 \ifdim\cuted@@tempdim@a<\z@
917 \if@right@column@shrink
918 \else
919 \vss
920 \fi
921 \fi
922 \fi
923 }%
924 \ht@viper=\cuted@@tempdim@b
925 \wlog{CUTED [rightcolumn badness]: \number\badness}%
926 \setbox\cuted@@tempbox@var\vbox{%
927 \hb@xt@\textwidth{%
928 \hb@xt@\columnwidth{%
929 \vbox to\ht@viper{\box\cuted@@tempbox@a\vss}%
930 \hss
931 }%
932 \hfil
933 {\normalcolor\vrule \@width\columnseprule}%
934 \hfil
935 \hb@xt@\columnwidth{%
936 \vbox to\ht@viper{\box\cuted@@varbox@a\vss}%
937 \hss
938 }%
939 }%
940 \vss
941 }%
942 %%
943 %% finalize cuted page
944 %%
945 \csname hold@viper@hook\endcsname
946 \ifvoid\hold@viper
947 \global\setbox\hold@viper\vbox{%
948 \unvbox\cuted@@tempbox@var
949 \penalty\interlinepenalty
950 \vskip\stripsep
951 \the\preCutedStrip
952 \ifnum\outputpenalty<-\@Mii
953 \vskip -\parskip
954 \fi
955 \outputpenalty\z@
956 }%
957 \else
958 \global\setbox\hold@viper\vbox{%
959 \unvbox\hold@viper
960 \unvbox\cuted@@tempbox@var
961 \penalty\interlinepenalty
962 \vskip\stripsep
963 \the\preCutedStrip
964 \ifnum\outputpenalty<-\@Mii
965 \vskip -\parskip
966 \fi
967 \outputpenalty\z@
968 }%
969 \fi
970 \ifdim\@colht>\@reqcolroom
971 \csname end@viper@hook\endcsname
972 \global\setbox\hold@viper\vbox{%
973 \unvbox\hold@viper
974 \box\@viper
975 \penalty\interlinepenalty
976 \the\postCutedStrip
977 \vskip\stripsep
978 \ifnum\outputpenalty<-\@Mii
979 \vskip -\parskip
980 \fi
981 \outputpenalty\z@
982 }%
983 \@inserttrue
984 \global\@firstcolumntrue
985 \advance\ht@hold@viper by-\ht\hold@viper
986 \global\advance\@colht by\ht@hold@viper
987 \ifdim\@colht<2.5\baselineskip
988 \@latex@warning@no@line {Optional argument of \noexpand\twocolumn
989 too tall on page \thepage (\var@@thecol@num column)}%
990 \@emptycol
991 \if@firstcolumn
992 \else
993 \@emptycol
994 \fi
995 \global\@lastvipertrue
996 \else
997 \global\vsize\@colht
998 \global\@colroom\@colht
999 \check@floats\cuted@@tempdim@a
1000 \ifdim\cuted@@tempdim@a>\z@
1001 \global\advance\@colroom by-\cuted@@tempdim@a
1002 \fi
1003 \ifdim\@colroom<\z@
1004 \global\@colroom1\p@
1005 \ifdim\cuted@@tempdim@a>\@colht
1006 \@latex@warning@no@line{TOP and/or BOT FLOAT's
1007 to large on \thepage (\var@@thecol@num column)}%
1008 \fi
1009 \@emptycol
1010 \if@firstcolumn
1011 \else
1012 \@emptycol
1013 \fi
1014 \global\@lastvipertrue
1015 \fi
1016 \fi
1017 \fi
1018 \if@insert
1019 \else
1020 \advance\ht@hold@viper by-\ht\hold@viper
1021 \global\advance\@colht by\ht@hold@viper
1022 \global\setbox\hold@viper\vbox{%
1023 \unvbox\hold@viper
1024 \set@split@topskip@to{\z@ plus2\p@}%
1025 \setbox\@tempboxa\vsplit\@viper to\@colht
1026 \csname split@viper@hook\endcsname
1027 \box\@tempboxa
1028 \vss
1029 }%
1030 \vbox{}%
1031 \global\@firstcolumnfalse
1032 \newpage
1033 \fi
1034 }
1035 \def\switchonecolumn{%
1036 \if@twocolumn
1037 \bgroup
1038 \stripsep\z@\strip\par\vskip-\topskip\endstrip%
1039 \egroup
1040 \global\@colht\textheight
1041 \global\vsize\@colht
1042 \@next\@currbox\@freelist{}{}%
1043 \ifx\@dbltoplist\@empty
1044 \global\setbox\@currbox\vbox{%
1045 \unvbox\hold@viper
1046 \vskip-\textfloatsep
1047 }%
1048 \xdef\@toplist{\@elt\@currbox}%
1049 \global\advance\vsize-\ht\@currbox
1050 \global\advance\vsize-\textfloatsep
1051 \else
1052 \global\setbox\@currbox\vbox{%
1053 \vskip\topskip
1054 \unvbox\hold@viper
1055 \vskip-\textfloatsep
1056 }%
1057 \@cons\@dbltoplist\@currbox
1058 \dbl@floats@ht\@dbltoplist
1059 \xdef\@toplist{\@dbltoplist}%
1060 \global\let\@dbltoplist\@empty
1061 \global\advance\vsize\dbltextfloatsep
1062 \global\advance\vsize-\textfloatsep
1063 \fi
1064 \@ifundefined{@dblbotlist}{}{%
1065 \ifx\@dblbotlist\@empty
1066 \else
1067 \dbl@floats@ht\@dblbotlist
1068 \xdef\@botlist{\@dblbotlist}%
1069 \global\let\@dblbotlist\@empty
1070 \global\advance\vsize\dbltextfloatsep
1071 \global\advance\vsize-\textfloatsep
1072 \fi
1073 }%
1074 \global\@colroom \vsize
1075 \global\columnwidth\textwidth
1076 \global\hsize\columnwidth
1077 \global\linewidth\columnwidth
1078 \global\@twocolumnfalse
1079 \col@number \@ne
1080 \@floatplacement
1081 \@noskipsectrue
1082 \fi
1083 }
1084 \def\dbl@floats@ht#1{%
1085 \begingroup
1086 \def \@elt ##1{%
1087 \global\advance\vsize-\ht##1%
1088 \global\advance\vsize-\dblfloatsep
1089 }%
1090 #1%
1091 \global\advance\vsize\dblfloatsep
1092 \global\advance\vsize-\dbltextfloatsep
1093 \endgroup
1094 }
1095 \def\switchtwocolumn{%
1096 \if@twocolumn
1097 \else
1098 \ifdim\dimexpr\@colht-\pagetotal\relax<2.5\baselineskip
1099 \ifdim\@colht>\pagetotal\relax
1100 \clearpage
1101 \else
1102 \par
1103 \penalty-\@Mv
1104 \fi
1105 \else
1106 \par
1107 \penalty-\@Mv
1108 \fi
1109 \global\columnwidth\textwidth
1110 \global\advance\columnwidth-\columnsep
1111 \global\divide\columnwidth\tw@
1112 \global\hsize\columnwidth
1113 \global\linewidth\columnwidth
1114 \global\@twocolumntrue
1115 \global\@firstcolumntrue
1116 \col@number \tw@
1117 \fi
1118 }
1119 \def\check@floats#1{%
1120 \begingroup
1121 \global#1\z@
1122 \def\@elt##1{%
1123 \setbox\@tempboxa\vbox{\unvcopy ##1\vskip\floatsep}%
1124 }%
1125 \ifx\@toplist\@empty
1126 \else
1127 \setbox\@tempboxa \vbox{}%
1128 \@toplist
1129 \setbox\@tempboxa\vbox{%
1130 \unvbox\@tempboxa
1131 \vskip -\floatsep
1132 \topfigrule
1133 \vskip \textfloatsep
1134 }%
1135 \global\advance#1 by\ht\@tempboxa
1136 \fi
1137 \ifx\@botlist\@empty
1138 \else
1139 \setbox\@tempboxa\vbox{%
1140 \vskip \textfloatsep
1141 \botfigrule
1142 }%
1143 \@botlist
1144 \global\advance#1 by-\floatsep
1145 \global\advance#1 by\ht\@tempboxa
1146 \fi
1147 \endgroup
1148 }
1149 \output{%
1150 \let\par\@@par
1151 \ifnum\outputpenalty<-\@M
1152 \@specialoutput
1153 \else
1154 \@makecol
1155 \@opcol
1156 \@startcolumn
1157 \@whilesw\if@fcolmade\fi
1158 {\@opcol \@startcolumn}%
1159 \fi
1160 \ifnum\outputpenalty>-\@Miv
1161 \ifdim\@colroom<1.5\baselineskip
1162 \ifdim\@colroom<\textheight
1163 \@latex@warning@no@line{%
1164 Text page \thepage\space contains only floats%
1165 }%
1166 \if@lastviper
1167 \else
1168 \@emptycol
1169 \fi
1170 \if@twocolumn
1171 \if@firstcolumn
1172 \else
1173 \@emptycol
1174 \fi
1175 \fi
1176 \global\@lastviperfalse
1177 \else
1178 \global\vsize\@colroom
1179 \fi
1180 \else
1181 \global\vsize\@colroom
1182 \fi
1183 \else
1184 \ifnum\outputpenalty<-\@Mv
1185 \global\vsize\maxdimen
1186 \else
1187 \global\vsize\@colroom
1188 \fi
1189 \fi
1190 }
1191 \ifcuted@@debug
1192 \xdef\cuted@@page@rule{.4\p@}
1193 \else
1194 \xdef\cuted@@page@rule{\z@}
1195 \fi
1196 % \end{macrocode}
1197 %
1198 % \iffalse
1199 %</package>
1200 % \fi
1201 %
1202 % \Finale