| 1 |
% \iffalse meta-comment/*% \end{macrocode}*/ |
| 2 |
% |
| 3 |
% Copyright (C) 2025 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 flushend.dtx and flushend.ins |
| 18 |
% and the derived filebase flushend.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 `flushend.sty', |
| 32 |
%% generated with the docstrip utility. |
| 33 |
%% |
| 34 |
%% The original source files were: |
| 35 |
%% |
| 36 |
%% flushend.dtx (with options: `package') |
| 37 |
%% |
| 38 |
\endpreamble |
| 39 |
\generate{\file{flushend.sty}{\from{flushend.dtx}{package}}} |
| 40 |
%</batchfile> |
| 41 |
%<batchfile>\endbatchfile |
| 42 |
%<*internal> |
| 43 |
\generate{\file{flushend.ins}{\from{flushend.dtx}{batchfile}}} |
| 44 |
\endgroup |
| 45 |
%</internal> |
| 46 |
%<*driver> |
| 47 |
\ProvidesFile{flushend.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: Balanced columns on last page in twocolumn mode. |
| 62 |
%% |
| 63 |
%</package> |
| 64 |
%<package>\NeedsTeXFormat{LaTeX2e}[2025/06/01] |
| 65 |
%<package>\ProvidesPackage{flushend} |
| 66 |
%<*package> |
| 67 |
[2025/06/18 v4.3 Balancing columns in twocolumn mode (ST)] |
| 68 |
%</package> |
| 69 |
% |
| 70 |
%<*driver> |
| 71 |
\documentclass{ltxdoc} |
| 72 |
\usepackage{flushend}[2021/10/04] |
| 73 |
\usepackage{geometry} |
| 74 |
\geometry{a4paper} |
| 75 |
\setlength\marginparwidth{5pc} |
| 76 |
\EnableCrossrefs |
| 77 |
\CodelineIndex |
| 78 |
%%\RecordChanges |
| 79 |
\OnlyDescription |
| 80 |
\begin{document} |
| 81 |
\DocInput{flushend.dtx} |
| 82 |
%%\PrintChanges |
| 83 |
%%\PrintIndex |
| 84 |
\end{document} |
| 85 |
%</driver> |
| 86 |
% \fi |
| 87 |
% |
| 88 |
% \CheckSum{2020} |
| 89 |
% |
| 90 |
% \CharacterTable |
| 91 |
% {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 |
| 92 |
% 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 |
| 93 |
% Digits \0\1\2\3\4\5\6\7\8\9 |
| 94 |
% Exclamation \! Double quote \" Hash (number) \# |
| 95 |
% Dollar \$ Percent \% Ampersand \& |
| 96 |
% Acute accent \' Left paren \( Right paren \) |
| 97 |
% Asterisk \* Plus \+ Comma \, |
| 98 |
% Minus \- Point \. Solidus \/ |
| 99 |
% Colon \: Semicolon \; Less than \< |
| 100 |
% Equals \= Greater than \> Question mark \? |
| 101 |
% Commercial at \@ Left bracket \[ Backslash \\ |
| 102 |
% Right bracket \] Circumflex \^ Underscore \_ |
| 103 |
% Grave accent \` Left brace \{ Vertical bar \| |
| 104 |
% Right brace \} Tilde \~} |
| 105 |
% |
| 106 |
% |
| 107 |
% \changes{v0.1}{1997/05/16}{first version} |
| 108 |
% \changes{v0.2}{1997/09/09}{support for compatibility with cuted.sty} |
| 109 |
% \changes{v1.0}{1997/10/01}{\string\vipersep changed to \string\stripsep for compatibility with cuted.sty} |
| 110 |
% \changes{v1.1}{2012/05/29}{Converted to DTX file} |
| 111 |
% \changes{v2.0}{2014/03/03}{rewritten with new balance algorithm} |
| 112 |
% \changes{v2.1}{2014/03/18}{Switched debug option off} |
| 113 |
% \changes{v2.2}{2014/04/24}{bugfix version: removing empty box at the right column end} |
| 114 |
% \changes{v3.0}{2015/04/08}{bugfix version and extra options: |
| 115 |
% ancient/modern, |
| 116 |
% spread/nospread, |
| 117 |
% removelastbox/keeplastbox} |
| 118 |
% \changes{v3.1}{2015/04/14}{set debug option off by default; keeplastbox modified;} |
| 119 |
% \changes{v3.2}{2016/06/21}{bugfix compatibility with luatexja} |
| 120 |
% \changes{v3.3}{2017/03/27}{bugfix for get@@footnoterule@@box; options for some checks on/off} |
| 121 |
% \changes{v3.4}{2020/10/14}{bugfix development and test} |
| 122 |
% \changes{v3.5}{2020/10/16}{bugfix version: modern with noautobase} |
| 123 |
% \changes{v4.0}{2021/10/04}{another rewrite with new balance algorithm and options} |
| 124 |
% |
| 125 |
% \DoNotIndex{\newcommand,\newenvironment} |
| 126 |
% |
| 127 |
% \providecommand*{\url}{\texttt} |
| 128 |
% \GetFileInfo{flushend.dtx} |
| 129 |
% \title{The \textsf{flushend} package} |
| 130 |
% \author{Sigitas Tolu\v{s}is \\ \url{[email protected]}} |
| 131 |
% \date{\fileversion~from \filedate} |
| 132 |
% |
| 133 |
% \maketitle |
| 134 |
% |
| 135 |
% \section{Introduction} |
| 136 |
% |
| 137 |
% The package is used to balance columns on any page in twocolumn |
| 138 |
% mode. By default it is switched on at the end of document. It is |
| 139 |
% expected to work with leftcolumn footnotes (option checkfootnote) |
| 140 |
% and rightcolumn top floats (option checkfloat). |
| 141 |
% |
| 142 |
% To compare with the previous version the package is completely rewritten |
| 143 |
% with new balancing algorithm and new options, removed dependency on other packages. |
| 144 |
% |
| 145 |
% \section{Usage} |
| 146 |
% |
| 147 |
% Just load the package to balance the last page: that's all. |
| 148 |
% To balance some page in middle of document use command |
| 149 |
% \cs{flushcolsend} at that page. |
| 150 |
% |
| 151 |
% \medskip |
| 152 |
% \leftline{\textbf{\textit{Available commands}}:} |
| 153 |
% |
| 154 |
% \begin{description} |
| 155 |
% |
| 156 |
% \item[\cs{flushend}] |
| 157 |
% This macro switches on column balancing on the last page. It is used |
| 158 |
% by default. |
| 159 |
% |
| 160 |
% \item[\cs{raggedend}] |
| 161 |
% This macro switches off column balancing on the last page. |
| 162 |
% |
| 163 |
% \item[\cs{flushcolsend}] |
| 164 |
% This macro switches on column balancing on the current page. |
| 165 |
% |
| 166 |
% \item[\cs{raggedcolsend}] |
| 167 |
% This macro switches off column balancing on the current page. |
| 168 |
% |
| 169 |
% \item[\cs{atColsBreak}\meta{tokens}] |
| 170 |
% Adds \meta{tokens} in place of the original column break (made without balancing). |
| 171 |
% |
| 172 |
% \medskip |
| 173 |
% \textit{Example}: |\atColsBreak{\vskip-2pt}| |
| 174 |
% |
| 175 |
% \item[\cs{atColsEnd}\meta{tokens}] |
| 176 |
% Adds \meta{tokens} at the end of right column. |
| 177 |
% |
| 178 |
% \item[\cs{showcolsendrule}] |
| 179 |
% It can be used just for debugging: adds rule to the bottom of columns. |
| 180 |
% |
| 181 |
% \end{description} |
| 182 |
% |
| 183 |
% \subsection{Package options} |
| 184 |
% |
| 185 |
% \begin{description} |
| 186 |
% |
| 187 |
% \item[\meta{|spread|}] |
| 188 |
% \texttt{[default]} It enables columns spreading trying to balance. |
| 189 |
% |
| 190 |
% \item[\meta{|nospread|}] |
| 191 |
% It disables columns spreading trying to balance. |
| 192 |
% |
| 193 |
% \item[\meta{|shrink|}] |
| 194 |
% \texttt{[default]} It enables columns shrinking trying to balance. |
| 195 |
% |
| 196 |
% \item[\meta{|noshrink|}] |
| 197 |
% It disables columns shrinking trying to balance. |
| 198 |
% |
| 199 |
% \medskip |
| 200 |
% \textit{Similiar options exist for single column separatly}: |
| 201 |
% |
| 202 |
% |lspread|, |nolspread|, |lshrink|, |nolshrink| -- for left column |
| 203 |
% |
| 204 |
% |rspread|, |norspread|, |rshrink|, |norshrink| -- for right column |
| 205 |
% |
| 206 |
% \item[\meta{|checkfootnote|}] |
| 207 |
% \texttt{[default]} Adds guess and checking for possible footnote on left column. |
| 208 |
% |
| 209 |
% \item[\meta{|nocheckfootnote|}] |
| 210 |
% Skips guess for possible footnote and ignores any existing one. |
| 211 |
% |
| 212 |
% \item[\meta{|checkfloat|}] |
| 213 |
% Adds guess for top float on right column. Any box with height bigger then 5|\topskip| |
| 214 |
% is considered as float. There are no user interface to change this limit except |
| 215 |
% internal macro definition: |\gdef\top@@floatbox@min@default{5\topskip}| |
| 216 |
% |
| 217 |
% As guess is too brutal, not accurate, and somehow dangerous in case for text misplacement |
| 218 |
% it is switched off by default. |
| 219 |
% |
| 220 |
% \item[\meta{|nocheckfloat|}] |
| 221 |
% \texttt{[default]} Skips guess for top float on right column. |
| 222 |
% |
| 223 |
% \item[\meta{|debug|}] |
| 224 |
% Adds rules to the bottom of columns (just for debugging) and leftcolumn break place. |
| 225 |
% Adds some additional log info. |
| 226 |
% |
| 227 |
% \item[\meta{|nodebug|}] |
| 228 |
% \texttt{[default]} Skips putting debuging lines and additional info. |
| 229 |
% |
| 230 |
% \end{description} |
| 231 |
% |
| 232 |
% \section{Implementation} |
| 233 |
% |
| 234 |
% Improved balancing (at least it is expected so) is based on using possible spread and shrink |
| 235 |
% in both columns checking constructed columns badness. |
| 236 |
% Hard coded limit for badness is |101|. Available only as internal macro: |\def\flushend@@column@badness{101}|. |
| 237 |
% |\pagediscards| material dimensions are used to restore original vertical skip at original columns break. |
| 238 |
% |
| 239 |
% \bigskip |
| 240 |
% \leftline{\textbf{\textit{Expected usecase}} \texttt{(with options [checkfootnote,checkfloat])}:} |
| 241 |
% |
| 242 |
% \begin{verbatim} |
| 243 |
% |
| 244 |
% -------------------------- -------------------------- |
| 245 |
% |xxxxxxxxxx ++++++++++| |xxxxxxxxxx ++++++++++| |
| 246 |
% |xxxxxxxxxx + +| |xxxxxxxxxx + +| |
| 247 |
% |xxxxxxxxxx + +| |xxxxxxxxxx + +| |
| 248 |
% |xxxxxxxxxx ++++++++++| |xxxxxxxxxx ++++++++++| |
| 249 |
% |xxxxxxxxxx figure | |xxxxxxxxxx figure | |
| 250 |
% | | | | |
| 251 |
% |section xxxxxxxxxx| |section yyyyyyyyyy| |
| 252 |
% | xxxxxxxxxx| -----> | yyyyyyyyyy| |
| 253 |
% |xxxxxxxxxx xxxxxxxxxx| |xxxxxxxxxx xxxxxxxxxx| |
| 254 |
% |xxxxxxxxxx xxxxxxxxxx| |xxxxxxxxxx xxxxxxxxxx| |
| 255 |
% |yyyyyyyyyy xxxxxxxxxx| | xxxxxxxxxx| |
| 256 |
% |yyyyyyyyyy | |--- xxxxxxxxxx| |
| 257 |
% | | |footnote xxxxxxxxxx| |
| 258 |
% |--- | | | |
| 259 |
% |footnote | | | |
| 260 |
% -------------------------- -------------------------- |
| 261 |
% |
| 262 |
% \end{verbatim} |
| 263 |
% \StopEventually{} |
| 264 |
% |
| 265 |
% \iffalse |
| 266 |
%<*package> |
| 267 |
% \fi |
| 268 |
% |
| 269 |
%/*% \begin{macrocode}*/ |
| 270 |
% \begin{macrocode} |
| 271 |
|
| 272 |
\newif\if@footnote@check \@footnote@checktrue |
| 273 |
\newif\if@right@column@spread \@right@column@spreadtrue |
| 274 |
\newif\if@right@column@shrink \@right@column@shrinktrue |
| 275 |
\newif\if@left@column@spread \@left@column@spreadtrue |
| 276 |
\newif\if@left@column@shrink \@left@column@shrinktrue |
| 277 |
\newif\if@balance@debug \@balance@debugfalse |
| 278 |
|
| 279 |
\DeclareOption{spread}{% |
| 280 |
\global\@left@column@spreadtrue |
| 281 |
\global\@right@column@spreadtrue |
| 282 |
} |
| 283 |
\DeclareOption{nospread}{% |
| 284 |
\global\@left@column@spreadfalse |
| 285 |
\global\@right@column@spreadfalse |
| 286 |
} |
| 287 |
\DeclareOption{lspread}{\global\@left@column@spreadtrue} |
| 288 |
\DeclareOption{nolspread}{\global\@left@column@spreadfalse} |
| 289 |
\DeclareOption{rspread}{\global\@right@column@spreadtrue} |
| 290 |
\DeclareOption{norspread}{\global\@right@column@spreadfalse} |
| 291 |
\DeclareOption{shrink}{% |
| 292 |
\global\@left@column@shrinktrue |
| 293 |
\global\@right@column@shrinktrue |
| 294 |
} |
| 295 |
\DeclareOption{noshrink}{% |
| 296 |
\global\@left@column@shrinkfalse |
| 297 |
\global\@right@column@shrinkfalse |
| 298 |
} |
| 299 |
\DeclareOption{lshrink}{\global\@left@column@shrinktrue} |
| 300 |
\DeclareOption{nolshrink}{\global\@left@column@shrinkfalse} |
| 301 |
\DeclareOption{rshrink}{\global\@right@column@shrinktrue} |
| 302 |
\DeclareOption{norshrink}{\global\@right@column@shrinkfalse} |
| 303 |
\DeclareOption{checkfootnote}{% |
| 304 |
\AtEndOfPackage{% |
| 305 |
\let\check@@footnoterule@@box\initial@check@@footnoterule@@box |
| 306 |
\@footnote@checktrue |
| 307 |
}% |
| 308 |
} |
| 309 |
\DeclareOption{nocheckfootnote}{% |
| 310 |
\AtEndOfPackage{% |
| 311 |
\let\check@@footnoterule@@box\@gobblethree |
| 312 |
\@footnote@checkfalse |
| 313 |
}% |
| 314 |
} |
| 315 |
\DeclareOption{checkfloat}{% |
| 316 |
\AtEndOfPackage{% |
| 317 |
\let\top@@floatbox@min\top@@floatbox@min@default |
| 318 |
}% |
| 319 |
} |
| 320 |
\DeclareOption{nocheckfloat}{% |
| 321 |
\AtEndOfPackage{% |
| 322 |
\let\top@@floatbox@min\maxdimen |
| 323 |
}% |
| 324 |
} |
| 325 |
\DeclareOption{debug}{\global\@balance@debugtrue} |
| 326 |
\DeclareOption{nodebug}{\global\@balance@debugfalse} |
| 327 |
|
| 328 |
\ProcessOptions |
| 329 |
|
| 330 |
\newskip\flushend@@lastskip@a |
| 331 |
\newskip\flushend@@lastskip@b |
| 332 |
\newcount\flushend@@lastnode |
| 333 |
\newcount\var@@loop@iter |
| 334 |
\newdimen\var@@temp@spread |
| 335 |
\newdimen\var@@temp@a |
| 336 |
\newdimen\var@@temp@loop |
| 337 |
\newdimen\flushend@@page@rule \flushend@@page@rule\z@ |
| 338 |
\def\showcolsendrule{\global\flushend@@page@rule=.4\p@} |
| 339 |
\gdef\top@@floatbox@min@default{5\topskip} |
| 340 |
\let\top@@floatbox@min\maxdimen |
| 341 |
\def\flushend@@column@badness{101} |
| 342 |
\newbox\flushend@@varbox@lastpage |
| 343 |
\newbox\flushend@@varbox@a |
| 344 |
\newbox\flushend@@varbox@c |
| 345 |
\newbox\flushend@@tempbox@a |
| 346 |
\newbox\flushend@@tempbox@c |
| 347 |
\newbox\flushend@@floatbox |
| 348 |
\@ifundefined{@viper}{\newbox\@viper}{} |
| 349 |
\@ifundefined{hold@viper}{\newbox\hold@viper}{} |
| 350 |
\newtoks\atColsBreak \atColsBreak={} |
| 351 |
\newtoks\atColsEnd \atColsEnd={} |
| 352 |
\@ifundefined{fmt@box@adds}{\def\fmt@box@adds#1{#1}}{} |
| 353 |
\@ifundefined{fmt@vbox@adds}{\def\fmt@vbox@adds[#1]#2{#2}}{} |
| 354 |
\def\wlog@balance@debug#1{\if@balance@debug \wlog{#1}\fi} |
| 355 |
\def\log@box@info#1{<box\the#1>(\the\ht#1+\the\dp#1)x\the\wd#1} |
| 356 |
|
| 357 |
\def\unskip@three@kern@penalty{% |
| 358 |
\unskip\unkern\unpenalty |
| 359 |
\unskip\unkern\unpenalty |
| 360 |
\unskip\unkern\unpenalty |
| 361 |
} |
| 362 |
|
| 363 |
\gdef\remove@empty@lastbox@at@balancing#1{% |
| 364 |
%% |
| 365 |
%% Removes lastbox without dimensions. |
| 366 |
%% Removes latest skip, kern, penalty. |
| 367 |
%% Cuts the lastbox's depth bigger then strutbox's depth. |
| 368 |
%% |
| 369 |
\var@@temp@a=\z@ |
| 370 |
\setbox\flushend@@tempbox@a\vbox{% |
| 371 |
\unvcopy#1% |
| 372 |
\unskip@three@kern@penalty |
| 373 |
\global\flushend@@lastnode=\lastnodetype |
| 374 |
}% |
| 375 |
\setbox#1\vbox{% |
| 376 |
\unvcopy\flushend@@tempbox@a |
| 377 |
\setbox\z@\lastbox |
| 378 |
\ifdim\dimexpr\ht\z@+\dp\z@+\wd\z@\relax>\z@ |
| 379 |
%% not empty lastbox - store depth of the lastbox |
| 380 |
\global\var@@temp@a=\dp\z@ |
| 381 |
\else |
| 382 |
%% empty lastbox |
| 383 |
\setbox\z@\box\flushend@@tempbox@a |
| 384 |
\expandafter\unskip@three@kern@penalty |
| 385 |
\fi |
| 386 |
}% |
| 387 |
\ifvoid\flushend@@tempbox@a\else |
| 388 |
%% not empty lastbox - restore original |
| 389 |
\setbox#1\box\flushend@@tempbox@a |
| 390 |
\fi |
| 391 |
\ifdim\var@@temp@a>\z@ |
| 392 |
%% cut the depth of the lastbox with the negative skip |
| 393 |
\ifdim\var@@temp@a>\dp\strutbox |
| 394 |
%% it is something more than single line depth |
| 395 |
\else |
| 396 |
\setbox#1\vbox{\unvbox#1\vskip-\var@@temp@a}% |
| 397 |
\fi |
| 398 |
\fi |
| 399 |
} |
| 400 |
|
| 401 |
\def\set@split@topskip@to#1{% |
| 402 |
\splittopskip=#1\relax |
| 403 |
\vfuzz=\maxdimen |
| 404 |
\vbadness=\maxdimen |
| 405 |
} |
| 406 |
|
| 407 |
\gdef\analyze@leftcolumn@box#1{% |
| 408 |
%% |
| 409 |
%% Try to find footnotes on the leftcolumn |
| 410 |
%% |
| 411 |
\set@split@topskip@to\z@ |
| 412 |
\flushend@@lastskip@b\ht#1% |
| 413 |
\advance\flushend@@lastskip@b\dp#1% |
| 414 |
\setbox\flushend@@varbox@a\vbox{% |
| 415 |
\unvbox#1% |
| 416 |
\global\flushend@@lastskip@a\lastskip |
| 417 |
\unskip\unkern\unpenalty |
| 418 |
\global\setbox\flushend@@tempbox@a\lastbox |
| 419 |
}% |
| 420 |
\advance\flushend@@lastskip@b -\ht\flushend@@varbox@a |
| 421 |
\advance\flushend@@lastskip@b -\ht\flushend@@tempbox@a |
| 422 |
\ifvoid\flushend@@tempbox@a |
| 423 |
\ifdim\ht\flushend@@varbox@a>\topskip |
| 424 |
\flushend@@lastskip@b\ht\flushend@@varbox@a |
| 425 |
\var@@temp@a\ht\flushend@@varbox@a |
| 426 |
\loop |
| 427 |
\setbox\flushend@@tempbox@c\vsplit\flushend@@varbox@a to\var@@temp@a |
| 428 |
\ifvoid\flushend@@varbox@a |
| 429 |
\setbox\flushend@@varbox@a\vbox{\unvbox\flushend@@tempbox@c}% |
| 430 |
\advance\var@@temp@a -3\p@ |
| 431 |
\else |
| 432 |
\var@@temp@a=-1\p@ |
| 433 |
\fi |
| 434 |
\ifdim \var@@temp@a>\z@ |
| 435 |
\repeat |
| 436 |
\setbox\flushend@@varbox@a\vbox{\unvbox\flushend@@varbox@a}% |
| 437 |
\setbox\flushend@@tempbox@c\vbox{\unvbox\flushend@@tempbox@c}% |
| 438 |
\advance\flushend@@lastskip@b -\ht\flushend@@varbox@a |
| 439 |
\advance\flushend@@lastskip@b -\ht\flushend@@tempbox@c |
| 440 |
\check@@footnoterule@@box\flushend@@varbox@a\flushend@@lastskip@b |
| 441 |
\flushend@@tempbox@c |
| 442 |
\setbox\flushend@@varbox@a\vbox{\unvbox\flushend@@tempbox@c}% |
| 443 |
\else |
| 444 |
\global\@footnote@checkfalse |
| 445 |
\fi |
| 446 |
\else |
| 447 |
\check@@footnoterule@@box\flushend@@tempbox@a\flushend@@lastskip@b\flushend@@varbox@a |
| 448 |
\fi |
| 449 |
\if@footnote@check |
| 450 |
\ifdim\var@@temp@loop=\ht\flushend@@varbox@a\relax |
| 451 |
\global\advance\var@@loop@iter\@ne |
| 452 |
\fi |
| 453 |
\var@@temp@loop=\ht\flushend@@varbox@a\relax |
| 454 |
\ifnum\var@@loop@iter<3\relax |
| 455 |
%% next iteration |
| 456 |
\else |
| 457 |
%% loop limit, break loop |
| 458 |
\ht\flushend@@varbox@a=\z@ |
| 459 |
\fi |
| 460 |
\ifdim\ht\flushend@@varbox@a>\topskip |
| 461 |
\expandafter\analyze@leftcolumn@box\expandafter\flushend@@varbox@a |
| 462 |
\fi |
| 463 |
\fi |
| 464 |
} |
| 465 |
|
| 466 |
\def\get@@footnoterule@@box{% |
| 467 |
\set@split@topskip@to\z@ |
| 468 |
\setbox\flushend@@varbox@a\vbox{\strut |
| 469 |
\vskip\z@ |
| 470 |
\footnoterule |
| 471 |
\unskip@three@kern@penalty |
| 472 |
}% |
| 473 |
\setbox\flushend@@tempbox@c\vsplit\flushend@@varbox@a to\p@ |
| 474 |
\xdef\footnoterule@@box@@ht{\the\ht\flushend@@varbox@a}% |
| 475 |
\xdef\footnoterule@@box@@dp{\the\dp\flushend@@varbox@a}% |
| 476 |
\xdef\footnoterule@@box@@wd{\the\wd\flushend@@varbox@a}% |
| 477 |
\wlog@balance@debug{:footnoterule: \log@box@info{\flushend@@varbox@a}}% |
| 478 |
\setbox\flushend@@tempbox@c\vbox{\unvbox\flushend@@varbox@a}% |
| 479 |
} |
| 480 |
|
| 481 |
\long\def\@gobblethree#1#2#3{} |
| 482 |
|
| 483 |
\def\check@@footnoterule@@box#1#2#3{% |
| 484 |
\ifdim\ht#1=\footnoterule@@box@@ht |
| 485 |
\ifdim\dp#1=\footnoterule@@box@@dp |
| 486 |
\ifdim\wd#1=\footnoterule@@box@@wd |
| 487 |
\ifdim#2=\topskip |
| 488 |
\else |
| 489 |
\xdef\main@box@height{\the\ht#3}% |
| 490 |
\xdef\main@box@depth{\the\dp#3}% |
| 491 |
\xdef\main@box@skip{\the#2}% |
| 492 |
\wlog@balance@debug{^^J:footnoterule found: |
| 493 |
main@box <ht=\main@box@height, |
| 494 |
skip=\main@box@skip> |
| 495 |
}% |
| 496 |
\global\let\check@@footnoterule@@box\@gobblethree |
| 497 |
\global\@footnote@checkfalse |
| 498 |
\fi |
| 499 |
\fi |
| 500 |
\fi |
| 501 |
\fi |
| 502 |
} |
| 503 |
|
| 504 |
\let\initial@check@@footnoterule@@box\check@@footnoterule@@box |
| 505 |
|
| 506 |
\def\analyze@rightcolumn@box#1{% |
| 507 |
%% |
| 508 |
%% Looking for the top floats on the right column. |
| 509 |
%% |
| 510 |
%% Top box is considered as float if box's height |
| 511 |
%% is larger then \top@@floatbox@min. |
| 512 |
%% So, it is a dangerous feature to be used carefully. |
| 513 |
%% |
| 514 |
\bgroup |
| 515 |
\xdef\top@@floatbox@ht{\z@}% |
| 516 |
\set@split@topskip@to\z@ |
| 517 |
\setbox\flushend@@varbox@a\vbox{\strut |
| 518 |
\vskip\z@ |
| 519 |
\unvcopy#1% |
| 520 |
}% |
| 521 |
\setbox\flushend@@tempbox@c\vsplit\flushend@@varbox@a to\p@ |
| 522 |
\flushend@@lastskip@a\ht\flushend@@varbox@a |
| 523 |
\advance\flushend@@lastskip@a\dp\flushend@@varbox@a |
| 524 |
\ifdim\flushend@@lastskip@a>\z@ |
| 525 |
%% analyze non empty rightcolumn box |
| 526 |
\var@@temp@a=3\p@ |
| 527 |
\loop |
| 528 |
\setbox\flushend@@tempbox@c\vsplit\flushend@@varbox@a to\var@@temp@a |
| 529 |
\flushend@@lastskip@b\ht\flushend@@varbox@a |
| 530 |
\advance\flushend@@lastskip@b\dp\flushend@@varbox@a |
| 531 |
\ifvoid\flushend@@tempbox@c |
| 532 |
\advance\var@@temp@a by3\p@ |
| 533 |
\ifdim\var@@temp@a>\flushend@@lastskip@b |
| 534 |
%% reach column end, break loop |
| 535 |
\var@@temp@a=-1\p@ |
| 536 |
\fi |
| 537 |
\else |
| 538 |
\setbox\flushend@@tempbox@c\vbox{\unvbox\flushend@@tempbox@c}% |
| 539 |
\ifdim\ht\flushend@@tempbox@c>\top@@floatbox@min |
| 540 |
%% found float; set height; look for the next |
| 541 |
\setbox\flushend@@tempbox@a\vbox{\splitdiscards}% |
| 542 |
\ifvoid\flushend@@tempbox@a |
| 543 |
\else |
| 544 |
\advance\flushend@@lastskip@b \ht\flushend@@tempbox@a |
| 545 |
\advance\flushend@@lastskip@b \dp\flushend@@tempbox@a |
| 546 |
\fi |
| 547 |
\advance\flushend@@lastskip@b -\flushend@@lastskip@a |
| 548 |
\flushend@@lastskip@b=-\flushend@@lastskip@b |
| 549 |
\xdef\top@@floatbox@ht{\the\flushend@@lastskip@b}% |
| 550 |
\var@@temp@a=3\p@ |
| 551 |
\else |
| 552 |
%% break loop |
| 553 |
\var@@temp@a=-1\p@ |
| 554 |
\fi |
| 555 |
\fi |
| 556 |
\ifdim \var@@temp@a>\z@ |
| 557 |
\repeat |
| 558 |
\fi |
| 559 |
\egroup |
| 560 |
} |
| 561 |
|
| 562 |
\def\set@outputbox@with@footnote@and@float{% |
| 563 |
%% |
| 564 |
%% The main unit formatting balanced columns. |
| 565 |
%% |
| 566 |
%% \flushend@@tempbox@a - left column |
| 567 |
%% \flushend@@tempbox@c - left column with natural dimensions |
| 568 |
%% \flushend@@varbox@a - right column |
| 569 |
%% \flushend@@varbox@c - right column with natural dimensions |
| 570 |
%% \flushend@@floatbox - rightcolumn top float |
| 571 |
%% \@leftcolumn - void or leftcolumn footnote |
| 572 |
%% |
| 573 |
\@tempdimb\ht\flushend@@varbox@lastpage |
| 574 |
\ifdim\top@@floatbox@ht>\z@ |
| 575 |
\advance\@tempdimb \textfloatsep |
| 576 |
\advance\@tempdimb \top@@floatbox@ht |
| 577 |
\fi |
| 578 |
\ifdim\main@box@skip>\z@ |
| 579 |
\advance\@tempdimb \main@box@skip |
| 580 |
\advance\@tempdimb \ht\@leftcolumn |
| 581 |
\fi |
| 582 |
\@tempdimb=.5\@tempdimb |
| 583 |
\ifdim\@tempdimb>\@colht |
| 584 |
\@tempdimb=\@colht |
| 585 |
\fi |
| 586 |
\ifdim\main@box@skip>\z@ |
| 587 |
\advance\@tempdimb -\main@box@skip |
| 588 |
\advance\@tempdimb -\ht\@leftcolumn |
| 589 |
\fi |
| 590 |
\set@split@topskip@to\topskip |
| 591 |
\loop |
| 592 |
\xdef\saved@tempdimb{\the\@tempdimb}% |
| 593 |
\setbox\flushend@@varbox@a\copy\flushend@@varbox@lastpage |
| 594 |
\setbox\flushend@@tempbox@a\vsplit\flushend@@varbox@a to\@tempdimb |
| 595 |
\ifdim\main@box@skip>\z@ |
| 596 |
\setbox\flushend@@tempbox@c\vbox{% |
| 597 |
\unvbox\flushend@@tempbox@a |
| 598 |
\vskip\main@box@skip |
| 599 |
\vskip\z@ plus\p@ |
| 600 |
\unvcopy\@leftcolumn |
| 601 |
}% |
| 602 |
\else |
| 603 |
\setbox\flushend@@tempbox@c\vbox{\unvbox\flushend@@tempbox@a}% |
| 604 |
\fi |
| 605 |
\setbox\flushend@@tempbox@a\vbox to\@tempdimb{\unvcopy\flushend@@tempbox@c}% |
| 606 |
\xdef\var@@leftcolumn@badness{\the\badness}% |
| 607 |
\ifdim\top@@floatbox@ht>\z@ |
| 608 |
\setbox\flushend@@varbox@c\vbox{% |
| 609 |
\unvcopy\flushend@@floatbox |
| 610 |
\vskip\textfloatsep |
| 611 |
\vskip\z@ plus\p@ minus\p@ |
| 612 |
\unvbox\flushend@@varbox@a |
| 613 |
}% |
| 614 |
\else |
| 615 |
\setbox\flushend@@varbox@c\vbox{\unvbox\flushend@@varbox@a}% |
| 616 |
\fi |
| 617 |
\setbox\flushend@@varbox@a\vbox to\@tempdimb{\unvcopy\flushend@@varbox@c}% |
| 618 |
\xdef\var@@rightcolumn@badness{\the\badness}% |
| 619 |
\var@@temp@spread=\ht\flushend@@tempbox@c |
| 620 |
\advance\var@@temp@spread by\dp\flushend@@tempbox@c |
| 621 |
\advance\var@@temp@spread by-\ht\flushend@@varbox@c |
| 622 |
\advance\var@@temp@spread by-\dp\flushend@@varbox@c |
| 623 |
\wlog@balance@debug{----- |
| 624 |
^^JLeft: \the\ht\flushend@@tempbox@c |
| 625 |
+\the\dp\flushend@@tempbox@c\space / \var@@leftcolumn@badness |
| 626 |
^^JRight: \the\ht\flushend@@varbox@c |
| 627 |
+\the\dp\flushend@@varbox@c\space / \var@@rightcolumn@badness |
| 628 |
^^JSplit: \the\@tempdimb |
| 629 |
^^JExtra height: \the\var@@temp@spread |
| 630 |
}% |
| 631 |
\ifdim\main@box@skip>\z@ |
| 632 |
\wlog@balance@debug{Footnote: \the\dimexpr\main@box@skip + \the\ht\@leftcolumn\relax}% |
| 633 |
\fi |
| 634 |
\ifdim\top@@floatbox@ht>\z@ |
| 635 |
\wlog@balance@debug{Float: \the\dimexpr\the\ht\flushend@@floatbox + \textfloatsep\relax}% |
| 636 |
\fi |
| 637 |
\ifnum\var@@leftcolumn@badness<\flushend@@column@badness |
| 638 |
\ifnum\var@@rightcolumn@badness<\flushend@@column@badness |
| 639 |
\ifdim\main@box@skip>\z@ |
| 640 |
\advance\@tempdimb -\main@box@skip |
| 641 |
\advance\@tempdimb -\ht\@leftcolumn |
| 642 |
\fi |
| 643 |
\var@@temp@spread=\z@ |
| 644 |
\fi |
| 645 |
\fi |
| 646 |
\ifdim\var@@temp@spread<\z@ |
| 647 |
\if@left@column@spread |
| 648 |
\if@right@column@shrink |
| 649 |
\ifdim\dimexpr\var@@temp@spread+\pageshrink>\z@ |
| 650 |
\var@@temp@a=\dimexpr\ht\flushend@@[email protected]\var@@temp@spread\relax |
| 651 |
\else |
| 652 |
\var@@temp@a=-\dimexpr\var@@temp@spread+.5\pageshrink\relax |
| 653 |
\fi |
| 654 |
\setbox\flushend@@varbox@a\vbox to\var@@temp@a{\unvcopy\flushend@@tempbox@c}% |
| 655 |
\ifnum\badness<\flushend@@column@badness |
| 656 |
\@tempdimb=\var@@temp@a |
| 657 |
\ifdim\main@box@skip>\z@ |
| 658 |
\advance\@tempdimb -\main@box@skip |
| 659 |
\advance\@tempdimb -\ht\@leftcolumn |
| 660 |
\fi |
| 661 |
\var@@temp@spread=\z@ |
| 662 |
\fi |
| 663 |
\wlog{[leftcolumn badness]: \number\badness\space on \the\var@@temp@a}% |
| 664 |
\setbox\flushend@@varbox@a\vbox to\var@@temp@a{\unvcopy\flushend@@varbox@c}% |
| 665 |
\wlog{[rightcolumn badness]: \number\badness\space on \the\var@@temp@a}% |
| 666 |
\else |
| 667 |
\setbox\flushend@@varbox@a\vbox to\ht\flushend@@varbox@c{% |
| 668 |
\unvcopy\flushend@@tempbox@c |
| 669 |
}% |
| 670 |
\ifnum\badness<\flushend@@column@badness |
| 671 |
\@tempdimb=\ht\flushend@@varbox@c |
| 672 |
\ifdim\main@box@skip>\z@ |
| 673 |
\advance\@tempdimb -\main@box@skip |
| 674 |
\advance\@tempdimb -\ht\@leftcolumn |
| 675 |
\fi |
| 676 |
\var@@temp@spread=\z@ |
| 677 |
\fi |
| 678 |
\wlog{[leftcolumn badness]: \number\badness on \the\ht\flushend@@varbox@c}% |
| 679 |
\setbox\flushend@@varbox@a\vbox to\ht\flushend@@varbox@c{% |
| 680 |
\unvcopy\flushend@@varbox@c |
| 681 |
}% |
| 682 |
\wlog{[rightcolumn badness]: \number\badness on \the\ht\flushend@@varbox@c}% |
| 683 |
\fi |
| 684 |
\else |
| 685 |
\if@right@column@shrink |
| 686 |
\ifdim\dimexpr\var@@temp@spread+\pageshrink<\z@ |
| 687 |
\else |
| 688 |
\@tempdimb=\ht\flushend@@tempbox@c |
| 689 |
\ifdim\main@box@skip>\z@ |
| 690 |
\advance\@tempdimb -\main@box@skip |
| 691 |
\advance\@tempdimb -\ht\@leftcolumn |
| 692 |
\fi |
| 693 |
\var@@temp@spread=\z@ |
| 694 |
\fi |
| 695 |
\fi |
| 696 |
\fi |
| 697 |
\else |
| 698 |
\ifdim\var@@temp@spread>\z@ |
| 699 |
\ifdim\dimexpr\@tempdimb+\p@\relax>\@colht |
| 700 |
\@tempdimb=\@colht |
| 701 |
\ifdim\main@box@skip>\z@ |
| 702 |
\advance\@tempdimb -\main@box@skip |
| 703 |
\advance\@tempdimb -\ht\@leftcolumn |
| 704 |
\fi |
| 705 |
\var@@temp@spread=\z@ |
| 706 |
\fi |
| 707 |
\fi |
| 708 |
\fi |
| 709 |
\ifdim\var@@temp@spread<\z@ |
| 710 |
\advance\@tempdimb 1\p@ |
| 711 |
\repeat |
| 712 |
%% final construction of the lastpage |
| 713 |
\wlog{- LAST -% |
| 714 |
^^JExtra skip:\the\var@@temp@spread |
| 715 |
^^JLeft:\the\ht\flushend@@tempbox@c/\the\dp\flushend@@tempbox@c |
| 716 |
^^JRight:\the\ht\flushend@@varbox@c/\the\dp\flushend@@varbox@c |
| 717 |
^^JSplit: \saved@tempdimb |
| 718 |
^^JOutput:\the\@tempdimb |
| 719 |
^^JPageshrink: \the\pageshrink |
| 720 |
^^JPagestretch: \the\pagestretch |
| 721 |
^^J@colht:\the\@colht |
| 722 |
}% |
| 723 |
\setbox\flushend@@tempbox@c\vsplit\flushend@@varbox@lastpage to\saved@tempdimb |
| 724 |
\ifdim\main@box@skip>\z@ |
| 725 |
\@tempdimb=\dimexpr\@tempdimb+\main@box@skip+\ht\@leftcolumn\relax |
| 726 |
\setbox\@leftcolumn\vbox to\@tempdimb{% |
| 727 |
\flushend@@lastskip@a=\dimexpr |
| 728 |
\@tempdimb |
| 729 |
-\ht\flushend@@tempbox@c |
| 730 |
-\main@box@skip |
| 731 |
-\ht\@leftcolumn |
| 732 |
\relax |
| 733 |
\unvbox\flushend@@tempbox@c |
| 734 |
\vskip\main@box@skip |
| 735 |
\vskip\z@ plus\p@ |
| 736 |
\unvbox\@leftcolumn |
| 737 |
\prevdepth\z@ |
| 738 |
\hrule\@height\flushend@@page@rule width\textwidth |
| 739 |
\vskip-\flushend@@page@rule |
| 740 |
\ifdim\flushend@@lastskip@a>\z@ |
| 741 |
\if@left@column@spread |
| 742 |
\else |
| 743 |
\vss |
| 744 |
\fi |
| 745 |
\else |
| 746 |
\ifdim\flushend@@lastskip@a<\z@ |
| 747 |
\if@left@column@shrink |
| 748 |
\else |
| 749 |
\vss |
| 750 |
\fi |
| 751 |
\fi |
| 752 |
\fi |
| 753 |
}% |
| 754 |
\else |
| 755 |
\setbox\@leftcolumn\vbox to\@tempdimb{% |
| 756 |
\flushend@@lastskip@a=\dimexpr |
| 757 |
\@tempdimb-\ht\flushend@@tempbox@c |
| 758 |
\relax |
| 759 |
\var@@temp@spread=\dp\flushend@@tempbox@c |
| 760 |
\unvbox\flushend@@tempbox@c |
| 761 |
\ifdim\var@@temp@spread>\dp\strutbox |
| 762 |
\else |
| 763 |
\vskip-\var@@temp@spread |
| 764 |
\fi |
| 765 |
\prevdepth\z@ |
| 766 |
\hrule\@height\flushend@@page@rule width\textwidth |
| 767 |
\vskip-\flushend@@page@rule |
| 768 |
\ifdim\flushend@@lastskip@a>\z@ |
| 769 |
\if@left@column@spread |
| 770 |
\else |
| 771 |
\vss |
| 772 |
\fi |
| 773 |
\else |
| 774 |
\ifdim\flushend@@lastskip@a<\z@ |
| 775 |
\if@left@column@shrink |
| 776 |
\else |
| 777 |
\vss |
| 778 |
\fi |
| 779 |
\fi |
| 780 |
\fi |
| 781 |
}% |
| 782 |
\fi |
| 783 |
\wlog{FLUSHEND [output]: \the\@tempdimb |
| 784 |
^^JFLUSHEND [leftcolumn badness]: \number\badness |
| 785 |
}% |
| 786 |
\global\ht\@leftcolumn=\the\@tempdima |
| 787 |
\ifdim\top@@floatbox@ht>\z@ |
| 788 |
\setbox\@outputbox\vbox to\@tempdimb{% |
| 789 |
\flushend@@lastskip@a=\dimexpr |
| 790 |
\@tempdimb |
| 791 |
-\ht\flushend@@floatbox |
| 792 |
-\textfloatsep |
| 793 |
-\ht\flushend@@varbox@lastpage |
| 794 |
\relax |
| 795 |
\unvbox\flushend@@floatbox |
| 796 |
\vskip\textfloatsep |
| 797 |
\vskip\z@ plus\p@ minus\p@ |
| 798 |
\unvbox\flushend@@varbox@lastpage |
| 799 |
\ifdim\flushend@@lastskip@a>\z@ |
| 800 |
\if@right@column@spread |
| 801 |
\else |
| 802 |
\vss |
| 803 |
\fi |
| 804 |
\else |
| 805 |
\ifdim\flushend@@lastskip@a<\z@ |
| 806 |
\if@right@column@shrink |
| 807 |
\else |
| 808 |
\vss |
| 809 |
\fi |
| 810 |
\fi |
| 811 |
\fi |
| 812 |
}% |
| 813 |
\else |
| 814 |
\setbox\@outputbox\vbox to\@tempdimb{% |
| 815 |
\flushend@@lastskip@a=\dimexpr |
| 816 |
\@tempdimb-\ht\flushend@@varbox@lastpage |
| 817 |
\relax |
| 818 |
\unvbox\flushend@@varbox@lastpage |
| 819 |
\ifdim\flushend@@lastskip@a>\z@ |
| 820 |
\if@right@column@spread |
| 821 |
\else |
| 822 |
\vss |
| 823 |
\fi |
| 824 |
\else |
| 825 |
\ifdim\flushend@@lastskip@a<\z@ |
| 826 |
\if@right@column@shrink |
| 827 |
\else |
| 828 |
\vss |
| 829 |
\fi |
| 830 |
\fi |
| 831 |
\fi |
| 832 |
}% |
| 833 |
\fi |
| 834 |
\wlog{FUSHEND [rightcolumn badness]: \number\badness}% |
| 835 |
\global\ht\@outputbox=\the\@tempdima |
| 836 |
} |
| 837 |
|
| 838 |
\newdimen\oldbreak@skip |
| 839 |
|
| 840 |
\def\combine@columns@for@balance{% |
| 841 |
%% |
| 842 |
%% Combines lastpage columns for balancing. |
| 843 |
%% |
| 844 |
\setbox\flushend@@tempbox@a\vbox{\pagediscards}% |
| 845 |
\oldbreak@skip=\ht\flushend@@tempbox@a |
| 846 |
\advance\oldbreak@skip by\dp\flushend@@tempbox@a |
| 847 |
\setbox\@outputbox\vbox{\strut |
| 848 |
\vskip\z@ |
| 849 |
\unvbox\@outputbox |
| 850 |
}% |
| 851 |
\set@split@topskip@to\z@ |
| 852 |
%% Removes topskip |
| 853 |
\setbox\flushend@@tempbox@c\vsplit\@outputbox to\p@ |
| 854 |
\ifdim\top@@floatbox@ht>\z@ |
| 855 |
%% removes top float from right column (if option enabled) |
| 856 |
\setbox\flushend@@floatbox\vsplit\@outputbox to\top@@floatbox@ht |
| 857 |
\setbox\flushend@@floatbox\vbox{\unvbox\flushend@@floatbox}% |
| 858 |
\fi |
| 859 |
\setbox\flushend@@varbox@lastpage\vbox{% |
| 860 |
\remove@empty@lastbox@at@balancing\flushend@@varbox@a |
| 861 |
\unvbox\flushend@@varbox@a |
| 862 |
\hrule\@height\flushend@@page@rule width\columnwidth |
| 863 |
\vskip-\flushend@@page@rule |
| 864 |
\hrule\@height\z@ width\columnwidth |
| 865 |
\csname oldbreak@flushend@hook\endcsname |
| 866 |
\penalty\z@ |
| 867 |
\ifdim\var@@temp@a>\z@ |
| 868 |
\ifdim\var@@temp@a>\dp\strutbox |
| 869 |
\else |
| 870 |
\vskip\var@@temp@a |
| 871 |
\fi |
| 872 |
\fi |
| 873 |
\vskip\oldbreak@skip |
| 874 |
\the\atColsBreak |
| 875 |
\remove@empty@lastbox@at@balancing\@outputbox |
| 876 |
\unvbox\@outputbox |
| 877 |
\the\atColsEnd |
| 878 |
}% |
| 879 |
} |
| 880 |
|
| 881 |
\def\last@outputdblcol{% |
| 882 |
%% |
| 883 |
%% Redefined \@outputdblcol with columns balancing. |
| 884 |
%% |
| 885 |
\if@firstcolumn |
| 886 |
\global \@firstcolumnfalse |
| 887 |
\global\setbox\@leftcolumn\copy\@outputbox |
| 888 |
\else |
| 889 |
\global \@firstcolumntrue |
| 890 |
\@tempdima\ht\@leftcolumn |
| 891 |
\advance\@tempdima by\dp\@leftcolumn |
| 892 |
\set@split@topskip@to\topskip |
| 893 |
\var@@temp@spread=\wd\@outputbox |
| 894 |
\xdef\top@@floatbox@ht{\z@}% |
| 895 |
\xdef\main@box@skip{\z@}% |
| 896 |
\ifdim\var@@temp@spread>\z@ |
| 897 |
%% rightcolumn non empty |
| 898 |
\setbox\flushend@@varbox@a\vbox{\unvcopy\@outputbox}% |
| 899 |
\ifdim\dimexpr\@colht-\ht\flushend@@varbox@a>\z@\relax |
| 900 |
\if@footnote@check |
| 901 |
\get@@footnoterule@@box |
| 902 |
\xdef\main@box@height{\the\ht\@leftcolumn}% |
| 903 |
\setbox\flushend@@varbox@a\vbox{\unvcopy\@leftcolumn}% |
| 904 |
\var@@loop@iter\z@ \var@@temp@loop\z@ |
| 905 |
\analyze@leftcolumn@box\flushend@@varbox@a |
| 906 |
\fi |
| 907 |
\ifdim\top@@floatbox@min<\maxdimen |
| 908 |
\setbox\flushend@@varbox@a\vbox{\unvcopy\@outputbox}% |
| 909 |
\var@@loop@iter\z@ \var@@temp@loop\z@ |
| 910 |
\analyze@rightcolumn@box\flushend@@varbox@a |
| 911 |
\fi |
| 912 |
\ifdim\main@box@skip>\z@ |
| 913 |
%% footnote in left column |
| 914 |
\set@split@topskip@to\z@ |
| 915 |
\setbox\flushend@@varbox@a\vsplit\@leftcolumn to\main@box@height |
| 916 |
\else |
| 917 |
%% no footnote in left column |
| 918 |
\setbox\flushend@@varbox@a\box\@leftcolumn |
| 919 |
\fi |
| 920 |
\combine@columns@for@balance |
| 921 |
\else |
| 922 |
\xdef\main@box@skip{\maxdimen}% |
| 923 |
\fi |
| 924 |
\else |
| 925 |
%% rightcolumn empty |
| 926 |
\setbox\flushend@@varbox@a\box\@leftcolumn |
| 927 |
\setbox\flushend@@varbox@lastpage\vbox{% |
| 928 |
\remove@empty@lastbox@at@balancing\flushend@@varbox@a |
| 929 |
\unvbox\flushend@@varbox@a |
| 930 |
\the\atColsEnd |
| 931 |
}% |
| 932 |
\fi |
| 933 |
\ifdim\main@box@skip<\maxdimen |
| 934 |
\set@outputbox@with@footnote@and@float |
| 935 |
\fi |
| 936 |
\setbox\@outputbox\vbox{% |
| 937 |
\hb@xt@\textwidth{% |
| 938 |
\hb@xt@\columnwidth{% |
| 939 |
\fmt@box@adds{\box\@leftcolumn}\hss}% |
| 940 |
\hfil |
| 941 |
{\normalcolor\vrule \@width\columnseprule}% |
| 942 |
\hfil |
| 943 |
\hb@xt@\columnwidth{% |
| 944 |
\fmt@box@adds{\box\@outputbox}\hss}% |
| 945 |
}% |
| 946 |
}% |
| 947 |
\global\let\@outputdblcol\saved@orig@@outputdblcol |
| 948 |
\global\atColsEnd{}% |
| 949 |
\ifvoid\hold@viper |
| 950 |
\else |
| 951 |
\setbox\@outputbox\vbox{\box\hold@viper\box\@outputbox}% |
| 952 |
\fi |
| 953 |
\@combinedblfloats |
| 954 |
\csname @setmarks\endcsname |
| 955 |
\@outputpage |
| 956 |
\begingroup |
| 957 |
\@dblfloatplacement |
| 958 |
\@startdblcolumn |
| 959 |
\@whilesw\if@fcolmade\fi |
| 960 |
{\@outputpage\@startdblcolumn}% |
| 961 |
\ifvoid\@viper |
| 962 |
\else |
| 963 |
\global\setbox\@viper\vbox{% |
| 964 |
\vskip-\stripsep |
| 965 |
\unvbox\@viper |
| 966 |
}% |
| 967 |
\csname @viperoutput\endcsname |
| 968 |
\fi |
| 969 |
\endgroup |
| 970 |
\fi |
| 971 |
} |
| 972 |
|
| 973 |
\def\initialize@flushend{% |
| 974 |
%% |
| 975 |
%% Activates flushend package functionality. |
| 976 |
%% |
| 977 |
\global\let\saved@orig@@outputdblcol\@outputdblcol |
| 978 |
\global\let\balanced@@outputdblcol\last@outputdblcol |
| 979 |
\g@addto@macro\@kernel@after@enddocument{\let\@outputdblcol\balanced@@outputdblcol}% |
| 980 |
\g@addto@macro\footnoterule{\vskip\z@}% |
| 981 |
\savingvdiscards=\@ne |
| 982 |
} |
| 983 |
|
| 984 |
\def\flushcolsend{\global\let\@outputdblcol\last@outputdblcol} |
| 985 |
\def\raggedcolsend{\global\let\@outputdblcol\saved@orig@@outputdblcol} |
| 986 |
\def\flushend{\global\let\balanced@@outputdblcol\last@outputdblcol} |
| 987 |
\def\raggedend{\global\let\balanced@@outputdblcol\saved@orig@@outputdblcol} |
| 988 |
\if@balance@debug |
| 989 |
\showcolsendrule |
| 990 |
\fi |
| 991 |
\AtBeginDocument{\initialize@flushend} |
| 992 |
% \end{macrocode} |
| 993 |
% |
| 994 |
% \iffalse |
| 995 |
%</package> |
| 996 |
% \fi |
| 997 |
% |
| 998 |
% \Finale |