texlive[43684] Master/texmf-dist: sttools (4Apr)

commits+preining at tug.org commits+preining at tug.org
Tue Apr 4 06:53:44 CEST 2017


Revision: 43684
          http://tug.org/svn/texlive?view=revision&revision=43684
Author:   preining
Date:     2017-04-04 06:53:44 +0200 (Tue, 04 Apr 2017)
Log Message:
-----------
sttools (4Apr)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/sttools/README.md
    trunk/Master/texmf-dist/doc/latex/sttools/flushend.pdf
    trunk/Master/texmf-dist/doc/latex/sttools/stfloats.pdf
    trunk/Master/texmf-dist/source/latex/sttools/flushend.dtx
    trunk/Master/texmf-dist/source/latex/sttools/stfloats.dtx
    trunk/Master/texmf-dist/tex/latex/sttools/flushend.sty
    trunk/Master/texmf-dist/tex/latex/sttools/stfloats.sty

Modified: trunk/Master/texmf-dist/doc/latex/sttools/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/sttools/README.md	2017-04-04 00:06:08 UTC (rev 43683)
+++ trunk/Master/texmf-dist/doc/latex/sttools/README.md	2017-04-04 04:53:44 UTC (rev 43684)
@@ -1,4 +1,4 @@
-README for sttools, v1.9 2016/06/28
+README for sttools, v2.0 2017/03/27
 
 INTRODUCTION
 ============
@@ -17,7 +17,7 @@
 * floatpag.sty, v1.1 2012/05/29:
   – sets pagestyle for floats page;
 
-* flushend.sty, v3.2 2016/06/21:
+* flushend.sty, v3.3 2017/03/27:
   – 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;
@@ -27,6 +27,7 @@
                  - optional old algorithm for backward compatability;
    (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;
 
 * marginal.sty, v1.1 2012/05/29:
   – enlarges room for marginal inserts;
@@ -42,9 +43,10 @@
        on page boundary;
        added tabular variant from array package;
 
-* stfloats.sty, v3.2 2016/06/28:
+* stfloats.sty, v3.3 2017/03/27:
   – enriches floats output mechanism; 
    (2016/06/28): compatibility bugfix with 2015 latexrelease;
+   (2017/03/27): compatibility bugfix with 2017-05-01 latexrelease;
 
 * texsort.sty, v1.1 2012/05/29:
   - sorts numerical values;

Modified: trunk/Master/texmf-dist/doc/latex/sttools/flushend.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/sttools/stfloats.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/source/latex/sttools/flushend.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/sttools/flushend.dtx	2017-04-04 00:06:08 UTC (rev 43683)
+++ trunk/Master/texmf-dist/source/latex/sttools/flushend.dtx	2017-04-04 04:53:44 UTC (rev 43684)
@@ -1,6 +1,6 @@
-% \iffalse meta-comment
+% \iffalse meta-comment/*%    \end{macrocode}*/
 %
-% Copyright (C) 2016 by Sigitas Tolu\v{s}is <sigitas at vtex.lt>
+% Copyright (C) 2017 by Sigitas Tolu\v{s}is <sigitas at vtex.lt>
 % ---------------------------------------------------------------------------
 % This work may be distributed and/or modified under the
 % conditions of the LaTeX Project Public License, either version 1.3
@@ -20,11 +20,25 @@
 % \fi
 %
 % \iffalse
+%<*internal>
+\begingroup
+%</internal>
+%<*batchfile>
+\input docstrip.tex
+\keepsilent\askforoverwritefalse
+\nopreamble\nopostamble
+\generate{\file{flushend.sty}{\from{flushend.dtx}{package}}}
+%</batchfile>
+%<batchfile>\endbatchfile
+%<*internal>
+\generate{\file{flushend.ins}{\from{flushend.dtx}{batchfile}}}
+\endgroup
+%</internal>
 %<*driver>
 \ProvidesFile{flushend.dtx}
 %</driver>
 %<*package>
-%% Copyright (C) 1997-2016 by Sigitas Tolu\v{s}is <sigitas at vtex.lt>
+%% Copyright (C) 1997-2017 by Sigitas Tolu\v{s}is <sigitas at vtex.lt>
 %% VTeX Ltd., Mokslinink\k{u} 2a, Vilnius, Lithuania
 %% http://www.vtex.lt/tex/download/macros/
 %% --------------------------------------------------------------------------
@@ -42,7 +56,7 @@
 %<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
 %<package>\ProvidesPackage{flushend}
 %<*package>
-    [2016/06/21 v3.2 Balancing columns in twocolumn mode]
+    [2017/03/27 v3.3 Balancing columns in twocolumn mode]
 %</package>
 %
 %<*driver>
@@ -51,6 +65,7 @@
 \EnableCrossrefs
 \CodelineIndex
 %%\RecordChanges
+%\OnlyDescription
 \begin{document}
   \DocInput{flushend.dtx}
   %%\PrintChanges
@@ -59,7 +74,7 @@
 %</driver>
 % \fi
 %
-% \CheckSum{1738}
+% \CheckSum{1855}
 %
 % \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
@@ -91,6 +106,7 @@
 %                            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} 
 %
 % \DoNotIndex{\newcommand,\newenvironment}
 %
@@ -164,14 +180,18 @@
 % \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}
-%   It is used to switch on new version of balancing algorithm.
+%   [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. 
 %
 % \medskip
 % \DescribeMacro{autobase}
-%   It is used to guess |\baselineskip| value on original columns
+%   [default] It is used to guess |\baselineskip| value on original columns
 %   break. On failure just use |\atColsBreak{...}|.
 % 
 % \medskip
@@ -180,7 +200,7 @@
 %
 % \medskip
 % \DescribeMacro{spread}
-%   It adds extra glue to the rightcolumn trying to balance.
+%   [default] It adds extra glue to the rightcolumn trying to balance.
 % 
 % \medskip
 % \DescribeMacro{nospread}
@@ -188,13 +208,30 @@
 %
 % \medskip
 % \DescribeMacro{removelastbox}
-%   It tries to remove an empty box (some more material) from the last column bottom.
+%   [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.
+%   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}
+%   [default] Adds guess for footnote on left column then modern balancing algorithm is in use.
+%
+% \medskip
+% \DescribeMacro{nocheckfootnote}
+%   Skips guess for footnote then modern balansing algorithm is in use.
+%
+% \medskip
+% \DescribeMacro{checkfloat}
+%   [default] Adds guess for top float on right column then modern balancing algorithm is in use.
+%
+% \medskip
+% \DescribeMacro{nocheckfloat}
+%   Skips guess for top float on right column then modern balancing algorithm is in use.
+%
+% \medskip
 % \DescribeMacro{debug}
 %   Adds rules to the bottom of columns (just for debugging) and leftcolumn break place.
 %   Adds some additional log info.
@@ -201,7 +238,7 @@
 %
 % \medskip
 % \DescribeMacro{nodebug}
-%   Skips putting debuging lines.
+%   [default] Skips putting debuging lines.
 %
 % \StopEventually{}
 % 
@@ -211,7 +248,7 @@
 %<*package>
 % \fi
 %
-%
+%/*%    \begin{macrocode}*/
 %    \begin{macrocode}
 \newif\if at auto@baselineskip \@auto at baselineskiptrue
 \newif\if at ancient@balance at version \@ancient at balance@versionfalse
@@ -226,12 +263,31 @@
 \DeclareOption{nospread}{\global\@right at column@spreadfalse} 
 \DeclareOption{removelastbox}{\global\@remove at lastbox@at at balancingtrue}
 \DeclareOption{keeplastbox}{\global\@remove at lastbox@at at balancingfalse}
+\DeclareOption{checkfootnote}{%
+    \AtEndOfPackage{%
+        \let\check@@footnoterule@@box\initial at check@@footnoterule@@box
+        }%
+    }
+\DeclareOption{nocheckfootnote}{%
+    \AtEndOfPackage{%
+        \let\check@@footnoterule@@box\@gobblethree
+        }%
+    }
+\DeclareOption{checkfloat}{%
+    \AtEndOfPackage{%
+        \let\top@@floatbox at min\top@@floatbox at min@default
+        }%
+    }
+\DeclareOption{nocheckfloat}{%
+    \AtEndOfPackage{%
+        \let\top@@floatbox at min\maxdimen
+        }%
+    }
 \DeclareOption{debug}{\global\@balance at debugtrue}
 \DeclareOption{nodebug}{\global\@balance at debugfalse}
 \ProcessOptions
 %    \end{macrocode}
 %
-%
 %    \begin{macrocode}
 \newskip\flushend@@lastskip at a
 \newskip\flushend@@lastskip at b
@@ -242,14 +298,14 @@
 \newdimen\var@@temp at a
 \def\top@@skip@@limit{.7\topskip}
 \newdimen\flushend@@page at rule \flushend@@page at rule\z@
-\def\showcolsendrule{\global\flushend@@page at rule=.4pt}
+\def\showcolsendrule{\global\flushend@@page at rule=.4\p@}
 %    \end{macrocode}
 %
-%
 % \begin{macro}{\top@@floatbox at min}\marg{float size}
 % This value is used to catch possible float on right column top.
 %    \begin{macrocode}
-\gdef\top@@floatbox at min{4\topskip}
+\gdef\top@@floatbox at min@default{4\topskip}
+\let\top@@floatbox at min\top@@floatbox at min@default
 %    \end{macrocode}
 % \end{macro}
 %
@@ -276,25 +332,28 @@
 % It is used to remove empty box at the right column end.
 %    \begin{macrocode}
 \def\unskip at three@kern at penalty{%
-  \unskip\unkern\unpenalty
-  \unskip\unkern\unpenalty
-  \unskip\unkern\unpenalty
-  }
+    \unskip\unkern\unpenalty
+    \unskip\unkern\unpenalty
+    \unskip\unkern\unpenalty
+    }
 \gdef\remove at lastbox@at at balancing{%
-  \unskip at three@kern at penalty
-  \if at remove@lastbox at at@balancing
-  \else
-    \expandafter\null
-  \fi
-  \bgroup
-    \setbox\z@\lastbox
-    \ifdim\wd\z@>\z@
-      \box\z@
+    \unskip at three@kern at penalty
+    \if at remove@lastbox at at@balancing
     \else
-      \aftergroup\unskip at three@kern at penalty
+        \expandafter\null
     \fi
-  \egroup
-  }
+    \bgroup
+        \setbox\z@\lastbox
+        \ifdim\wd\z@>\z@
+            \box\z@
+        \else
+            \aftergroup\unskip at three@kern at penalty
+        \fi
+    \egroup
+    }
+\def\set at split@topskip at to#1{%
+    \splittopskip#1\relax \vfuzz\maxdimen \vbadness\maxdimen
+    }	
 %    \end{macrocode}
 % \end{macro}
 %
@@ -302,11 +361,11 @@
 %
 %    \begin{macrocode}
 \def\show@@box#1{%
-  \bgroup
-    \showboxbreadth=20000\showboxdepth=20000%
-    \showbox#1\relax
-  \egroup
-  }
+    \bgroup
+        \showboxbreadth=20000\showboxdepth=20000%
+        \showbox#1\relax
+    \egroup
+    }
 \def\wlog at balance@debug#1{\if at balance@debug \wlog{#1}\fi}
 \def\log at box@info#1{<box\the#1>(\the\ht#1+\the\dp#1)x\the\wd#1}
 \let\show@@box at next\@gobble
@@ -318,109 +377,131 @@
 %
 %    \begin{macrocode}
 \gdef\analyze at lastbox@box#1{%
-  \setbox\flushend@@varbox at a\vbox{%
-      \unvbox#1%
-      \global\flushend@@lastskip at a\lastskip 
-      \unskip
-      \global\var@@temp at a\lastkern 
-      \unkern
-      \global\flushend@@penalty at a\lastpenalty 
-      \unpenalty
-      \ifdim\lastskip>\z@
-          \global\flushend@@lastskip at a\lastskip 
-      \fi 
-      \unskip
-      \ifdim\lastkern>\z@
-          \global\var@@temp at a\lastkern 
-      \fi 
-      \unkern
-      \ifnum\lastpenalty>\z@
-          \global\flushend@@penalty at a\lastpenalty 
-      \fi
-      \unpenalty
-      \global\setbox\flushend@@tempbox at a\lastbox
-      }%
-  \wlog at balance@debug{^^J::analyze at lastbox@box::\log at box@info{#1}%
-     ^^J ::unvbox: \log at box@info{\flushend@@varbox at a}%
-     ^^J::lastbox: \log at box@info{\flushend@@tempbox at a}%
-     ^^J::lastskip: \the\flushend@@lastskip at a; 
-          lastkern: \the\var@@temp at a;
-       lastpenalty: \the\flushend@@penalty at a
-     }%
-  }
+    \setbox\flushend@@varbox at a\vbox{%
+        \unvbox#1%
+        \global\flushend@@lastskip at a\lastskip 
+        \unskip
+        \global\var@@temp at a\lastkern 
+        \unkern
+        \global\flushend@@penalty at a\lastpenalty 
+        \unpenalty
+        \ifdim\lastskip>\z@
+            \global\flushend@@lastskip at a\lastskip 
+        \fi 
+        \unskip
+        \ifdim\lastkern>\z@
+            \global\var@@temp at a\lastkern 
+        \fi 
+        \unkern
+        \ifnum\lastpenalty>\z@
+            \global\flushend@@penalty at a\lastpenalty 
+        \fi
+        \unpenalty
+        \global\setbox\flushend@@tempbox at a\lastbox
+        }%
+    \wlog at balance@debug{^^J::analyze at lastbox@box::\log at box@info{#1}%
+                        ^^J ::unvbox: \log at box@info{\flushend@@varbox at a}%
+                        ^^J::lastbox: \log at box@info{\flushend@@tempbox at a}%
+                        ^^J::lastskip: \the\flushend@@lastskip at a; 
+                            lastkern: \the\var@@temp at a;
+                         lastpenalty: \the\flushend@@penalty at a
+                       }%
+    }
 %    \end{macrocode}
 %
 % \begin{macro}{\analyze at leftcolumn@box}\marg{box}
+%
+% Fills:
+% \begin{itemize}
+%   \item baselineskip skip from the last boxes to |\flushend@@lastskip at c|
+%   \item leftcolumn height without the footnote to |\main at box@height|
+%   \item footnote skip to |\main at box@skip|
+% \end{itemize}
+%
 %    \begin{macrocode}
 \gdef\analyze at leftcolumn@box#1{%
-  \splittopskip\z@ \vfuzz\maxdimen \vbadness\maxdimen
-  \flushend@@lastskip at b\ht#1%
-  \wlog at balance@debug{^^Jmainbox: \log at box@info{#1}}%
-  \setbox\flushend@@varbox at a\vbox{%
-      \unvbox#1%
-      \global\flushend@@lastskip at a\lastskip 
-      \unskip
-      \global\flushend@@lastkern at a\lastkern
-      \unkern
-      \global\flushend@@penalty at a\lastpenalty 
-      \unpenalty
-      \global\setbox\flushend@@tempbox at a\lastbox
-      }%
-  \advance\flushend@@lastskip at b -\ht\flushend@@varbox at a
-  \advance\flushend@@lastskip at b -\ht\flushend@@tempbox at a
-  \wlog at balance@debug{.-box: \log at box@info{\flushend@@varbox at a}%
-     ^^J.-lastbox: \log at box@info{\flushend@@tempbox at a}%
-     ^^J.-lastskip: \the\flushend@@lastskip at a; 
-         lastkern: \the\flushend@@lastkern at a; 
-      lastpenalty: \the\flushend@@penalty at a
-     ^^J.-diff: \the\flushend@@lastskip at b
-     }%
-  \check@@footnoterule@@box\flushend@@tempbox at a\flushend@@lastskip at b\flushend@@varbox at a
-  \check@@baselineskip@@skip\flushend@@lastskip at a\flushend@@lastskip at b\flushend@@lastskip at c
-  \ifvoid\flushend@@tempbox at a
-      \ifdim\ht\flushend@@varbox at a>\topskip
-          \flushend@@lastskip at b\ht\flushend@@varbox at a
-          \var@@temp at a\ht\flushend@@varbox at a
-          \loop
-              \setbox\flushend@@tempbox at c\vsplit\flushend@@varbox at a to\var@@temp at a
-              \ifvoid\flushend@@varbox at a
-                  \setbox\flushend@@varbox at a\vbox{\unvbox\flushend@@tempbox at c}%
-                  \advance \var@@temp at a -3\p@
-              \else
-                  \var@@temp at a=-1\p@
-              \fi
-          \ifdim \var@@temp at a>\z@
-          \repeat
-          \setbox\flushend@@varbox at a\vbox{\unvbox\flushend@@varbox at a}%
-          \setbox\flushend@@tempbox at c\vbox{\unvbox\flushend@@tempbox at c}%
-          \advance\flushend@@lastskip at b -\ht\flushend@@varbox at a
-          \advance\flushend@@lastskip at b -\ht\flushend@@tempbox at c
-          \wlog at balance@debug{..--box: \log at box@info{\flushend@@tempbox at c}%
-                ^^J..--lastbox: \log at box@info{\flushend@@varbox at a}%
-                ^^J..--diff: \the\flushend@@lastskip at b}%
-          \check@@footnoterule@@box\flushend@@varbox at a\flushend@@lastskip at b
-              \flushend@@tempbox at c
-          \check@@baselineskip@@skip\flushend@@lastskip at a\flushend@@lastskip at b
-              \flushend@@lastskip at c
-          \ifdim\ht\flushend@@varbox at a>.5\topskip
-              \analyze at lastbox@box\flushend@@varbox at a
-          \fi
-          \setbox\flushend@@varbox at a\vbox{\unvbox\flushend@@tempbox at c}%
-      \else
-          \wlog at balance@debug{lastbox: \log at box@info{\flushend@@varbox at a}}%
-      \fi
-  \fi
-  \ifdim\ht\flushend@@varbox at a>\topskip
-      \expandafter\analyze at leftcolumn@box\expandafter\flushend@@varbox at a
-  \fi
-  }
+    \set at split@topskip at to\z@
+    \flushend@@lastskip at b\ht#1%
+    \wlog at balance@debug{^^Jmainbox: \log at box@info{#1}}%
+    \setbox\flushend@@varbox at a\vbox{%
+        \unvbox#1%
+        \global\flushend@@lastskip at a\lastskip 
+        \unskip
+        \global\flushend@@lastkern at a\lastkern
+        \unkern
+        \global\flushend@@penalty at a\lastpenalty 
+        \unpenalty
+        \global\setbox\flushend@@tempbox at a\lastbox
+        }%
+    \advance\flushend@@lastskip at b -\ht\flushend@@varbox at a
+    \advance\flushend@@lastskip at b -\ht\flushend@@tempbox at a
+    \wlog at balance@debug{.-box: \log at box@info{\flushend@@varbox at a}%
+                 ^^J.-lastbox: \log at box@info{\flushend@@tempbox at a}%
+                ^^J.-lastskip: \the\flushend@@lastskip at a; 
+                     lastkern: \the\flushend@@lastkern at a; 
+                  lastpenalty: \the\flushend@@penalty at a
+                    ^^J.-diff: \the\flushend@@lastskip at b
+        }%
+    \check@@footnoterule@@box\flushend@@tempbox at a\flushend@@lastskip at b\flushend@@varbox at a
+    \check@@baselineskip@@skip
+        \flushend@@lastskip at a
+        \flushend@@lastskip at b
+        \flushend@@lastskip at c
+    \ifx\check@@footnoterule@@box\check@@baselineskip@@skip
+    \else
+        \ifvoid\flushend@@tempbox at a
+            \ifdim\ht\flushend@@varbox at a>\topskip
+                \flushend@@lastskip at b\ht\flushend@@varbox at a
+                \var@@temp at a\ht\flushend@@varbox at a
+                \loop
+                    \setbox\flushend@@tempbox at c\vsplit\flushend@@varbox at a to\var@@temp at a
+                    \ifvoid\flushend@@varbox at a
+                        \setbox\flushend@@varbox at a\vbox{\unvbox\flushend@@tempbox at c}%
+                        \advance \var@@temp at a -3\p@
+                    \else
+                        \var@@temp at a=-1\p@
+                    \fi
+                \ifdim \var@@temp at a>\z@
+                \repeat
+                \setbox\flushend@@varbox at a\vbox{\unvbox\flushend@@varbox at a}%
+                \setbox\flushend@@tempbox at c\vbox{\unvbox\flushend@@tempbox at c}%
+                \advance\flushend@@lastskip at b -\ht\flushend@@varbox at a
+                \advance\flushend@@lastskip at b -\ht\flushend@@tempbox at c
+                \wlog at balance@debug{..--box: \log at box@info{\flushend@@tempbox at c}%
+                             ^^J..--lastbox: \log at box@info{\flushend@@varbox at a}%
+                                ^^J..--diff: \the\flushend@@lastskip at b
+                    }%
+                \check@@footnoterule@@box\flushend@@varbox at a\flushend@@lastskip at b
+                    \flushend@@tempbox at c
+                \check@@baselineskip@@skip\flushend@@lastskip at a\flushend@@lastskip at b
+                    \flushend@@lastskip at c
+                \ifx\check@@footnoterule@@box\check@@baselineskip@@skip
+                \else
+                    \ifdim\ht\flushend@@varbox at a>.5\topskip
+                        \analyze at lastbox@box\flushend@@varbox at a
+                    \fi
+                    \setbox\flushend@@varbox at a\vbox{\unvbox\flushend@@tempbox at c}%
+                \fi
+            \else
+                \wlog at balance@debug{lastbox: \log at box@info{\flushend@@varbox at a}}%
+            \fi
+        \fi
+        \ifdim\ht\flushend@@varbox at a>\topskip
+            \expandafter\analyze at leftcolumn@box\expandafter\flushend@@varbox at a
+        \fi
+    \fi
+    }
 %    \end{macrocode}
 % \end{macro}
 %
 % \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|. 
+%
 %    \begin{macrocode}
 \def\get@@footnoterule@@box{%
-    \splittopskip\z@ \vfuzz\maxdimen \vbadness\maxdimen
+    \set at split@topskip at to\z@
     \setbox\flushend@@varbox at a\vbox{\strut
         \vskip\z@
         \footnoterule
@@ -427,424 +508,551 @@
         \unskip\unkern\unpenalty
         \unskip\unkern\unpenalty
         }%
-    \setbox\flushend@@tempbox at c\vsplit\flushend@@varbox at a to\ht\strutbox
+    \setbox\flushend@@tempbox at c\vsplit\flushend@@varbox at a to\p@
     \xdef\footnoterule@@box@@ht{\the\ht\flushend@@varbox at a}%
     \xdef\footnoterule@@box@@dp{\the\dp\flushend@@varbox at a}%
     \xdef\footnoterule@@box@@wd{\the\wd\flushend@@varbox at a}%
     \wlog at balance@debug{:footnoterule: \log at box@info{\flushend@@varbox at a}}%
+    \setbox\flushend@@tempbox at c\vbox{\unvbox\flushend@@varbox at a}%
     }
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{\check@@footnoterule@@box}\marg{box}\marg{skip}\marg{box}
+% \begin{macro}{\check@@footnoterule@@box}\marg{box1}\marg{skip}\marg{box2}
+%
+% 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 at box@height|. Skip from text to 
+% footnote define as |\main at box@skip|.
+%
 %    \begin{macrocode}
+\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
-        \ifdim\wd#1=\footnoterule@@box@@wd
-          \ifdim#2>\topskip
-             \xdef\main at box@height{\the\ht#3}%
-             \xdef\main at box@skip{\the#2}%
-          \fi
+        \ifdim\dp#1=\footnoterule@@box@@dp
+            \ifdim\wd#1=\footnoterule@@box@@wd
+                \ifdim#2=\topskip
+                \else
+                    \xdef\main at box@height{\the\ht#3}%
+                    \xdef\main at box@skip{\the#2}%
+                    \wlog at balance@debug{^^J:footnoterule found: 
+                                        main at box <ht=\main at box@height, 
+                                        skip=\main at box@skip>
+                                       }%
+                    \global\let\check@@footnoterule@@box\@gobblethree
+                    \global\let\check@@baselineskip@@skip\reset at check@@baselineskip@@skip
+                \fi
+            \fi
         \fi
-      \fi
     \fi
-  }
+    }
+\let\initial at check@@footnoterule@@box\check@@footnoterule@@box
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{\check@@baselineskip@@skip}\marg{dimension}\marg{dimension}\marg{var}
+% \begin{macro}{\check@@baselineskip@@skip}\marg{dimension1}\marg{dimension2}\marg{var}
+%
+% If both dimensions: \marg{dimension1} and \marg{dimension2} are positive we
+% define by \marg{var} value of \marg{dimension1} as last skip between text lines
+% and deactivate |\check@@baselineskip@@skip| itself.
+%
 %    \begin{macrocode}
 \def\check@@baselineskip@@skip#1#2#3{%
     \ifdim#1>\z@
         \ifdim#2>\z@
             \global#3=\the#1%
-            \gdef\check@@baselineskip@@skip##1##2##3{}%
+            \global\let\check@@baselineskip@@skip\@gobblethree
         \fi
     \fi
-  }
+    }
+\let\initial at 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 
+% |\reset at check@@baselineskip@@skip|. It activates |\check@@baselineskip@@skip|.
+%
+%    \begin{macrocode}
+\def\reset at check@@baselineskip@@skip#1#2#3{%
+    \global#3=\z@
+    \global\let\check@@baselineskip@@skip\initial at check@@baselineskip@@skip
+    }
+%    \end{macrocode}
 % \end{macro}
 %
 % \begin{macro}{\analyze at rightcolumn@box}\marg{box}
+%
+% Some guess of possible float or section title at the top of right column.\break
+% Fills:
+% \begin{itemize}
+%    \item float height to |\top@@floatbox at ht|
+%    \item float skip to |\top@@floatbox at skip|
+%    \item head skip to |\top@@section at skip|
+% \end{itemize}
+%
 %    \begin{macrocode}
 \def\analyze at rightcolumn@box#1{%
-  \bgroup
-      \xdef\top@@floatbox at ht{\z@}%
-      \xdef\top@@floatbox at skip{\z@}%
-      \xdef\top@@section at skip{\z@}%
-      \splittopskip\z@ \vfuzz\maxdimen \vbadness\maxdimen
-      \wlog at balance@debug{^^J(R)mainbox: \log at box@info{#1}}%
-      \var@@temp at a3\p@
-      \setbox\flushend@@varbox at a\vbox{\strut
-                 \vskip\z@
-                 \unvcopy#1%
-                }%
-      \splittopskip\z@ 
-      \setbox\flushend@@tempbox at c\vsplit\flushend@@varbox at a to\ht\strutbox
-      \flushend@@lastskip at a\ht\flushend@@varbox at a
-      \advance\flushend@@lastskip at a\dp\flushend@@varbox at a
-      \loop
-          \flushend@@lastskip at b\ht\flushend@@varbox at a
-          \advance\flushend@@lastskip at b\dp\flushend@@varbox at a
-          \setbox\flushend@@tempbox at c\vsplit\flushend@@varbox at a to\var@@temp at a
-          \ifvoid\flushend@@tempbox at c
-              \advance \var@@temp at a 3\p@
-              \ifdim\var@@temp at a>\flushend@@lastskip at b
-                  \var@@temp at a=-1\p@
-              \fi
-          \else
-              \setbox\flushend@@tempbox at c\vbox{\unvbox\flushend@@tempbox at c}%
-              \ifdim\ht\flushend@@tempbox at c>\top@@floatbox at min
-                  \advance\flushend@@lastskip at b -\ht\flushend@@tempbox at c
-                  \advance\flushend@@lastskip at b -\dp\flushend@@tempbox at c
-                  \advance\flushend@@lastskip at b -\ht\flushend@@varbox at a
-                  \advance\flushend@@lastskip at b -\dp\flushend@@varbox at a
-                  \xdef\top@@floatbox at skip{\the\flushend@@lastskip at b}%
-                  \flushend@@lastskip at b\flushend@@lastskip at a
-                  \advance\flushend@@lastskip at b -\ht\flushend@@varbox at a
-                  \advance\flushend@@lastskip at b -\top@@floatbox at skip
-                  \xdef\top@@floatbox at ht{\the\flushend@@lastskip at b}%
-                  \var@@temp at a=3\p@
-              \else
-                  \advance\flushend@@lastskip at b -\ht\flushend@@tempbox at c
-                  \advance\flushend@@lastskip at b -\dp\flushend@@tempbox at c
-                  \advance\flushend@@lastskip at b -\ht\flushend@@varbox at a
-                  \advance\flushend@@lastskip at b -\dp\flushend@@varbox at a
-                  \ifdim\ht\flushend@@tempbox at c>\topskip
-                  \else
-                      \xdef\top@@section at skip{\the\flushend@@lastskip at b}%
-                  \fi
-                  \var@@temp at a=-1\p@
-              \fi
-          \fi
-      \ifdim \var@@temp at a>\z@
-      \repeat
-      \ifvoid\flushend@@tempbox at c
-      \else
-          \ifdim\top@@section at skip>\z@
-          \else
-              \ifdim\ht\flushend@@tempbox at c>\z@
-                  \setbox\flushend@@varbox at a\vbox{\unvbox\flushend@@tempbox at c}%
-              \fi
-              \flushend@@lastskip at b\ht\flushend@@varbox at a
-              \var@@temp at a=3\p@
-              \loop
-                  \setbox\flushend@@tempbox at c\vsplit\flushend@@varbox at a to\var@@temp at a
-                  \ifvoid\flushend@@tempbox at c
-                      \advance \var@@temp at a 3\p@
-                      \ifdim\var@@temp at a>\flushend@@lastskip at b
-                          \var@@temp at a=-1\p@
-                      \fi
-                  \else
-                      \ifdim\ht\flushend@@tempbox at c<\z@
-                      \else
-                          \var@@temp at a=-1\p@
-                      \fi
-                  \fi
-              \ifdim \var@@temp at a>\z@
-              \repeat
-              \loop
-                  \setbox\flushend@@varbox at a\vbox{%
-                      \unvbox\flushend@@tempbox at c
-                      \unskip\unkern\unpenalty
-                      \unskip\unkern\unpenalty
-                      \unskip\unkern\unpenalty
-                      \setbox\flushend@@tempbox at c\lastbox
-                    }%
-                  \flushend@@lastskip at b\ht\flushend@@varbox at a
-                  \setbox\flushend@@varbox at a\vbox{%
-                      \unvbox\flushend@@varbox at a
-                      \unskip\unkern\unpenalty
-                      \unskip\unkern\unpenalty
-                      \unskip\unkern\unpenalty
-                    }%
-                  \advance\flushend@@lastskip at b -\ht\flushend@@varbox at a
-                  \ifdim\flushend@@lastskip at b>\topskip
-                      \xdef\top@@section at skip{\the\flushend@@lastskip at b}%
-                  \fi
-              \ifdim\ht\flushend@@varbox at a>2\topskip 
-                  \setbox\flushend@@tempbox at c\vbox{\unvbox\flushend@@varbox at a}%
-              \repeat
-          \fi
-      \fi
-  \egroup
-  }
+    \bgroup
+        \xdef\top@@floatbox at ht{\z@}%
+        \xdef\top@@floatbox at skip{\z@}%
+        \xdef\top@@section at skip{\z@}%
+        \set at split@topskip at to\z@
+        \setbox\flushend@@varbox at a\vbox{\strut
+            \vskip\z@
+            \unvcopy#1%
+            }%
+        \setbox\flushend@@tempbox at c\vsplit\flushend@@varbox at a to\p@
+        \wlog at balance@debug{^^J(R)mainbox: \log at box@info{#1}}%
+        \flushend@@lastskip at a\ht\flushend@@varbox at a
+        \advance\flushend@@lastskip at a\dp\flushend@@varbox at a
+        \ifdim\flushend@@lastskip at a>\z@
+            \analyze at nonempty@rightcolumn at box
+        \fi
+    \egroup
+    }
+\def\analyze at nonempty@rightcolumn at box{%
+    \bgroup
+        \var@@temp at a3\p@
+        \loop
+            \flushend@@lastskip at b\ht\flushend@@varbox at a
+            \advance\flushend@@lastskip at b\dp\flushend@@varbox at a
+            \setbox\flushend@@tempbox at c\vsplit\flushend@@varbox at a to\var@@temp at a
+            \ifvoid\flushend@@tempbox at c
+                \advance \var@@temp at a 3\p@
+                \ifdim\var@@temp at a>\flushend@@lastskip at b
+                    \var@@temp at a=-1\p@
+                \fi
+            \else
+                \setbox\flushend@@tempbox at c\vbox{\unvbox\flushend@@tempbox at c}%
+                \ifdim\ht\flushend@@tempbox at c>\top@@floatbox at min
+                    \advance\flushend@@lastskip at b -\ht\flushend@@tempbox at c
+                    \advance\flushend@@lastskip at b -\dp\flushend@@tempbox at c
+                    \advance\flushend@@lastskip at b -\ht\flushend@@varbox at a
+                    \advance\flushend@@lastskip at b -\dp\flushend@@varbox at a
+                    \xdef\top@@floatbox at skip{\the\flushend@@lastskip at b}%
+                    \flushend@@lastskip at b\flushend@@lastskip at a
+                    \advance\flushend@@lastskip at b -\ht\flushend@@varbox at a
+                    \advance\flushend@@lastskip at b -\top@@floatbox at skip
+                    \xdef\top@@floatbox at ht{\the\flushend@@lastskip at b}%
+                    \var@@temp at a=3\p@
+                \else
+                    \advance\flushend@@lastskip at b -\ht\flushend@@tempbox at c
+                    \advance\flushend@@lastskip at b -\dp\flushend@@tempbox at c
+                    \advance\flushend@@lastskip at b -\ht\flushend@@varbox at a
+                    \advance\flushend@@lastskip at b -\dp\flushend@@varbox at a
+                    \ifdim\ht\flushend@@tempbox at c>\topskip
+                    \else
+                        \xdef\top@@section at skip{\the\flushend@@lastskip at b}%
+                    \fi
+                    \var@@temp at a=-1\p@
+                \fi
+            \fi
+        \ifdim \var@@temp at a>\z@
+        \repeat
+        \ifvoid\flushend@@tempbox at c
+        \else
+            \ifdim\top@@section at skip>\z@
+            \else
+                \ifdim\ht\flushend@@tempbox at c>\z@
+                    \setbox\flushend@@varbox at a\vbox{\unvbox\flushend@@tempbox at c}%
+                \fi
+                \flushend@@lastskip at b\ht\flushend@@varbox at a
+                \var@@temp at a=3\p@
+                \loop
+                    \setbox\flushend@@tempbox at c\vsplit\flushend@@varbox at a to\var@@temp at a
+                    \ifvoid\flushend@@tempbox at c
+                        \advance \var@@temp at a 3\p@
+                        \ifdim\var@@temp at a>\flushend@@lastskip at b
+                            \var@@temp at a=-1\p@
+                        \fi
+                    \else
+                        \ifdim\ht\flushend@@tempbox at c<\z@
+                        \else
+                            \var@@temp at a=-1\p@
+                        \fi
+                    \fi
+                \ifdim \var@@temp at a>\z@
+                \repeat
+                \loop
+                    \setbox\flushend@@varbox at a\vbox{%
+                        \unvbox\flushend@@tempbox at c
+                        \unskip\unkern\unpenalty
+                        \unskip\unkern\unpenalty
+                        \unskip\unkern\unpenalty
+                        \setbox\flushend@@tempbox at c\lastbox
+                        }%
+                    \flushend@@lastskip at b\ht\flushend@@varbox at a
+                    \setbox\flushend@@varbox at a\vbox{%
+                        \unvbox\flushend@@varbox at a
+                        \unskip\unkern\unpenalty
+                        \unskip\unkern\unpenalty
+                        \unskip\unkern\unpenalty
+                        }%
+                    \advance\flushend@@lastskip at b -\ht\flushend@@varbox at a
+                    \ifdim\flushend@@lastskip at b>\topskip
+                        \xdef\top@@section at skip{\the\flushend@@lastskip at b}%
+                    \fi
+                \ifdim\ht\flushend@@varbox at a>2\topskip 
+                    \setbox\flushend@@tempbox at c\vbox{\unvbox\flushend@@varbox at a}%
+                \repeat
+            \fi
+        \fi
+    \egroup
+    }
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{\last at outputdblcol}
+% \begin{macro}{\combine at columns@for at balance}
 %
-% Columns balancing of the twocolumn mode page (modern variant).
+% Collects both columns to one box removing left column footnotes 
+% and right column top float and adding right skip in between them.
 %
 %    \begin{macrocode}
-\def\last at outputdblcol@modern{%
-  \if at firstcolumn
-      \global \@firstcolumnfalse
-      \global \setbox\@leftcolumn \box\@outputbox
-  \else
-      \global \@firstcolumntrue
-      \@tempdima\ht\@leftcolumn
-      \splittopskip\topskip \splitmaxdepth\maxdepth
-      \var@@temp at spread=\wd\@outputbox
-      \get@@footnoterule@@box
-      \xdef\main at box@height{\the\ht\@leftcolumn}%
-      \xdef\main at box@skip{\z@}%
-      \global\flushend@@lastskip at c\z@
-      \setbox\flushend@@varbox at a\vbox{\unvcopy\@leftcolumn}%    
-      \analyze at leftcolumn@box\flushend@@varbox at a
-      \setbox\flushend@@varbox at a\vbox{\unvcopy\@outputbox}%    
-      \analyze at rightcolumn@box\flushend@@varbox at a
-      \if at auto@baselineskip
-          %% Trying guess baselineskip value on column break
-          \ifdim\main at box@skip>\z@
-            \splittopskip\z@
-            \setbox\flushend@@varbox at a\vsplit\@leftcolumn to\main at box@height
-          \else
-            \setbox\flushend@@varbox at a\box\@leftcolumn
-          \fi
-          \ifdim\var@@temp at spread>\z@
-              \setbox\@outputbox\vbox{\strut
-                 \vskip\z@
-                 \unvbox\@outputbox
+\def\combine at columns@for at balance{%
+    \setbox\@outputbox\vbox{\strut
+        \vskip\z@
+        \unvbox\@outputbox
+        }%
+    \set at split@topskip at to\z@
+    \setbox\flushend@@tempbox at c\vsplit\@outputbox to\p@
+    \if at auto@baselineskip
+        %% Trying guess baselineskip value on column break
+        \ifdim\top@@floatbox at skip>\z@
+            \setbox\flushend@@tempbox at c\vsplit\@outputbox to\top@@floatbox at ht
+            \setbox\flushend@@tempbox at c\vbox{\unvbox\flushend@@tempbox at c}%
+        \fi
+        \setbox\@tempboxa\vbox{%
+            \unvbox\flushend@@varbox at a
+            \unskip\unkern\unpenalty
+            \vskip\flushend@@lastskip at c
+            \the\atColsBreak
+            \hrule\@height\flushend@@page at rule width\columnwidth
+            \ifdim\top@@section at skip>\top@@skip@@limit
+                \vskip\top@@section at skip
+            \fi
+            \unvbox\@outputbox
+            \remove at lastbox@at at balancing
+            \the\atColsEnd
+            }%
+        \ifdim\top@@floatbox at skip>\z@
+            \setbox\@outputbox\vbox{\unvbox\flushend@@tempbox at c}%
+        \fi
+    \else
+        %% Ignore baselineskip value on column break
+        \setbox\@tempboxa\vbox{%
+            \unvbox\@leftcolumn
+            \setbox\z@\lastbox
+            \unskip\unkern\unpenalty
+            \the\atColsBreak
+            \hrule\@height\flushend@@page at rule width\columnwidth
+            \unvbox\@outputbox
+            \remove at lastbox@at at balancing
+            \the\atColsEnd
+            }%
+    \fi
+    }
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\set at outputbox@with at footnote}
+%
+% Calculates break position and formats balanced columns in the |\@outputbox|
+% with footnotes.  
+%
+%    \begin{macrocode}
+\def\set at outputbox@with at footnote{%
+    %% footnote in left column 
+    \@tempdimb\ht\@tempboxa
+    \ifdim\top@@floatbox at skip>\z@
+        \advance\@tempdimb \top@@floatbox at skip
+        \advance\@tempdimb \top@@floatbox at ht
+    \fi
+    \advance\@tempdimb \main at box@skip
+    \advance\@tempdimb \ht\@leftcolumn
+    \@tempdimb .5\@tempdimb
+    \advance\@tempdimb -\main at box@skip
+    \advance\@tempdimb -\ht\@leftcolumn
+    \set at split@topskip at to\topskip
+    \loop
+        \setbox\flushend@@varbox at a\copy\@tempboxa
+        \setbox\flushend@@tempbox at a\vsplit\flushend@@varbox at a to\@tempdimb
+        \setbox\flushend@@tempbox at c\vbox{\unvcopy\flushend@@tempbox at a}%
+        \ifdim\top@@floatbox at skip>\z@
+        \setbox\flushend@@varbox at c\vbox{%
+                \unvcopy\@outputbox
+                \vskip\top@@floatbox at skip
+                \unvbox\flushend@@varbox at a
                 }%
-              \splittopskip\z@ 
-              \setbox\flushend@@tempbox at c\vsplit\@outputbox to\ht\strutbox
-              \ifdim\top@@floatbox at skip>\z@
-                  \setbox\flushend@@tempbox at c\vsplit\@outputbox to\top@@floatbox at ht
-                  \setbox\flushend@@tempbox at c\vbox{\unvbox\flushend@@tempbox at c}%
-              \fi
-              \setbox\@tempboxa\vbox{%
-                  \unvbox\flushend@@varbox at a
-                  \unskip\unkern\unpenalty
-                  \vskip\flushend@@lastskip at c
-                  \the\atColsBreak
-                  \hrule\@height\flushend@@page at rule width\columnwidth
-                  \ifdim\top@@section at skip>\top@@skip@@limit
-                      \vskip\top@@section at skip
-                  \fi
-                  \unvbox\@outputbox
-                  \remove at lastbox@at at balancing
-                  \the\atColsEnd
-                  }%
-              \ifdim\top@@floatbox at skip>\z@
-                  \setbox\@outputbox\vbox{\unvbox\flushend@@tempbox at c}%
-              \fi
-          \else %% rightcolumn empty
-              \setbox\@tempboxa\vbox{%
-                  \unvbox\flushend@@varbox at a
-                  \remove at lastbox@at at balancing
-                  \the\atColsEnd
-                  }%
-          \fi
-      \else
-          %% Ignore baselineskip value on column break
-          \ifdim\var@@temp at spread>\z@
-              \setbox\@outputbox\vbox{\strut
-                  \vskip\z@
-                  \unvbox\@outputbox
-                }%
-              \splittopskip\z@ 
-              \setbox\flushend@@tempbox at c\vsplit\@outputbox to\ht\strutbox
-              \setbox\@tempboxa\vbox{%
-                  \unvbox\@leftcolumn
-                  \setbox\z@\lastbox
-                  \unskip\unkern\unpenalty
-                  \the\atColsBreak
-                  \hrule\@height\flushend@@page at rule width\columnwidth
-                  \unvbox\@outputbox
-                  \remove at lastbox@at at balancing
-                  \the\atColsEnd
-                  }%
-          \else
-              \setbox\@tempboxa\vbox{%
-                  \unvbox\@leftcolumn
-                  \remove at lastbox@at at balancing
-                  \the\atColsEnd
-                  }%
-          \fi
-      \fi
-      \ifdim\main at box@skip>\z@
-          \@tempdimb\ht\@tempboxa
-          \advance\@tempdimb -\main at box@skip
-          \advance\@tempdimb -\ht\@leftcolumn
-          \@tempdimb .5\@tempdimb
-          \splittopskip\topskip \splitmaxdepth\maxdepth
-          \loop
-              \setbox\flushend@@varbox at a\copy\@tempboxa
-              \setbox\flushend@@tempbox at a\vsplit\flushend@@varbox at a to\@tempdimb
-              \setbox\flushend@@tempbox at c\vbox{%
-                  \unvcopy\flushend@@tempbox at a
-                  \vskip\main at box@skip
-                  \unvcopy\@leftcolumn
-                  }%
-              \setbox\flushend@@varbox at c\vbox{\unvbox\flushend@@varbox at a}%
-              \var@@temp at spread=\ht\flushend@@tempbox at c
-              \advance\var@@temp at spread by-\ht\flushend@@varbox at c
-              \wlog at balance@debug{Left x: \the\ht\flushend@@tempbox at a
+        \else
+            \setbox\flushend@@varbox at c\vbox{\unvbox\flushend@@varbox at a}%
+        \fi
+        \var@@temp at spread=\ht\flushend@@tempbox at c
+        \advance\var@@temp at spread by\dp\flushend@@tempbox at c
+        \advance\var@@temp at spread \main at box@skip
+        \advance\var@@temp at spread \ht\@leftcolumn
+        \advance\var@@temp at spread by-\ht\flushend@@varbox at c
+        \advance\var@@temp at spread by-\dp\flushend@@varbox at c
+        \wlog at balance@debug{Left x: \the\ht\flushend@@tempbox at a
                             +\the\dp\flushend@@tempbox at a=\the\ht\flushend@@varbox at a
                             +\the\dp\flushend@@varbox at a::\the\@tempdimb
-                 ^^JLeft 0: \the\ht\flushend@@tempbox at c
+                            ^^JLeft 0: \the\ht\flushend@@tempbox at c
                             +\the\dp\flushend@@tempbox at c::\the\@tempdimb
-                 ^^JRight x: \the\ht\flushend@@varbox at c
+                            ^^JRight x: \the\ht\flushend@@varbox at c
                             +\the\dp\flushend@@varbox at c=\the\ht\flushend@@varbox at a
                             +\the\dp\flushend@@varbox at a::\the\@tempdimb
-                 ^^JExtra height:\the\var@@temp at spread\space when \the\@tempdimb
-                 }%
-          \ifdim\var@@temp at spread<\z@ \advance\@tempdimb 1\p@ \repeat
-          \flushend@@lastskip at a\the\ht\flushend@@tempbox at c
-          \flushend@@lastskip at b\the\@tempdimb
-          \setbox\flushend@@tempbox at a\vsplit\@tempboxa to\@tempdimb
-          \setbox\@leftcolumn\vbox to\@tempdima{%
-              \vbox to \flushend@@lastskip at a{%
-                  \unvbox\flushend@@tempbox at a
-                  \vskip\main at box@skip
-                  \unvbox\@leftcolumn
-                  \vss
+                            ^^JExtra height:\the\var@@temp at spread\space when \the\@tempdimb
+                            }%
+    \ifdim\var@@temp at spread<\z@
+        \advance\@tempdimb 1\p@
+    \repeat
+    \flushend@@lastskip at a\the\ht\flushend@@tempbox at c
+    \advance\flushend@@lastskip at a \main at box@skip
+    \advance\flushend@@lastskip at a \ht\@leftcolumn
+    \flushend@@lastskip at b\the\@tempdimb
+    \setbox\flushend@@tempbox at a\vsplit\@tempboxa to\@tempdimb
+    \setbox\@leftcolumn\vbox to\@tempdima{%
+        \vbox to \flushend@@lastskip at a{%
+            \unvbox\flushend@@tempbox at a
+            \vskip\main at box@skip
+            \unvbox\@leftcolumn
+            \vss
+            }%
+        \hrule\@height\flushend@@page at rule width\textwidth
+        \vss
+        }%
+    \global\ht\@leftcolumn=\the\@tempdima
+    \wlog{- LAST -%
+          ^^JExtra skip:\the\var@@temp at spread
+          ^^JLeft:\the\ht\@leftcolumn/\the\dp\@leftcolumn
+          ^^JRight:\the\ht\@tempboxa/\the\dp\@tempboxa
+          ^^JOutput:\the\@tempdimb
+          }%
+    \ifdim\top@@floatbox at skip>\z@
+        \setbox\@outputbox\vbox to\@tempdima{%
+            \if at right@column at spread
+                \vbox spread\var@@temp at spread{%
+                    \unvbox\@outputbox
+                    \vskip\top@@floatbox at skip
+                    \unvbox\@tempboxa
+                    }%
+            \else
+                \vbox spread\var@@temp at spread{%
+                    \unvbox\@outputbox
+                    \vskip\top@@floatbox at skip
+                    \unvbox\@tempboxa
+                    \vss
+                    }%
+            \fi
+            \vss
+            }%
+    \else
+        \setbox\@outputbox\vbox to\@tempdima{%
+            \if at right@column at spread
+                \vbox spread\var@@temp at spread{%
+                    \unvbox\@tempboxa
+                    }%
+            \else
+                \vbox spread\var@@temp at spread{%
+                    \unvbox\@tempboxa
+                    \vss
+                    }%
+            \fi
+            \vss
+            }%
+    \fi
+    }
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\set at outputbox@without at footnote}
+%
+% Calculates break position and formats balanced columns in the |\@outputbox|
+% without footnotes.  
+%
+%    \begin{macrocode}
+\def\set at outputbox@without at footnote{%
+    %% no footnote in left column 
+    \@tempdimb \ht\@tempboxa
+    \ifdim\top@@floatbox at skip>\z@
+        \advance\@tempdimb \top@@floatbox at skip
+        \advance\@tempdimb \top@@floatbox at ht
+    \fi
+    \@tempdimb .5\@tempdimb
+    \set at split@topskip at to\topskip
+    \loop
+        \setbox\flushend@@varbox at a\copy\@tempboxa
+        \setbox\flushend@@tempbox at a\vsplit\flushend@@varbox at a to\@tempdimb
+        \setbox\flushend@@tempbox at c\vbox{\unvcopy\flushend@@tempbox at a}%
+        \ifdim\top@@floatbox at skip>\z@
+            \setbox\flushend@@varbox at c\vbox{%
+                \unvcopy\@outputbox
+                \vskip\top@@floatbox at skip
+                \unvbox\flushend@@varbox at a
                 }%
-              \hrule\@height\flushend@@page at rule width\textwidth
-              \vss
-              }%
-          \global\ht\@leftcolumn=\the\@tempdima
-          \wlog{- LAST -%
-                ^^JExtra skip:\the\var@@temp at spread
-                ^^JLeft:\the\ht\@leftcolumn/\the\dp\@leftcolumn
-                ^^JRight:\the\ht\@tempboxa/\the\dp\@tempboxa
-                ^^JOutput:\the\@tempdimb
-               }%
-          \setbox\@outputbox\vbox to\@tempdima{%
-              \vbox spread\var@@temp at spread{%
-                  \unvbox\@tempboxa
-                  }%
-              \vss
-              }%
-      \else
-          \@tempdimb \ht\@tempboxa
-          \ifdim\top@@floatbox at skip>\z@
-              \advance\@tempdimb \top@@floatbox at skip
-              \advance\@tempdimb \top@@floatbox at ht
-          \fi
-          \@tempdimb .5\@tempdimb
-          \splittopskip\topskip \splitmaxdepth\maxdepth
-          \loop
-              \setbox\flushend@@varbox at a\copy\@tempboxa
-              \setbox\flushend@@tempbox at a\vsplit\flushend@@varbox at a to\@tempdimb
-              \setbox\flushend@@tempbox at c\vbox{\unvcopy\flushend@@tempbox at a}%
-              \ifdim\top@@floatbox at skip>\z@
-                  \setbox\flushend@@varbox at c\vbox{%
-                      \unvcopy\@outputbox
-                      \vskip\top@@floatbox at skip
-                      \unvbox\flushend@@varbox at a
-                    }%
-              \else
-                  \setbox\flushend@@varbox at c\vbox{\unvbox\flushend@@varbox at a}%
-              \fi
-              \var@@temp at spread=\ht\flushend@@tempbox at c
-              \advance\var@@temp at spread by\dp\flushend@@tempbox at c
-              \advance\var@@temp at spread by-\ht\flushend@@varbox at c
-              \advance\var@@temp at spread by-\dp\flushend@@varbox at c
-              \wlog at balance@debug{Left x: \the\ht\flushend@@tempbox at a
+        \else
+            \setbox\flushend@@varbox at c\vbox{\unvbox\flushend@@varbox at a}%
+        \fi
+        \var@@temp at spread=\ht\flushend@@tempbox at c
+        \advance\var@@temp at spread by\dp\flushend@@tempbox at c
+        \advance\var@@temp at spread by-\ht\flushend@@varbox at c
+        \advance\var@@temp at spread by-\dp\flushend@@varbox at c
+        \wlog at balance@debug{Left x: \the\ht\flushend@@tempbox at a
                             +\the\dp\flushend@@tempbox at a=\the\ht\flushend@@varbox at a
                             +\the\dp\flushend@@varbox at a::\the\@tempdimb
-                 ^^JLeft 0: \the\ht\flushend@@tempbox at c
+                            ^^JLeft 0: \the\ht\flushend@@tempbox at c
                             +\the\dp\flushend@@tempbox at c::\the\@tempdimb
-                 ^^JRight x: \the\ht\flushend@@varbox at c
+                            ^^JRight x: \the\ht\flushend@@varbox at c
                             +\the\dp\flushend@@varbox at c=\the\ht\flushend@@varbox at a
                             +\the\dp\flushend@@varbox at a::\the\@tempdimb
-                 ^^JExtra height:\the\var@@temp at spread\space when \the\@tempdimb
-                 }%
-          \ifdim\var@@temp at spread<\z@ \advance\@tempdimb 1\p@ \repeat
-          %\@tempdimb\ht\flushend@@tempbox at c
-          %\advance\@tempdimb by\dp\flushend@@tempbox at c
-          \wlog{- LAST -%
-                ^^JExtra skip:\the\var@@temp at spread
-                ^^JLeft:\the\ht\flushend@@tempbox at c/\the\dp\flushend@@tempbox at c
-                ^^JRight:\the\ht\flushend@@varbox at c/\the\dp\flushend@@varbox at c
-                ^^JOutput:\the\@tempdimb
-               }%
-          \setbox\flushend@@tempbox at c\vsplit\@tempboxa to\@tempdimb
-          \setbox\flushend@@varbox at c\vbox{\unvbox\flushend@@tempbox at c}%
-          \setbox\@leftcolumn\vbox to\@tempdima{%
-              \vbox to\@tempdimb{\unvbox\flushend@@varbox at c\vss}%
-              \hrule\@height\flushend@@page at rule width\textwidth
-              \vss
-              }%
-          \global\ht\@leftcolumn=\the\@tempdima
-          \ifdim\top@@floatbox at skip>\z@
-              \setbox\@outputbox\vbox to\@tempdima{%
-                  \if at right@column at spread
-                      \vbox spread\var@@temp at spread{%
-                          \unvbox\@outputbox
-                          \vskip\top@@floatbox at skip
-                          \unvbox\@tempboxa
-                          }%
-                  \else
-                      \vbox spread\var@@temp at spread{%
-                          \unvbox\@outputbox
-                          \vskip\top@@floatbox at skip
-                          \unvbox\@tempboxa
-                          \vss
-                          }%
-                  \fi
-                  \vss
-                  }%
-          \else
-              \setbox\@outputbox\vbox to\@tempdima{%
-                  \if at right@column at spread
-                      \vbox spread\var@@temp at spread{%
-                          \unvbox\@tempboxa
-                          }%
-                  \else
-                      \vbox spread\var@@temp at spread{%
-                          \unvbox\@tempboxa
-                          \vss
-                          }%
-                  \fi
-                  \vss
-                  }%
-          \fi
-      \fi
-      \setbox\@outputbox \vbox {%
-          \hb at xt@\textwidth {%
-              \hb at xt@\columnwidth {%
-                  \fmt at box@adds{\box\@leftcolumn}\hss}%
-                  \hfil
-                  \vrule \@width\columnseprule
-                  \hfil
-                  \hb at xt@\columnwidth {%
-                      \fmt at box@adds{\box\@outputbox}\hss}%
-                      }%
-                  }%
-      \global\let\@outputdblcol\saved at orig@@outputdblcol
-      \global\atColsEnd{}%
-      \ifvoid\hold at viper
-      \else
-          \setbox\@outputbox\vbox{\box\hold at viper\box\@outputbox}%
-      \fi
-      \@combinedblfloats
-      \@outputpage
-      \begingroup
-          \@dblfloatplacement
-          \@startdblcolumn
-          \@whilesw\if at fcolmade\fi
-              {\@outputpage\@startdblcolumn}%
-          \ifvoid\@viper
-          \else
-              \global\setbox\@viper\vbox{%
-                  \vskip-\stripsep
-                  \unvbox\@viper
-                  }%
-              \csname @viperoutput\endcsname
-          \fi
-      \endgroup
-  \fi
-  }
+                            ^^JExtra height:\the\var@@temp at spread\space when \the\@tempdimb
+                           }%
+    \ifdim\var@@temp at spread<\z@ \advance\@tempdimb 1\p@ \repeat
+    \wlog{- LAST -%
+          ^^JExtra skip:\the\var@@temp at spread
+          ^^JLeft:\the\ht\flushend@@tempbox at c/\the\dp\flushend@@tempbox at c
+          ^^JRight:\the\ht\flushend@@varbox at c/\the\dp\flushend@@varbox at c
+          ^^JOutput:\the\@tempdimb
+          }%
+    \setbox\flushend@@tempbox at c\vsplit\@tempboxa to\@tempdimb
+    \setbox\flushend@@varbox at c\vbox{\unvbox\flushend@@tempbox at c}%
+    \setbox\@leftcolumn\vbox to\@tempdima{%
+        \vbox to\@tempdimb{\unvbox\flushend@@varbox at c\vss}%
+        \hrule\@height\flushend@@page at rule width\textwidth
+        \vss
+        }%
+    \global\ht\@leftcolumn=\the\@tempdima
+    \ifdim\top@@floatbox at skip>\z@
+        \setbox\@outputbox\vbox to\@tempdima{%
+            \if at right@column at spread
+                \vbox spread\var@@temp at spread{%
+                    \unvbox\@outputbox
+                    \vskip\top@@floatbox at skip
+                    \unvbox\@tempboxa
+                    }%
+            \else
+                \vbox spread\var@@temp at spread{%
+                    \unvbox\@outputbox
+                    \vskip\top@@floatbox at skip
+                    \unvbox\@tempboxa
+                    \vss
+                    }%
+            \fi
+            \vss
+            }%
+    \else
+        \setbox\@outputbox\vbox to\@tempdima{%
+            \if at right@column at spread
+                \vbox spread\var@@temp at spread{%
+                    \unvbox\@tempboxa
+                    }%
+            \else
+                \vbox spread\var@@temp at spread{%
+                    \unvbox\@tempboxa
+                    \vss
+                    }%
+            \fi
+            \vss
+            }%
+    \fi
+    }
 %    \end{macrocode}
 % \end{macro}
+% \begin{macro}{\last at outputdblcol@modern}
+%
+% 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. 
+% 
+%    \begin{macrocode}
+\def\last at outputdblcol@modern{%
+    \if at firstcolumn
+        \global \@firstcolumnfalse
+        \global \setbox\@leftcolumn \box\@outputbox
+    \else
+        \global \@firstcolumntrue
+        \@tempdima\ht\@leftcolumn
+        \set at split@topskip at to\topskip
+        \var@@temp at spread=\wd\@outputbox
+        \get@@footnoterule@@box
+        \xdef\main at box@height{\the\ht\@leftcolumn}%
+        \xdef\main at box@skip{\z@}%
+        \global\flushend@@lastskip at c\z@
+        \setbox\flushend@@varbox at a\vbox{\unvcopy\@leftcolumn}%    
+        \analyze at leftcolumn@box\flushend@@varbox at a
+        \setbox\flushend@@varbox at a\vbox{\unvcopy\@outputbox}%    
+        \analyze at rightcolumn@box\flushend@@varbox at a
+        \ifdim\main at box@skip>\z@ 
+            %% footnote in left column  
+            \set at split@topskip at to\z@
+            \setbox\flushend@@varbox at a\vsplit\@leftcolumn to\main at box@height
+        \else 
+            %% no footnote in left column  
+            \setbox\flushend@@varbox at a\box\@leftcolumn
+        \fi
+        \ifdim\var@@temp at spread>\z@ 
+            %% rightcolumn non empty
+            \combine at columns@for at balance
+  	    \else                       
+            %% rightcolumn empty
+            \setbox\@tempboxa\vbox{%
+                \unvbox\flushend@@varbox at a
+                \remove at lastbox@at at balancing
+                \the\atColsEnd
+                }%
+  	    \fi
+        \ifdim\main at box@skip>\z@
+            %% footnote in left column 
+            \set at outputbox@with at footnote
+        \else
+            %% no footnote in left column 
+  	        \set at outputbox@without at footnote
+        \fi
+        \setbox\@outputbox \vbox {%
+            \hb at xt@\textwidth {%
+                \hb at xt@\columnwidth {%
+                    \fmt at box@adds{\box\@leftcolumn}\hss}%
+                    \hfil
+                    \vrule \@width\columnseprule
+                    \hfil
+                    \hb at xt@\columnwidth {%
+                        \fmt at box@adds{\box\@outputbox}\hss}%
+                        }%
+                    }%
+        \global\let\@outputdblcol\saved at orig@@outputdblcol
+        \global\atColsEnd{}%
+        \ifvoid\hold at viper
+        \else
+            \setbox\@outputbox\vbox{\box\hold at viper\box\@outputbox}%
+        \fi
+        \@combinedblfloats
+        \@outputpage
+        \begingroup
+            \@dblfloatplacement
+            \@startdblcolumn
+            \@whilesw\if at fcolmade\fi
+                {\@outputpage\@startdblcolumn}%
+            \ifvoid\@viper
+            \else
+                \global\setbox\@viper\vbox{%
+                    \vskip-\stripsep
+                    \unvbox\@viper
+                    }%
+                \csname @viperoutput\endcsname
+            \fi
+        \endgroup
+    \fi
+    }
+%    \end{macrocode}
+% \end{macro}
 % \begin{macro}{\last at 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 
+% moving or missing at all.
+% 
 %    \begin{macrocode}
 \def\last at outputdblcol@ancient{%
     \if at firstcolumn
@@ -853,36 +1061,36 @@
     \else
         \global\@firstcolumntrue
         \@tempdima\ht\@leftcolumn
-        \splittopskip\topskip\splitmaxdepth\maxdepth
+        \set at split@topskip at to\topskip
         \if at auto@baselineskip
             \setbox\@tempboxa\vbox{%
                 \unvcopy\@leftcolumn
-	        \global\flushend@@lastskip at c\lastskip
-	        \global\flushend@@lastskip at b\lastskip
+                \global\flushend@@lastskip at c\lastskip
+                \global\flushend@@lastskip at b\lastskip
                 \loop
-	            \global\flushend@@lastskip at a\flushend@@lastskip at b
-	            \unskip\unpenalty
-	            \global\flushend@@lastskip at b\lastskip
-	            \global\advance\flushend@@lastskip at c by\lastskip
-	        \ifdim\flushend@@lastskip at b=-\flushend@@lastskip at a
-	            \global\advance\flushend@@lastskip at c by-\lastskip
+                    \global\flushend@@lastskip at a\flushend@@lastskip at b
+                    \unskip\unpenalty
+                    \global\flushend@@lastskip at b\lastskip
+                    \global\advance\flushend@@lastskip at c by\lastskip
+                \ifdim\flushend@@lastskip at b=-\flushend@@lastskip at a
+                    \global\advance\flushend@@lastskip at c by-\lastskip
                 \else
                 \repeat
-	        \ifdim\flushend@@lastskip at b=-\flushend@@lastskip at a
-	            \ifdim\flushend@@lastskip at b=\z@
-	                \setbox\flushend@@varbox at a\lastbox
-	                \global\advance\flushend@@lastskip at c by\ht\flushend@@varbox at a
-	                \global\advance\flushend@@lastskip at c by\lastskip
-	                \unskip\unpenalty
-	                \setbox\flushend@@varbox at a\lastbox
-	                \global\advance\flushend@@lastskip at c by\dp\flushend@@varbox at a
-	            \else
-	                \global\flushend@@lastskip at c\lastskip
-	                \global\advance\flushend@@lastskip at c by\topskip
-	            \fi
+                \ifdim\flushend@@lastskip at b=-\flushend@@lastskip at a
+                    \ifdim\flushend@@lastskip at b=\z@
+                        \setbox\flushend@@varbox at a\lastbox
+                        \global\advance\flushend@@lastskip at c by\ht\flushend@@varbox at a
+                        \global\advance\flushend@@lastskip at c by\lastskip
+                        \unskip\unpenalty
+                        \setbox\flushend@@varbox at a\lastbox
+                        \global\advance\flushend@@lastskip at c by\dp\flushend@@varbox at a
+                    \else
+                        \global\flushend@@lastskip at c\lastskip
+                        \global\advance\flushend@@lastskip at c by\topskip
+                    \fi
                 \fi
                 \global\advance\flushend@@lastskip at c by-\topskip
-	        }%
+                }%
             \setbox\@tempboxa\vbox{%
                 \unvbox\@leftcolumn
                 \unskip\unpenalty
@@ -889,11 +1097,10 @@
                 \vskip\flushend@@lastskip at c
                 \hrule\@height\flushend@@page at rule width\columnwidth
                 \the\atColsBreak
-	        \unvbox\@outputbox
+                \unvbox\@outputbox
                 \remove at lastbox@at at balancing
-                %%\unskip
                 \the\atColsEnd
-	        }%
+            }%
         \else
             \setbox\@tempboxa\vbox{%
                 \unvbox\@leftcolumn
@@ -903,8 +1110,6 @@
                 \the\atColsBreak
                 \unvbox\@outputbox
                 \remove at lastbox@at at balancing
-                %%\setbox\z@\lastbox
-                %%\unskip
                 \the\atColsEnd
                 }%
         \fi
@@ -917,15 +1122,23 @@
                 \vsplit\flushend@@tempbox at a to\@tempdimb
                 }%
             \wlog{Extra height:\the\ht\flushend@@tempbox at a\space when \the\@tempdimb}%
-        \ifvoid\flushend@@tempbox at a \else \advance\@tempdimb 1\p@ \repeat
+        \ifvoid\flushend@@tempbox at a
+        \else
+            \advance\@tempdimb 1\p@
+        \repeat
         \loop
             \setbox\flushend@@tempbox at a\copy\@tempboxa
-            \setbox\flushend@@tempbox at c\vbox to\@tempdimb{\vsplit\flushend@@tempbox at a to\@tempdimb\vss}%
+            \setbox\flushend@@tempbox at c\vbox to\@tempdimb{%
+                \vsplit\flushend@@tempbox at a to\@tempdimb
+                \vss
+                }%
             \wlog{(2)Left:\the\ht\flushend@@tempbox at c\space 
-                Right:\the\ht\flushend@@tempbox at a\space 
-                Output:\the\@tempdimb
-               }%
-        \ifdim\ht\flushend@@tempbox at c<\ht\flushend@@tempbox at a \@tempdimb=\the\ht\flushend@@tempbox at a \repeat
+                    Right:\the\ht\flushend@@tempbox at a\space 
+                   Output:\the\@tempdimb
+                 }%
+        \ifdim\ht\flushend@@tempbox at c<\ht\flushend@@tempbox at a
+            \@tempdimb=\the\ht\flushend@@tempbox at a
+        \repeat
         \wlog{- LAST -^^JExtra skip: \the\z@
                       ^^JLeft:\the\ht\flushend@@tempbox at c
                       ^^JRight:\the\ht\flushend@@tempbox at a
@@ -936,7 +1149,12 @@
             \vss
             }%
         \setbox\@leftcolumn\vbox to\@tempdima{%
-            \fmt at vbox@adds[\columnwidth]{\vbox to\@tempdimb{\unvbox\flushend@@tempbox at c}}%
+            \fmt at vbox@adds[\columnwidth]{%
+                \vbox to\@tempdimb{%
+                    \unvbox
+                    \flushend@@tempbox at c
+                    }%
+                }%
             \hrule\@height\flushend@@page at rule
             \vss
             }%
@@ -944,11 +1162,10 @@
             \fmt at vbox@adds[\columnwidth]{%
                 \vbox to\@tempdimb{%
                     \unvbox\@tempboxa
-                    %\vfilneg
                     \vskip\z@
                     }%
                 }%
-              \hrule\@height\flushend@@page at rule
+            \hrule\@height\flushend@@page at rule
             \vss
             }%
         \setbox\@outputbox\vbox{%
@@ -1006,13 +1223,35 @@
 %
 % User interface commands for the balancing pages.
 %
+% \cs{flushcolsend} is used to switch on column balancing on the current page.
+%
 %    \begin{macrocode}
 \def\flushcolsend{\global\let\@outputdblcol\last at outputdblcol}
+%    \end{macrocode}
+%
+% \cs{raggedcolsend} is used to switch off column balancing on the current page.
+%
+%    \begin{macrocode}
 \def\raggedcolsend{\global\let\@outputdblcol\saved at orig@@outputdblcol}
+%    \end{macrocode}
+%
+% \cs{flushend} is used to switch on column balancing on the last page. 
+% It is used by default.
+%
+%    \begin{macrocode}
 \def\flushend{\global\let\balanced@@outputdblcol\last at outputdblcol}
+%    \end{macrocode}
+%
+% \cs{raggedend} is used to switch off column balancing on the last page.
+%
+%    \begin{macrocode}
 \def\raggedend{\global\let\balanced@@outputdblcol\saved at orig@@outputdblcol}
 %    \end{macrocode}
 %
+% In the case to see some debug information |debug| option is used and it is
+% possible to see how package calculates dimensions of balanced columns by
+% additional rules on balanced page and some log records in log file.
+%
 %    \begin{macrocode}
 \if at balance@debug
     \showcolsendrule

Modified: trunk/Master/texmf-dist/source/latex/sttools/stfloats.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/sttools/stfloats.dtx	2017-04-04 00:06:08 UTC (rev 43683)
+++ trunk/Master/texmf-dist/source/latex/sttools/stfloats.dtx	2017-04-04 04:53:44 UTC (rev 43684)
@@ -24,7 +24,7 @@
 \ProvidesFile{stfloats.dtx}
 %</driver>
 %<*package>
-%% Copyright (C) 1997-2016 by Sigitas Tolu\v{s}is <sigitas at vtex.lt>
+%% Copyright (C) 1997-2017 by Sigitas Tolu\v{s}is <sigitas at vtex.lt>
 %% VTeX UAB, Mokslininku 2a, Vilnius, Lithuania
 %% --------------------------------------------------------------------------
 %% This work may be distributed and/or modified under the
@@ -41,12 +41,12 @@
 %<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
 %<package>\ProvidesPackage{stfloats}
 %<*package>
-    [2016/06/28 v3.2 Improve float mechanism and baselineskip settings]
+    [2017/03/27 v3.3 Improve float mechanism and baselineskip settings]
 %</package>
 %
 %<*driver>
 \documentclass{ltxdoc}
-\usepackage{stfloats}[2016/06/28]
+\usepackage{stfloats}[2017/03/27]
 \EnableCrossrefs
 \CodelineIndex
 \RecordChanges
@@ -86,6 +86,7 @@
 % \changes{v3.0}{2012/05/29}{Converted to DTX file}
 % \changes{v3.1}{2016/02/08}{Compatibility with 2015 latexrelease}
 % \changes{v3.2}{2016/06/28}{Compatibility bugfix with 2015 latexrelease}
+% \changes{v3.3}{2017/03/27}{Compatibility bugfix with 2017-05-01 latexrelease}
 %
 % \DoNotIndex{\newcommand,\newenvironment}
 %
@@ -218,11 +219,11 @@
 % This conditional code is used to check the \LaTeX\ release age.
 %    \begin{macrocode}
 \newif\if at before@latex at release
-\def\tmp at reserved@a#1/#2/#3\@nil{%
-    \ifnum #1<2015\relax
+\def\tmp at reserved@a#1#2#3#4#5\@nil{%
+    \ifnum #1#2#3#4<2015\relax
         \@before at latex@releasetrue
     \else
-        \@before at latex@releasefalse    
+        \@before at latex@releasefalse
     \fi
     }
 \expandafter\tmp at reserved@a\fmtversion\@nil

Modified: trunk/Master/texmf-dist/tex/latex/sttools/flushend.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/sttools/flushend.sty	2017-04-04 00:06:08 UTC (rev 43683)
+++ trunk/Master/texmf-dist/tex/latex/sttools/flushend.sty	2017-04-04 04:53:44 UTC (rev 43684)
@@ -6,7 +6,7 @@
 %%
 %% flushend.dtx  (with options: `package')
 %% 
-%% Copyright (C) 1997-2016 by Sigitas Tolu\v{s}is <sigitas at vtex.lt>
+%% Copyright (C) 1997-2017 by Sigitas Tolu\v{s}is <sigitas at vtex.lt>
 %% VTeX Ltd., Mokslinink\k{u} 2a, Vilnius, Lithuania
 %% http://www.vtex.lt/tex/download/macros/
 %% --------------------------------------------------------------------------
@@ -22,7 +22,7 @@
 %%
 \NeedsTeXFormat{LaTeX2e}[1999/12/01]
 \ProvidesPackage{flushend}
-    [2016/06/21 v3.2 Balancing columns in twocolumn mode]
+    [2017/03/27 v3.3 Balancing columns in twocolumn mode]
 \newif\if at auto@baselineskip \@auto at baselineskiptrue
 \newif\if at ancient@balance at version \@ancient at balance@versionfalse
 \newif\if at right@column at spread \@right at column@spreadtrue
@@ -36,6 +36,26 @@
 \DeclareOption{nospread}{\global\@right at column@spreadfalse}
 \DeclareOption{removelastbox}{\global\@remove at lastbox@at at balancingtrue}
 \DeclareOption{keeplastbox}{\global\@remove at lastbox@at at balancingfalse}
+\DeclareOption{checkfootnote}{%
+    \AtEndOfPackage{%
+        \let\check@@footnoterule@@box\initial at check@@footnoterule@@box
+        }%
+    }
+\DeclareOption{nocheckfootnote}{%
+    \AtEndOfPackage{%
+        \let\check@@footnoterule@@box\@gobblethree
+        }%
+    }
+\DeclareOption{checkfloat}{%
+    \AtEndOfPackage{%
+        \let\top@@floatbox at min\top@@floatbox at min@default
+        }%
+    }
+\DeclareOption{nocheckfloat}{%
+    \AtEndOfPackage{%
+        \let\top@@floatbox at min\maxdimen
+        }%
+    }
 \DeclareOption{debug}{\global\@balance at debugtrue}
 \DeclareOption{nodebug}{\global\@balance at debugfalse}
 \ProcessOptions
@@ -48,8 +68,9 @@
 \newdimen\var@@temp at a
 \def\top@@skip@@limit{.7\topskip}
 \newdimen\flushend@@page at rule \flushend@@page at rule\z@
-\def\showcolsendrule{\global\flushend@@page at rule=.4pt}
-\gdef\top@@floatbox at min{4\topskip}
+\def\showcolsendrule{\global\flushend@@page at rule=.4\p@}
+\gdef\top@@floatbox at min@default{4\topskip}
+\let\top@@floatbox at min\top@@floatbox at min@default
 \newbox\flushend@@varbox at a
 \newbox\flushend@@varbox at c
 \newbox\flushend@@tempbox at a
@@ -61,129 +82,142 @@
 \@ifundefined{fmt at box@adds}{\def\fmt at box@adds#1{#1}}{}
 \@ifundefined{fmt at vbox@adds}{\def\fmt at vbox@adds[#1]#2{#2}}{}
 \def\unskip at three@kern at penalty{%
-  \unskip\unkern\unpenalty
-  \unskip\unkern\unpenalty
-  \unskip\unkern\unpenalty
-  }
+    \unskip\unkern\unpenalty
+    \unskip\unkern\unpenalty
+    \unskip\unkern\unpenalty
+    }
 \gdef\remove at lastbox@at at balancing{%
-  \unskip at three@kern at penalty
-  \if at remove@lastbox at at@balancing
-  \else
-    \expandafter\null
-  \fi
-  \bgroup
-    \setbox\z@\lastbox
-    \ifdim\wd\z@>\z@
-      \box\z@
+    \unskip at three@kern at penalty
+    \if at remove@lastbox at at@balancing
     \else
-      \aftergroup\unskip at three@kern at penalty
+        \expandafter\null
     \fi
-  \egroup
-  }
+    \bgroup
+        \setbox\z@\lastbox
+        \ifdim\wd\z@>\z@
+            \box\z@
+        \else
+            \aftergroup\unskip at three@kern at penalty
+        \fi
+    \egroup
+    }
+\def\set at split@topskip at to#1{%
+    \splittopskip#1\relax \vfuzz\maxdimen \vbadness\maxdimen
+    }
 \def\show@@box#1{%
-  \bgroup
-    \showboxbreadth=20000\showboxdepth=20000%
-    \showbox#1\relax
-  \egroup
-  }
+    \bgroup
+        \showboxbreadth=20000\showboxdepth=20000%
+        \showbox#1\relax
+    \egroup
+    }
 \def\wlog at balance@debug#1{\if at balance@debug \wlog{#1}\fi}
 \def\log at box@info#1{<box\the#1>(\the\ht#1+\the\dp#1)x\the\wd#1}
 \let\show@@box at next\@gobble
 \gdef\analyze at lastbox@box#1{%
-  \setbox\flushend@@varbox at a\vbox{%
-      \unvbox#1%
-      \global\flushend@@lastskip at a\lastskip
-      \unskip
-      \global\var@@temp at a\lastkern
-      \unkern
-      \global\flushend@@penalty at a\lastpenalty
-      \unpenalty
-      \ifdim\lastskip>\z@
-          \global\flushend@@lastskip at a\lastskip
-      \fi
-      \unskip
-      \ifdim\lastkern>\z@
-          \global\var@@temp at a\lastkern
-      \fi
-      \unkern
-      \ifnum\lastpenalty>\z@
-          \global\flushend@@penalty at a\lastpenalty
-      \fi
-      \unpenalty
-      \global\setbox\flushend@@tempbox at a\lastbox
-      }%
-  \wlog at balance@debug{^^J::analyze at lastbox@box::\log at box@info{#1}%
-     ^^J ::unvbox: \log at box@info{\flushend@@varbox at a}%
-     ^^J::lastbox: \log at box@info{\flushend@@tempbox at a}%
-     ^^J::lastskip: \the\flushend@@lastskip at a;
-          lastkern: \the\var@@temp at a;
-       lastpenalty: \the\flushend@@penalty at a
-     }%
-  }
+    \setbox\flushend@@varbox at a\vbox{%
+        \unvbox#1%
+        \global\flushend@@lastskip at a\lastskip
+        \unskip
+        \global\var@@temp at a\lastkern
+        \unkern
+        \global\flushend@@penalty at a\lastpenalty
+        \unpenalty
+        \ifdim\lastskip>\z@
+            \global\flushend@@lastskip at a\lastskip
+        \fi
+        \unskip
+        \ifdim\lastkern>\z@
+            \global\var@@temp at a\lastkern
+        \fi
+        \unkern
+        \ifnum\lastpenalty>\z@
+            \global\flushend@@penalty at a\lastpenalty
+        \fi
+        \unpenalty
+        \global\setbox\flushend@@tempbox at a\lastbox
+        }%
+    \wlog at balance@debug{^^J::analyze at lastbox@box::\log at box@info{#1}%
+                        ^^J ::unvbox: \log at box@info{\flushend@@varbox at a}%
+                        ^^J::lastbox: \log at box@info{\flushend@@tempbox at a}%
+                        ^^J::lastskip: \the\flushend@@lastskip at a;
+                            lastkern: \the\var@@temp at a;
+                         lastpenalty: \the\flushend@@penalty at a
+                       }%
+    }
 \gdef\analyze at leftcolumn@box#1{%
-  \splittopskip\z@ \vfuzz\maxdimen \vbadness\maxdimen
-  \flushend@@lastskip at b\ht#1%
-  \wlog at balance@debug{^^Jmainbox: \log at box@info{#1}}%
-  \setbox\flushend@@varbox at a\vbox{%
-      \unvbox#1%
-      \global\flushend@@lastskip at a\lastskip
-      \unskip
-      \global\flushend@@lastkern at a\lastkern
-      \unkern
-      \global\flushend@@penalty at a\lastpenalty
-      \unpenalty
-      \global\setbox\flushend@@tempbox at a\lastbox
-      }%
-  \advance\flushend@@lastskip at b -\ht\flushend@@varbox at a
-  \advance\flushend@@lastskip at b -\ht\flushend@@tempbox at a
-  \wlog at balance@debug{.-box: \log at box@info{\flushend@@varbox at a}%
-     ^^J.-lastbox: \log at box@info{\flushend@@tempbox at a}%
-     ^^J.-lastskip: \the\flushend@@lastskip at a;
-         lastkern: \the\flushend@@lastkern at a;
-      lastpenalty: \the\flushend@@penalty at a
-     ^^J.-diff: \the\flushend@@lastskip at b
-     }%
-  \check@@footnoterule@@box\flushend@@tempbox at a\flushend@@lastskip at b\flushend@@varbox at a
-  \check@@baselineskip@@skip\flushend@@lastskip at a\flushend@@lastskip at b\flushend@@lastskip at c
-  \ifvoid\flushend@@tempbox at a
-      \ifdim\ht\flushend@@varbox at a>\topskip
-          \flushend@@lastskip at b\ht\flushend@@varbox at a
-          \var@@temp at a\ht\flushend@@varbox at a
-          \loop
-              \setbox\flushend@@tempbox at c\vsplit\flushend@@varbox at a to\var@@temp at a
-              \ifvoid\flushend@@varbox at a
-                  \setbox\flushend@@varbox at a\vbox{\unvbox\flushend@@tempbox at c}%
-                  \advance \var@@temp at a -3\p@
-              \else
-                  \var@@temp at a=-1\p@
-              \fi
-          \ifdim \var@@temp at a>\z@
-          \repeat
-          \setbox\flushend@@varbox at a\vbox{\unvbox\flushend@@varbox at a}%
-          \setbox\flushend@@tempbox at c\vbox{\unvbox\flushend@@tempbox at c}%
-          \advance\flushend@@lastskip at b -\ht\flushend@@varbox at a
-          \advance\flushend@@lastskip at b -\ht\flushend@@tempbox at c
-          \wlog at balance@debug{..--box: \log at box@info{\flushend@@tempbox at c}%
-                ^^J..--lastbox: \log at box@info{\flushend@@varbox at a}%
-                ^^J..--diff: \the\flushend@@lastskip at b}%
-          \check@@footnoterule@@box\flushend@@varbox at a\flushend@@lastskip at b
-              \flushend@@tempbox at c
-          \check@@baselineskip@@skip\flushend@@lastskip at a\flushend@@lastskip at b
-              \flushend@@lastskip at c
-          \ifdim\ht\flushend@@varbox at a>.5\topskip
-              \analyze at lastbox@box\flushend@@varbox at a
-          \fi
-          \setbox\flushend@@varbox at a\vbox{\unvbox\flushend@@tempbox at c}%
-      \else
-          \wlog at balance@debug{lastbox: \log at box@info{\flushend@@varbox at a}}%
-      \fi
-  \fi
-  \ifdim\ht\flushend@@varbox at a>\topskip
-      \expandafter\analyze at leftcolumn@box\expandafter\flushend@@varbox at a
-  \fi
-  }
+    \set at split@topskip at to\z@
+    \flushend@@lastskip at b\ht#1%
+    \wlog at balance@debug{^^Jmainbox: \log at box@info{#1}}%
+    \setbox\flushend@@varbox at a\vbox{%
+        \unvbox#1%
+        \global\flushend@@lastskip at a\lastskip
+        \unskip
+        \global\flushend@@lastkern at a\lastkern
+        \unkern
+        \global\flushend@@penalty at a\lastpenalty
+        \unpenalty
+        \global\setbox\flushend@@tempbox at a\lastbox
+        }%
+    \advance\flushend@@lastskip at b -\ht\flushend@@varbox at a
+    \advance\flushend@@lastskip at b -\ht\flushend@@tempbox at a
+    \wlog at balance@debug{.-box: \log at box@info{\flushend@@varbox at a}%
+                 ^^J.-lastbox: \log at box@info{\flushend@@tempbox at a}%
+                ^^J.-lastskip: \the\flushend@@lastskip at a;
+                     lastkern: \the\flushend@@lastkern at a;
+                  lastpenalty: \the\flushend@@penalty at a
+                    ^^J.-diff: \the\flushend@@lastskip at b
+        }%
+    \check@@footnoterule@@box\flushend@@tempbox at a\flushend@@lastskip at b\flushend@@varbox at a
+    \check@@baselineskip@@skip
+        \flushend@@lastskip at a
+        \flushend@@lastskip at b
+        \flushend@@lastskip at c
+    \ifx\check@@footnoterule@@box\check@@baselineskip@@skip
+    \else
+        \ifvoid\flushend@@tempbox at a
+            \ifdim\ht\flushend@@varbox at a>\topskip
+                \flushend@@lastskip at b\ht\flushend@@varbox at a
+                \var@@temp at a\ht\flushend@@varbox at a
+                \loop
+                    \setbox\flushend@@tempbox at c\vsplit\flushend@@varbox at a to\var@@temp at a
+                    \ifvoid\flushend@@varbox at a
+                        \setbox\flushend@@varbox at a\vbox{\unvbox\flushend@@tempbox at c}%
+                        \advance \var@@temp at a -3\p@
+                    \else
+                        \var@@temp at a=-1\p@
+                    \fi
+                \ifdim \var@@temp at a>\z@
+                \repeat
+                \setbox\flushend@@varbox at a\vbox{\unvbox\flushend@@varbox at a}%
+                \setbox\flushend@@tempbox at c\vbox{\unvbox\flushend@@tempbox at c}%
+                \advance\flushend@@lastskip at b -\ht\flushend@@varbox at a
+                \advance\flushend@@lastskip at b -\ht\flushend@@tempbox at c
+                \wlog at balance@debug{..--box: \log at box@info{\flushend@@tempbox at c}%
+                             ^^J..--lastbox: \log at box@info{\flushend@@varbox at a}%
+                                ^^J..--diff: \the\flushend@@lastskip at b
+                    }%
+                \check@@footnoterule@@box\flushend@@varbox at a\flushend@@lastskip at b
+                    \flushend@@tempbox at c
+                \check@@baselineskip@@skip\flushend@@lastskip at a\flushend@@lastskip at b
+                    \flushend@@lastskip at c
+                \ifx\check@@footnoterule@@box\check@@baselineskip@@skip
+                \else
+                    \ifdim\ht\flushend@@varbox at a>.5\topskip
+                        \analyze at lastbox@box\flushend@@varbox at a
+                    \fi
+                    \setbox\flushend@@varbox at a\vbox{\unvbox\flushend@@tempbox at c}%
+                \fi
+            \else
+                \wlog at balance@debug{lastbox: \log at box@info{\flushend@@varbox at a}}%
+            \fi
+        \fi
+        \ifdim\ht\flushend@@varbox at a>\topskip
+            \expandafter\analyze at leftcolumn@box\expandafter\flushend@@varbox at a
+        \fi
+    \fi
+    }
 \def\get@@footnoterule@@box{%
-    \splittopskip\z@ \vfuzz\maxdimen \vbadness\maxdimen
+    \set at split@topskip at to\z@
     \setbox\flushend@@varbox at a\vbox{\strut
         \vskip\z@
         \footnoterule
@@ -190,395 +224,462 @@
         \unskip\unkern\unpenalty
         \unskip\unkern\unpenalty
         }%
-    \setbox\flushend@@tempbox at c\vsplit\flushend@@varbox at a to\ht\strutbox
+    \setbox\flushend@@tempbox at c\vsplit\flushend@@varbox at a to\p@
     \xdef\footnoterule@@box@@ht{\the\ht\flushend@@varbox at a}%
     \xdef\footnoterule@@box@@dp{\the\dp\flushend@@varbox at a}%
     \xdef\footnoterule@@box@@wd{\the\wd\flushend@@varbox at a}%
     \wlog at balance@debug{:footnoterule: \log at box@info{\flushend@@varbox at a}}%
+    \setbox\flushend@@tempbox at c\vbox{\unvbox\flushend@@varbox at 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
-        \ifdim\wd#1=\footnoterule@@box@@wd
-          \ifdim#2>\topskip
-             \xdef\main at box@height{\the\ht#3}%
-             \xdef\main at box@skip{\the#2}%
-          \fi
+        \ifdim\dp#1=\footnoterule@@box@@dp
+            \ifdim\wd#1=\footnoterule@@box@@wd
+                \ifdim#2=\topskip
+                \else
+                    \xdef\main at box@height{\the\ht#3}%
+                    \xdef\main at box@skip{\the#2}%
+                    \wlog at balance@debug{^^J:footnoterule found:
+                                        main at box <ht=\main at box@height,
+                                        skip=\main at box@skip>
+                                       }%
+                    \global\let\check@@footnoterule@@box\@gobblethree
+                    \global\let\check@@baselineskip@@skip\reset at check@@baselineskip@@skip
+                \fi
+            \fi
         \fi
-      \fi
     \fi
-  }
+    }
+\let\initial at check@@footnoterule@@box\check@@footnoterule@@box
 \def\check@@baselineskip@@skip#1#2#3{%
     \ifdim#1>\z@
         \ifdim#2>\z@
             \global#3=\the#1%
-            \gdef\check@@baselineskip@@skip##1##2##3{}%
+            \global\let\check@@baselineskip@@skip\@gobblethree
         \fi
     \fi
-  }
+    }
+\let\initial at check@@baselineskip@@skip\check@@baselineskip@@skip
+\def\reset at check@@baselineskip@@skip#1#2#3{%
+    \global#3=\z@
+    \global\let\check@@baselineskip@@skip\initial at check@@baselineskip@@skip
+    }
 \def\analyze at rightcolumn@box#1{%
-  \bgroup
-      \xdef\top@@floatbox at ht{\z@}%
-      \xdef\top@@floatbox at skip{\z@}%
-      \xdef\top@@section at skip{\z@}%
-      \splittopskip\z@ \vfuzz\maxdimen \vbadness\maxdimen
-      \wlog at balance@debug{^^J(R)mainbox: \log at box@info{#1}}%
-      \var@@temp at a3\p@
-      \setbox\flushend@@varbox at a\vbox{\strut
-                 \vskip\z@
-                 \unvcopy#1%
+    \bgroup
+        \xdef\top@@floatbox at ht{\z@}%
+        \xdef\top@@floatbox at skip{\z@}%
+        \xdef\top@@section at skip{\z@}%
+        \set at split@topskip at to\z@
+        \setbox\flushend@@varbox at a\vbox{\strut
+            \vskip\z@
+            \unvcopy#1%
+            }%
+        \setbox\flushend@@tempbox at c\vsplit\flushend@@varbox at a to\p@
+        \wlog at balance@debug{^^J(R)mainbox: \log at box@info{#1}}%
+        \flushend@@lastskip at a\ht\flushend@@varbox at a
+        \advance\flushend@@lastskip at a\dp\flushend@@varbox at a
+        \ifdim\flushend@@lastskip at a>\z@
+            \analyze at nonempty@rightcolumn at box
+        \fi
+    \egroup
+    }
+\def\analyze at nonempty@rightcolumn at box{%
+    \bgroup
+        \var@@temp at a3\p@
+        \loop
+            \flushend@@lastskip at b\ht\flushend@@varbox at a
+            \advance\flushend@@lastskip at b\dp\flushend@@varbox at a
+            \setbox\flushend@@tempbox at c\vsplit\flushend@@varbox at a to\var@@temp at a
+            \ifvoid\flushend@@tempbox at c
+                \advance \var@@temp at a 3\p@
+                \ifdim\var@@temp at a>\flushend@@lastskip at b
+                    \var@@temp at a=-1\p@
+                \fi
+            \else
+                \setbox\flushend@@tempbox at c\vbox{\unvbox\flushend@@tempbox at c}%
+                \ifdim\ht\flushend@@tempbox at c>\top@@floatbox at min
+                    \advance\flushend@@lastskip at b -\ht\flushend@@tempbox at c
+                    \advance\flushend@@lastskip at b -\dp\flushend@@tempbox at c
+                    \advance\flushend@@lastskip at b -\ht\flushend@@varbox at a
+                    \advance\flushend@@lastskip at b -\dp\flushend@@varbox at a
+                    \xdef\top@@floatbox at skip{\the\flushend@@lastskip at b}%
+                    \flushend@@lastskip at b\flushend@@lastskip at a
+                    \advance\flushend@@lastskip at b -\ht\flushend@@varbox at a
+                    \advance\flushend@@lastskip at b -\top@@floatbox at skip
+                    \xdef\top@@floatbox at ht{\the\flushend@@lastskip at b}%
+                    \var@@temp at a=3\p@
+                \else
+                    \advance\flushend@@lastskip at b -\ht\flushend@@tempbox at c
+                    \advance\flushend@@lastskip at b -\dp\flushend@@tempbox at c
+                    \advance\flushend@@lastskip at b -\ht\flushend@@varbox at a
+                    \advance\flushend@@lastskip at b -\dp\flushend@@varbox at a
+                    \ifdim\ht\flushend@@tempbox at c>\topskip
+                    \else
+                        \xdef\top@@section at skip{\the\flushend@@lastskip at b}%
+                    \fi
+                    \var@@temp at a=-1\p@
+                \fi
+            \fi
+        \ifdim \var@@temp at a>\z@
+        \repeat
+        \ifvoid\flushend@@tempbox at c
+        \else
+            \ifdim\top@@section at skip>\z@
+            \else
+                \ifdim\ht\flushend@@tempbox at c>\z@
+                    \setbox\flushend@@varbox at a\vbox{\unvbox\flushend@@tempbox at c}%
+                \fi
+                \flushend@@lastskip at b\ht\flushend@@varbox at a
+                \var@@temp at a=3\p@
+                \loop
+                    \setbox\flushend@@tempbox at c\vsplit\flushend@@varbox at a to\var@@temp at a
+                    \ifvoid\flushend@@tempbox at c
+                        \advance \var@@temp at a 3\p@
+                        \ifdim\var@@temp at a>\flushend@@lastskip at b
+                            \var@@temp at a=-1\p@
+                        \fi
+                    \else
+                        \ifdim\ht\flushend@@tempbox at c<\z@
+                        \else
+                            \var@@temp at a=-1\p@
+                        \fi
+                    \fi
+                \ifdim \var@@temp at a>\z@
+                \repeat
+                \loop
+                    \setbox\flushend@@varbox at a\vbox{%
+                        \unvbox\flushend@@tempbox at c
+                        \unskip\unkern\unpenalty
+                        \unskip\unkern\unpenalty
+                        \unskip\unkern\unpenalty
+                        \setbox\flushend@@tempbox at c\lastbox
+                        }%
+                    \flushend@@lastskip at b\ht\flushend@@varbox at a
+                    \setbox\flushend@@varbox at a\vbox{%
+                        \unvbox\flushend@@varbox at a
+                        \unskip\unkern\unpenalty
+                        \unskip\unkern\unpenalty
+                        \unskip\unkern\unpenalty
+                        }%
+                    \advance\flushend@@lastskip at b -\ht\flushend@@varbox at a
+                    \ifdim\flushend@@lastskip at b>\topskip
+                        \xdef\top@@section at skip{\the\flushend@@lastskip at b}%
+                    \fi
+                \ifdim\ht\flushend@@varbox at a>2\topskip
+                    \setbox\flushend@@tempbox at c\vbox{\unvbox\flushend@@varbox at a}%
+                \repeat
+            \fi
+        \fi
+    \egroup
+    }
+\def\combine at columns@for at balance{%
+    \setbox\@outputbox\vbox{\strut
+        \vskip\z@
+        \unvbox\@outputbox
+        }%
+    \set at split@topskip at to\z@
+    \setbox\flushend@@tempbox at c\vsplit\@outputbox to\p@
+    \if at auto@baselineskip
+        %% Trying guess baselineskip value on column break
+        \ifdim\top@@floatbox at skip>\z@
+            \setbox\flushend@@tempbox at c\vsplit\@outputbox to\top@@floatbox at ht
+            \setbox\flushend@@tempbox at c\vbox{\unvbox\flushend@@tempbox at c}%
+        \fi
+        \setbox\@tempboxa\vbox{%
+            \unvbox\flushend@@varbox at a
+            \unskip\unkern\unpenalty
+            \vskip\flushend@@lastskip at c
+            \the\atColsBreak
+            \hrule\@height\flushend@@page at rule width\columnwidth
+            \ifdim\top@@section at skip>\top@@skip@@limit
+                \vskip\top@@section at skip
+            \fi
+            \unvbox\@outputbox
+            \remove at lastbox@at at balancing
+            \the\atColsEnd
+            }%
+        \ifdim\top@@floatbox at skip>\z@
+            \setbox\@outputbox\vbox{\unvbox\flushend@@tempbox at c}%
+        \fi
+    \else
+        %% Ignore baselineskip value on column break
+        \setbox\@tempboxa\vbox{%
+            \unvbox\@leftcolumn
+            \setbox\z@\lastbox
+            \unskip\unkern\unpenalty
+            \the\atColsBreak
+            \hrule\@height\flushend@@page at rule width\columnwidth
+            \unvbox\@outputbox
+            \remove at lastbox@at at balancing
+            \the\atColsEnd
+            }%
+    \fi
+    }
+\def\set at outputbox@with at footnote{%
+    %% footnote in left column
+    \@tempdimb\ht\@tempboxa
+    \ifdim\top@@floatbox at skip>\z@
+        \advance\@tempdimb \top@@floatbox at skip
+        \advance\@tempdimb \top@@floatbox at ht
+    \fi
+    \advance\@tempdimb \main at box@skip
+    \advance\@tempdimb \ht\@leftcolumn
+    \@tempdimb .5\@tempdimb
+    \advance\@tempdimb -\main at box@skip
+    \advance\@tempdimb -\ht\@leftcolumn
+    \set at split@topskip at to\topskip
+    \loop
+        \setbox\flushend@@varbox at a\copy\@tempboxa
+        \setbox\flushend@@tempbox at a\vsplit\flushend@@varbox at a to\@tempdimb
+        \setbox\flushend@@tempbox at c\vbox{\unvcopy\flushend@@tempbox at a}%
+        \ifdim\top@@floatbox at skip>\z@
+        \setbox\flushend@@varbox at c\vbox{%
+                \unvcopy\@outputbox
+                \vskip\top@@floatbox at skip
+                \unvbox\flushend@@varbox at a
                 }%
-      \splittopskip\z@
-      \setbox\flushend@@tempbox at c\vsplit\flushend@@varbox at a to\ht\strutbox
-      \flushend@@lastskip at a\ht\flushend@@varbox at a
-      \advance\flushend@@lastskip at a\dp\flushend@@varbox at a
-      \loop
-          \flushend@@lastskip at b\ht\flushend@@varbox at a
-          \advance\flushend@@lastskip at b\dp\flushend@@varbox at a
-          \setbox\flushend@@tempbox at c\vsplit\flushend@@varbox at a to\var@@temp at a
-          \ifvoid\flushend@@tempbox at c
-              \advance \var@@temp at a 3\p@
-              \ifdim\var@@temp at a>\flushend@@lastskip at b
-                  \var@@temp at a=-1\p@
-              \fi
-          \else
-              \setbox\flushend@@tempbox at c\vbox{\unvbox\flushend@@tempbox at c}%
-              \ifdim\ht\flushend@@tempbox at c>\top@@floatbox at min
-                  \advance\flushend@@lastskip at b -\ht\flushend@@tempbox at c
-                  \advance\flushend@@lastskip at b -\dp\flushend@@tempbox at c
-                  \advance\flushend@@lastskip at b -\ht\flushend@@varbox at a
-                  \advance\flushend@@lastskip at b -\dp\flushend@@varbox at a
-                  \xdef\top@@floatbox at skip{\the\flushend@@lastskip at b}%
-                  \flushend@@lastskip at b\flushend@@lastskip at a
-                  \advance\flushend@@lastskip at b -\ht\flushend@@varbox at a
-                  \advance\flushend@@lastskip at b -\top@@floatbox at skip
-                  \xdef\top@@floatbox at ht{\the\flushend@@lastskip at b}%
-                  \var@@temp at a=3\p@
-              \else
-                  \advance\flushend@@lastskip at b -\ht\flushend@@tempbox at c
-                  \advance\flushend@@lastskip at b -\dp\flushend@@tempbox at c
-                  \advance\flushend@@lastskip at b -\ht\flushend@@varbox at a
-                  \advance\flushend@@lastskip at b -\dp\flushend@@varbox at a
-                  \ifdim\ht\flushend@@tempbox at c>\topskip
-                  \else
-                      \xdef\top@@section at skip{\the\flushend@@lastskip at b}%
-                  \fi
-                  \var@@temp at a=-1\p@
-              \fi
-          \fi
-      \ifdim \var@@temp at a>\z@
-      \repeat
-      \ifvoid\flushend@@tempbox at c
-      \else
-          \ifdim\top@@section at skip>\z@
-          \else
-              \ifdim\ht\flushend@@tempbox at c>\z@
-                  \setbox\flushend@@varbox at a\vbox{\unvbox\flushend@@tempbox at c}%
-              \fi
-              \flushend@@lastskip at b\ht\flushend@@varbox at a
-              \var@@temp at a=3\p@
-              \loop
-                  \setbox\flushend@@tempbox at c\vsplit\flushend@@varbox at a to\var@@temp at a
-                  \ifvoid\flushend@@tempbox at c
-                      \advance \var@@temp at a 3\p@
-                      \ifdim\var@@temp at a>\flushend@@lastskip at b
-                          \var@@temp at a=-1\p@
-                      \fi
-                  \else
-                      \ifdim\ht\flushend@@tempbox at c<\z@
-                      \else
-                          \var@@temp at a=-1\p@
-                      \fi
-                  \fi
-              \ifdim \var@@temp at a>\z@
-              \repeat
-              \loop
-                  \setbox\flushend@@varbox at a\vbox{%
-                      \unvbox\flushend@@tempbox at c
-                      \unskip\unkern\unpenalty
-                      \unskip\unkern\unpenalty
-                      \unskip\unkern\unpenalty
-                      \setbox\flushend@@tempbox at c\lastbox
-                    }%
-                  \flushend@@lastskip at b\ht\flushend@@varbox at a
-                  \setbox\flushend@@varbox at a\vbox{%
-                      \unvbox\flushend@@varbox at a
-                      \unskip\unkern\unpenalty
-                      \unskip\unkern\unpenalty
-                      \unskip\unkern\unpenalty
-                    }%
-                  \advance\flushend@@lastskip at b -\ht\flushend@@varbox at a
-                  \ifdim\flushend@@lastskip at b>\topskip
-                      \xdef\top@@section at skip{\the\flushend@@lastskip at b}%
-                  \fi
-              \ifdim\ht\flushend@@varbox at a>2\topskip
-                  \setbox\flushend@@tempbox at c\vbox{\unvbox\flushend@@varbox at a}%
-              \repeat
-          \fi
-      \fi
-  \egroup
-  }
-\def\last at outputdblcol@modern{%
-  \if at firstcolumn
-      \global \@firstcolumnfalse
-      \global \setbox\@leftcolumn \box\@outputbox
-  \else
-      \global \@firstcolumntrue
-      \@tempdima\ht\@leftcolumn
-      \splittopskip\topskip \splitmaxdepth\maxdepth
-      \var@@temp at spread=\wd\@outputbox
-      \get@@footnoterule@@box
-      \xdef\main at box@height{\the\ht\@leftcolumn}%
-      \xdef\main at box@skip{\z@}%
-      \global\flushend@@lastskip at c\z@
-      \setbox\flushend@@varbox at a\vbox{\unvcopy\@leftcolumn}%
-      \analyze at leftcolumn@box\flushend@@varbox at a
-      \setbox\flushend@@varbox at a\vbox{\unvcopy\@outputbox}%
-      \analyze at rightcolumn@box\flushend@@varbox at a
-      \if at auto@baselineskip
-          %% Trying guess baselineskip value on column break
-          \ifdim\main at box@skip>\z@
-            \splittopskip\z@
-            \setbox\flushend@@varbox at a\vsplit\@leftcolumn to\main at box@height
-          \else
-            \setbox\flushend@@varbox at a\box\@leftcolumn
-          \fi
-          \ifdim\var@@temp at spread>\z@
-              \setbox\@outputbox\vbox{\strut
-                 \vskip\z@
-                 \unvbox\@outputbox
-                }%
-              \splittopskip\z@
-              \setbox\flushend@@tempbox at c\vsplit\@outputbox to\ht\strutbox
-              \ifdim\top@@floatbox at skip>\z@
-                  \setbox\flushend@@tempbox at c\vsplit\@outputbox to\top@@floatbox at ht
-                  \setbox\flushend@@tempbox at c\vbox{\unvbox\flushend@@tempbox at c}%
-              \fi
-              \setbox\@tempboxa\vbox{%
-                  \unvbox\flushend@@varbox at a
-                  \unskip\unkern\unpenalty
-                  \vskip\flushend@@lastskip at c
-                  \the\atColsBreak
-                  \hrule\@height\flushend@@page at rule width\columnwidth
-                  \ifdim\top@@section at skip>\top@@skip@@limit
-                      \vskip\top@@section at skip
-                  \fi
-                  \unvbox\@outputbox
-                  \remove at lastbox@at at balancing
-                  \the\atColsEnd
-                  }%
-              \ifdim\top@@floatbox at skip>\z@
-                  \setbox\@outputbox\vbox{\unvbox\flushend@@tempbox at c}%
-              \fi
-          \else %% rightcolumn empty
-              \setbox\@tempboxa\vbox{%
-                  \unvbox\flushend@@varbox at a
-                  \remove at lastbox@at at balancing
-                  \the\atColsEnd
-                  }%
-          \fi
-      \else
-          %% Ignore baselineskip value on column break
-          \ifdim\var@@temp at spread>\z@
-              \setbox\@outputbox\vbox{\strut
-                  \vskip\z@
-                  \unvbox\@outputbox
-                }%
-              \splittopskip\z@
-              \setbox\flushend@@tempbox at c\vsplit\@outputbox to\ht\strutbox
-              \setbox\@tempboxa\vbox{%
-                  \unvbox\@leftcolumn
-                  \setbox\z@\lastbox
-                  \unskip\unkern\unpenalty
-                  \the\atColsBreak
-                  \hrule\@height\flushend@@page at rule width\columnwidth
-                  \unvbox\@outputbox
-                  \remove at lastbox@at at balancing
-                  \the\atColsEnd
-                  }%
-          \else
-              \setbox\@tempboxa\vbox{%
-                  \unvbox\@leftcolumn
-                  \remove at lastbox@at at balancing
-                  \the\atColsEnd
-                  }%
-          \fi
-      \fi
-      \ifdim\main at box@skip>\z@
-          \@tempdimb\ht\@tempboxa
-          \advance\@tempdimb -\main at box@skip
-          \advance\@tempdimb -\ht\@leftcolumn
-          \@tempdimb .5\@tempdimb
-          \splittopskip\topskip \splitmaxdepth\maxdepth
-          \loop
-              \setbox\flushend@@varbox at a\copy\@tempboxa
-              \setbox\flushend@@tempbox at a\vsplit\flushend@@varbox at a to\@tempdimb
-              \setbox\flushend@@tempbox at c\vbox{%
-                  \unvcopy\flushend@@tempbox at a
-                  \vskip\main at box@skip
-                  \unvcopy\@leftcolumn
-                  }%
-              \setbox\flushend@@varbox at c\vbox{\unvbox\flushend@@varbox at a}%
-              \var@@temp at spread=\ht\flushend@@tempbox at c
-              \advance\var@@temp at spread by-\ht\flushend@@varbox at c
-              \wlog at balance@debug{Left x: \the\ht\flushend@@tempbox at a
+        \else
+            \setbox\flushend@@varbox at c\vbox{\unvbox\flushend@@varbox at a}%
+        \fi
+        \var@@temp at spread=\ht\flushend@@tempbox at c
+        \advance\var@@temp at spread by\dp\flushend@@tempbox at c
+        \advance\var@@temp at spread \main at box@skip
+        \advance\var@@temp at spread \ht\@leftcolumn
+        \advance\var@@temp at spread by-\ht\flushend@@varbox at c
+        \advance\var@@temp at spread by-\dp\flushend@@varbox at c
+        \wlog at balance@debug{Left x: \the\ht\flushend@@tempbox at a
                             +\the\dp\flushend@@tempbox at a=\the\ht\flushend@@varbox at a
                             +\the\dp\flushend@@varbox at a::\the\@tempdimb
-                 ^^JLeft 0: \the\ht\flushend@@tempbox at c
+                            ^^JLeft 0: \the\ht\flushend@@tempbox at c
                             +\the\dp\flushend@@tempbox at c::\the\@tempdimb
-                 ^^JRight x: \the\ht\flushend@@varbox at c
+                            ^^JRight x: \the\ht\flushend@@varbox at c
                             +\the\dp\flushend@@varbox at c=\the\ht\flushend@@varbox at a
                             +\the\dp\flushend@@varbox at a::\the\@tempdimb
-                 ^^JExtra height:\the\var@@temp at spread\space when \the\@tempdimb
-                 }%
-          \ifdim\var@@temp at spread<\z@ \advance\@tempdimb 1\p@ \repeat
-          \flushend@@lastskip at a\the\ht\flushend@@tempbox at c
-          \flushend@@lastskip at b\the\@tempdimb
-          \setbox\flushend@@tempbox at a\vsplit\@tempboxa to\@tempdimb
-          \setbox\@leftcolumn\vbox to\@tempdima{%
-              \vbox to \flushend@@lastskip at a{%
-                  \unvbox\flushend@@tempbox at a
-                  \vskip\main at box@skip
-                  \unvbox\@leftcolumn
-                  \vss
+                            ^^JExtra height:\the\var@@temp at spread\space when \the\@tempdimb
+                            }%
+    \ifdim\var@@temp at spread<\z@
+        \advance\@tempdimb 1\p@
+    \repeat
+    \flushend@@lastskip at a\the\ht\flushend@@tempbox at c
+    \advance\flushend@@lastskip at a \main at box@skip
+    \advance\flushend@@lastskip at a \ht\@leftcolumn
+    \flushend@@lastskip at b\the\@tempdimb
+    \setbox\flushend@@tempbox at a\vsplit\@tempboxa to\@tempdimb
+    \setbox\@leftcolumn\vbox to\@tempdima{%
+        \vbox to \flushend@@lastskip at a{%
+            \unvbox\flushend@@tempbox at a
+            \vskip\main at box@skip
+            \unvbox\@leftcolumn
+            \vss
+            }%
+        \hrule\@height\flushend@@page at rule width\textwidth
+        \vss
+        }%
+    \global\ht\@leftcolumn=\the\@tempdima
+    \wlog{- LAST -%
+          ^^JExtra skip:\the\var@@temp at spread
+          ^^JLeft:\the\ht\@leftcolumn/\the\dp\@leftcolumn
+          ^^JRight:\the\ht\@tempboxa/\the\dp\@tempboxa
+          ^^JOutput:\the\@tempdimb
+          }%
+    \ifdim\top@@floatbox at skip>\z@
+        \setbox\@outputbox\vbox to\@tempdima{%
+            \if at right@column at spread
+                \vbox spread\var@@temp at spread{%
+                    \unvbox\@outputbox
+                    \vskip\top@@floatbox at skip
+                    \unvbox\@tempboxa
+                    }%
+            \else
+                \vbox spread\var@@temp at spread{%
+                    \unvbox\@outputbox
+                    \vskip\top@@floatbox at skip
+                    \unvbox\@tempboxa
+                    \vss
+                    }%
+            \fi
+            \vss
+            }%
+    \else
+        \setbox\@outputbox\vbox to\@tempdima{%
+            \if at right@column at spread
+                \vbox spread\var@@temp at spread{%
+                    \unvbox\@tempboxa
+                    }%
+            \else
+                \vbox spread\var@@temp at spread{%
+                    \unvbox\@tempboxa
+                    \vss
+                    }%
+            \fi
+            \vss
+            }%
+    \fi
+    }
+\def\set at outputbox@without at footnote{%
+    %% no footnote in left column
+    \@tempdimb \ht\@tempboxa
+    \ifdim\top@@floatbox at skip>\z@
+        \advance\@tempdimb \top@@floatbox at skip
+        \advance\@tempdimb \top@@floatbox at ht
+    \fi
+    \@tempdimb .5\@tempdimb
+    \set at split@topskip at to\topskip
+    \loop
+        \setbox\flushend@@varbox at a\copy\@tempboxa
+        \setbox\flushend@@tempbox at a\vsplit\flushend@@varbox at a to\@tempdimb
+        \setbox\flushend@@tempbox at c\vbox{\unvcopy\flushend@@tempbox at a}%
+        \ifdim\top@@floatbox at skip>\z@
+            \setbox\flushend@@varbox at c\vbox{%
+                \unvcopy\@outputbox
+                \vskip\top@@floatbox at skip
+                \unvbox\flushend@@varbox at a
                 }%
-              \hrule\@height\flushend@@page at rule width\textwidth
-              \vss
-              }%
-          \global\ht\@leftcolumn=\the\@tempdima
-          \wlog{- LAST -%
-                ^^JExtra skip:\the\var@@temp at spread
-                ^^JLeft:\the\ht\@leftcolumn/\the\dp\@leftcolumn
-                ^^JRight:\the\ht\@tempboxa/\the\dp\@tempboxa
-                ^^JOutput:\the\@tempdimb
-               }%
-          \setbox\@outputbox\vbox to\@tempdima{%
-              \vbox spread\var@@temp at spread{%
-                  \unvbox\@tempboxa
-                  }%
-              \vss
-              }%
-      \else
-          \@tempdimb \ht\@tempboxa
-          \ifdim\top@@floatbox at skip>\z@
-              \advance\@tempdimb \top@@floatbox at skip
-              \advance\@tempdimb \top@@floatbox at ht
-          \fi
-          \@tempdimb .5\@tempdimb
-          \splittopskip\topskip \splitmaxdepth\maxdepth
-          \loop
-              \setbox\flushend@@varbox at a\copy\@tempboxa
-              \setbox\flushend@@tempbox at a\vsplit\flushend@@varbox at a to\@tempdimb
-              \setbox\flushend@@tempbox at c\vbox{\unvcopy\flushend@@tempbox at a}%
-              \ifdim\top@@floatbox at skip>\z@
-                  \setbox\flushend@@varbox at c\vbox{%
-                      \unvcopy\@outputbox
-                      \vskip\top@@floatbox at skip
-                      \unvbox\flushend@@varbox at a
-                    }%
-              \else
-                  \setbox\flushend@@varbox at c\vbox{\unvbox\flushend@@varbox at a}%
-              \fi
-              \var@@temp at spread=\ht\flushend@@tempbox at c
-              \advance\var@@temp at spread by\dp\flushend@@tempbox at c
-              \advance\var@@temp at spread by-\ht\flushend@@varbox at c
-              \advance\var@@temp at spread by-\dp\flushend@@varbox at c
-              \wlog at balance@debug{Left x: \the\ht\flushend@@tempbox at a
+        \else
+            \setbox\flushend@@varbox at c\vbox{\unvbox\flushend@@varbox at a}%
+        \fi
+        \var@@temp at spread=\ht\flushend@@tempbox at c
+        \advance\var@@temp at spread by\dp\flushend@@tempbox at c
+        \advance\var@@temp at spread by-\ht\flushend@@varbox at c
+        \advance\var@@temp at spread by-\dp\flushend@@varbox at c
+        \wlog at balance@debug{Left x: \the\ht\flushend@@tempbox at a
                             +\the\dp\flushend@@tempbox at a=\the\ht\flushend@@varbox at a
                             +\the\dp\flushend@@varbox at a::\the\@tempdimb
-                 ^^JLeft 0: \the\ht\flushend@@tempbox at c
+                            ^^JLeft 0: \the\ht\flushend@@tempbox at c
                             +\the\dp\flushend@@tempbox at c::\the\@tempdimb
-                 ^^JRight x: \the\ht\flushend@@varbox at c
+                            ^^JRight x: \the\ht\flushend@@varbox at c
                             +\the\dp\flushend@@varbox at c=\the\ht\flushend@@varbox at a
                             +\the\dp\flushend@@varbox at a::\the\@tempdimb
-                 ^^JExtra height:\the\var@@temp at spread\space when \the\@tempdimb
-                 }%
-          \ifdim\var@@temp at spread<\z@ \advance\@tempdimb 1\p@ \repeat
-          %\@tempdimb\ht\flushend@@tempbox at c
-          %\advance\@tempdimb by\dp\flushend@@tempbox at c
-          \wlog{- LAST -%
-                ^^JExtra skip:\the\var@@temp at spread
-                ^^JLeft:\the\ht\flushend@@tempbox at c/\the\dp\flushend@@tempbox at c
-                ^^JRight:\the\ht\flushend@@varbox at c/\the\dp\flushend@@varbox at c
-                ^^JOutput:\the\@tempdimb
-               }%
-          \setbox\flushend@@tempbox at c\vsplit\@tempboxa to\@tempdimb
-          \setbox\flushend@@varbox at c\vbox{\unvbox\flushend@@tempbox at c}%
-          \setbox\@leftcolumn\vbox to\@tempdima{%
-              \vbox to\@tempdimb{\unvbox\flushend@@varbox at c\vss}%
-              \hrule\@height\flushend@@page at rule width\textwidth
-              \vss
-              }%
-          \global\ht\@leftcolumn=\the\@tempdima
-          \ifdim\top@@floatbox at skip>\z@
-              \setbox\@outputbox\vbox to\@tempdima{%
-                  \if at right@column at spread
-                      \vbox spread\var@@temp at spread{%
-                          \unvbox\@outputbox
-                          \vskip\top@@floatbox at skip
-                          \unvbox\@tempboxa
-                          }%
-                  \else
-                      \vbox spread\var@@temp at spread{%
-                          \unvbox\@outputbox
-                          \vskip\top@@floatbox at skip
-                          \unvbox\@tempboxa
-                          \vss
-                          }%
-                  \fi
-                  \vss
-                  }%
-          \else
-              \setbox\@outputbox\vbox to\@tempdima{%
-                  \if at right@column at spread
-                      \vbox spread\var@@temp at spread{%
-                          \unvbox\@tempboxa
-                          }%
-                  \else
-                      \vbox spread\var@@temp at spread{%
-                          \unvbox\@tempboxa
-                          \vss
-                          }%
-                  \fi
-                  \vss
-                  }%
-          \fi
-      \fi
-      \setbox\@outputbox \vbox {%
-          \hb at xt@\textwidth {%
-              \hb at xt@\columnwidth {%
-                  \fmt at box@adds{\box\@leftcolumn}\hss}%
-                  \hfil
-                  \vrule \@width\columnseprule
-                  \hfil
-                  \hb at xt@\columnwidth {%
-                      \fmt at box@adds{\box\@outputbox}\hss}%
-                      }%
-                  }%
-      \global\let\@outputdblcol\saved at orig@@outputdblcol
-      \global\atColsEnd{}%
-      \ifvoid\hold at viper
-      \else
-          \setbox\@outputbox\vbox{\box\hold at viper\box\@outputbox}%
-      \fi
-      \@combinedblfloats
-      \@outputpage
-      \begingroup
-          \@dblfloatplacement
-          \@startdblcolumn
-          \@whilesw\if at fcolmade\fi
-              {\@outputpage\@startdblcolumn}%
-          \ifvoid\@viper
-          \else
-              \global\setbox\@viper\vbox{%
-                  \vskip-\stripsep
-                  \unvbox\@viper
-                  }%
-              \csname @viperoutput\endcsname
-          \fi
-      \endgroup
-  \fi
-  }
+                            ^^JExtra height:\the\var@@temp at spread\space when \the\@tempdimb
+                           }%
+    \ifdim\var@@temp at spread<\z@ \advance\@tempdimb 1\p@ \repeat
+    \wlog{- LAST -%
+          ^^JExtra skip:\the\var@@temp at spread
+          ^^JLeft:\the\ht\flushend@@tempbox at c/\the\dp\flushend@@tempbox at c
+          ^^JRight:\the\ht\flushend@@varbox at c/\the\dp\flushend@@varbox at c
+          ^^JOutput:\the\@tempdimb
+          }%
+    \setbox\flushend@@tempbox at c\vsplit\@tempboxa to\@tempdimb
+    \setbox\flushend@@varbox at c\vbox{\unvbox\flushend@@tempbox at c}%
+    \setbox\@leftcolumn\vbox to\@tempdima{%
+        \vbox to\@tempdimb{\unvbox\flushend@@varbox at c\vss}%
+        \hrule\@height\flushend@@page at rule width\textwidth
+        \vss
+        }%
+    \global\ht\@leftcolumn=\the\@tempdima
+    \ifdim\top@@floatbox at skip>\z@
+        \setbox\@outputbox\vbox to\@tempdima{%
+            \if at right@column at spread
+                \vbox spread\var@@temp at spread{%
+                    \unvbox\@outputbox
+                    \vskip\top@@floatbox at skip
+                    \unvbox\@tempboxa
+                    }%
+            \else
+                \vbox spread\var@@temp at spread{%
+                    \unvbox\@outputbox
+                    \vskip\top@@floatbox at skip
+                    \unvbox\@tempboxa
+                    \vss
+                    }%
+            \fi
+            \vss
+            }%
+    \else
+        \setbox\@outputbox\vbox to\@tempdima{%
+            \if at right@column at spread
+                \vbox spread\var@@temp at spread{%
+                    \unvbox\@tempboxa
+                    }%
+            \else
+                \vbox spread\var@@temp at spread{%
+                    \unvbox\@tempboxa
+                    \vss
+                    }%
+            \fi
+            \vss
+            }%
+    \fi
+    }
+\def\last at outputdblcol@modern{%
+    \if at firstcolumn
+        \global \@firstcolumnfalse
+        \global \setbox\@leftcolumn \box\@outputbox
+    \else
+        \global \@firstcolumntrue
+        \@tempdima\ht\@leftcolumn
+        \set at split@topskip at to\topskip
+        \var@@temp at spread=\wd\@outputbox
+        \get@@footnoterule@@box
+        \xdef\main at box@height{\the\ht\@leftcolumn}%
+        \xdef\main at box@skip{\z@}%
+        \global\flushend@@lastskip at c\z@
+        \setbox\flushend@@varbox at a\vbox{\unvcopy\@leftcolumn}%
+        \analyze at leftcolumn@box\flushend@@varbox at a
+        \setbox\flushend@@varbox at a\vbox{\unvcopy\@outputbox}%
+        \analyze at rightcolumn@box\flushend@@varbox at a
+        \ifdim\main at box@skip>\z@
+            %% footnote in left column
+            \set at split@topskip at to\z@
+            \setbox\flushend@@varbox at a\vsplit\@leftcolumn to\main at box@height
+        \else
+            %% no footnote in left column
+            \setbox\flushend@@varbox at a\box\@leftcolumn
+        \fi
+        \ifdim\var@@temp at spread>\z@
+            %% rightcolumn non empty
+            \combine at columns@for at balance
+       \else
+            %% rightcolumn empty
+            \setbox\@tempboxa\vbox{%
+                \unvbox\flushend@@varbox at a
+                \remove at lastbox@at at balancing
+                \the\atColsEnd
+                }%
+       \fi
+        \ifdim\main at box@skip>\z@
+            %% footnote in left column
+            \set at outputbox@with at footnote
+        \else
+            %% no footnote in left column
+           \set at outputbox@without at footnote
+        \fi
+        \setbox\@outputbox \vbox {%
+            \hb at xt@\textwidth {%
+                \hb at xt@\columnwidth {%
+                    \fmt at box@adds{\box\@leftcolumn}\hss}%
+                    \hfil
+                    \vrule \@width\columnseprule
+                    \hfil
+                    \hb at xt@\columnwidth {%
+                        \fmt at box@adds{\box\@outputbox}\hss}%
+                        }%
+                    }%
+        \global\let\@outputdblcol\saved at orig@@outputdblcol
+        \global\atColsEnd{}%
+        \ifvoid\hold at viper
+        \else
+            \setbox\@outputbox\vbox{\box\hold at viper\box\@outputbox}%
+        \fi
+        \@combinedblfloats
+        \@outputpage
+        \begingroup
+            \@dblfloatplacement
+            \@startdblcolumn
+            \@whilesw\if at fcolmade\fi
+                {\@outputpage\@startdblcolumn}%
+            \ifvoid\@viper
+            \else
+                \global\setbox\@viper\vbox{%
+                    \vskip-\stripsep
+                    \unvbox\@viper
+                    }%
+                \csname @viperoutput\endcsname
+            \fi
+        \endgroup
+    \fi
+    }
 \def\last at outputdblcol@ancient{%
     \if at firstcolumn
         \global\@firstcolumnfalse
@@ -586,36 +687,36 @@
     \else
         \global\@firstcolumntrue
         \@tempdima\ht\@leftcolumn
-        \splittopskip\topskip\splitmaxdepth\maxdepth
+        \set at split@topskip at to\topskip
         \if at auto@baselineskip
             \setbox\@tempboxa\vbox{%
                 \unvcopy\@leftcolumn
-        \global\flushend@@lastskip at c\lastskip
-        \global\flushend@@lastskip at b\lastskip
+                \global\flushend@@lastskip at c\lastskip
+                \global\flushend@@lastskip at b\lastskip
                 \loop
-            \global\flushend@@lastskip at a\flushend@@lastskip at b
-            \unskip\unpenalty
-            \global\flushend@@lastskip at b\lastskip
-            \global\advance\flushend@@lastskip at c by\lastskip
-        \ifdim\flushend@@lastskip at b=-\flushend@@lastskip at a
-            \global\advance\flushend@@lastskip at c by-\lastskip
+                    \global\flushend@@lastskip at a\flushend@@lastskip at b
+                    \unskip\unpenalty
+                    \global\flushend@@lastskip at b\lastskip
+                    \global\advance\flushend@@lastskip at c by\lastskip
+                \ifdim\flushend@@lastskip at b=-\flushend@@lastskip at a
+                    \global\advance\flushend@@lastskip at c by-\lastskip
                 \else
                 \repeat
-        \ifdim\flushend@@lastskip at b=-\flushend@@lastskip at a
-            \ifdim\flushend@@lastskip at b=\z@
-                \setbox\flushend@@varbox at a\lastbox
-                \global\advance\flushend@@lastskip at c by\ht\flushend@@varbox at a
-                \global\advance\flushend@@lastskip at c by\lastskip
-                \unskip\unpenalty
-                \setbox\flushend@@varbox at a\lastbox
-                \global\advance\flushend@@lastskip at c by\dp\flushend@@varbox at a
-            \else
-                \global\flushend@@lastskip at c\lastskip
-                \global\advance\flushend@@lastskip at c by\topskip
-            \fi
+                \ifdim\flushend@@lastskip at b=-\flushend@@lastskip at a
+                    \ifdim\flushend@@lastskip at b=\z@
+                        \setbox\flushend@@varbox at a\lastbox
+                        \global\advance\flushend@@lastskip at c by\ht\flushend@@varbox at a
+                        \global\advance\flushend@@lastskip at c by\lastskip
+                        \unskip\unpenalty
+                        \setbox\flushend@@varbox at a\lastbox
+                        \global\advance\flushend@@lastskip at c by\dp\flushend@@varbox at a
+                    \else
+                        \global\flushend@@lastskip at c\lastskip
+                        \global\advance\flushend@@lastskip at c by\topskip
+                    \fi
                 \fi
                 \global\advance\flushend@@lastskip at c by-\topskip
-        }%
+                }%
             \setbox\@tempboxa\vbox{%
                 \unvbox\@leftcolumn
                 \unskip\unpenalty
@@ -622,11 +723,10 @@
                 \vskip\flushend@@lastskip at c
                 \hrule\@height\flushend@@page at rule width\columnwidth
                 \the\atColsBreak
-        \unvbox\@outputbox
+                \unvbox\@outputbox
                 \remove at lastbox@at at balancing
-                %%\unskip
                 \the\atColsEnd
-        }%
+            }%
         \else
             \setbox\@tempboxa\vbox{%
                 \unvbox\@leftcolumn
@@ -636,8 +736,6 @@
                 \the\atColsBreak
                 \unvbox\@outputbox
                 \remove at lastbox@at at balancing
-                %%\setbox\z@\lastbox
-                %%\unskip
                 \the\atColsEnd
                 }%
         \fi
@@ -650,15 +748,23 @@
                 \vsplit\flushend@@tempbox at a to\@tempdimb
                 }%
             \wlog{Extra height:\the\ht\flushend@@tempbox at a\space when \the\@tempdimb}%
-        \ifvoid\flushend@@tempbox at a \else \advance\@tempdimb 1\p@ \repeat
+        \ifvoid\flushend@@tempbox at a
+        \else
+            \advance\@tempdimb 1\p@
+        \repeat
         \loop
             \setbox\flushend@@tempbox at a\copy\@tempboxa
-            \setbox\flushend@@tempbox at c\vbox to\@tempdimb{\vsplit\flushend@@tempbox at a to\@tempdimb\vss}%
+            \setbox\flushend@@tempbox at c\vbox to\@tempdimb{%
+                \vsplit\flushend@@tempbox at a to\@tempdimb
+                \vss
+                }%
             \wlog{(2)Left:\the\ht\flushend@@tempbox at c\space
-                Right:\the\ht\flushend@@tempbox at a\space
-                Output:\the\@tempdimb
-               }%
-        \ifdim\ht\flushend@@tempbox at c<\ht\flushend@@tempbox at a \@tempdimb=\the\ht\flushend@@tempbox at a \repeat
+                    Right:\the\ht\flushend@@tempbox at a\space
+                   Output:\the\@tempdimb
+                 }%
+        \ifdim\ht\flushend@@tempbox at c<\ht\flushend@@tempbox at a
+            \@tempdimb=\the\ht\flushend@@tempbox at a
+        \repeat
         \wlog{- LAST -^^JExtra skip: \the\z@
                       ^^JLeft:\the\ht\flushend@@tempbox at c
                       ^^JRight:\the\ht\flushend@@tempbox at a
@@ -669,7 +775,12 @@
             \vss
             }%
         \setbox\@leftcolumn\vbox to\@tempdima{%
-            \fmt at vbox@adds[\columnwidth]{\vbox to\@tempdimb{\unvbox\flushend@@tempbox at c}}%
+            \fmt at vbox@adds[\columnwidth]{%
+                \vbox to\@tempdimb{%
+                    \unvbox
+                    \flushend@@tempbox at c
+                    }%
+                }%
             \hrule\@height\flushend@@page at rule
             \vss
             }%
@@ -677,11 +788,10 @@
             \fmt at vbox@adds[\columnwidth]{%
                 \vbox to\@tempdimb{%
                     \unvbox\@tempboxa
-                    %\vfilneg
                     \vskip\z@
                     }%
                 }%
-              \hrule\@height\flushend@@page at rule
+            \hrule\@height\flushend@@page at rule
             \vss
             }%
         \setbox\@outputbox\vbox{%

Modified: trunk/Master/texmf-dist/tex/latex/sttools/stfloats.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/sttools/stfloats.sty	2017-04-04 00:06:08 UTC (rev 43683)
+++ trunk/Master/texmf-dist/tex/latex/sttools/stfloats.sty	2017-04-04 04:53:44 UTC (rev 43684)
@@ -6,7 +6,7 @@
 %%
 %% stfloats.dtx  (with options: `package')
 %% 
-%% Copyright (C) 1997-2016 by Sigitas Tolu\v{s}is <sigitas at vtex.lt>
+%% Copyright (C) 1997-2017 by Sigitas Tolu\v{s}is <sigitas at vtex.lt>
 %% VTeX UAB, Mokslininku 2a, Vilnius, Lithuania
 %% --------------------------------------------------------------------------
 %% This work may be distributed and/or modified under the
@@ -21,7 +21,7 @@
 %%
 \NeedsTeXFormat{LaTeX2e}[1999/12/01]
 \ProvidesPackage{stfloats}
-    [2016/06/28 v3.2 Improve float mechanism and baselineskip settings]
+    [2017/03/27 v3.3 Improve float mechanism and baselineskip settings]
 \gdef\@dblbotlist{}
 \newcount\@dblbotnum
 \newcount\c at dblbotnumber
@@ -40,8 +40,8 @@
     \def\f at depth{1sp}%
     }
 \newif\if at before@latex at release
-\def\tmp at reserved@a#1/#2/#3\@nil{%
-    \ifnum #1<2015\relax
+\def\tmp at reserved@a#1#2#3#4#5\@nil{%
+    \ifnum #1#2#3#4<2015\relax
         \@before at latex@releasetrue
     \else
         \@before at latex@releasefalse



More information about the tex-live-commits mailing list