summaryrefslogtreecommitdiff
path: root/Master
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2020-10-26 20:59:29 +0000
committerKarl Berry <karl@freefriends.org>2020-10-26 20:59:29 +0000
commit3b6712112858f1def3b95f5d4ce48503cc6a84b3 (patch)
tree4e2e818aa5c46dbec5f642043e1132b80abdaa17 /Master
parent65b181c99290a8a43c3c7dff65d534b92ea5762c (diff)
latex (26oct20)
git-svn-id: svn://tug.org/texlive/trunk@56774 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r--Master/texmf-dist/doc/latex/sttools/README.md6
-rw-r--r--Master/texmf-dist/doc/latex/sttools/flushend.pdfbin147962 -> 83883 bytes
-rw-r--r--Master/texmf-dist/source/latex/sttools/flushend.dtx231
-rw-r--r--Master/texmf-dist/tex/latex/sttools/flushend.sty74
4 files changed, 218 insertions, 93 deletions
diff --git a/Master/texmf-dist/doc/latex/sttools/README.md b/Master/texmf-dist/doc/latex/sttools/README.md
index eea5d0d9fc8..3c48f3a113a 100644
--- a/Master/texmf-dist/doc/latex/sttools/README.md
+++ b/Master/texmf-dist/doc/latex/sttools/README.md
@@ -1,4 +1,4 @@
-README for sttools, v2.0 2017/03/27
+README for sttools, v2.1 2020/10/16
INTRODUCTION
============
@@ -17,7 +17,7 @@ PACKAGES
* floatpag.sty, v1.1 2012/05/29:
– sets pagestyle for floats page;
-* flushend.sty, v3.3 2017/03/27:
+* flushend.sty, v3.5 2017/10/16:
– balances page in twocolumn mode;
(2014/03/03): totally rewritten with new algorithm to support footnotes,
top floats and column break before one line section title;
@@ -28,6 +28,8 @@ PACKAGES
(2015/04/14): set debug option off by default; keeplastbox modified;
(2016/06/21): bugfix compatibility with luatexja package;
(2017/03/27): bugfix version with new options for some checks on/off;
+ (2020/10/14): bugfix development and test;
+ (2020/10/16): bugfix version: modern with noautobase;
* marginal.sty, v1.1 2012/05/29:
– enlarges room for marginal inserts;
diff --git a/Master/texmf-dist/doc/latex/sttools/flushend.pdf b/Master/texmf-dist/doc/latex/sttools/flushend.pdf
index 00a66aa2082..0be3cddabcf 100644
--- a/Master/texmf-dist/doc/latex/sttools/flushend.pdf
+++ b/Master/texmf-dist/doc/latex/sttools/flushend.pdf
Binary files differ
diff --git a/Master/texmf-dist/source/latex/sttools/flushend.dtx b/Master/texmf-dist/source/latex/sttools/flushend.dtx
index 2634f02e804..20d20f396e5 100644
--- a/Master/texmf-dist/source/latex/sttools/flushend.dtx
+++ b/Master/texmf-dist/source/latex/sttools/flushend.dtx
@@ -1,6 +1,6 @@
% \iffalse meta-comment/*% \end{macrocode}*/
%
-% Copyright (C) 2017 by Sigitas Tolu\v{s}is <sigitas@vtex.lt>
+% Copyright (C) 2020 by Sigitas Tolu\v{s}is <sigitas@vtex.lt>
% ---------------------------------------------------------------------------
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
@@ -26,7 +26,16 @@
%<*batchfile>
\input docstrip.tex
\keepsilent\askforoverwritefalse
-\nopreamble\nopostamble
+\preamble
+%%
+%% This is file `flushend.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% flushend.dtx (with options: `package')
+%%
+\endpreamble
\generate{\file{flushend.sty}{\from{flushend.dtx}{package}}}
%</batchfile>
%<batchfile>\endbatchfile
@@ -38,9 +47,8 @@
\ProvidesFile{flushend.dtx}
%</driver>
%<*package>
-%% Copyright (C) 1997-2017 by Sigitas Tolu\v{s}is <sigitas@vtex.lt>
+%% Copyright (C) 1997-2020 by Sigitas Tolu\v{s}is <sigitas@vtex.lt>
%% VTeX Ltd., Mokslinink\k{u} 2a, Vilnius, Lithuania
-%% http://www.vtex.lt/tex/download/macros/
%% --------------------------------------------------------------------------
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
@@ -56,12 +64,12 @@
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<package>\ProvidesPackage{flushend}
%<*package>
- [2017/03/27 v3.3 Balancing columns in twocolumn mode]
+ [2020/10/16 v3.5 Balancing columns in twocolumn mode]
%</package>
%
%<*driver>
\documentclass{ltxdoc}
-\usepackage{flushend}[2016/06/21]
+\usepackage{flushend}[2020/10/16]
\EnableCrossrefs
\CodelineIndex
%%\RecordChanges
@@ -74,7 +82,7 @@
%</driver>
% \fi
%
-% \CheckSum{1855}
+% \CheckSum{2020}
%
% \CharacterTable
% {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
@@ -104,9 +112,11 @@
% ancient/modern,
% spread/nospread,
% removelastbox/keeplastbox}
-% \changes{v3.1}{2015/04/14}{set debug option off by default; keeplastbox modified;}
-% \changes{v3.2}{2016/06/21}{bugfix compatibility with luatexja}
-% \changes{v3.3}{2017/03/27}{bugfix for get@@footnoterule@@box; options for some checks on/off}
+% \changes{v3.1}{2015/04/14}{set debug option off by default; keeplastbox modified;}
+% \changes{v3.2}{2016/06/21}{bugfix compatibility with luatexja}
+% \changes{v3.3}{2017/03/27}{bugfix for get@@footnoterule@@box; options for some checks on/off}
+% \changes{v3.4}{2020/10/14}{bugfix development and test}
+% \changes{v3.5}{2020/10/16}{bugfix version: modern with noautobase}
%
% \DoNotIndex{\newcommand,\newenvironment}
%
@@ -121,16 +131,16 @@
% \section{Introduction}
%
% The package is used to balance columns on any page in twocolumn
-% mode. By default it is switched on at the end of document. It is
-% expected to work with footnotes, top floats and column break
+% mode. By default it is switched on at the end of document. It is
+% expected to work with footnotes, top floats and column break
% before one line section title.
%
% \section{Usage}
%
-% Just load the package to balance the last page: that's all.
+% Just load the package to balance the last page: that's all.
% To balance some page in middle of document use command
-% \cs{flushcolsend} at that page.
-%
+% \cs{flushcolsend} at that page.
+%
% \medskip
% \DescribeMacro{\flushend}
%
@@ -168,7 +178,7 @@
% Adds \meta{tokens} at the end of right column.
%
% \medskip
-% \textit{Example}: |\atColsEnd{\vfil}|.
+% \textit{Example}: |\atColsEnd{\vfil}|.
%
% \medskip
% \DescribeMacro{\showcolsendrule}
@@ -176,24 +186,24 @@
% It can be used just for debugging: adds rule to the bottom of columns.
%
% \subsection{Package options}
-%
+%
% \medskip
% \DescribeMacro{ancient}
% It is used to switch on old version of balancing algorithm.
% This version is not so accurate or "clever" but quite safe.
-%
+%
% \medskip
% \DescribeMacro{modern}
% [default] It is used to switch on new version of balancing algorithm.
% This version has some heuristic guesses for footnotes, floats
% and section like head skip. So it is more dangerous in the case
-% for text misplace or disappear.
+% for text misplace or disappear.
%
% \medskip
% \DescribeMacro{autobase}
% [default] It is used to guess |\baselineskip| value on original columns
% break. On failure just use |\atColsBreak{...}|.
-%
+%
% \medskip
% \DescribeMacro{noautobase}
% It is used to switch off the previous option behaviour.
@@ -201,7 +211,7 @@
% \medskip
% \DescribeMacro{spread}
% [default] It adds extra glue to the rightcolumn trying to balance.
-%
+%
% \medskip
% \DescribeMacro{nospread}
% It skips adding extra glue to the last column.
@@ -209,11 +219,11 @@
% \medskip
% \DescribeMacro{removelastbox}
% [default] It tries to remove an empty box (some more material) from the last column bottom.
-%
+%
% \medskip
% \DescribeMacro{keeplastbox}
-% It skips removing anything from the last column. As example it is usefull and can be used
-% then document ends by reference item and last line of text should be with indend.
+% It skips removing anything from the last column. As example it is usefull and can be used
+% then document ends by reference item and last line of text should be with indend.
%
% \medskip
% \DescribeMacro{checkfootnote}
@@ -241,7 +251,7 @@
% [default] Skips putting debuging lines.
%
% \StopEventually{}
-%
+%
% \section{Implementation}
%
% \iffalse
@@ -257,10 +267,10 @@
\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{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{checkfootnote}{%
@@ -293,9 +303,11 @@
\newskip\flushend@@lastskip@b
\newskip\flushend@@lastskip@c
\newcount\flushend@@penalty@a
+\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@}
@@ -353,7 +365,7 @@
}
\def\set@split@topskip@to#1{%
\splittopskip#1\relax \vfuzz\maxdimen \vbadness\maxdimen
- }
+ }
% \end{macrocode}
% \end{macro}
%
@@ -373,28 +385,28 @@
%
% To get more or less proper result we need to know about footnotes at
% the left column end, top floats at the right column top, skips and
-% so on. This part of the package is responsible for such analysis.
+% so on. This part of the package is responsible for such analysis.
%
% \begin{macrocode}
\gdef\analyze@lastbox@box#1{%
\setbox\flushend@@varbox@a\vbox{%
\unvbox#1%
- \global\flushend@@lastskip@a\lastskip
+ \global\flushend@@lastskip@a\lastskip
\unskip
- \global\var@@temp@a\lastkern
+ \global\var@@temp@a\lastkern
\unkern
- \global\flushend@@penalty@a\lastpenalty
+ \global\flushend@@penalty@a\lastpenalty
\unpenalty
\ifdim\lastskip>\z@
- \global\flushend@@lastskip@a\lastskip
- \fi
+ \global\flushend@@lastskip@a\lastskip
+ \fi
\unskip
\ifdim\lastkern>\z@
- \global\var@@temp@a\lastkern
- \fi
+ \global\var@@temp@a\lastkern
+ \fi
\unkern
\ifnum\lastpenalty>\z@
- \global\flushend@@penalty@a\lastpenalty
+ \global\flushend@@penalty@a\lastpenalty
\fi
\unpenalty
\global\setbox\flushend@@tempbox@a\lastbox
@@ -402,7 +414,7 @@
\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;
+ ^^J::lastskip: \the\flushend@@lastskip@a;
lastkern: \the\var@@temp@a;
lastpenalty: \the\flushend@@penalty@a
}%
@@ -425,11 +437,11 @@
\wlog@balance@debug{^^Jmainbox: \log@box@info{#1}}%
\setbox\flushend@@varbox@a\vbox{%
\unvbox#1%
- \global\flushend@@lastskip@a\lastskip
+ \global\flushend@@lastskip@a\lastskip
\unskip
\global\flushend@@lastkern@a\lastkern
\unkern
- \global\flushend@@penalty@a\lastpenalty
+ \global\flushend@@penalty@a\lastpenalty
\unpenalty
\global\setbox\flushend@@tempbox@a\lastbox
}%
@@ -437,8 +449,8 @@
\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;
+ ^^J.-lastskip: \the\flushend@@lastskip@a;
+ lastkern: \the\flushend@@lastkern@a;
lastpenalty: \the\flushend@@penalty@a
^^J.-diff: \the\flushend@@lastskip@b
}%
@@ -486,6 +498,16 @@
\wlog@balance@debug{lastbox: \log@box@info{\flushend@@varbox@a}}%
\fi
\fi
+ \ifdim\var@@temp@loop=\ht\flushend@@varbox@a\relax
+ \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}%
+ \else
+ \wlog@balance@debug{analyze left col loop limit!}%
+ \ht\flushend@@varbox@a\z@
+ \fi
\ifdim\ht\flushend@@varbox@a>\topskip
\expandafter\analyze@leftcolumn@box\expandafter\flushend@@varbox@a
\fi
@@ -497,7 +519,7 @@
% \begin{macro}{\get@@footnoterule@@box}
%
% Gets dimensions of the box made by |footnoterule| and writes to:
-% |\footnoterule@@box@@ht|, |\footnoterule@@box@@dp|, |\footnoterule@@box@@wd|.
+% |\footnoterule@@box@@ht|, |\footnoterule@@box@@dp|, |\footnoterule@@box@@wd|.
%
% \begin{macrocode}
\def\get@@footnoterule@@box{%
@@ -522,8 +544,8 @@
%
% Checks if \marg{box1} dimensions equals to |footnoterule| box dimensions.
% If so and if \marg{skip} is not |\topskip| we guess it is footnote.
-% In that case we define |leftcolumn| height without |footnote| as
-% \marg{box2} height and save it as |\main@box@height|. Skip from text to
+% In that case we define |leftcolumn| height without |footnote| as
+% \marg{box2} height and save it as |\main@box@height|. Skip from text to
% footnote define as |\main@box@skip|.
%
% \begin{macrocode}
@@ -536,8 +558,8 @@
\else
\xdef\main@box@height{\the\ht#3}%
\xdef\main@box@skip{\the#2}%
- \wlog@balance@debug{^^J:footnoterule found:
- main@box <ht=\main@box@height,
+ \wlog@balance@debug{^^J:footnoterule found:
+ main@box <ht=\main@box@height,
skip=\main@box@skip>
}%
\global\let\check@@footnoterule@@box\@gobblethree
@@ -569,8 +591,8 @@
\let\initial@check@@baselineskip@@skip\check@@baselineskip@@skip
% \end{macrocode}
%
-% In the case we found footnote it is necessary to look for the last skip
-% between text lines again. For that we use
+% In the case we found footnote it is necessary to look for the last skip
+% between text lines again. For that we use
% |\reset@check@@baselineskip@@skip|. It activates |\check@@baselineskip@@skip|.
%
% \begin{macrocode}
@@ -693,7 +715,17 @@
\ifdim\flushend@@lastskip@b>\topskip
\xdef\top@@section@skip{\the\flushend@@lastskip@b}%
\fi
- \ifdim\ht\flushend@@varbox@a>2\topskip
+ \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}%
+ \else
+ \wlog@balance@debug{analyze right col loop limit!}%
+ \ht\flushend@@varbox@a=\z@
+ \fi
+ \ifdim\ht\flushend@@varbox@a>2\topskip
\setbox\flushend@@tempbox@c\vbox{\unvbox\flushend@@varbox@a}%
\repeat
\fi
@@ -705,7 +737,7 @@
%
% \begin{macro}{\combine@columns@for@balance}
%
-% Collects both columns to one box removing left column footnotes
+% Collects both columns to one box removing left column footnotes
% and right column top float and adding right skip in between them.
%
% \begin{macrocode}
@@ -725,9 +757,11 @@
\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
- \hrule\@height\flushend@@page@rule width\columnwidth
\ifdim\top@@section@skip>\top@@skip@@limit
\vskip\top@@section@skip
\fi
@@ -741,11 +775,12 @@
\else
%% Ignore baselineskip value on column break
\setbox\@tempboxa\vbox{%
- \unvbox\@leftcolumn
- \setbox\z@\lastbox
+ \unvbox\flushend@@varbox@a
\unskip\unkern\unpenalty
- \the\atColsBreak
\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
@@ -758,11 +793,11 @@
% \begin{macro}{\set@outputbox@with@footnote}
%
% Calculates break position and formats balanced columns in the |\@outputbox|
-% with footnotes.
+% with footnotes.
%
% \begin{macrocode}
\def\set@outputbox@with@footnote{%
- %% footnote in left column
+ %% footnote in left column
\@tempdimb\ht\@tempboxa
\ifdim\top@@floatbox@skip>\z@
\advance\@tempdimb \top@@floatbox@skip
@@ -819,6 +854,8 @@
\vss
}%
\hrule\@height\flushend@@page@rule width\textwidth
+ \vskip-\flushend@@page@rule
+ \hrule\@height\z@ width\columnwidth
\vss
}%
\global\ht\@leftcolumn=\the\@tempdima
@@ -868,11 +905,11 @@
% \begin{macro}{\set@outputbox@without@footnote}
%
% Calculates break position and formats balanced columns in the |\@outputbox|
-% without footnotes.
+% without footnotes.
%
% \begin{macrocode}
\def\set@outputbox@without@footnote{%
- %% no footnote in left column
+ %% no footnote in left column
\@tempdimb \ht\@tempboxa
\ifdim\top@@floatbox@skip>\z@
\advance\@tempdimb \top@@floatbox@skip
@@ -919,6 +956,8 @@
\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
}%
\global\ht\@leftcolumn=\the\@tempdima
@@ -963,51 +1002,70 @@
% Columns balancing of the twocolumn mode page (modern algorithm).
% It is maybe not so safe for text moving or missing at all
% as it uses some heuristic technique to find footnotes, last skip between lines
-% at left column and floats or section like heads at right column top
-% for replacing them (except heads of course) to other places in text.
-%
+% at left column and floats or section like heads at right column top
+% for replacing them (except heads of course) to other places in text.
+%
% \begin{macrocode}
\def\last@outputdblcol@modern{%
\if@firstcolumn
\global \@firstcolumnfalse
- \global \setbox\@leftcolumn \box\@outputbox
+ \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
\global \@firstcolumntrue
\@tempdima\ht\@leftcolumn
+ \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\main@box@skip{\z@}%
- \global\flushend@@lastskip@c\z@
- \setbox\flushend@@varbox@a\vbox{\unvcopy\@leftcolumn}%
+ \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}%
+ \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
+ \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
+ \else
+ %% no footnote in left column
\setbox\flushend@@varbox@a\box\@leftcolumn
\fi
- \ifdim\var@@temp@spread>\z@
+ \ifdim\var@@temp@spread>\z@
%% rightcolumn non empty
\combine@columns@for@balance
- \else
+ \else
%% rightcolumn empty
\setbox\@tempboxa\vbox{%
\unvbox\flushend@@varbox@a
\remove@lastbox@at@balancing
\the\atColsEnd
}%
- \fi
+ \fi
\ifdim\main@box@skip>\z@
- %% footnote in left column
+ %% footnote in left column
\set@outputbox@with@footnote
\else
- %% no footnote in left column
+ %% no footnote in left column
\set@outputbox@without@footnote
\fi
\setbox\@outputbox \vbox {%
@@ -1028,6 +1086,7 @@
\setbox\@outputbox\vbox{\box\hold@viper\box\@outputbox}%
\fi
\@combinedblfloats
+ \csname @setmarks\endcsname
\@outputpage
\begingroup
\@dblfloatplacement
@@ -1050,9 +1109,9 @@
% \begin{macro}{\last@outputdblcol@old}
%
% Columns balancing of the twocolumn mode page (ancient algorithm).
-% It is maybe not so good in some cases but maybe more safe for text
+% It is maybe not so good in some cases but maybe more safe for text
% moving or missing at all.
-%
+%
% \begin{macrocode}
\def\last@outputdblcol@ancient{%
\if@firstcolumn
@@ -1096,6 +1155,8 @@
\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
@@ -1107,6 +1168,8 @@
\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
@@ -1132,8 +1195,8 @@
\vsplit\flushend@@tempbox@a to\@tempdimb
\vss
}%
- \wlog{(2)Left:\the\ht\flushend@@tempbox@c\space
- Right:\the\ht\flushend@@tempbox@a\space
+ \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
@@ -1156,6 +1219,8 @@
}%
}%
\hrule\@height\flushend@@page@rule
+ \vskip-\flushend@@page@rule
+ \hrule\@height\z@ width\textwidth
\vss
}%
\setbox\@outputbox\vbox to\@tempdima{%
@@ -1166,6 +1231,8 @@
}%
}%
\hrule\@height\flushend@@page@rule
+ \vskip-\flushend@@page@rule
+ \hrule\@height\z@ width\textwidth
\vss
}%
\setbox\@outputbox\vbox{%
@@ -1235,7 +1302,7 @@
\def\raggedcolsend{\global\let\@outputdblcol\saved@orig@@outputdblcol}
% \end{macrocode}
%
-% \cs{flushend} is used to switch on column balancing on the last page.
+% \cs{flushend} is used to switch on column balancing on the last page.
% It is used by default.
%
% \begin{macrocode}
diff --git a/Master/texmf-dist/tex/latex/sttools/flushend.sty b/Master/texmf-dist/tex/latex/sttools/flushend.sty
index 56cea6e0f17..1dcff1fc01b 100644
--- a/Master/texmf-dist/tex/latex/sttools/flushend.sty
+++ b/Master/texmf-dist/tex/latex/sttools/flushend.sty
@@ -6,9 +6,8 @@
%%
%% flushend.dtx (with options: `package')
%%
-%% Copyright (C) 1997-2017 by Sigitas Tolu\v{s}is <sigitas@vtex.lt>
+%% Copyright (C) 1997-2020 by Sigitas Tolu\v{s}is <sigitas@vtex.lt>
%% VTeX Ltd., Mokslinink\k{u} 2a, Vilnius, Lithuania
-%% http://www.vtex.lt/tex/download/macros/
%% --------------------------------------------------------------------------
%% 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{flushend}
- [2017/03/27 v3.3 Balancing columns in twocolumn mode]
+ [2020/10/16 v3.5 Balancing columns in twocolumn mode]
\newif\if@auto@baselineskip \@auto@baselineskiptrue
\newif\if@ancient@balance@version \@ancient@balance@versionfalse
\newif\if@right@column@spread \@right@column@spreadtrue
@@ -63,9 +62,11 @@
\newskip\flushend@@lastskip@b
\newskip\flushend@@lastskip@c
\newcount\flushend@@penalty@a
+\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@}
@@ -211,6 +212,16 @@
\wlog@balance@debug{lastbox: \log@box@info{\flushend@@varbox@a}}%
\fi
\fi
+ \ifdim\var@@temp@loop=\ht\flushend@@varbox@a\relax
+ \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}%
+ \else
+ \wlog@balance@debug{analyze left col loop limit!}%
+ \ht\flushend@@varbox@a\z@
+ \fi
\ifdim\ht\flushend@@varbox@a>\topskip
\expandafter\analyze@leftcolumn@box\expandafter\flushend@@varbox@a
\fi
@@ -366,6 +377,16 @@
\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}%
+ \else
+ \wlog@balance@debug{analyze right col loop limit!}%
+ \ht\flushend@@varbox@a=\z@
+ \fi
\ifdim\ht\flushend@@varbox@a>2\topskip
\setbox\flushend@@tempbox@c\vbox{\unvbox\flushend@@varbox@a}%
\repeat
@@ -389,9 +410,11 @@
\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
- \hrule\@height\flushend@@page@rule width\columnwidth
\ifdim\top@@section@skip>\top@@skip@@limit
\vskip\top@@section@skip
\fi
@@ -405,11 +428,12 @@
\else
%% Ignore baselineskip value on column break
\setbox\@tempboxa\vbox{%
- \unvbox\@leftcolumn
- \setbox\z@\lastbox
+ \unvbox\flushend@@varbox@a
\unskip\unkern\unpenalty
- \the\atColsBreak
\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
@@ -474,6 +498,8 @@
\vss
}%
\hrule\@height\flushend@@page@rule width\textwidth
+ \vskip-\flushend@@page@rule
+ \hrule\@height\z@ width\columnwidth
\vss
}%
\global\ht\@leftcolumn=\the\@tempdima
@@ -565,6 +591,8 @@
\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
}%
\global\ht\@leftcolumn=\the\@tempdima
@@ -605,19 +633,38 @@
\def\last@outputdblcol@modern{%
\if@firstcolumn
\global \@firstcolumnfalse
- \global \setbox\@leftcolumn \box\@outputbox
+ \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
\global \@firstcolumntrue
\@tempdima\ht\@leftcolumn
+ \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\main@box@skip{\z@}%
- \global\flushend@@lastskip@c\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
@@ -663,6 +710,7 @@
\setbox\@outputbox\vbox{\box\hold@viper\box\@outputbox}%
\fi
\@combinedblfloats
+ \csname @setmarks\endcsname
\@outputpage
\begingroup
\@dblfloatplacement
@@ -722,6 +770,8 @@
\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
@@ -733,6 +783,8 @@
\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
@@ -782,6 +834,8 @@
}%
}%
\hrule\@height\flushend@@page@rule
+ \vskip-\flushend@@page@rule
+ \hrule\@height\z@ width\textwidth
\vss
}%
\setbox\@outputbox\vbox to\@tempdima{%
@@ -792,6 +846,8 @@
}%
}%
\hrule\@height\flushend@@page@rule
+ \vskip-\flushend@@page@rule
+ \hrule\@height\z@ width\textwidth
\vss
}%
\setbox\@outputbox\vbox{%