summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/sttools
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2021-10-11 20:25:22 +0000
committerKarl Berry <karl@freefriends.org>2021-10-11 20:25:22 +0000
commit2077deb33c2d217375849387f233e7a7421e3fbd (patch)
tree68c93fba497e36f57827a9373ecf2660e6377682 /Master/texmf-dist/tex/latex/sttools
parent5aef2543fad393e3a312080775d7c2ff894f9fa6 (diff)
sttools (11oct21)
git-svn-id: svn://tug.org/texlive/trunk@60736 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/sttools')
-rw-r--r--Master/texmf-dist/tex/latex/sttools/cuted.sty1016
-rw-r--r--Master/texmf-dist/tex/latex/sttools/floatpag.sty93
-rw-r--r--Master/texmf-dist/tex/latex/sttools/flushend.sty1137
-rw-r--r--Master/texmf-dist/tex/latex/sttools/midfloat.sty5
-rw-r--r--Master/texmf-dist/tex/latex/sttools/stabular.sty11
-rw-r--r--Master/texmf-dist/tex/latex/sttools/stfloats.sty2
-rw-r--r--Master/texmf-dist/tex/latex/sttools/texsort.sty5
7 files changed, 1103 insertions, 1166 deletions
diff --git a/Master/texmf-dist/tex/latex/sttools/cuted.sty b/Master/texmf-dist/tex/latex/sttools/cuted.sty
index 972720acffb..86ca9ae9b73 100644
--- a/Master/texmf-dist/tex/latex/sttools/cuted.sty
+++ b/Master/texmf-dist/tex/latex/sttools/cuted.sty
@@ -6,9 +6,8 @@
%%
%% cuted.dtx (with options: `package')
%%
-%% Copyright (C) 1997-2012 by Sigitas Tolu\v{s}is <sigitas@vtex.lt>
-%% VTeX Ltd., Akademijos 4, Vilnius, Lithuania
-%% http://www.vtex.lt/tex/download/macros/
+%% Copyright (C) 1997-2021 by Sigitas Tolu\v{s}is <sigitas@vtex.lt>
+%% UAB VTeX, Mokslininkų 2A, LT-08412 Vilnius, Lithuania
%% --------------------------------------------------------------------------
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
@@ -22,419 +21,527 @@
%%
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{cuted}
- [2012/10/04 v1.5 Mixing onecolumn and twocolumn modes]
-\def\on@stripcols@break{\hbox{}}
-\DeclareOption{unskipbreak}{\gdef\on@stripcols@break{\unskip}}
-\newif\if@flushend@auto@baselineskip
-\DeclareOption{autobase}{\global\@flushend@auto@baselineskiptrue}
+ [2021/10/04 v2.0 Mixing onecolumn and twocolumn modes]
+
+\newif\if@right@column@spread \@right@column@spreadtrue
+\newif\if@right@column@shrink \@right@column@shrinktrue
+\newif\if@left@column@spread \@left@column@spreadtrue
+\newif\if@left@column@shrink \@left@column@shrinktrue
+\newif\ifcuted@@debug \cuted@@debugfalse
+
+\DeclareOption{spread}{%
+ \global\@left@column@spreadtrue
+ \global\@right@column@spreadtrue
+ }
+\DeclareOption{nospread}{%
+ \global\@left@column@spreadfalse
+ \global\@right@column@spreadfalse
+ }
+\DeclareOption{lspread}{\global\@left@column@spreadtrue}
+\DeclareOption{nolspread}{\global\@left@column@spreadfalse}
+\DeclareOption{rspread}{\global\@right@column@spreadtrue}
+\DeclareOption{norspread}{\global\@right@column@spreadfalse}
+
+\DeclareOption{shrink}{%
+ \global\@left@column@shrinktrue
+ \global\@right@column@shrinktrue
+ }
+\DeclareOption{noshrink}{%
+ \global\@left@column@shrinkfalse
+ \global\@right@column@shrinkfalse
+ }
+\DeclareOption{lshrink}{\global\@left@column@shrinktrue}
+\DeclareOption{nolshrink}{\global\@left@column@shrinkfalse}
+\DeclareOption{rshrink}{\global\@right@column@shrinktrue}
+\DeclareOption{norshrink}{\global\@right@column@shrinkfalse}
+
+\DeclareOption{debug}{\global\cuted@@debugtrue}
+\DeclareOption{nodebug}{\global\cutted@@debugfalse}
+
\ProcessOptions
+\newif\if@lastviper \@lastviperfalse
\newtoks\At@ViperColsBreak \At@ViperColsBreak{}
+\newtoks\preCutedStrip \preCutedStrip{}
+\newtoks\postCutedStrip \postCutedStrip{}
+\newbox\cuted@@tempbox@a
+\newbox\cuted@@tempbox@c
+\newbox\cuted@@tempbox@var
+\@ifundefined{hold@viper}
+ {\newbox\hold@viper}{}
+\@ifundefined{@viper}
+ {\newbox\@viper}{}
+\newbox\cuted@@varbox@a
+\newbox\cuted@@varbox@c
+\newdimen\cuted@@tempdim@spread
+\newdimen\cuted@@tempdim@a
+\newdimen\cuted@@tempdim@b
+\newdimen\ht@hold@viper
+\newdimen\ht@viper
+\newdimen\var@@pagediscards@ht \var@@pagediscards@ht=\z@
+\@ifundefined{stripsep}
+ {\newskip\stripsep \stripsep 15\p@ plus 2\p@ minus 2\p@}{}
+\newcount\viper@penalty
+\mathchardef\@Mv=10005
+\def\cuted@@column@badness{101}
+\def\cuted@@page@rule{\z@}
+\savingvdiscards=\@ne
+
+\def\cuted@@wlog@debug#1{\ifcuted@@debug \wlog{#1}\fi}
+
+\def\set@split@topskip@to#1{%
+ \splittopskip=#1\relax
+ \vfuzz=\maxdimen
+ \vbadness=\maxdimen
+ }
+
\def\oldcolsbreak#1{\global\At@ViperColsBreak{#1}}
-\def\viper@top@hook{\splittopskip0pt plus 2pt}
-\newbox\v@aaa
-\newbox\v@ccc
-\@ifundefined{lastskip@a}{\newskip\lastskip@a}{}
-\@ifundefined{lastskip@b}{\newskip\lastskip@b}{}
-\@ifundefined{lastskip@d}{\newskip\lastskip@d}{}
-\@ifundefined{lastbox@a}{\newbox\lastbox@a}{}
-\@ifundefined{stripsep}{\newskip\stripsep \stripsep 15pt plus 2pt minus 2pt}{}
+\def\on@stripcols@break{%
+ %%
+ %% adds original vertical page break skip
+ %%
+ \begingroup
+ \setbox\cuted@@tempbox@var\vbox{\pagediscards}%
+ \ifvoid\cuted@@tempbox@var
+ \else
+ \global\var@@pagediscards@ht=\ht\cuted@@tempbox@var
+ \global\advance\var@@pagediscards@ht by\dp\cuted@@tempbox@var
+ \fi
+ \endgroup
+ \ifdim\var@@pagediscards@ht=\z@
+ \else
+ \vskip\var@@pagediscards@ht
+ \fi
+ }
-\@ifundefined{@viper}{\newbox\@viper}{}
-\newif\if@lastviper \@lastviperfalse
\def\@outputdblcol{%
- \if@firstcolumn
- \global \@firstcolumnfalse
- \global \setbox\@leftcolumn \box\@outputbox
- \else
- \global \@firstcolumntrue
- \setbox\@outputbox \vbox {%
- \hb@xt@\textwidth {%
- \hb@xt@\columnwidth {%
- \box\@leftcolumn \hss}%
- \hfil
- \vrule \@width\columnseprule
- \hfil
- \hb@xt@\columnwidth {%
- \box\@outputbox \hss}%
- }%
- }%
- \ifvoid\hold@viper
+ \if@firstcolumn
+ \global\@firstcolumnfalse
+ \global\setbox\@leftcolumn\copy\@outputbox
+ \splitmaxdepth\maxdimen
+ \vbadness\maxdimen
+ \setbox\@outputbox\vbox{\unvbox\@outputbox\unskip}%
+ \setbox\@outputbox\vsplit\@outputbox to\maxdimen
+ \toks@\expandafter{\topmark}%
+ \xdef\@firstcoltopmark{\the\toks@}%
+ \toks@\expandafter{\splitfirstmark}%
+ \xdef\@firstcolfirstmark{\the\toks@}%
+ \ifx\@firstcolfirstmark\@empty
+ \global\let\@setmarks\relax
+ \else
+ \gdef\@setmarks{%
+ \let\firstmark\@firstcolfirstmark
+ \let\topmark\@firstcoltopmark
+ }%
+ \fi
\else
- \setbox\@outputbox \vbox to\textheight{%
- \box\hold@viper
- \box\@outputbox
- \vss
- }%
+ \global\@firstcolumntrue
+ \setbox\@outputbox\vbox{%
+ \hb@xt@\textwidth{%
+ \hb@xt@\columnwidth{\box\@leftcolumn \hss}%
+ \hfil
+ {\normalcolor\vrule \@width\columnseprule}%
+ \hfil
+ \hb@xt@\columnwidth{\box\@outputbox \hss}%
+ }%
+ }%
+ \ifvoid\hold@viper
+ \else
+ \setbox\@outputbox\vbox to\textheight{%
+ \box\hold@viper
+ \box\@outputbox
+ \vss
+ }%
+ \fi
+ \@combinedblfloats
+ \@setmarks
+ \@outputpage
+ \begingroup
+ \@dblfloatplacement
+ \@startdblcolumn
+ \@whilesw\if@fcolmade \fi
+ {\@outputpage \@startdblcolumn}%
+ \ifvoid\@viper
+ \else
+ \global\setbox\@viper\vbox{%
+ \vskip-\stripsep
+ \unvbox\@viper
+ }%
+ \@viperoutput
+ \fi
+ \endgroup
\fi
- \@combinedblfloats
- \@outputpage
- \begingroup
- \@dblfloatplacement
- \@startdblcolumn
- \@whilesw\if@fcolmade \fi
- {\@outputpage
- \@startdblcolumn}%
- \ifvoid\@viper
- \else
- \global\setbox\@viper\vbox{%
- \vskip-\stripsep
- \unvbox\@viper
- }%
- \@viperoutput
- \fi
- \endgroup
- \fi
- }
-\mathchardef\@Mv=10005
-\newcount\viper@penalty
+ }
\def\strip{%
- \ifinner
- \@parmoderr\viper@penalty\z@
- \else
- \viper@penalty=-\@Mv\relax
- \fi
- \global \setbox\@viper\vbox\bgroup%
+ \ifinner
+ \@parmoderr
+ \viper@penalty\z@
+ \else
+ \viper@penalty=-\@Mv
+ \fi
+ \global\setbox\@viper\vbox\bgroup
\hsize\textwidth
\@parboxrestore
- \col@number \@ne
+ \col@number=\@ne
\vrule height\topskip width\z@ depth\z@
- }
+ }
\def\endstrip{%
\egroup
- \ifnum\viper@penalty <-\@Mii
- \penalty -\@Miv
- \ifvmode
- \@tempdima\prevdepth %% saving and restoring \prevdepth added
- \vbox{}% %% 26 May 87 to prevent extra vertical
- \prevdepth\@tempdima %% space when used in vertical mode
- \penalty-\@Mv\relax
- \else
- \par
- \penalty-\@Mv\relax
- \noindent
- \fi
+ \ifnum\viper@penalty<-\@Mii
+ \penalty-\@Miv
+ \ifvmode
+ \@tempdima\prevdepth
+ \vbox{}%
+ \prevdepth\@tempdima
+ \penalty-\@Mv\relax
+ \else
+ \par
+ \penalty-\@Mv
+ \noindent
+ \fi
\fi
}
\gdef\@viperoutput{%
- \global \setbox\@holdpg \vbox{%
- \unvbox\@holdpg
- \unvbox\@cclv
- \setbox\@tempboxa \lastbox
- \unskip
- }%
- \@pagedp \dp\@holdpg
- \@pageht \ht\@holdpg
- \ifvoid\@viper\else
- \advance \@pageht \@pagedp
- \ifvoid\footins \else
- \advance \@pageht \ht\footins
- \advance \@pageht \skip\footins
- \advance \@pageht \dp\footins
- \fi
- \ifvbox \@kludgeins
- \ifdim \wd\@kludgeins=\z@
- \advance \@pageht \ht\@kludgeins
- \fi
- \fi
- \@reinserts
- \@addviper
- \fi
- }
+ \global\setbox\@holdpg\vbox{%
+ \unvbox\@holdpg
+ \unvbox\@cclv
+ \setbox\@tempboxa\lastbox
+ \unskip
+ }%
+ \@pagedp=\dp\@holdpg
+ \@pageht=\ht\@holdpg
+ \ifvoid\@viper
+ \else
+ \advance\@pageht by\@pagedp
+ \ifvoid\footins
+ \else
+ \advance\@pageht by\ht\footins
+ \advance\@pageht by\skip\footins
+ \advance\@pageht by\dp\footins
+ \fi
+ \ifvbox\@kludgeins
+ \ifdim\wd\@kludgeins=\z@
+ \advance\@pageht by\ht\@kludgeins
+ \fi
+ \fi
+ \@reinserts
+ \@addviper
+ \fi
+ }
\gdef\@specialoutput{%
- \ifnum \outputpenalty>-\@Mii
- \@doclearpage
- \else
- \ifnum \outputpenalty<-\@Miii
- \ifnum \outputpenalty<-\@MM \deadcycles \z@ \fi
- \ifnum \outputpenalty=-\@Mv
- \@viperoutput
- \ifnum \outputpenalty<\z@
- \if@nobreak
- \else
- \addpenalty \interlinepenalty
- \fi
- \fi
- \else
- \global \setbox\@holdpg \vbox {\unvbox\@cclv}%
- \fi
- \else
- \global \setbox\@holdpg \vbox{%
- \unvbox\@holdpg
- \unvbox\@cclv
- \setbox\@tempboxa \lastbox
- \unskip
- }%
- \@pagedp \dp\@holdpg
- \@pageht \ht\@holdpg
- \unvbox \@holdpg
- \@next\@currbox\@currlist{%
- \ifnum \count\@currbox>\z@
- \advance \@pageht \@pagedp
- \ifvoid\footins \else
- \advance \@pageht \ht\footins
- \advance \@pageht \skip\footins
- \advance \@pageht \dp\footins
- \fi
- \ifvbox \@kludgeins
- \ifdim \wd\@kludgeins=\z@
- \advance \@pageht \ht\@kludgeins
- \fi
- \fi
- \@reinserts
- \@addtocurcol
- \else
- \@reinserts
- \@addmarginpar
- \fi
- }\@latexbug
- \ifnum \outputpenalty<\z@
- \if@nobreak
- \else
- \addpenalty \interlinepenalty
- \fi
- \fi
- \fi
+ \ifnum\outputpenalty>-\@Mii
+ \@doclearpage
+ \else
+ \ifnum\outputpenalty<-\@Miii
+ \ifnum\outputpenalty<-\@MM \deadcycles \z@ \fi
+ \ifnum\outputpenalty=-\@Mv
+ \@viperoutput
+ \ifnum\outputpenalty<\z@
+ \if@nobreak
+ \else
+ \addpenalty \interlinepenalty
+ \fi
+ \fi
+ \else
+ \global\setbox\@holdpg\vbox{\unvbox\@cclv}%
+ \fi
+ \else
+ \global\setbox\@holdpg\vbox{%
+ \unvbox\@holdpg
+ \unvbox\@cclv
+ \setbox\@tempboxa\lastbox
+ \unskip
+ }%
+ \@pagedp=\dp\@holdpg
+ \@pageht=\ht\@holdpg
+ \unvbox\@holdpg
+ \@next\@currbox\@currlist{%
+ \ifnum\count\@currbox>\z@
+ \advance \@pageht \@pagedp
+ \ifvoid\footins
+ \else
+ \advance\@pageht by\ht\footins
+ \advance\@pageht by\skip\footins
+ \advance\@pageht by\dp\footins
+ \fi
+ \ifvbox\@kludgeins
+ \ifdim\wd\@kludgeins=\z@
+ \advance\@pageht by\ht\@kludgeins
+ \fi
+ \fi
+ \@reinserts
+ \@addtocurcol
+ \else
+ \@reinserts
+ \@addmarginpar
+ \fi
+ }\@latexbug
+ \ifnum\outputpenalty<\z@
+ \if@nobreak
+ \else
+ \addpenalty \interlinepenalty
+ \fi
+ \fi
+ \fi
\fi
}
-\@ifundefined{hold@viper}{\newbox\hold@viper}{}
-\newdimen\ht@viper
-\def \@addviper {%
- \if@firstcolumn
- \@insertfalse
- \@reqcolroom .5\@pageht
- \ht@viper\@reqcolroom
- \advance \@reqcolroom \ht\@viper
- \advance \@reqcolroom \stripsep
- \ifvoid\hold@viper\@tempdima=\z@\else\@tempdima\ht\hold@viper\fi
-%%
- \@tempdimb \ht@viper
- \loop
- \setbox\v@aaa\copy\@holdpg
- \setbox\v@ccc\vbox to\@tempdimb{%
- \vsplit\v@aaa to\@tempdimb\vss\vsplit\v@aaa to\@tempdimb}%
- \wlog{Extra height:\the\ht\v@aaa\space when \the\@tempdimb}%
- \ifvoid\v@aaa \else \advance\@tempdimb 1pt \repeat
- \loop
- \setbox\v@aaa\copy\@holdpg
- \setbox\v@ccc\vbox to\@tempdimb{%
- \vsplit\v@aaa to\@tempdimb\vss}%
- \wlog{(2)Left:\the\ht\v@ccc\space Right:\the\ht\v@aaa\space Output:\the\@tempdimb}%
- \ifdim \ht\v@ccc<\ht\v@aaa \@tempdimb \the\ht\v@aaa \repeat
- \wlog{- LAST -^^JLeft:\the\ht\v@ccc^^JRight:\the\ht\v@aaa^^JOutput:\the\@tempdimb}%
- \setbox\v@ccc\vbox to\@tempdimb{%
- \vsplit\@holdpg to\@tempdimb\vss}%
-%%
- \setbox\@tempboxa \vbox {%
- \hb@xt@\textwidth {%
- \hb@xt@\columnwidth {%
- \vbox to\ht@viper{\box\v@ccc\vss} \hss}%
- \hfil
- \vrule \@width\columnseprule
- \hfil
- \hb@xt@\columnwidth {%
- \vbox to\ht@viper{\box\@holdpg\vss} \hss}%
- }%
- }%
- \ifvoid\hold@viper
- \global\setbox\hold@viper \vbox {%
- \unvbox\@tempboxa
- \penalty\interlinepenalty
- \vskip\stripsep
- \ifnum\outputpenalty <-\@Mii \vskip -\parskip\fi
- \outputpenalty \z@
- }%
- \else
- \global\setbox\hold@viper \vbox {%
- \unvbox\hold@viper
- \unvbox\@tempboxa
- \penalty\interlinepenalty
- \vskip\stripsep
- \ifnum\outputpenalty <-\@Mii \vskip -\parskip\fi
- \outputpenalty \z@
+\def\@addviper{%
+ \@insertfalse
+ \def\var@@thecol@num{2}%
+ \if@firstcolumn
+ \def\var@@thecol@num{1}%
+ \@reqcolroom=.5\@pageht
+ \ht@viper=\@reqcolroom
+ \advance\@reqcolroom by\ht\@viper
+ \advance\@reqcolroom by\stripsep
+ \else
+ \@reqcolroom=\@colht
+ \advance\@reqcolroom by\@pageht
+ \ht@viper.5\@reqcolroom
+ \@reqcolroom=\ht@viper
+ \advance\@reqcolroom by\ht\@viper
+ \advance\@reqcolroom by\stripsep
+ \global\setbox\@holdpg\vbox{%
+ \setbox\cuted@@tempbox@a\vbox{%
+ \aftergroup\unvbox
+ \unvcopy\@leftcolumn
+ \unskip\unkern\unpenalty
+ \setbox\@tempboxa\lastbox
+ \ifdim\dimexpr\ht\@tempboxa+\wd\@tempboxa+\dp\@tempboxa>\z@
+ %% keeps lastbox
+ \aftergroup\@leftcolumn
+ \else
+ %% removes lastbox
+ \aftergroup\cuted@@tempbox@a
+ \fi
+ }%
+ \unskip\unkern\unpenalty
+ \on@stripcols@break
+ \the\At@ViperColsBreak
+ \unvbox\@holdpg
+ }%
+ \global\At@ViperColsBreak{}%
+ \ht@viper=.5\ht\@holdpg
+ \ifdim\ht@viper>\@colht
+ \ht@viper=\@colht
+ \fi
+ \fi
+ %%
+ %% calculations for breaking
+ %%
+ \ifvoid\hold@viper
+ \ht@hold@viper=\z@
+ \else
+ \ht@hold@viper=\ht\hold@viper
+ \fi
+ \cuted@@tempdim@b\ht@viper
+ \set@split@topskip@to\topskip
+ \loop
+ \xdef\saved@tempdimb{\the\cuted@@tempdim@b}%
+ \setbox\cuted@@varbox@a\copy\@holdpg
+ \setbox\cuted@@tempbox@a\vsplit\cuted@@varbox@a to\cuted@@tempdim@b
+ %% set leftcolumn boxes
+ \setbox\cuted@@tempbox@c\vbox{\unvbox\cuted@@tempbox@a}%
+ \setbox\cuted@@tempbox@a\vbox to\cuted@@tempdim@b{\unvcopy\cuted@@tempbox@c}%
+ \xdef\var@@leftcolumn@badness{\the\badness}%
+ %% set rightcolumn boxes
+ \setbox\cuted@@varbox@c\vbox{\unvbox\cuted@@varbox@a}%
+ \setbox\cuted@@varbox@a\vbox to\cuted@@tempdim@b{\unvcopy\cuted@@varbox@c}%
+ \xdef\var@@rightcolumn@badness{\the\badness}%
+ %% analyzing split goodness
+ \cuted@@tempdim@spread=\ht\cuted@@tempbox@c
+ \advance\cuted@@tempdim@spread by\dp\cuted@@tempbox@c
+ \advance\cuted@@tempdim@spread by-\ht\cuted@@varbox@c
+ \advance\cuted@@tempdim@spread by-\dp\cuted@@varbox@c
+ \cuted@@wlog@debug{CUTED [-----]%
+ ^^JLeft: \the\ht\cuted@@tempbox@c
+ +\the\dp\cuted@@tempbox@c\space/\var@@leftcolumn@badness
+ ^^JRight: \the\ht\cuted@@varbox@c
+ +\the\dp\cuted@@varbox@c\space/\var@@rightcolumn@badness
+ ^^JSplit: \the\cuted@@tempdim@b
+ ^^JExtra height: \the\cuted@@tempdim@spread
+ }%
+ \ifnum\var@@leftcolumn@badness<\cuted@@column@badness
+ \ifnum\var@@rightcolumn@badness<\cuted@@column@badness
+ \cuted@@tempdim@spread=\z@
+ \fi
+ \fi
+ \ifdim\cuted@@tempdim@spread<\z@
+ \if@left@column@spread
+ \if@right@column@shrink
+ \ifdim\dimexpr\cuted@@tempdim@spread+\pageshrink>\z@
+ \cuted@@tempdim@a=\dimexpr\ht\cuted@@tempbox@c-0.5\cuted@@tempdim@spread\relax
+ \else
+ \cuted@@tempdim@a=-\dimexpr\cuted@@tempdim@spread+.5\pageshrink\relax
+ \fi
+ \setbox\cuted@@varbox@a\vbox to\cuted@@tempdim@a{\unvcopy\cuted@@tempbox@c}%
+ \ifnum\badness<\cuted@@column@badness
+ \cuted@@tempdim@b=\cuted@@tempdim@a
+ \cuted@@tempdim@spread=\z@
+ \fi
+ \cuted@@wlog@debug{CUTED [leftcolumn badness]: \number\badness\space on \the\cuted@@tempdim@a}%
+ \setbox\cuted@@varbox@a\vbox to\cuted@@tempdim@a{\unvcopy\cuted@@varbox@c}%
+ \cuted@@wlog@debug{CUTED [rightcolumn badness]: \number\badness\space on \the\cuted@@tempdim@a}%
+ \else
+ \setbox\cuted@@varbox@a\vbox to\ht\cuted@@varbox@c{%
+ \unvcopy\cuted@@tempbox@c
}%
- \fi
- \ifdim \@colroom>\@reqcolroom
- \global\setbox\hold@viper \vbox {%
- \unvbox\hold@viper
- \box\@viper
- \penalty\interlinepenalty
- \vskip\stripsep
- \ifnum\outputpenalty <-\@Mii \vskip -\parskip\fi
- \outputpenalty \z@
+ \ifnum\badness<\cuted@@column@badness
+ \@tempdimb=\ht\cuted@@varbox@c
+ \cuted@@tempdim@spread=\z@
+ \fi
+ \cuted@@wlog@debug{CUTED [leftcolumn badness]: \number\badness on \the\ht\cuted@@varbox@c}%
+ \setbox\cuted@@varbox@a\vbox to\ht\cuted@@varbox@c{%
+ \unvcopy\cuted@@varbox@c
}%
- \@inserttrue
- \advance\@tempdima by-\ht\hold@viper
- \global \advance \@colht \@tempdima
- \ifdim \@colht<2.5\baselineskip
- \@latex@warning@no@line {Optional argument of \noexpand\twocolumn
- too tall on page \thepage (1 stulpelis)}%
- \@emptycol
- \if@firstcolumn
- \else
- \@emptycol
- \fi
- \global\@lastvipertrue
+ \cuted@@wlog@debug{CUTED [rightcolumn badness]: \number\badness on \the\ht\cuted@@varbox@c}%
+ \fi
+ \else
+ \if@right@column@shrink
+ \ifdim\dimexpr\cuted@@tempdim@spread+\pageshrink<\z@
+ \else
+ \cuted@@tempdim@b=\ht\cuted@@tempbox@c
+ \cuted@@tempdim@spread=\z@
+ \fi
+ \fi
+ \fi
+ \else
+ \ifdim\cuted@@tempdim@spread>\z@
+ \ifdim\dimexpr\@tempdimb+\p@\relax>\@colht
+ \cuted@@tempdim@b=\@colht
+ \cuted@@tempdim@spread=\z@
+ \fi
+ \fi
+ \fi
+ \ifdim\cuted@@tempdim@spread<\z@
+ \advance\cuted@@tempdim@b 1\p@
+ \repeat
+ \wlog{CUTED [- LAST -]%
+ ^^JExtra skip:\the\cuted@@tempdim@spread
+ ^^JLeft:\the\ht\cuted@@tempbox@c/\the\dp\cuted@@tempbox@c
+ ^^JRight:\the\ht\cuted@@varbox@c/\the\dp\cuted@@varbox@c
+ ^^JSplit: \saved@tempdimb
+ ^^JOutput:\the\cuted@@tempdim@b
+ ^^JPageshrink: \the\pageshrink
+ ^^JPagestretch: \the\pagestretch
+ ^^J@colht:\the\@colht
+ }%
+ %%
+ %% final construction of the cuted page above strip
+ %%
+ \setbox\cuted@@tempbox@c\vsplit\@holdpg to\saved@tempdimb
+ \setbox\cuted@@tempbox@a\vbox to\cuted@@tempdim@b{%
+ \cuted@@tempdim@a=\dimexpr
+ \cuted@@tempdim@b-\ht\cuted@@tempbox@c
+ \relax
+ \cuted@@tempdim@spread=\dp\cuted@@tempbox@c
+ \unvbox\cuted@@tempbox@c
+ \ifdim\cuted@@tempdim@spread>\dp\strutbox
\else
- \global \vsize \@colht
- \global \@colroom \@colht
- \check@floats
- \ifdim\@tempdima>\z@
- \global\advance\@colroom by-\@tempdima
- \fi
- \ifdim\@colroom<\z@
- \global\@colroom 1pt
- \ifdim\@tempdima>\@colht
- \@latex@warning@no@line {TOP ir/ar BOT FLOAT's
- netelpa lape \thepage (1 stulpelis)}%
- \fi
- \@emptycol
- \if@firstcolumn
- \else
- \@emptycol
- \fi
- \global\@lastvipertrue
- \fi
+ \vskip-\cuted@@tempdim@spread
\fi
- \fi
- \else
- \@insertfalse
- \@reqcolroom\@colht
- \advance\@reqcolroom \@pageht
- \ht@viper.5\@reqcolroom
- \@reqcolroom\ht@viper
- \advance \@reqcolroom \ht\@viper
- \advance \@reqcolroom \stripsep
- \if@flushend@auto@baselineskip
- \setbox\@tempboxa\vbox{\unvcopy\@leftcolumn
- \global\lastskip@d\lastskip
- \global\lastskip@b\lastskip
- \loop
- \global\lastskip@a\lastskip@b
- \unskip\unpenalty
- \global\lastskip@b\lastskip
- \global\advance\lastskip@d by\lastskip
- \ifdim\lastskip@b=-\lastskip@a
- \global\advance\lastskip@d by-\lastskip
- \else
- \repeat
- \ifdim\lastskip@b=-\lastskip@a
- \ifdim\lastskip@b=\z@
- \setbox\lastbox@a\lastbox
- \global\advance\lastskip@d by\ht\lastbox@a
- \global\advance\lastskip@d by\lastskip
- \unskip\unpenalty
- \setbox\lastbox@a\lastbox
- \global\advance\lastskip@d by\dp\lastbox@a
+ \prevdepth\z@
+ \hrule\@height\cuted@@page@rule width\textwidth
+ \vskip-\cuted@@page@rule
+ \ifdim\cuted@@tempdim@a>\z@
+ \if@left@column@spread
\else
- \global\lastskip@d\lastskip
- \global\advance\lastskip@d by\topskip
+ \vss
\fi
- \fi
- \global\advance\lastskip@d by-\topskip
- }%
- \ifdim\ht\@holdpg>\@colht
- \global\setbox\@holdpg\vbox{\unvbox\@leftcolumn\unskip\unpenalty
- \par\eject
- \vbox to \@colht{\unvbox\@holdpg\unskip}%
- }%
- \else
- \global\setbox\@holdpg\vbox{%
- \unvbox\@leftcolumn\unskip\unpenalty
- \vskip\lastskip@d
- \the\At@ViperColsBreak
- \unvbox\@holdpg
- \unskip
- }%
- \fi
- \else
- \global\setbox\@holdpg\vbox{%
- \unvbox\@leftcolumn
- \setbox\@tempboxa\lastbox
- \on@stripcols@break
- \the\At@ViperColsBreak
- \unvbox\@holdpg
- }%
- \fi
- \global\At@ViperColsBreak{}%
- \ht@viper .5\ht\@holdpg
- \ifdim \ht@viper>\@colht
- \ht@viper \@colht
- \fi
- \ifvoid\hold@viper\@tempdima=\z@\else\@tempdima\ht\hold@viper\fi
-%%
- \@tempdimb \ht@viper
- \loop
- \setbox\v@aaa\copy\@holdpg
- \setbox\v@ccc\vbox to\@tempdimb{%
- \vsplit\v@aaa to\@tempdimb
+ \else
+ \ifdim\cuted@@tempdim@a<\z@
+ \if@left@column@shrink
+ \else
+ \vss
+ \fi
+ \fi
+ \fi
+ }%
+ \wlog{CUTED [output]: \the\cuted@@tempdim@b
+ ^^JCUTED [leftcolumn badness]: \number\badness
+ }%
+ \setbox\cuted@@varbox@a\vbox to\cuted@@tempdim@b{%
+ \cuted@@tempdim@a=\dimexpr
+ \cuted@@tempdim@b-\ht\@holdpg
+ \relax
+ \unvbox\@holdpg
+ \ifdim\cuted@@tempdim@a>\z@
+ \if@right@column@spread
+ \else
\vss
- \vsplit\v@aaa to\@tempdimb
+ \fi
+ \else
+ \ifdim\cuted@@tempdim@a<\z@
+ \if@right@column@shrink
+ \else
+ \vss
+ \fi
+ \fi
+ \fi
+ }%
+ \wlog{CUTED [rightcolumn badness]: \number\badness}%
+ \setbox\cuted@@tempbox@var\vbox{%
+ \hb@xt@\textwidth{%
+ \hb@xt@\columnwidth{%
+ \vbox to\ht@viper{\box\cuted@@tempbox@a\vss}%
+ \hss
}%
- \wlog{Extra height:\the\ht\v@aaa\space when \the\@tempdimb}%
- \ifvoid\v@aaa
- \else
- \advance\@tempdimb 1\p@
- \repeat
- \loop
- \setbox\v@aaa\copy\@holdpg
- \setbox\v@ccc\vbox to\@tempdimb{\vsplit\v@aaa to\@tempdimb\vss}%
- \wlog{(2)Left:\the\ht\v@ccc\space
- Right:\the\ht\v@aaa\space
- Output:\the\@tempdimb
- }%
- \ifdim\ht\v@ccc<\ht\v@aaa
- \@tempdimb \the\ht\v@aaa
- \repeat
- \wlog{- LAST -^^JLeft:\the\ht\v@ccc
- ^^JRight:\the\ht\v@aaa
- ^^JOutput:\the\@tempdimb
- }%
- \setbox\v@ccc\vbox to\@tempdimb{\vsplit\@holdpg to\@tempdimb\vss}%
- \setbox\@tempboxa\vbox{%
- \hb@xt@\textwidth {%
- \hb@xt@\columnwidth{\vbox to\ht@viper{\box\v@ccc\vss} \hss}%
\hfil
- \vrule \@width\columnseprule
+ {\normalcolor\vrule \@width\columnseprule}%
\hfil
- \hb@xt@\columnwidth {\vbox to\ht@viper{\box\@holdpg\vss} \hss}%
+ \hb@xt@\columnwidth{%
+ \vbox to\ht@viper{\box\cuted@@varbox@a\vss}%
+ \hss
+ }%
}%
}%
- \ifvoid\hold@viper
- \global\setbox\hold@viper \vbox {%
- \unvbox\@tempboxa
- \penalty\interlinepenalty
- \vskip\stripsep
- \ifnum\outputpenalty <-\@Mii \vskip -\parskip\fi
- \outputpenalty \z@
- }%
- \else
- \global\setbox\hold@viper \vbox {%
- \unvbox\hold@viper
- \unvbox\@tempboxa
- \penalty\interlinepenalty
- \vskip\stripsep
- \ifnum\outputpenalty <-\@Mii \vskip -\parskip\fi
- \outputpenalty \z@
- }%
- \fi
- \ifdim \@colht>\@reqcolroom
- \global\setbox\hold@viper \vbox {%
- \unvbox\hold@viper
- \box\@viper
- \penalty\interlinepenalty
- \vskip\stripsep
- \ifnum\outputpenalty <-\@Mii \vskip -\parskip\fi
- \outputpenalty \z@
- }%
+ %%
+ %% finalize cuted page
+ %%
+ \ifvoid\hold@viper
+ \global\setbox\hold@viper\vbox{%
+ \unvbox\cuted@@tempbox@var
+ \penalty\interlinepenalty
+ \vskip\stripsep
+ \the\preCutedStrip
+ \ifnum\outputpenalty<-\@Mii
+ \vskip -\parskip
+ \fi
+ \outputpenalty\z@
+ }%
+ \else
+ \global\setbox\hold@viper\vbox{%
+ \unvbox\hold@viper
+ \cuted@@tempbox@var
+ \penalty\interlinepenalty
+ \vskip\stripsep
+ \the\preCutedStrip
+ \ifnum\outputpenalty<-\@Mii
+ \vskip -\parskip
+ \fi
+ \outputpenalty\z@
+ }%
+ \fi
+ \ifdim\@colht>\@reqcolroom
+ \global\setbox\hold@viper\vbox{%
+ \unvbox\hold@viper
+ \box\@viper
+ \penalty\interlinepenalty
+ \the\postCutedStrip
+ \vskip\stripsep
+ \ifnum\outputpenalty<-\@Mii
+ \vskip -\parskip
+ \fi
+ \outputpenalty\z@
+ }%
\@inserttrue
\global\@firstcolumntrue
- \advance\@tempdima by-\ht\hold@viper
- \global \advance \@colht \@tempdima
- \ifdim \@colht<2.5\baselineskip
+ \advance\ht@hold@viper by-\ht\hold@viper
+ \global\advance\@colht by\ht@hold@viper
+ \ifdim\@colht<2.5\baselineskip
\@latex@warning@no@line {Optional argument of \noexpand\twocolumn
- too tall on page \thepage (2 stulpelis)}%
+ too tall on page \thepage (\var@@thecol@num column)}%
\@emptycol
\if@firstcolumn
\else
@@ -442,17 +549,17 @@
\fi
\global\@lastvipertrue
\else
- \global \vsize \@colht
- \global \@colroom \@colht
- \check@floats
- \ifdim\@tempdima>\z@
- \global\advance\@colroom by-\@tempdima
+ \global\vsize\@colht
+ \global\@colroom\@colht
+ \check@floats\cuted@@tempdim@a
+ \ifdim\cuted@@tempdim@a>\z@
+ \global\advance\@colroom by-\cuted@@tempdim@a
\fi
\ifdim\@colroom<\z@
- \global\@colroom 1pt
- \ifdim\@tempdima>\@colht
- \@latex@warning@no@line {TOP ir/ar BOT FLOAT's
- netelpa lape \thepage (2 stulpelis)}%
+ \global\@colroom1\p@
+ \ifdim\cuted@@tempdim@a>\@colht
+ \@latex@warning@no@line{TOP and/or BOT FLOAT's
+ to large on \thepage (\var@@thecol@num column)}%
\fi
\@emptycol
\if@firstcolumn
@@ -462,73 +569,80 @@
\global\@lastvipertrue
\fi
\fi
- \fi
- \fi
- \if@insert
- \else
- \advance\@tempdima by-\ht\hold@viper
- \global \advance \@colht \@tempdima
- \global\setbox\hold@viper \vbox {%
- \unvbox\hold@viper
- \csname viper@top@hook\endcsname
- \vsplit\@viper to \@colht
- \vss
- }%
- \vbox{}%
- \global\@firstcolumnfalse
- \newpage
- \fi
- }
-
-\def\check@floats{%
- \global\@tempdima\z@
- \let\@elt\ht@comflelt
- \ifx\@toplist\@empty \else \@toplist \fi
- \ifx\@botlist\@empty \else \@botlist \fi
+ \fi
+ \if@insert
+ \else
+ \advance\ht@hold@viper by-\ht\hold@viper
+ \global\advance\@colht by\ht@hold@viper
+ \global\setbox\hold@viper\vbox{%
+ \unvbox\hold@viper
+ \set@split@topskip@to{\z@ plus2\p@}%
+ \vsplit\@viper to\@colht
+ \vss
+ }%
+ \vbox{}%
+ \global\@firstcolumnfalse
+ \newpage
+ \fi
}
-\def\ht@comflelt#1{%
- \setbox\@tempboxa\vbox{\copy #1\vskip\floatsep}%
- \global\advance\@tempdima by\ht\@tempboxa
- }
-\output {%
- \let \par \@@par
- \ifnum \outputpenalty<-\@M
- \@specialoutput
- \else
- \@makecol
- \@opcol
- \@startcolumn
- \@whilesw \if@fcolmade \fi
- {%
- \@opcol\@startcolumn}%
- \fi
- \ifnum \outputpenalty>-\@Miv
- \ifdim \@colroom<1.5\baselineskip
- \ifdim \@colroom<\textheight
- \@latex@warning@no@line {Text page \thepage\space
- contains only floats}%
- \if@lastviper\else\@emptycol\fi
- \if@twocolumn
- \if@firstcolumn
- \else
- \@emptycol
- \fi
- \fi
- \global\@lastviperfalse
- \else
- \global \vsize \@colroom
- \fi
+\def\check@floats#1{%
+ \begingroup
+ \global#1\z@
+ \def\@elt##1{%
+ \setbox\@tempboxa\vbox{\copy #1\vskip\floatsep}%
+ \global\advance##1 by\ht\@tempboxa
+ }%
+ \ifx\@toplist\@empty \else \@toplist \fi
+ \ifx\@botlist\@empty \else \@botlist \fi
+ \endgroup
+ }
+\output{%
+ \let\par\@@par
+ \ifnum\outputpenalty<-\@M
+ \@specialoutput
\else
- \global \vsize \@colroom
+ \@makecol
+ \@opcol
+ \@startcolumn
+ \@whilesw\if@fcolmade\fi
+ {\@opcol \@startcolumn}%
\fi
- \else
- \ifnum\outputpenalty<-100005
- \global \vsize \maxdimen
+ \ifnum\outputpenalty>-\@Miv
+ \ifdim\@colroom<1.5\baselineskip
+ \ifdim\@colroom<\textheight
+ \@latex@warning@no@line{%
+ Text page \thepage\space contains only floats%
+ }%
+ \if@lastviper
+ \else
+ \@emptycol
+ \fi
+ \if@twocolumn
+ \if@firstcolumn
+ \else
+ \@emptycol
+ \fi
+ \fi
+ \global\@lastviperfalse
+ \else
+ \global\vsize\@colroom
+ \fi
+ \else
+ \global\vsize\@colroom
+ \fi
\else
- \global \vsize \@colroom
+ \ifnum\outputpenalty<-\@Mv
+ \global\vsize\maxdimen
+ \else
+ \global\vsize\@colroom
+ \fi
\fi
- \fi
- }
+ }
+\ifcuted@@debug
+ \xdef\cuted@@page@rule{.4\p@}
+\else
+ \xdef\cuted@@page@rule{\z@}
+\fi
\endinput
%%
%% End of file `cuted.sty'.
diff --git a/Master/texmf-dist/tex/latex/sttools/floatpag.sty b/Master/texmf-dist/tex/latex/sttools/floatpag.sty
index 98b32de3206..d6e468e07e3 100644
--- a/Master/texmf-dist/tex/latex/sttools/floatpag.sty
+++ b/Master/texmf-dist/tex/latex/sttools/floatpag.sty
@@ -7,8 +7,8 @@
%% floatpag.dtx (with options: `package')
%%
%% Copyright (C) 1999-2012 by Vytas Statulevi\v{c}ius <vytas@vtex.lt>
-%% VTeX Ltd., Akademijos 4, Vilnius, Lithuania
-%% http://www.vtex.lt/tex/download/macros/
+%% Copyright (C) 2021 by Sigitas Tolu\v{s}is <sigitas@vtex.lt>
+%% UAB VTeX, Mokslininkų 2A, LT-08412 Vilnius, Lithuania
%% --------------------------------------------------------------------------
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
@@ -28,21 +28,14 @@
%%
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{floatpag}
- [2012/05/29 v1.1 Different pagestyles on float pages]
-\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{floatpag}
- [1999/04/29
- FLOAT PAGESTYLE]
+ [2021/10/04 v2.0 Different pagestyles on float pages]
+
\def\floatpagestyle#1{\gdef\at@float@page{\thispagestyle{#1}}}
-\def\rotfloatpagestyle#1{%
- \gdef\@r@f@pagestyle{#1}%
- \gdef\at@rotfloat@page{\thispagestyle{#1}}%
- }
+\def\rotfloatpagestyle#1{\gdef\@r@f@pagestyle{#1}}
\floatpagestyle{headings}
\rotfloatpagestyle{plain}
\def\thisfloatpagestyle#1{%
- \expandafter\expandafter\expandafter\gdef\expandafter
- \csname\number\@currbox @float\endcsname{\thispagestyle{#1}}\relax
+ \global\@namedef{\number\@currbox @float}{\thispagestyle{#1}}\relax
}
%% Modify |\x@float| - ordinary floats
\def\@xfloat #1[#2]{%
@@ -79,28 +72,27 @@
\else
\advance \@tempcnta \@ne
\fi
- \fi
- \if \reserved@a t%
+ \else\if \reserved@a t%
\@setfpsbit \tw@
- \fi
- \if \reserved@a b%
+ \else\if \reserved@a b%
\@setfpsbit 4%
- \fi
- \if \reserved@a p%
+ \else\if \reserved@a p%
\@setfpsbit 8%
- \fi
- \if \reserved@a !%
+ \else\if \reserved@a !%
\ifnum \@tempcnta>15
\advance\@tempcnta -\sixt@@n\relax
\fi
- \fi
+ \else
+ \@latex@error{Unknown float option `\reserved@a'}%
+ {Option `\reserved@a' ignored and `p' used.}%
+ \@setfpsbit 8%
+ \fi\fi\fi\fi\fi
}%
\@tempcntb \csname ftype@\@captype \endcsname
\multiply \@tempcntb \@xxxii
\advance \@tempcnta \@tempcntb
\global \count\@currbox \@tempcnta
- \expandafter\expandafter\expandafter\gdef\expandafter
- \csname\number\@currbox @float\endcsname{\at@float@page}\relax
+ \global\@namedef{\number\@currbox @float}{\at@float@page}\relax
}%
\@fltovf
\fi
@@ -112,52 +104,27 @@
\@parboxrestore
\@floatboxreset
}
-%% 2e rotating.sty v. 2.10:
-\def\e@xrotfloat#1[#2]{%
+\def\floatpag@@xrotfloat#1[#2]{%
\@float{#1}[#2]%
\thisfloatpagestyle{\@r@f@pagestyle}%
\begin{lrbox}\rot@float@box
\begin{minipage}\textheight
}
-%% 2.09 rotating.sty v. 1.6
-\def\n@xrotfloat#1[#2]{%
- \ifhmode
- \@bsphack
- \@floatpenalty -\@Mii
- \else
- \@floatpenalty-\@Miii
- \fi
- \def\@captype{#1}%
- \ifinner
- \@parmoderr\@floatpenalty\z@
- \else
- \@next\@currbox\@freelist{\@tempcnta\csname ftype@#1\endcsname
- \multiply\@tempcnta\@xxxii\advance\@tempcnta\sixt@@n
- \@tfor \@tempa :=#2\do{%
- \if\@tempa h\advance\@tempcnta \@ne\fi
- \if\@tempa t\advance\@tempcnta \tw@\fi
- \if\@tempa b\advance\@tempcnta 4\relax\fi
- \if\@tempa p\advance\@tempcnta 8\relax\fi
- }%
- \global\count\@currbox\@tempcnta
- }%
- \@fltovf
- \fi
- \expandafter\expandafter\expandafter\gdef\expandafter
- \csname\number\@currbox @float\endcsname{\at@rotfloat@page}\relax
- \global\setbox\@currbox\vbox\bgroup
- \hsize\textheight
- \@parboxrestore
- }
-%% Check for |rotating| version: 2e ar 209:
-%% 1999.02.08 To be sure check at begin document.
+\def\floatpag@@rotxdblfloat#1[#2]{%
+ \@float{#1}[#2]%
+ \thisfloatpagestyle{\@r@f@pagestyle}%
+ \hsize\textwidth\linewidth\textwidth
+ \begin{lrbox}\rot@float@box
+ \begin{minipage}\textheight
+}
\AtBeginDocument{%
-\@ifpackageloaded{rotating}%
-{\let\@xrotfloat\e@xrotfloat\let\n@xrotfloat\relax}%
-{\let\@xrotfloat\n@xrotfloat\let\e@xrotfloat\relax}}%
+ \let\@xrotfloat\floatpag@@xrotfloat
+ \let\@rotxdblfloat\floatpag@@rotxdblfloat
+ }%
%% "Hook" in the output procedure.
-\def\spec@float#1{\expandafter\csname\number#1@float\endcsname
- \expandafter\expandafter\expandafter\gdef\expandafter\csname\number#1@float\endcsname{}%
+\def\spec@float#1{%
+ \@nameuse{\number#1@float}%
+ \global\@namedef{\number#1@float}{}%
}
\def\@vtryfc#1{%
\global\setbox\@outputbox\vbox{}%
diff --git a/Master/texmf-dist/tex/latex/sttools/flushend.sty b/Master/texmf-dist/tex/latex/sttools/flushend.sty
index 1dcff1fc01b..124df49334c 100644
--- a/Master/texmf-dist/tex/latex/sttools/flushend.sty
+++ b/Master/texmf-dist/tex/latex/sttools/flushend.sty
@@ -6,8 +6,8 @@
%%
%% flushend.dtx (with options: `package')
%%
-%% Copyright (C) 1997-2020 by Sigitas Tolu\v{s}is <sigitas@vtex.lt>
-%% VTeX Ltd., Mokslinink\k{u} 2a, Vilnius, Lithuania
+%% Copyright (C) 1997-2021 by Sigitas Tolu\v{s}is <sigitas@vtex.lt>
+%% UAB VTeX, Mokslininkų 2A, LT-08412 Vilnius, Lithuania
%% --------------------------------------------------------------------------
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
@@ -21,28 +21,49 @@
%%
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{flushend}
- [2020/10/16 v3.5 Balancing columns in twocolumn mode]
-\newif\if@auto@baselineskip \@auto@baselineskiptrue
-\newif\if@ancient@balance@version \@ancient@balance@versionfalse
+ [2021/10/04 v4.0 Balancing columns in twocolumn mode]
+
+\newif\if@footnote@check \@footnote@checktrue
\newif\if@right@column@spread \@right@column@spreadtrue
-\newif\if@remove@lastbox@at@balancing \@remove@lastbox@at@balancingtrue
+\newif\if@right@column@shrink \@right@column@shrinktrue
+\newif\if@left@column@spread \@left@column@spreadtrue
+\newif\if@left@column@shrink \@left@column@shrinktrue
\newif\if@balance@debug \@balance@debugfalse
-\DeclareOption{autobase}{\global\@auto@baselineskiptrue}
-\DeclareOption{noautobase}{\global\@auto@baselineskipfalse}
-\DeclareOption{ancient}{\global\@ancient@balance@versiontrue}
-\DeclareOption{modern}{\global\@ancient@balance@versionfalse}
-\DeclareOption{spread}{\global\@right@column@spreadtrue}
-\DeclareOption{nospread}{\global\@right@column@spreadfalse}
-\DeclareOption{removelastbox}{\global\@remove@lastbox@at@balancingtrue}
-\DeclareOption{keeplastbox}{\global\@remove@lastbox@at@balancingfalse}
+
+\DeclareOption{spread}{%
+ \global\@left@column@spreadtrue
+ \global\@right@column@spreadtrue
+ }
+\DeclareOption{nospread}{%
+ \global\@left@column@spreadfalse
+ \global\@right@column@spreadfalse
+ }
+\DeclareOption{lspread}{\global\@left@column@spreadtrue}
+\DeclareOption{nolspread}{\global\@left@column@spreadfalse}
+\DeclareOption{rspread}{\global\@right@column@spreadtrue}
+\DeclareOption{norspread}{\global\@right@column@spreadfalse}
+\DeclareOption{shrink}{%
+ \global\@left@column@shrinktrue
+ \global\@right@column@shrinktrue
+ }
+\DeclareOption{noshrink}{%
+ \global\@left@column@shrinkfalse
+ \global\@right@column@shrinkfalse
+ }
+\DeclareOption{lshrink}{\global\@left@column@shrinktrue}
+\DeclareOption{nolshrink}{\global\@left@column@shrinkfalse}
+\DeclareOption{rshrink}{\global\@right@column@shrinktrue}
+\DeclareOption{norshrink}{\global\@right@column@shrinkfalse}
\DeclareOption{checkfootnote}{%
\AtEndOfPackage{%
\let\check@@footnoterule@@box\initial@check@@footnoterule@@box
+ \@footnote@checktrue
}%
}
\DeclareOption{nocheckfootnote}{%
\AtEndOfPackage{%
\let\check@@footnoterule@@box\@gobblethree
+ \@footnote@checkfalse
}%
}
\DeclareOption{checkfloat}{%
@@ -57,183 +78,151 @@
}
\DeclareOption{debug}{\global\@balance@debugtrue}
\DeclareOption{nodebug}{\global\@balance@debugfalse}
+
\ProcessOptions
+
\newskip\flushend@@lastskip@a
\newskip\flushend@@lastskip@b
-\newskip\flushend@@lastskip@c
-\newcount\flushend@@penalty@a
+\newcount\flushend@@lastnode
\newcount\var@@loop@iter
-\newdimen\flushend@@lastkern@a
\newdimen\var@@temp@spread
\newdimen\var@@temp@a
\newdimen\var@@temp@loop
-\def\top@@skip@@limit{.7\topskip}
\newdimen\flushend@@page@rule \flushend@@page@rule\z@
\def\showcolsendrule{\global\flushend@@page@rule=.4\p@}
-\gdef\top@@floatbox@min@default{4\topskip}
-\let\top@@floatbox@min\top@@floatbox@min@default
+\gdef\top@@floatbox@min@default{5\topskip}
+\let\top@@floatbox@min\maxdimen
+\def\flushend@@column@badness{101}
+\newbox\flushend@@varbox@lastpage
\newbox\flushend@@varbox@a
\newbox\flushend@@varbox@c
\newbox\flushend@@tempbox@a
\newbox\flushend@@tempbox@c
+\newbox\flushend@@floatbox
\@ifundefined{@viper}{\newbox\@viper}{}
\@ifundefined{hold@viper}{\newbox\hold@viper}{}
\newtoks\atColsBreak \atColsBreak={}
\newtoks\atColsEnd \atColsEnd={}
\@ifundefined{fmt@box@adds}{\def\fmt@box@adds#1{#1}}{}
\@ifundefined{fmt@vbox@adds}{\def\fmt@vbox@adds[#1]#2{#2}}{}
+\def\wlog@balance@debug#1{\if@balance@debug \wlog{#1}\fi}
+\def\log@box@info#1{<box\the#1>(\the\ht#1+\the\dp#1)x\the\wd#1}
+
\def\unskip@three@kern@penalty{%
\unskip\unkern\unpenalty
\unskip\unkern\unpenalty
\unskip\unkern\unpenalty
}
-\gdef\remove@lastbox@at@balancing{%
- \unskip@three@kern@penalty
- \if@remove@lastbox@at@balancing
- \else
- \expandafter\null
- \fi
- \bgroup
+
+\gdef\remove@empty@lastbox@at@balancing#1{%
+ %%
+ %% Removes lastbox without dimensions.
+ %% Removes latest skip, kern, penalty.
+ %% Cuts the lastbox's depth bigger then strutbox's depth.
+ %%
+ \var@@temp@a=\z@
+ \setbox\flushend@@tempbox@a\vbox{%
+ \unvcopy#1%
+ \unskip@three@kern@penalty
+ \global\flushend@@lastnode=\lastnodetype
+ }%
+ \setbox#1\vbox{%
+ \unvcopy\flushend@@tempbox@a
\setbox\z@\lastbox
- \ifdim\wd\z@>\z@
- \box\z@
+ \ifdim\dimexpr\ht\z@+\dp\z@+\wd\z@\relax>\z@
+ %% not empty lastbox - store depth of the lastbox
+ \global\var@@temp@a=\dp\z@
\else
- \aftergroup\unskip@three@kern@penalty
+ %% empty lastbox
+ \setbox\z@\box\flushend@@tempbox@a
+ \expandafter\unskip@three@kern@penalty
\fi
- \egroup
+ }%
+ \ifvoid\flushend@@tempbox@a\else
+ %% not empty lastbox - restore original
+ \setbox#1\box\flushend@@tempbox@a
+ \fi
+ \ifdim\var@@temp@a>\z@
+ %% cut the depth of the lastbox with the negative skip
+ \ifdim\var@@temp@a>\dp\strutbox
+ %% it is something more than single line depth
+ \else
+ \setbox#1\vbox{\unvbox#1\vskip-\var@@temp@a}%
+ \fi
+ \fi
}
+
\def\set@split@topskip@to#1{%
- \splittopskip#1\relax \vfuzz\maxdimen \vbadness\maxdimen
- }
-\def\show@@box#1{%
- \bgroup
- \showboxbreadth=20000\showboxdepth=20000%
- \showbox#1\relax
- \egroup
- }
-\def\wlog@balance@debug#1{\if@balance@debug \wlog{#1}\fi}
-\def\log@box@info#1{<box\the#1>(\the\ht#1+\the\dp#1)x\the\wd#1}
-\let\show@@box@next\@gobble
-\gdef\analyze@lastbox@box#1{%
- \setbox\flushend@@varbox@a\vbox{%
- \unvbox#1%
- \global\flushend@@lastskip@a\lastskip
- \unskip
- \global\var@@temp@a\lastkern
- \unkern
- \global\flushend@@penalty@a\lastpenalty
- \unpenalty
- \ifdim\lastskip>\z@
- \global\flushend@@lastskip@a\lastskip
- \fi
- \unskip
- \ifdim\lastkern>\z@
- \global\var@@temp@a\lastkern
- \fi
- \unkern
- \ifnum\lastpenalty>\z@
- \global\flushend@@penalty@a\lastpenalty
- \fi
- \unpenalty
- \global\setbox\flushend@@tempbox@a\lastbox
- }%
- \wlog@balance@debug{^^J::analyze@lastbox@box::\log@box@info{#1}%
- ^^J ::unvbox: \log@box@info{\flushend@@varbox@a}%
- ^^J::lastbox: \log@box@info{\flushend@@tempbox@a}%
- ^^J::lastskip: \the\flushend@@lastskip@a;
- lastkern: \the\var@@temp@a;
- lastpenalty: \the\flushend@@penalty@a
- }%
+ \splittopskip=#1\relax
+ \vfuzz=\maxdimen
+ \vbadness=\maxdimen
}
+
\gdef\analyze@leftcolumn@box#1{%
+ %%
+ %% Try to find footnotes on the leftcolumn
+ %%
\set@split@topskip@to\z@
\flushend@@lastskip@b\ht#1%
- \wlog@balance@debug{^^Jmainbox: \log@box@info{#1}}%
+ \advance\flushend@@lastskip@b\dp#1%
\setbox\flushend@@varbox@a\vbox{%
\unvbox#1%
\global\flushend@@lastskip@a\lastskip
- \unskip
- \global\flushend@@lastkern@a\lastkern
- \unkern
- \global\flushend@@penalty@a\lastpenalty
- \unpenalty
+ \unskip\unkern\unpenalty
\global\setbox\flushend@@tempbox@a\lastbox
}%
\advance\flushend@@lastskip@b -\ht\flushend@@varbox@a
\advance\flushend@@lastskip@b -\ht\flushend@@tempbox@a
- \wlog@balance@debug{.-box: \log@box@info{\flushend@@varbox@a}%
- ^^J.-lastbox: \log@box@info{\flushend@@tempbox@a}%
- ^^J.-lastskip: \the\flushend@@lastskip@a;
- lastkern: \the\flushend@@lastkern@a;
- lastpenalty: \the\flushend@@penalty@a
- ^^J.-diff: \the\flushend@@lastskip@b
- }%
- \check@@footnoterule@@box\flushend@@tempbox@a\flushend@@lastskip@b\flushend@@varbox@a
- \check@@baselineskip@@skip
- \flushend@@lastskip@a
- \flushend@@lastskip@b
- \flushend@@lastskip@c
- \ifx\check@@footnoterule@@box\check@@baselineskip@@skip
- \else
- \ifvoid\flushend@@tempbox@a
- \ifdim\ht\flushend@@varbox@a>\topskip
- \flushend@@lastskip@b\ht\flushend@@varbox@a
- \var@@temp@a\ht\flushend@@varbox@a
- \loop
- \setbox\flushend@@tempbox@c\vsplit\flushend@@varbox@a to\var@@temp@a
- \ifvoid\flushend@@varbox@a
- \setbox\flushend@@varbox@a\vbox{\unvbox\flushend@@tempbox@c}%
- \advance \var@@temp@a -3\p@
- \else
- \var@@temp@a=-1\p@
- \fi
- \ifdim \var@@temp@a>\z@
- \repeat
- \setbox\flushend@@varbox@a\vbox{\unvbox\flushend@@varbox@a}%
- \setbox\flushend@@tempbox@c\vbox{\unvbox\flushend@@tempbox@c}%
- \advance\flushend@@lastskip@b -\ht\flushend@@varbox@a
- \advance\flushend@@lastskip@b -\ht\flushend@@tempbox@c
- \wlog@balance@debug{..--box: \log@box@info{\flushend@@tempbox@c}%
- ^^J..--lastbox: \log@box@info{\flushend@@varbox@a}%
- ^^J..--diff: \the\flushend@@lastskip@b
- }%
- \check@@footnoterule@@box\flushend@@varbox@a\flushend@@lastskip@b
- \flushend@@tempbox@c
- \check@@baselineskip@@skip\flushend@@lastskip@a\flushend@@lastskip@b
- \flushend@@lastskip@c
- \ifx\check@@footnoterule@@box\check@@baselineskip@@skip
- \else
- \ifdim\ht\flushend@@varbox@a>.5\topskip
- \analyze@lastbox@box\flushend@@varbox@a
- \fi
+ \ifvoid\flushend@@tempbox@a
+ \ifdim\ht\flushend@@varbox@a>\topskip
+ \flushend@@lastskip@b\ht\flushend@@varbox@a
+ \var@@temp@a\ht\flushend@@varbox@a
+ \loop
+ \setbox\flushend@@tempbox@c\vsplit\flushend@@varbox@a to\var@@temp@a
+ \ifvoid\flushend@@varbox@a
\setbox\flushend@@varbox@a\vbox{\unvbox\flushend@@tempbox@c}%
+ \advance\var@@temp@a -3\p@
+ \else
+ \var@@temp@a=-1\p@
\fi
- \else
- \wlog@balance@debug{lastbox: \log@box@info{\flushend@@varbox@a}}%
- \fi
+ \ifdim \var@@temp@a>\z@
+ \repeat
+ \setbox\flushend@@varbox@a\vbox{\unvbox\flushend@@varbox@a}%
+ \setbox\flushend@@tempbox@c\vbox{\unvbox\flushend@@tempbox@c}%
+ \advance\flushend@@lastskip@b -\ht\flushend@@varbox@a
+ \advance\flushend@@lastskip@b -\ht\flushend@@tempbox@c
+ \check@@footnoterule@@box\flushend@@varbox@a\flushend@@lastskip@b
+ \flushend@@tempbox@c
+ \setbox\flushend@@varbox@a\vbox{\unvbox\flushend@@tempbox@c}%
+ \else
+ \global\@footnote@checkfalse
\fi
+ \else
+ \check@@footnoterule@@box\flushend@@tempbox@a\flushend@@lastskip@b\flushend@@varbox@a
+ \fi
+ \if@footnote@check
\ifdim\var@@temp@loop=\ht\flushend@@varbox@a\relax
- \global\advance\var@@loop@iter\@ne
+ \global\advance\var@@loop@iter\@ne
\fi
\var@@temp@loop=\ht\flushend@@varbox@a\relax
\ifnum\var@@loop@iter<3\relax
- \wlog@balance@debug{analyze left col: iteration \number\var@@loop@iter; ht \the\var@@temp@loop}%
+ %% next iteration
\else
- \wlog@balance@debug{analyze left col loop limit!}%
- \ht\flushend@@varbox@a\z@
+ %% loop limit, break loop
+ \ht\flushend@@varbox@a=\z@
\fi
\ifdim\ht\flushend@@varbox@a>\topskip
\expandafter\analyze@leftcolumn@box\expandafter\flushend@@varbox@a
\fi
\fi
}
+
\def\get@@footnoterule@@box{%
\set@split@topskip@to\z@
\setbox\flushend@@varbox@a\vbox{\strut
\vskip\z@
\footnoterule
- \unskip\unkern\unpenalty
- \unskip\unkern\unpenalty
+ \unskip@three@kern@penalty
}%
\setbox\flushend@@tempbox@c\vsplit\flushend@@varbox@a to\p@
\xdef\footnoterule@@box@@ht{\the\ht\flushend@@varbox@a}%
@@ -242,7 +231,9 @@
\wlog@balance@debug{:footnoterule: \log@box@info{\flushend@@varbox@a}}%
\setbox\flushend@@tempbox@c\vbox{\unvbox\flushend@@varbox@a}%
}
+
\long\def\@gobblethree#1#2#3{}
+
\def\check@@footnoterule@@box#1#2#3{%
\ifdim\ht#1=\footnoterule@@box@@ht
\ifdim\dp#1=\footnoterule@@box@@dp
@@ -250,387 +241,400 @@
\ifdim#2=\topskip
\else
\xdef\main@box@height{\the\ht#3}%
+ \xdef\main@box@depth{\the\dp#3}%
\xdef\main@box@skip{\the#2}%
\wlog@balance@debug{^^J:footnoterule found:
main@box <ht=\main@box@height,
skip=\main@box@skip>
}%
\global\let\check@@footnoterule@@box\@gobblethree
- \global\let\check@@baselineskip@@skip\reset@check@@baselineskip@@skip
+ \global\@footnote@checkfalse
\fi
\fi
\fi
\fi
}
+
\let\initial@check@@footnoterule@@box\check@@footnoterule@@box
-\def\check@@baselineskip@@skip#1#2#3{%
- \ifdim#1>\z@
- \ifdim#2>\z@
- \global#3=\the#1%
- \global\let\check@@baselineskip@@skip\@gobblethree
- \fi
- \fi
- }
-\let\initial@check@@baselineskip@@skip\check@@baselineskip@@skip
-\def\reset@check@@baselineskip@@skip#1#2#3{%
- \global#3=\z@
- \global\let\check@@baselineskip@@skip\initial@check@@baselineskip@@skip
- }
+
\def\analyze@rightcolumn@box#1{%
+ %%
+ %% Looking for the top floats on the right column.
+ %%
+ %% Top box is considered as float if box's height
+ %% is larger then \top@@floatbox@min.
+ %% So, it is a dangerous feature to be used carefully.
+ %%
\bgroup
\xdef\top@@floatbox@ht{\z@}%
- \xdef\top@@floatbox@skip{\z@}%
- \xdef\top@@section@skip{\z@}%
\set@split@topskip@to\z@
\setbox\flushend@@varbox@a\vbox{\strut
\vskip\z@
\unvcopy#1%
}%
\setbox\flushend@@tempbox@c\vsplit\flushend@@varbox@a to\p@
- \wlog@balance@debug{^^J(R)mainbox: \log@box@info{#1}}%
\flushend@@lastskip@a\ht\flushend@@varbox@a
\advance\flushend@@lastskip@a\dp\flushend@@varbox@a
\ifdim\flushend@@lastskip@a>\z@
- \analyze@nonempty@rightcolumn@box
- \fi
- \egroup
- }
-\def\analyze@nonempty@rightcolumn@box{%
- \bgroup
- \var@@temp@a3\p@
- \loop
- \flushend@@lastskip@b\ht\flushend@@varbox@a
- \advance\flushend@@lastskip@b\dp\flushend@@varbox@a
- \setbox\flushend@@tempbox@c\vsplit\flushend@@varbox@a to\var@@temp@a
- \ifvoid\flushend@@tempbox@c
- \advance \var@@temp@a 3\p@
- \ifdim\var@@temp@a>\flushend@@lastskip@b
- \var@@temp@a=-1\p@
- \fi
- \else
- \setbox\flushend@@tempbox@c\vbox{\unvbox\flushend@@tempbox@c}%
- \ifdim\ht\flushend@@tempbox@c>\top@@floatbox@min
- \advance\flushend@@lastskip@b -\ht\flushend@@tempbox@c
- \advance\flushend@@lastskip@b -\dp\flushend@@tempbox@c
- \advance\flushend@@lastskip@b -\ht\flushend@@varbox@a
- \advance\flushend@@lastskip@b -\dp\flushend@@varbox@a
- \xdef\top@@floatbox@skip{\the\flushend@@lastskip@b}%
- \flushend@@lastskip@b\flushend@@lastskip@a
- \advance\flushend@@lastskip@b -\ht\flushend@@varbox@a
- \advance\flushend@@lastskip@b -\top@@floatbox@skip
- \xdef\top@@floatbox@ht{\the\flushend@@lastskip@b}%
- \var@@temp@a=3\p@
- \else
- \advance\flushend@@lastskip@b -\ht\flushend@@tempbox@c
- \advance\flushend@@lastskip@b -\dp\flushend@@tempbox@c
- \advance\flushend@@lastskip@b -\ht\flushend@@varbox@a
- \advance\flushend@@lastskip@b -\dp\flushend@@varbox@a
- \ifdim\ht\flushend@@tempbox@c>\topskip
- \else
- \xdef\top@@section@skip{\the\flushend@@lastskip@b}%
- \fi
- \var@@temp@a=-1\p@
- \fi
- \fi
- \ifdim \var@@temp@a>\z@
- \repeat
- \ifvoid\flushend@@tempbox@c
- \else
- \ifdim\top@@section@skip>\z@
- \else
- \ifdim\ht\flushend@@tempbox@c>\z@
- \setbox\flushend@@varbox@a\vbox{\unvbox\flushend@@tempbox@c}%
- \fi
+ %% analyze non empty rightcolumn box
+ \var@@temp@a=3\p@
+ \loop
+ \setbox\flushend@@tempbox@c\vsplit\flushend@@varbox@a to\var@@temp@a
\flushend@@lastskip@b\ht\flushend@@varbox@a
- \var@@temp@a=3\p@
- \loop
- \setbox\flushend@@tempbox@c\vsplit\flushend@@varbox@a to\var@@temp@a
- \ifvoid\flushend@@tempbox@c
- \advance \var@@temp@a 3\p@
- \ifdim\var@@temp@a>\flushend@@lastskip@b
- \var@@temp@a=-1\p@
- \fi
- \else
- \ifdim\ht\flushend@@tempbox@c<\z@
+ \advance\flushend@@lastskip@b\dp\flushend@@varbox@a
+ \ifvoid\flushend@@tempbox@c
+ \advance\var@@temp@a by3\p@
+ \ifdim\var@@temp@a>\flushend@@lastskip@b
+ %% reach column end, break loop
+ \var@@temp@a=-1\p@
+ \fi
+ \else
+ \setbox\flushend@@tempbox@c\vbox{\unvbox\flushend@@tempbox@c}%
+ \ifdim\ht\flushend@@tempbox@c>\top@@floatbox@min
+ %% found float; set height; look for the next
+ \setbox\flushend@@tempbox@a\vbox{\splitdiscards}%
+ \ifvoid\flushend@@tempbox@a
\else
- \var@@temp@a=-1\p@
+ \advance\flushend@@lastskip@b \ht\flushend@@tempbox@a
+ \advance\flushend@@lastskip@b \dp\flushend@@tempbox@a
\fi
- \fi
- \ifdim \var@@temp@a>\z@
- \repeat
- \loop
- \setbox\flushend@@varbox@a\vbox{%
- \unvbox\flushend@@tempbox@c
- \unskip\unkern\unpenalty
- \unskip\unkern\unpenalty
- \unskip\unkern\unpenalty
- \setbox\flushend@@tempbox@c\lastbox
- }%
- \flushend@@lastskip@b\ht\flushend@@varbox@a
- \setbox\flushend@@varbox@a\vbox{%
- \unvbox\flushend@@varbox@a
- \unskip\unkern\unpenalty
- \unskip\unkern\unpenalty
- \unskip\unkern\unpenalty
- }%
- \advance\flushend@@lastskip@b -\ht\flushend@@varbox@a
- \ifdim\flushend@@lastskip@b>\topskip
- \xdef\top@@section@skip{\the\flushend@@lastskip@b}%
- \fi
- \ifdim\var@@temp@loop=\ht\flushend@@varbox@a\relax
- \advance\var@@loop@iter\@ne
- \fi
- \var@@temp@loop=\ht\flushend@@varbox@a\relax
- \ifnum\var@@loop@iter<3\relax
- \wlog@balance@debug{analyze right col: iteration \number\var@@loop@iter; ht \the\var@@temp@loop}%
+ \advance\flushend@@lastskip@b -\flushend@@lastskip@a
+ \flushend@@lastskip@b=-\flushend@@lastskip@b
+ \xdef\top@@floatbox@ht{\the\flushend@@lastskip@b}%
+ \var@@temp@a=3\p@
\else
- \wlog@balance@debug{analyze right col loop limit!}%
- \ht\flushend@@varbox@a=\z@
+ %% break loop
+ \var@@temp@a=-1\p@
\fi
- \ifdim\ht\flushend@@varbox@a>2\topskip
- \setbox\flushend@@tempbox@c\vbox{\unvbox\flushend@@varbox@a}%
- \repeat
- \fi
+ \fi
+ \ifdim \var@@temp@a>\z@
+ \repeat
\fi
\egroup
}
-\def\combine@columns@for@balance{%
- \setbox\@outputbox\vbox{\strut
- \vskip\z@
- \unvbox\@outputbox
- }%
- \set@split@topskip@to\z@
- \setbox\flushend@@tempbox@c\vsplit\@outputbox to\p@
- \if@auto@baselineskip
- %% Trying guess baselineskip value on column break
- \ifdim\top@@floatbox@skip>\z@
- \setbox\flushend@@tempbox@c\vsplit\@outputbox to\top@@floatbox@ht
- \setbox\flushend@@tempbox@c\vbox{\unvbox\flushend@@tempbox@c}%
- \fi
- \setbox\@tempboxa\vbox{%
- \unvbox\flushend@@varbox@a
- \unskip\unkern\unpenalty
- \hrule\@height\flushend@@page@rule width\columnwidth
- \vskip-\flushend@@page@rule
- \hrule\@height\z@ width\columnwidth
- \vskip\flushend@@lastskip@c
- \the\atColsBreak
- \ifdim\top@@section@skip>\top@@skip@@limit
- \vskip\top@@section@skip
- \fi
- \unvbox\@outputbox
- \remove@lastbox@at@balancing
- \the\atColsEnd
- }%
- \ifdim\top@@floatbox@skip>\z@
- \setbox\@outputbox\vbox{\unvbox\flushend@@tempbox@c}%
- \fi
- \else
- %% Ignore baselineskip value on column break
- \setbox\@tempboxa\vbox{%
- \unvbox\flushend@@varbox@a
- \unskip\unkern\unpenalty
- \hrule\@height\flushend@@page@rule width\columnwidth
- \vskip-\flushend@@page@rule
- \hrule\@height\z@ width\columnwidth
- \the\atColsBreak
- \unvbox\@outputbox
- \remove@lastbox@at@balancing
- \the\atColsEnd
- }%
- \fi
- }
-\def\set@outputbox@with@footnote{%
- %% footnote in left column
- \@tempdimb\ht\@tempboxa
- \ifdim\top@@floatbox@skip>\z@
- \advance\@tempdimb \top@@floatbox@skip
+
+\def\set@outputbox@with@footnote@and@float{%
+ %%
+ %% The main unit formatting balanced columns.
+ %%
+ %% \flushend@@tempbox@a - left column
+ %% \flushend@@tempbox@c - left column with natural dimensions
+ %% \flushend@@varbox@a - right column
+ %% \flushend@@varbox@c - right column with natural dimensions
+ %% \flushend@@floatbox - rightcolumn top float
+ %% \@leftcolumn - void or leftcolumn footnote
+ %%
+ \@tempdimb\ht\flushend@@varbox@lastpage
+ \ifdim\top@@floatbox@ht>\z@
+ \advance\@tempdimb \textfloatsep
\advance\@tempdimb \top@@floatbox@ht
\fi
- \advance\@tempdimb \main@box@skip
- \advance\@tempdimb \ht\@leftcolumn
- \@tempdimb .5\@tempdimb
- \advance\@tempdimb -\main@box@skip
- \advance\@tempdimb -\ht\@leftcolumn
+ \ifdim\main@box@skip>\z@
+ \advance\@tempdimb \main@box@skip
+ \advance\@tempdimb \ht\@leftcolumn
+ \fi
+ \@tempdimb=.5\@tempdimb
+ \ifdim\@tempdimb>\@colht
+ \@tempdimb=\@colht
+ \fi
+ \ifdim\main@box@skip>\z@
+ \advance\@tempdimb -\main@box@skip
+ \advance\@tempdimb -\ht\@leftcolumn
+ \fi
\set@split@topskip@to\topskip
\loop
- \setbox\flushend@@varbox@a\copy\@tempboxa
+ \xdef\saved@tempdimb{\the\@tempdimb}%
+ \setbox\flushend@@varbox@a\copy\flushend@@varbox@lastpage
\setbox\flushend@@tempbox@a\vsplit\flushend@@varbox@a to\@tempdimb
- \setbox\flushend@@tempbox@c\vbox{\unvcopy\flushend@@tempbox@a}%
- \ifdim\top@@floatbox@skip>\z@
- \setbox\flushend@@varbox@c\vbox{%
- \unvcopy\@outputbox
- \vskip\top@@floatbox@skip
+ \ifdim\main@box@skip>\z@
+ \setbox\flushend@@tempbox@c\vbox{%
+ \unvbox\flushend@@tempbox@a
+ \vskip\main@box@skip
+ \vskip\z@ plus\p@
+ \unvcopy\@leftcolumn
+ }%
+ \else
+ \setbox\flushend@@tempbox@c\vbox{\unvbox\flushend@@tempbox@a}%
+ \fi
+ \setbox\flushend@@tempbox@a\vbox to\@tempdimb{\unvcopy\flushend@@tempbox@c}%
+ \xdef\var@@leftcolumn@badness{\the\badness}%
+ \ifdim\top@@floatbox@ht>\z@
+ \setbox\flushend@@varbox@c\vbox{%
+ \unvcopy\flushend@@floatbox
+ \vskip\textfloatsep
+ \vskip\z@ plus\p@ minus\p@
\unvbox\flushend@@varbox@a
}%
\else
\setbox\flushend@@varbox@c\vbox{\unvbox\flushend@@varbox@a}%
\fi
+ \setbox\flushend@@varbox@a\vbox to\@tempdimb{\unvcopy\flushend@@varbox@c}%
+ \xdef\var@@rightcolumn@badness{\the\badness}%
\var@@temp@spread=\ht\flushend@@tempbox@c
\advance\var@@temp@spread by\dp\flushend@@tempbox@c
- \advance\var@@temp@spread \main@box@skip
- \advance\var@@temp@spread \ht\@leftcolumn
\advance\var@@temp@spread by-\ht\flushend@@varbox@c
\advance\var@@temp@spread by-\dp\flushend@@varbox@c
- \wlog@balance@debug{Left x: \the\ht\flushend@@tempbox@a
- +\the\dp\flushend@@tempbox@a=\the\ht\flushend@@varbox@a
- +\the\dp\flushend@@varbox@a::\the\@tempdimb
- ^^JLeft 0: \the\ht\flushend@@tempbox@c
- +\the\dp\flushend@@tempbox@c::\the\@tempdimb
- ^^JRight x: \the\ht\flushend@@varbox@c
- +\the\dp\flushend@@varbox@c=\the\ht\flushend@@varbox@a
- +\the\dp\flushend@@varbox@a::\the\@tempdimb
- ^^JExtra height:\the\var@@temp@spread\space when \the\@tempdimb
- }%
+ \wlog@balance@debug{-----
+ ^^JLeft: \the\ht\flushend@@tempbox@c
+ +\the\dp\flushend@@tempbox@c\space / \var@@leftcolumn@badness
+ ^^JRight: \the\ht\flushend@@varbox@c
+ +\the\dp\flushend@@varbox@c\space / \var@@rightcolumn@badness
+ ^^JSplit: \the\@tempdimb
+ ^^JExtra height: \the\var@@temp@spread
+ }%
+ \ifdim\main@box@skip>\z@
+ \wlog@balance@debug{Footnote: \the\dimexpr\main@box@skip + \the\ht\@leftcolumn\relax}%
+ \fi
+ \ifdim\top@@floatbox@ht>\z@
+ \wlog@balance@debug{Float: \the\dimexpr\the\ht\flushend@@floatbox + \textfloatsep\relax}%
+ \fi
+ \ifnum\var@@leftcolumn@badness<\flushend@@column@badness
+ \ifnum\var@@rightcolumn@badness<\flushend@@column@badness
+ \ifdim\main@box@skip>\z@
+ \advance\@tempdimb -\main@box@skip
+ \advance\@tempdimb -\ht\@leftcolumn
+ \fi
+ \var@@temp@spread=\z@
+ \fi
+ \fi
+ \ifdim\var@@temp@spread<\z@
+ \if@left@column@spread
+ \if@right@column@shrink
+ \ifdim\dimexpr\var@@temp@spread+\pageshrink>\z@
+ \var@@temp@a=\dimexpr\ht\flushend@@tempbox@c-0.5\var@@temp@spread\relax
+ \else
+ \var@@temp@a=-\dimexpr\var@@temp@spread+.5\pageshrink\relax
+ \fi
+ \setbox\flushend@@varbox@a\vbox to\var@@temp@a{\unvcopy\flushend@@tempbox@c}%
+ \ifnum\badness<\flushend@@column@badness
+ \@tempdimb=\var@@temp@a
+ \ifdim\main@box@skip>\z@
+ \advance\@tempdimb -\main@box@skip
+ \advance\@tempdimb -\ht\@leftcolumn
+ \fi
+ \var@@temp@spread=\z@
+ \fi
+ \wlog{[leftcolumn badness]: \number\badness\space on \the\var@@temp@a}%
+ \setbox\flushend@@varbox@a\vbox to\var@@temp@a{\unvcopy\flushend@@varbox@c}%
+ \wlog{[rightcolumn badness]: \number\badness\space on \the\var@@temp@a}%
+ \else
+ \setbox\flushend@@varbox@a\vbox to\ht\flushend@@varbox@c{%
+ \unvcopy\flushend@@tempbox@c
+ }%
+ \ifnum\badness<\flushend@@column@badness
+ \@tempdimb=\ht\flushend@@varbox@c
+ \ifdim\main@box@skip>\z@
+ \advance\@tempdimb -\main@box@skip
+ \advance\@tempdimb -\ht\@leftcolumn
+ \fi
+ \var@@temp@spread=\z@
+ \fi
+ \wlog{[leftcolumn badness]: \number\badness on \the\ht\flushend@@varbox@c}%
+ \setbox\flushend@@varbox@a\vbox to\ht\flushend@@varbox@c{%
+ \unvcopy\flushend@@varbox@c
+ }%
+ \wlog{[rightcolumn badness]: \number\badness on \the\ht\flushend@@varbox@c}%
+ \fi
+ \else
+ \if@right@column@shrink
+ \ifdim\dimexpr\var@@temp@spread+\pageshrink<\z@
+ \else
+ \@tempdimb=\ht\flushend@@tempbox@c
+ \ifdim\main@box@skip>\z@
+ \advance\@tempdimb -\main@box@skip
+ \advance\@tempdimb -\ht\@leftcolumn
+ \fi
+ \var@@temp@spread=\z@
+ \fi
+ \fi
+ \fi
+ \else
+ \ifdim\var@@temp@spread>\z@
+ \ifdim\dimexpr\@tempdimb+\p@\relax>\@colht
+ \@tempdimb=\@colht
+ \ifdim\main@box@skip>\z@
+ \advance\@tempdimb -\main@box@skip
+ \advance\@tempdimb -\ht\@leftcolumn
+ \fi
+ \var@@temp@spread=\z@
+ \fi
+ \fi
+ \fi
\ifdim\var@@temp@spread<\z@
\advance\@tempdimb 1\p@
\repeat
- \flushend@@lastskip@a\the\ht\flushend@@tempbox@c
- \advance\flushend@@lastskip@a \main@box@skip
- \advance\flushend@@lastskip@a \ht\@leftcolumn
- \flushend@@lastskip@b\the\@tempdimb
- \setbox\flushend@@tempbox@a\vsplit\@tempboxa to\@tempdimb
- \setbox\@leftcolumn\vbox to\@tempdima{%
- \vbox to \flushend@@lastskip@a{%
- \unvbox\flushend@@tempbox@a
- \vskip\main@box@skip
- \unvbox\@leftcolumn
- \vss
- }%
- \hrule\@height\flushend@@page@rule width\textwidth
- \vskip-\flushend@@page@rule
- \hrule\@height\z@ width\columnwidth
- \vss
- }%
- \global\ht\@leftcolumn=\the\@tempdima
+ %% final construction of the lastpage
\wlog{- LAST -%
^^JExtra skip:\the\var@@temp@spread
- ^^JLeft:\the\ht\@leftcolumn/\the\dp\@leftcolumn
- ^^JRight:\the\ht\@tempboxa/\the\dp\@tempboxa
+ ^^JLeft:\the\ht\flushend@@tempbox@c/\the\dp\flushend@@tempbox@c
+ ^^JRight:\the\ht\flushend@@varbox@c/\the\dp\flushend@@varbox@c
+ ^^JSplit: \saved@tempdimb
^^JOutput:\the\@tempdimb
+ ^^JPageshrink: \the\pageshrink
+ ^^JPagestretch: \the\pagestretch
+ ^^J@colht:\the\@colht
}%
- \ifdim\top@@floatbox@skip>\z@
- \setbox\@outputbox\vbox to\@tempdima{%
- \if@right@column@spread
- \vbox spread\var@@temp@spread{%
- \unvbox\@outputbox
- \vskip\top@@floatbox@skip
- \unvbox\@tempboxa
- }%
- \else
- \vbox spread\var@@temp@spread{%
- \unvbox\@outputbox
- \vskip\top@@floatbox@skip
- \unvbox\@tempboxa
+ \setbox\flushend@@tempbox@c\vsplit\flushend@@varbox@lastpage to\saved@tempdimb
+ \ifdim\main@box@skip>\z@
+ \@tempdimb=\dimexpr\@tempdimb+\main@box@skip+\ht\@leftcolumn\relax
+ \setbox\@leftcolumn\vbox to\@tempdimb{%
+ \flushend@@lastskip@a=\dimexpr
+ \@tempdimb
+ -\ht\flushend@@tempbox@c
+ -\main@box@skip
+ -\ht\@leftcolumn
+ \relax
+ \unvbox\flushend@@tempbox@c
+ \vskip\main@box@skip
+ \vskip\z@ plus\p@
+ \unvbox\@leftcolumn
+ \prevdepth\z@
+ \hrule\@height\flushend@@page@rule width\textwidth
+ \vskip-\flushend@@page@rule
+ \ifdim\flushend@@lastskip@a>\z@
+ \if@left@column@spread
+ \else
\vss
- }%
+ \fi
+ \else
+ \ifdim\flushend@@lastskip@a<\z@
+ \if@left@column@shrink
+ \else
+ \vss
+ \fi
+ \fi
\fi
- \vss
}%
\else
- \setbox\@outputbox\vbox to\@tempdima{%
- \if@right@column@spread
- \vbox spread\var@@temp@spread{%
- \unvbox\@tempboxa
- }%
+ \setbox\@leftcolumn\vbox to\@tempdimb{%
+ \flushend@@lastskip@a=\dimexpr
+ \@tempdimb-\ht\flushend@@tempbox@c
+ \relax
+ \var@@temp@spread=\dp\flushend@@tempbox@c
+ \unvbox\flushend@@tempbox@c
+ \ifdim\var@@temp@spread>\dp\strutbox
\else
- \vbox spread\var@@temp@spread{%
- \unvbox\@tempboxa
+ \vskip-\var@@temp@spread
+ \fi
+ \prevdepth\z@
+ \hrule\@height\flushend@@page@rule width\textwidth
+ \vskip-\flushend@@page@rule
+ \ifdim\flushend@@lastskip@a>\z@
+ \if@left@column@spread
+ \else
\vss
- }%
+ \fi
+ \else
+ \ifdim\flushend@@lastskip@a<\z@
+ \if@left@column@shrink
+ \else
+ \vss
+ \fi
+ \fi
\fi
- \vss
}%
\fi
- }
-\def\set@outputbox@without@footnote{%
- %% no footnote in left column
- \@tempdimb \ht\@tempboxa
- \ifdim\top@@floatbox@skip>\z@
- \advance\@tempdimb \top@@floatbox@skip
- \advance\@tempdimb \top@@floatbox@ht
- \fi
- \@tempdimb .5\@tempdimb
- \set@split@topskip@to\topskip
- \loop
- \setbox\flushend@@varbox@a\copy\@tempboxa
- \setbox\flushend@@tempbox@a\vsplit\flushend@@varbox@a to\@tempdimb
- \setbox\flushend@@tempbox@c\vbox{\unvcopy\flushend@@tempbox@a}%
- \ifdim\top@@floatbox@skip>\z@
- \setbox\flushend@@varbox@c\vbox{%
- \unvcopy\@outputbox
- \vskip\top@@floatbox@skip
- \unvbox\flushend@@varbox@a
- }%
- \else
- \setbox\flushend@@varbox@c\vbox{\unvbox\flushend@@varbox@a}%
- \fi
- \var@@temp@spread=\ht\flushend@@tempbox@c
- \advance\var@@temp@spread by\dp\flushend@@tempbox@c
- \advance\var@@temp@spread by-\ht\flushend@@varbox@c
- \advance\var@@temp@spread by-\dp\flushend@@varbox@c
- \wlog@balance@debug{Left x: \the\ht\flushend@@tempbox@a
- +\the\dp\flushend@@tempbox@a=\the\ht\flushend@@varbox@a
- +\the\dp\flushend@@varbox@a::\the\@tempdimb
- ^^JLeft 0: \the\ht\flushend@@tempbox@c
- +\the\dp\flushend@@tempbox@c::\the\@tempdimb
- ^^JRight x: \the\ht\flushend@@varbox@c
- +\the\dp\flushend@@varbox@c=\the\ht\flushend@@varbox@a
- +\the\dp\flushend@@varbox@a::\the\@tempdimb
- ^^JExtra height:\the\var@@temp@spread\space when \the\@tempdimb
- }%
- \ifdim\var@@temp@spread<\z@ \advance\@tempdimb 1\p@ \repeat
- \wlog{- LAST -%
- ^^JExtra skip:\the\var@@temp@spread
- ^^JLeft:\the\ht\flushend@@tempbox@c/\the\dp\flushend@@tempbox@c
- ^^JRight:\the\ht\flushend@@varbox@c/\the\dp\flushend@@varbox@c
- ^^JOutput:\the\@tempdimb
- }%
- \setbox\flushend@@tempbox@c\vsplit\@tempboxa to\@tempdimb
- \setbox\flushend@@varbox@c\vbox{\unvbox\flushend@@tempbox@c}%
- \setbox\@leftcolumn\vbox to\@tempdima{%
- \vbox to\@tempdimb{\unvbox\flushend@@varbox@c\vss}%
- \hrule\@height\flushend@@page@rule width\textwidth
- \vskip-\flushend@@page@rule
- \hrule\@height\z@ width\textwidth
- \vss
- }%
+ \wlog{FLUSHEND [output]: \the\@tempdimb
+ ^^JFLUSHEND [leftcolumn badness]: \number\badness
+ }%
\global\ht\@leftcolumn=\the\@tempdima
- \ifdim\top@@floatbox@skip>\z@
- \setbox\@outputbox\vbox to\@tempdima{%
- \if@right@column@spread
- \vbox spread\var@@temp@spread{%
- \unvbox\@outputbox
- \vskip\top@@floatbox@skip
- \unvbox\@tempboxa
- }%
- \else
- \vbox spread\var@@temp@spread{%
- \unvbox\@outputbox
- \vskip\top@@floatbox@skip
- \unvbox\@tempboxa
+ \ifdim\top@@floatbox@ht>\z@
+ \setbox\@outputbox\vbox to\@tempdimb{%
+ \flushend@@lastskip@a=\dimexpr
+ \@tempdimb
+ -\ht\flushend@@floatbox
+ -\textfloatsep
+ -\ht\flushend@@varbox@lastpage
+ \relax
+ \unvbox\flushend@@floatbox
+ \vskip\textfloatsep
+ \vskip\z@ plus\p@ minus\p@
+ \unvbox\flushend@@varbox@lastpage
+ \ifdim\flushend@@lastskip@a>\z@
+ \if@right@column@spread
+ \else
\vss
- }%
+ \fi
+ \else
+ \ifdim\flushend@@lastskip@a<\z@
+ \if@right@column@shrink
+ \else
+ \vss
+ \fi
+ \fi
\fi
- \vss
}%
\else
- \setbox\@outputbox\vbox to\@tempdima{%
- \if@right@column@spread
- \vbox spread\var@@temp@spread{%
- \unvbox\@tempboxa
- }%
- \else
- \vbox spread\var@@temp@spread{%
- \unvbox\@tempboxa
+ \setbox\@outputbox\vbox to\@tempdimb{%
+ \flushend@@lastskip@a=\dimexpr
+ \@tempdimb-\ht\flushend@@varbox@lastpage
+ \relax
+ \unvbox\flushend@@varbox@lastpage
+ \ifdim\flushend@@lastskip@a>\z@
+ \if@right@column@spread
+ \else
\vss
- }%
+ \fi
+ \else
+ \ifdim\flushend@@lastskip@a<\z@
+ \if@right@column@shrink
+ \else
+ \vss
+ \fi
+ \fi
\fi
- \vss
}%
\fi
+ \wlog{FUSHEND [rightcolumn badness]: \number\badness}%
+ \global\ht\@outputbox=\the\@tempdima
}
-\def\last@outputdblcol@modern{%
+
+\newdimen\oldbreak@skip
+
+\def\combine@columns@for@balance{%
+ %%
+ %% Combines lastpage columns for balancing.
+ %%
+ \setbox\flushend@@tempbox@a\vbox{\pagediscards}%
+ \oldbreak@skip=\ht\flushend@@tempbox@a
+ \advance\oldbreak@skip by\dp\flushend@@tempbox@a
+ \setbox\@outputbox\vbox{\strut
+ \vskip\z@
+ \unvbox\@outputbox
+ }%
+ \set@split@topskip@to\z@
+ %% Removes topskip
+ \setbox\flushend@@tempbox@c\vsplit\@outputbox to\p@
+ \ifdim\top@@floatbox@ht>\z@
+ %% removes top float from right column (if option enabled)
+ \setbox\flushend@@floatbox\vsplit\@outputbox to\top@@floatbox@ht
+ \setbox\flushend@@floatbox\vbox{\unvbox\flushend@@floatbox}%
+ \fi
+ \setbox\flushend@@varbox@lastpage\vbox{%
+ \remove@empty@lastbox@at@balancing\flushend@@varbox@a
+ \unvbox\flushend@@varbox@a
+ \hrule\@height\flushend@@page@rule width\columnwidth
+ \vskip-\flushend@@page@rule
+ \hrule\@height\z@ width\columnwidth
+ \penalty\z@
+ \ifdim\var@@temp@a>\z@
+ \ifdim\var@@temp@a>\dp\strutbox
+ \else
+ \vskip\var@@temp@a
+ \fi
+ \fi
+ \vskip\oldbreak@skip
+ \the\atColsBreak
+ \remove@empty@lastbox@at@balancing\@outputbox
+ \unvbox\@outputbox
+ \the\atColsEnd
+ }%
+ }
+
+\def\last@outputdblcol{%
+ %%
+ %% Redefined \@outputdblcol with columns balancing.
+ %%
\if@firstcolumn
\global \@firstcolumnfalse
\global\setbox\@leftcolumn\copy\@outputbox
@@ -656,207 +660,57 @@
\advance\@tempdima by\dp\@leftcolumn
\set@split@topskip@to\topskip
\var@@temp@spread=\wd\@outputbox
- \get@@footnoterule@@box
- \xdef\main@box@height{\the\ht\@leftcolumn}%
+ \xdef\top@@floatbox@ht{\z@}%
\xdef\main@box@skip{\z@}%
- \reset@check@@baselineskip@@skip\relax\relax\flushend@@lastskip@c
- \setbox\flushend@@varbox@a\vbox{\unvcopy\@leftcolumn}%
- \var@@loop@iter\z@ \var@@temp@loop\z@
- \analyze@leftcolumn@box\flushend@@varbox@a
- \setbox\flushend@@varbox@a\vbox{\unvcopy\@outputbox}%
- \var@@loop@iter\z@ \var@@temp@loop\z@
- \analyze@rightcolumn@box\flushend@@varbox@a
- \ifdim\main@box@skip>\z@
- %% footnote in left column
- \set@split@topskip@to\z@
- \setbox\flushend@@varbox@a\vsplit\@leftcolumn to\main@box@height
- \else
- %% no footnote in left column
- \setbox\flushend@@varbox@a\box\@leftcolumn
- \fi
\ifdim\var@@temp@spread>\z@
%% rightcolumn non empty
- \combine@columns@for@balance
- \else
- %% rightcolumn empty
- \setbox\@tempboxa\vbox{%
- \unvbox\flushend@@varbox@a
- \remove@lastbox@at@balancing
- \the\atColsEnd
- }%
- \fi
- \ifdim\main@box@skip>\z@
- %% footnote in left column
- \set@outputbox@with@footnote
- \else
- %% no footnote in left column
- \set@outputbox@without@footnote
- \fi
- \setbox\@outputbox \vbox {%
- \hb@xt@\textwidth {%
- \hb@xt@\columnwidth {%
- \fmt@box@adds{\box\@leftcolumn}\hss}%
- \hfil
- \vrule \@width\columnseprule
- \hfil
- \hb@xt@\columnwidth {%
- \fmt@box@adds{\box\@outputbox}\hss}%
- }%
- }%
- \global\let\@outputdblcol\saved@orig@@outputdblcol
- \global\atColsEnd{}%
- \ifvoid\hold@viper
- \else
- \setbox\@outputbox\vbox{\box\hold@viper\box\@outputbox}%
- \fi
- \@combinedblfloats
- \csname @setmarks\endcsname
- \@outputpage
- \begingroup
- \@dblfloatplacement
- \@startdblcolumn
- \@whilesw\if@fcolmade\fi
- {\@outputpage\@startdblcolumn}%
- \ifvoid\@viper
- \else
- \global\setbox\@viper\vbox{%
- \vskip-\stripsep
- \unvbox\@viper
- }%
- \csname @viperoutput\endcsname
- \fi
- \endgroup
- \fi
- }
-\def\last@outputdblcol@ancient{%
- \if@firstcolumn
- \global\@firstcolumnfalse
- \global\setbox\@leftcolumn\box\@outputbox
- \else
- \global\@firstcolumntrue
- \@tempdima\ht\@leftcolumn
- \set@split@topskip@to\topskip
- \if@auto@baselineskip
- \setbox\@tempboxa\vbox{%
- \unvcopy\@leftcolumn
- \global\flushend@@lastskip@c\lastskip
- \global\flushend@@lastskip@b\lastskip
- \loop
- \global\flushend@@lastskip@a\flushend@@lastskip@b
- \unskip\unpenalty
- \global\flushend@@lastskip@b\lastskip
- \global\advance\flushend@@lastskip@c by\lastskip
- \ifdim\flushend@@lastskip@b=-\flushend@@lastskip@a
- \global\advance\flushend@@lastskip@c by-\lastskip
+ \setbox\flushend@@varbox@a\vbox{\unvcopy\@outputbox}%
+ \ifdim\dimexpr\@colht-\ht\flushend@@varbox@a>\z@\relax
+ \if@footnote@check
+ \get@@footnoterule@@box
+ \xdef\main@box@height{\the\ht\@leftcolumn}%
+ \setbox\flushend@@varbox@a\vbox{\unvcopy\@leftcolumn}%
+ \var@@loop@iter\z@ \var@@temp@loop\z@
+ \analyze@leftcolumn@box\flushend@@varbox@a
+ \fi
+ \ifdim\top@@floatbox@min<\maxdimen
+ \setbox\flushend@@varbox@a\vbox{\unvcopy\@outputbox}%
+ \var@@loop@iter\z@ \var@@temp@loop\z@
+ \analyze@rightcolumn@box\flushend@@varbox@a
+ \fi
+ \ifdim\main@box@skip>\z@
+ %% footnote in left column
+ \set@split@topskip@to\z@
+ \setbox\flushend@@varbox@a\vsplit\@leftcolumn to\main@box@height
\else
- \repeat
- \ifdim\flushend@@lastskip@b=-\flushend@@lastskip@a
- \ifdim\flushend@@lastskip@b=\z@
- \setbox\flushend@@varbox@a\lastbox
- \global\advance\flushend@@lastskip@c by\ht\flushend@@varbox@a
- \global\advance\flushend@@lastskip@c by\lastskip
- \unskip\unpenalty
- \setbox\flushend@@varbox@a\lastbox
- \global\advance\flushend@@lastskip@c by\dp\flushend@@varbox@a
- \else
- \global\flushend@@lastskip@c\lastskip
- \global\advance\flushend@@lastskip@c by\topskip
- \fi
+ %% no footnote in left column
+ \setbox\flushend@@varbox@a\box\@leftcolumn
\fi
- \global\advance\flushend@@lastskip@c by-\topskip
- }%
- \setbox\@tempboxa\vbox{%
- \unvbox\@leftcolumn
- \unskip\unpenalty
- \vskip\flushend@@lastskip@c
- \hrule\@height\flushend@@page@rule width\columnwidth
- \vskip-\flushend@@page@rule
- \hrule\@height\z@ width\textwidth
- \the\atColsBreak
- \unvbox\@outputbox
- \remove@lastbox@at@balancing
- \the\atColsEnd
- }%
- \else
- \setbox\@tempboxa\vbox{%
- \unvbox\@leftcolumn
- \setbox\z@\lastbox
- \unskip
- \hrule\@height\flushend@@page@rule width\columnwidth
- \vskip-\flushend@@page@rule
- \hrule\@height\z@ width\textwidth
- \the\atColsBreak
- \unvbox\@outputbox
- \remove@lastbox@at@balancing
- \the\atColsEnd
- }%
- \fi
- \@tempdimb .5\ht\@tempboxa
- \loop
- \setbox\flushend@@tempbox@a\copy\@tempboxa
- \setbox\flushend@@tempbox@c\vbox to\@tempdimb{%
- \vsplit\flushend@@tempbox@a to\@tempdimb
- \vss
- \vsplit\flushend@@tempbox@a to\@tempdimb
- }%
- \wlog{Extra height:\the\ht\flushend@@tempbox@a\space when \the\@tempdimb}%
- \ifvoid\flushend@@tempbox@a
+ \combine@columns@for@balance
+ \else
+ \xdef\main@box@skip{\maxdimen}%
+ \fi
\else
- \advance\@tempdimb 1\p@
- \repeat
- \loop
- \setbox\flushend@@tempbox@a\copy\@tempboxa
- \setbox\flushend@@tempbox@c\vbox to\@tempdimb{%
- \vsplit\flushend@@tempbox@a to\@tempdimb
- \vss
- }%
- \wlog{(2)Left:\the\ht\flushend@@tempbox@c\space
- Right:\the\ht\flushend@@tempbox@a\space
- Output:\the\@tempdimb
- }%
- \ifdim\ht\flushend@@tempbox@c<\ht\flushend@@tempbox@a
- \@tempdimb=\the\ht\flushend@@tempbox@a
- \repeat
- \wlog{- LAST -^^JExtra skip: \the\z@
- ^^JLeft:\the\ht\flushend@@tempbox@c
- ^^JRight:\the\ht\flushend@@tempbox@a
- ^^JOutput:\the\@tempdimb
- }%
- \setbox\flushend@@tempbox@c\vbox to\@tempdimb{%
- \vsplit\@tempboxa to\@tempdimb
- \vss
- }%
- \setbox\@leftcolumn\vbox to\@tempdima{%
- \fmt@vbox@adds[\columnwidth]{%
- \vbox to\@tempdimb{%
- \unvbox
- \flushend@@tempbox@c
+ %% rightcolumn empty
+ \setbox\flushend@@varbox@a\box\@leftcolumn
+ \setbox\flushend@@varbox@lastpage\vbox{%
+ \remove@empty@lastbox@at@balancing\flushend@@varbox@a
+ \unvbox\flushend@@varbox@a
+ \the\atColsEnd
}%
- }%
- \hrule\@height\flushend@@page@rule
- \vskip-\flushend@@page@rule
- \hrule\@height\z@ width\textwidth
- \vss
- }%
- \setbox\@outputbox\vbox to\@tempdima{%
- \fmt@vbox@adds[\columnwidth]{%
- \vbox to\@tempdimb{%
- \unvbox\@tempboxa
- \vskip\z@
- }%
- }%
- \hrule\@height\flushend@@page@rule
- \vskip-\flushend@@page@rule
- \hrule\@height\z@ width\textwidth
- \vss
- }%
+ \fi
+ \ifdim\main@box@skip<\maxdimen
+ \set@outputbox@with@footnote@and@float
+ \fi
\setbox\@outputbox\vbox{%
\hb@xt@\textwidth{%
- \hb@xt@\columnwidth{\box\@leftcolumn\hss}%
+ \hb@xt@\columnwidth{%
+ \fmt@box@adds{\box\@leftcolumn}\hss}%
\hfil
\vrule \@width\columnseprule
\hfil
- \hb@xt@\columnwidth{\box\@outputbox\hss}%
+ \hb@xt@\columnwidth{%
+ \fmt@box@adds{\box\@outputbox}\hss}%
}%
}%
\global\let\@outputdblcol\saved@orig@@outputdblcol
@@ -866,6 +720,7 @@
\setbox\@outputbox\vbox{\box\hold@viper\box\@outputbox}%
\fi
\@combinedblfloats
+ \csname @setmarks\endcsname
\@outputpage
\begingroup
\@dblfloatplacement
@@ -883,18 +738,21 @@
\endgroup
\fi
}
-\usepackage{etoolbox}
-\AtBeginDocument{%
+
+\def\initialize@flushend{%
+ %%
+ %% Activates flushend package functionality.
+ %%
\global\let\saved@orig@@outputdblcol\@outputdblcol
- \if@ancient@balance@version
- \global\let\last@outputdblcol\last@outputdblcol@ancient
- \else
- \global\let\last@outputdblcol\last@outputdblcol@modern
- \fi
\global\let\balanced@@outputdblcol\last@outputdblcol
- \preto\enddocument{\let\@outputdblcol\balanced@@outputdblcol}%
- \appto\footnoterule{\vskip\z@}%
+ \edef\enddocument{%
+ \unexpanded{\let\@outputdblcol\balanced@@outputdblcol}%
+ \unexpanded\expandafter{\enddocument}%
+ }%
+ \g@addto@macro\footnoterule{\vskip\z@}%
+ \savingvdiscards=\@ne
}
+
\def\flushcolsend{\global\let\@outputdblcol\last@outputdblcol}
\def\raggedcolsend{\global\let\@outputdblcol\saved@orig@@outputdblcol}
\def\flushend{\global\let\balanced@@outputdblcol\last@outputdblcol}
@@ -902,6 +760,7 @@
\if@balance@debug
\showcolsendrule
\fi
+\AtBeginDocument{\initialize@flushend}
\endinput
%%
%% End of file `flushend.sty'.
diff --git a/Master/texmf-dist/tex/latex/sttools/midfloat.sty b/Master/texmf-dist/tex/latex/sttools/midfloat.sty
index 93f6248a549..92959f4ac5e 100644
--- a/Master/texmf-dist/tex/latex/sttools/midfloat.sty
+++ b/Master/texmf-dist/tex/latex/sttools/midfloat.sty
@@ -6,9 +6,8 @@
%%
%% midfloat.dtx (with options: `package')
%%
-%% Copyright (C) 1997-2012 by Sigitas Tolu\v{s}is <sigitas@vtex.lt>
-%% VTeX Ltd., Akademijos 4, Vilnius, Lithuania
-%% http://www.vtex.lt/tex/download/macros/
+%% Copyright (C) 1997-2021 by Sigitas Tolu\v{s}is <sigitas@vtex.lt>
+%% UAB VTeX, Mokslininkų 2A, LT-08412 Vilnius, Lithuania
%% --------------------------------------------------------------------------
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
diff --git a/Master/texmf-dist/tex/latex/sttools/stabular.sty b/Master/texmf-dist/tex/latex/sttools/stabular.sty
index 0ac82f47fc7..8c97bbf53a4 100644
--- a/Master/texmf-dist/tex/latex/sttools/stabular.sty
+++ b/Master/texmf-dist/tex/latex/sttools/stabular.sty
@@ -6,9 +6,8 @@
%%
%% stabular.dtx (with options: `package')
%%
-%% Copyright (C) 1998-2014 by Sigitas Tolu\v{s}is <sigitas@vtex.lt>
-%% VTeX Ltd., Akademijos 4, Vilnius, Lithuania
-%% http://www.vtex.lt/tex/download/macros/
+%% Copyright (C) 1998-2021 by Sigitas Tolu\v{s}is <sigitas@vtex.lt>
+%% UAB VTeX, Mokslininkų 2A, LT-08412 Vilnius, Lithuania
%% --------------------------------------------------------------------------
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
@@ -22,7 +21,7 @@
%%
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{stabular}
- [2014/03/20 v2.0 Improve tabular environment]
+ [2021/10/04 v2.1 Improve tabular environment]
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{stabular}[2014/03/20]
\def\use@@pkg@@array@@variant{0}
@@ -88,10 +87,10 @@
\@preamble
}
\def\pkgarray@@stabarray{\@ifnextchar[{\pkgarray@@sarray}{\pkgarray@@sarray[c]}}
-\def\pkgarray@stabular{\gdef\@halignto{}\pkgarray@@stabular}
+\def\pkgarray@stabular{\def\@halignto{}\pkgarray@@stabular}
\expandafter\def\csname pkgarray@stabular*\endcsname#1{%
\setlength\dimen@{#1}%
- \xdef\@halignto{to\the\dimen@}\pkgarray@@stabular}
+ \edef\@halignto{to\the\dimen@}\pkgarray@@stabular}
\def\pkgarray@@stabular{%
\leavevmode
\bgroup
diff --git a/Master/texmf-dist/tex/latex/sttools/stfloats.sty b/Master/texmf-dist/tex/latex/sttools/stfloats.sty
index efcb7c4ea37..b6fb8ece0a8 100644
--- a/Master/texmf-dist/tex/latex/sttools/stfloats.sty
+++ b/Master/texmf-dist/tex/latex/sttools/stfloats.sty
@@ -6,7 +6,7 @@
%%
%% stfloats.dtx (with options: `package')
%%
-%% Copyright (C) 1997-2017 by Sigitas Tolu\v{s}is <sigitas@vtex.lt>
+%% Copyright (C) 1997-2021 by Sigitas Tolu\v{s}is <sigitas@vtex.lt>
%% VTeX UAB, Mokslininku 2a, Vilnius, Lithuania
%% --------------------------------------------------------------------------
%% This work may be distributed and/or modified under the
diff --git a/Master/texmf-dist/tex/latex/sttools/texsort.sty b/Master/texmf-dist/tex/latex/sttools/texsort.sty
index a78fe40bed4..be67de50783 100644
--- a/Master/texmf-dist/tex/latex/sttools/texsort.sty
+++ b/Master/texmf-dist/tex/latex/sttools/texsort.sty
@@ -6,9 +6,8 @@
%%
%% texsort.dtx (with options: `package')
%%
-%% Copyright (C) 2000-2012 by Sigitas Tolu\v{s}is <sigitas@vtex.lt>
-%% VTeX Ltd., Akademijos 4, Vilnius, Lithuania
-%% http://www.vtex.lt/tex/download/macros/
+%% Copyright (C) 2000-2021 by Sigitas Tolu\v{s}is <sigitas@vtex.lt>
+%% UAB VTeX, Mokslininkų 2A, LT-08412 Vilnius, Lithuania
%% --------------------------------------------------------------------------
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3