summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/sttools
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/latex/contrib/sttools
Initial commit
Diffstat (limited to 'macros/latex/contrib/sttools')
-rw-r--r--macros/latex/contrib/sttools/README.md85
-rw-r--r--macros/latex/contrib/sttools/cuted.dtx753
-rw-r--r--macros/latex/contrib/sttools/cuted.pdfbin0 -> 129830 bytes
-rw-r--r--macros/latex/contrib/sttools/floatpag.dtx354
-rw-r--r--macros/latex/contrib/sttools/floatpag.pdfbin0 -> 130401 bytes
-rw-r--r--macros/latex/contrib/sttools/flushend.dtx1265
-rw-r--r--macros/latex/contrib/sttools/flushend.pdfbin0 -> 147962 bytes
-rw-r--r--macros/latex/contrib/sttools/midfloat.dtx393
-rw-r--r--macros/latex/contrib/sttools/midfloat.pdfbin0 -> 122155 bytes
-rw-r--r--macros/latex/contrib/sttools/stabular.dtx263
-rw-r--r--macros/latex/contrib/sttools/stabular.pdfbin0 -> 107168 bytes
-rw-r--r--macros/latex/contrib/sttools/stfloats.dtx923
-rw-r--r--macros/latex/contrib/sttools/stfloats.pdfbin0 -> 125623 bytes
-rw-r--r--macros/latex/contrib/sttools/sttools.dtx113
-rw-r--r--macros/latex/contrib/sttools/sttools.ins55
-rw-r--r--macros/latex/contrib/sttools/sttools.pdfbin0 -> 107283 bytes
-rw-r--r--macros/latex/contrib/sttools/texsort.dtx556
-rw-r--r--macros/latex/contrib/sttools/texsort.pdfbin0 -> 122530 bytes
18 files changed, 4760 insertions, 0 deletions
diff --git a/macros/latex/contrib/sttools/README.md b/macros/latex/contrib/sttools/README.md
new file mode 100644
index 0000000000..eea5d0d9fc
--- /dev/null
+++ b/macros/latex/contrib/sttools/README.md
@@ -0,0 +1,85 @@
+README for sttools, v2.0 2017/03/27
+
+INTRODUCTION
+============
+
+It is a collection of macro packages historically placed in a bundle
+and maintained by Sigitas Tolušis.
+
+PACKAGES
+========
+
+* cuted.sty, v1.5 2012/10/04:
+ – puts some material page width wide at any place on twocolumn page
+ with existing text reformatted under inserted material;
+ TODO: add optional rules to separate from text;
+
+* floatpag.sty, v1.1 2012/05/29:
+ – sets pagestyle for floats page;
+
+* 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;
+ (2014/04/24): bugfix version;
+ (2015/04/08): bugfix version with improved funcionality:
+ - spreaded or fixed right column height;
+ - 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;
+ (2016/06/28): removed from the bundle;
+
+* midfloat.sty, v1.1 2012/05/29:
+ – inserts onecolumn stuff in twocolumn page;
+ TODO: extend to work on both columns;
+
+* stabular.sty, v2.0 2014/03/20:
+ – modifies tabular environment;
+ (2014/03/20): removed extra stuff and left only possibility to break
+ on page boundary;
+ added tabular variant from array package;
+
+* 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;
+ TODO: extend (rewrite) to support alphanumerical values
+ for sorting.
+
+INSTALLATION
+============
+
+Install in a standard way as any other LaTeX macro package.
+
+AUTHORS/MAINTAINER
+==================
+
+* Sigitas Tolušis
+* Vytas Statulevičius (floatpag.sty)
+
+DOCUMENTATION
+=============
+
+Please see the sttools.pdf for a package list in collection
+and <package>.pdf for particular macro package.
+
+LICENSE
+=======
+
+This work may be distributed and/or modified under the
+conditions of the LaTeX Project Public License, either version 1.3
+of this license or (at your option) any later version.
+The latest version of this license is in
+ http://www.latex-project.org/lppl.txt
+and version 1.3 or later is part of all distributions of LaTeX
+version 2005/12/01 or later.
+
+
+
diff --git a/macros/latex/contrib/sttools/cuted.dtx b/macros/latex/contrib/sttools/cuted.dtx
new file mode 100644
index 0000000000..453ba5d051
--- /dev/null
+++ b/macros/latex/contrib/sttools/cuted.dtx
@@ -0,0 +1,753 @@
+% \iffalse meta-comment
+%
+% Copyright (C) 2012 by Sigitas Tolu\v{s}is <sigitas@vtex.lt>
+% ---------------------------------------------------------------------------
+% This work may be distributed and/or modified under the
+% conditions of the LaTeX Project Public License, either version 1.3
+% of this license or (at your option) any later version.
+% The latest version of this license is in
+% http://www.latex-project.org/lppl.txt
+% and version 1.3 or later is part of all distributions of LaTeX
+% version 2005/12/01 or later.
+%
+% This work has the LPPL maintenance status `maintained'.
+%
+% The Current Maintainer of this work is Sigitas Tolu\v{s}is.
+%
+% This work consists of the files cuted.dtx and cuted.ins
+% and the derived filebase cuted.sty.
+%
+% \fi
+%
+% \iffalse
+%<*driver>
+\ProvidesFile{cuted.dtx}
+%</driver>
+%<*package>
+%% Copyright (C) 1997-2012 by Sigitas Tolu\v{s}is <sigitas@vtex.lt>
+%% VTeX Ltd., Akademijos 4, Vilnius, Lithuania
+%% http://www.vtex.lt/tex/download/macros/
+%% --------------------------------------------------------------------------
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3
+%% of this license or (at your option) any later version.
+%% The latest version of this license is in
+%% http://www.latex-project.org/lppl.txt
+%% and version 1.3 or later is part of all distributions of LaTeX
+%% version 2005/12/01 or later.
+%%
+%% PURPOSE: Insert some onecolumn material in full-width on double-column page.
+%%
+%</package>
+%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
+%<package>\ProvidesPackage{cuted}
+%<*package>
+ [2012/10/04 v1.5 Mixing onecolumn and twocolumn modes]
+%</package>
+%
+%<*driver>
+\documentclass{ltxdoc}
+\usepackage{cuted}[2012/10/04]
+\EnableCrossrefs
+\CodelineIndex
+\RecordChanges
+\begin{document}
+ \DocInput{cuted.dtx}
+ \PrintChanges
+ \PrintIndex
+\end{document}
+%</driver>
+% \fi
+%
+% \CheckSum{1136}
+%
+% \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
+% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
+% Digits \0\1\2\3\4\5\6\7\8\9
+% Exclamation \! Double quote \" Hash (number) \#
+% Dollar \$ Percent \% Ampersand \&
+% Acute accent \' Left paren \( Right paren \)
+% Asterisk \* Plus \+ Comma \,
+% Minus \- Point \. Solidus \/
+% Colon \: Semicolon \; Less than \<
+% Equals \= Greater than \> Question mark \?
+% Commercial at \@ Left bracket \[ Backslash \\
+% Right bracket \] Circumflex \^ Underscore \_
+% Grave accent \` Left brace \{ Vertical bar \|
+% Right brace \} Tilde \~}
+%
+%
+% \changes{}{1997/09/02}{improved column balancing}
+% \changes{}{1997/09/03}{float control for \cs{@colroom} setting}
+% \changes{}{1997/09/04}{improved \cs{@colroom} setting}
+% \changes{}{1997/09/05}{checking for \cs{@viper} and \cs{hold@viper}}
+% \changes{}{1997/09/09}{compatibility with flushend.sty}
+% \changes{}{1997/09/22}{improved \cs{output} ir \cs{@specialoutput}}
+% \changes{}{1997/10/01}{improved \cs{output} ir \cs{@addviper}}
+% \changes{}{1998/10/23}{pakeistas koloneliu sujungimas}
+% \changes{}{2000/01/18}{pakeistas \cs{@outputdblcol}}
+% \changes{}{2002/06/11}{added options unskipbreak and autobase}
+% \changes{v1.4}{2012/05/29}{Converted to DTX file}
+%
+% \DoNotIndex{\newcommand,\newenvironment}
+%
+% \providecommand*{\url}{\texttt}
+% \GetFileInfo{cuted.dtx}
+% \title{The \textsf{cuted} package}
+% \author{Sigitas Tolu\v{s}is\\ \url{sigitas@vtex.lt}}
+% \date{\fileversion~from \filedate}
+%
+% \maketitle
+%
+% \section{Introduction}
+%
+% It is denoted to place some material in full-width at any place
+% on double-column page (|\twocolumn| mode). The part of material
+% can be placed on the next page. Existing text is placed
+% under inserted material in two columns (it is reformatted).
+%
+% \section{Usage}
+%
+%
+% \DescribeMacro{strip}
+% Provides new environment:
+%
+% \begin{verbatim}
+% \begin{strip}
+% <wide onecolumn material>
+% \end{strip}
+% \end{verbatim}
+%
+% Puts |\vbox|\marg{wide onecolumn material} in full-width on
+% double-column page.
+%
+% \medskip
+% Adds |\stripsep| glue before and after
+% (by default: |15pt plus2pt minus 2pt|).
+%
+% \medskip
+% It can be problems with floats and footnotes. In the case of
+% problems with footnotes it is possible to correct the situation
+% using commands |\footnotemark| and |\footnotetext|.
+%
+% \medskip
+% \DescribeMacro{\oldcolsbreak}
+% \marg{adds}
+%
+% Adds \meta{adds} in place of original column break if strip is placed
+% on the right column.
+%
+% \subsection{Package options}
+%
+% \DescribeMacro{unskipbreak}
+% \indent It is used to change |\hbox{}| to |\unskip| after leftcolumn break on striped page.
+%
+% \medskip
+% \DescribeMacro{autobase}
+% It is used to guess |\baselineskip| value on original columns break.
+%
+%
+% \StopEventually{}
+%
+% \section{Implementation}
+%
+% \iffalse
+%<*package>
+% \fi
+%
+%
+% \begin{macro}{unskipbreak}
+% \begin{macrocode}
+\def\on@stripcols@break{\hbox{}}
+\DeclareOption{unskipbreak}{\gdef\on@stripcols@break{\unskip}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{autobase}
+% \begin{macrocode}
+\newif\if@flushend@auto@baselineskip
+\DeclareOption{autobase}{\global\@flushend@auto@baselineskiptrue}
+\ProcessOptions
+
+\newtoks\At@ViperColsBreak \At@ViperColsBreak{}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\oldcolsbreak}
+% \begin{macrocode}
+\def\oldcolsbreak#1{\global\At@ViperColsBreak{#1}}
+\def\viper@top@hook{\splittopskip0pt plus 2pt}
+
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
+\newbox\v@aaa
+\newbox\v@ccc
+\@ifundefined{lastskip@a}{\newskip\lastskip@a}{}
+\@ifundefined{lastskip@b}{\newskip\lastskip@b}{}
+\@ifundefined{lastskip@d}{\newskip\lastskip@d}{}
+\@ifundefined{lastbox@a}{\newbox\lastbox@a}{}
+\@ifundefined{stripsep}{\newskip\stripsep \stripsep 15pt plus 2pt minus 2pt}{}
+
+\@ifundefined{@viper}{\newbox\@viper}{}
+\newif\if@lastviper \@lastviperfalse
+% \end{macrocode}
+%
+%
+% \begin{macro}{\@outputdblcol}
+% \begin{macrocode}
+\def\@outputdblcol{%
+ \if@firstcolumn
+ \global \@firstcolumnfalse
+ \global \setbox\@leftcolumn \box\@outputbox
+ \else
+ \global \@firstcolumntrue
+ \setbox\@outputbox \vbox {%
+ \hb@xt@\textwidth {%
+ \hb@xt@\columnwidth {%
+ \box\@leftcolumn \hss}%
+ \hfil
+ \vrule \@width\columnseprule
+ \hfil
+ \hb@xt@\columnwidth {%
+ \box\@outputbox \hss}%
+ }%
+ }%
+ \ifvoid\hold@viper
+ \else
+ \setbox\@outputbox \vbox to\textheight{%
+ \box\hold@viper
+ \box\@outputbox
+ \vss
+ }%
+ \fi
+ \@combinedblfloats
+ \@outputpage
+ \begingroup
+ \@dblfloatplacement
+ \@startdblcolumn
+ \@whilesw\if@fcolmade \fi
+ {\@outputpage
+ \@startdblcolumn}%
+ \ifvoid\@viper
+ \else
+ \global\setbox\@viper\vbox{%
+ \vskip-\stripsep
+ \unvbox\@viper
+ }%
+ \@viperoutput
+ \fi
+ \endgroup
+ \fi
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
+\mathchardef\@Mv=10005
+\newcount\viper@penalty
+% \end{macrocode}
+%
+% \begin{macro}{\strip}
+% \begin{macrocode}
+\def\strip{%
+ \ifinner
+ \@parmoderr\viper@penalty\z@
+ \else
+ \viper@penalty=-\@Mv\relax
+ \fi
+ \global \setbox\@viper\vbox\bgroup%
+ \hsize\textwidth
+ \@parboxrestore
+ \col@number \@ne
+ \vrule height\topskip width\z@ depth\z@
+ }
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\endstrip}
+% \begin{macrocode}
+\def\endstrip{%
+ \egroup
+ \ifnum\viper@penalty <-\@Mii
+ \penalty -\@Miv
+ \ifvmode
+ \@tempdima\prevdepth %% saving and restoring \prevdepth added
+ \vbox{}% %% 26 May 87 to prevent extra vertical
+ \prevdepth\@tempdima %% space when used in vertical mode
+ \penalty-\@Mv\relax
+ \else
+ \par
+ \penalty-\@Mv\relax
+ \noindent
+ \fi
+ \fi
+ }
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\@viperoutput}
+% \begin{macrocode}
+\gdef\@viperoutput{%
+ \global \setbox\@holdpg \vbox{%
+ \unvbox\@holdpg
+ \unvbox\@cclv
+ \setbox\@tempboxa \lastbox
+ \unskip
+ }%
+ \@pagedp \dp\@holdpg
+ \@pageht \ht\@holdpg
+ \ifvoid\@viper\else
+ \advance \@pageht \@pagedp
+ \ifvoid\footins \else
+ \advance \@pageht \ht\footins
+ \advance \@pageht \skip\footins
+ \advance \@pageht \dp\footins
+ \fi
+ \ifvbox \@kludgeins
+ \ifdim \wd\@kludgeins=\z@
+ \advance \@pageht \ht\@kludgeins
+ \fi
+ \fi
+ \@reinserts
+ \@addviper
+ \fi
+ }
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\@specialoutput}
+% \begin{macrocode}
+\gdef\@specialoutput{%
+ \ifnum \outputpenalty>-\@Mii
+ \@doclearpage
+ \else
+ \ifnum \outputpenalty<-\@Miii
+ \ifnum \outputpenalty<-\@MM \deadcycles \z@ \fi
+ \ifnum \outputpenalty=-\@Mv
+ \@viperoutput
+ \ifnum \outputpenalty<\z@
+ \if@nobreak
+ \else
+ \addpenalty \interlinepenalty
+ \fi
+ \fi
+ \else
+ \global \setbox\@holdpg \vbox {\unvbox\@cclv}%
+ \fi
+ \else
+ \global \setbox\@holdpg \vbox{%
+ \unvbox\@holdpg
+ \unvbox\@cclv
+ \setbox\@tempboxa \lastbox
+ \unskip
+ }%
+ \@pagedp \dp\@holdpg
+ \@pageht \ht\@holdpg
+ \unvbox \@holdpg
+ \@next\@currbox\@currlist{%
+ \ifnum \count\@currbox>\z@
+ \advance \@pageht \@pagedp
+ \ifvoid\footins \else
+ \advance \@pageht \ht\footins
+ \advance \@pageht \skip\footins
+ \advance \@pageht \dp\footins
+ \fi
+ \ifvbox \@kludgeins
+ \ifdim \wd\@kludgeins=\z@
+ \advance \@pageht \ht\@kludgeins
+ \fi
+ \fi
+ \@reinserts
+ \@addtocurcol
+ \else
+ \@reinserts
+ \@addmarginpar
+ \fi
+ }\@latexbug
+ \ifnum \outputpenalty<\z@
+ \if@nobreak
+ \else
+ \addpenalty \interlinepenalty
+ \fi
+ \fi
+ \fi
+ \fi
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
+\@ifundefined{hold@viper}{\newbox\hold@viper}{}
+\newdimen\ht@viper
+% \end{macrocode}
+%
+% \begin{macro}{\@addviper}
+% \begin{macrocode}
+\def \@addviper {%
+ \if@firstcolumn
+ \@insertfalse
+ \@reqcolroom .5\@pageht
+ \ht@viper\@reqcolroom
+ \advance \@reqcolroom \ht\@viper
+ \advance \@reqcolroom \stripsep
+ \ifvoid\hold@viper\@tempdima=\z@\else\@tempdima\ht\hold@viper\fi
+%%
+ \@tempdimb \ht@viper
+ \loop
+ \setbox\v@aaa\copy\@holdpg
+ \setbox\v@ccc\vbox to\@tempdimb{%
+ \vsplit\v@aaa to\@tempdimb\vss\vsplit\v@aaa to\@tempdimb}%
+ \wlog{Extra height:\the\ht\v@aaa\space when \the\@tempdimb}%
+ \ifvoid\v@aaa \else \advance\@tempdimb 1pt \repeat
+ \loop
+ \setbox\v@aaa\copy\@holdpg
+ \setbox\v@ccc\vbox to\@tempdimb{%
+ \vsplit\v@aaa to\@tempdimb\vss}%
+ \wlog{(2)Left:\the\ht\v@ccc\space Right:\the\ht\v@aaa\space Output:\the\@tempdimb}%
+ \ifdim \ht\v@ccc<\ht\v@aaa \@tempdimb \the\ht\v@aaa \repeat
+ \wlog{- LAST -^^JLeft:\the\ht\v@ccc^^JRight:\the\ht\v@aaa^^JOutput:\the\@tempdimb}%
+ \setbox\v@ccc\vbox to\@tempdimb{%
+ \vsplit\@holdpg to\@tempdimb\vss}%
+%%
+ \setbox\@tempboxa \vbox {%
+ \hb@xt@\textwidth {%
+ \hb@xt@\columnwidth {%
+ \vbox to\ht@viper{\box\v@ccc\vss} \hss}%
+ \hfil
+ \vrule \@width\columnseprule
+ \hfil
+ \hb@xt@\columnwidth {%
+ \vbox to\ht@viper{\box\@holdpg\vss} \hss}%
+ }%
+ }%
+ \ifvoid\hold@viper
+ \global\setbox\hold@viper \vbox {%
+ \unvbox\@tempboxa
+ \penalty\interlinepenalty
+ \vskip\stripsep
+ \ifnum\outputpenalty <-\@Mii \vskip -\parskip\fi
+ \outputpenalty \z@
+ }%
+ \else
+ \global\setbox\hold@viper \vbox {%
+ \unvbox\hold@viper
+ \unvbox\@tempboxa
+ \penalty\interlinepenalty
+ \vskip\stripsep
+ \ifnum\outputpenalty <-\@Mii \vskip -\parskip\fi
+ \outputpenalty \z@
+ }%
+ \fi
+ \ifdim \@colroom>\@reqcolroom
+ \global\setbox\hold@viper \vbox {%
+ \unvbox\hold@viper
+ \box\@viper
+ \penalty\interlinepenalty
+ \vskip\stripsep
+ \ifnum\outputpenalty <-\@Mii \vskip -\parskip\fi
+ \outputpenalty \z@
+ }%
+ \@inserttrue
+ \advance\@tempdima by-\ht\hold@viper
+ \global \advance \@colht \@tempdima
+ \ifdim \@colht<2.5\baselineskip
+ \@latex@warning@no@line {Optional argument of \noexpand\twocolumn
+ too tall on page \thepage (1 stulpelis)}%
+ \@emptycol
+ \if@firstcolumn
+ \else
+ \@emptycol
+ \fi
+ \global\@lastvipertrue
+ \else
+ \global \vsize \@colht
+ \global \@colroom \@colht
+ \check@floats
+ \ifdim\@tempdima>\z@
+ \global\advance\@colroom by-\@tempdima
+ \fi
+ \ifdim\@colroom<\z@
+ \global\@colroom 1pt
+ \ifdim\@tempdima>\@colht
+ \@latex@warning@no@line {TOP ir/ar BOT FLOAT's
+ netelpa lape \thepage (1 stulpelis)}%
+ \fi
+ \@emptycol
+ \if@firstcolumn
+ \else
+ \@emptycol
+ \fi
+ \global\@lastvipertrue
+ \fi
+ \fi
+ \fi
+ \else
+ \@insertfalse
+ \@reqcolroom\@colht
+ \advance\@reqcolroom \@pageht
+ \ht@viper.5\@reqcolroom
+ \@reqcolroom\ht@viper
+ \advance \@reqcolroom \ht\@viper
+ \advance \@reqcolroom \stripsep
+ \if@flushend@auto@baselineskip
+ \setbox\@tempboxa\vbox{\unvcopy\@leftcolumn
+ \global\lastskip@d\lastskip
+ \global\lastskip@b\lastskip
+ \loop
+ \global\lastskip@a\lastskip@b
+ \unskip\unpenalty
+ \global\lastskip@b\lastskip
+ \global\advance\lastskip@d by\lastskip
+ \ifdim\lastskip@b=-\lastskip@a
+ \global\advance\lastskip@d by-\lastskip
+ \else
+ \repeat
+ \ifdim\lastskip@b=-\lastskip@a
+ \ifdim\lastskip@b=\z@
+ \setbox\lastbox@a\lastbox
+ \global\advance\lastskip@d by\ht\lastbox@a
+ \global\advance\lastskip@d by\lastskip
+ \unskip\unpenalty
+ \setbox\lastbox@a\lastbox
+ \global\advance\lastskip@d by\dp\lastbox@a
+ \else
+ \global\lastskip@d\lastskip
+ \global\advance\lastskip@d by\topskip
+ \fi
+ \fi
+ \global\advance\lastskip@d by-\topskip
+ }%
+ \ifdim\ht\@holdpg>\@colht
+ \global\setbox\@holdpg\vbox{\unvbox\@leftcolumn\unskip\unpenalty
+ \par\eject
+ \vbox to \@colht{\unvbox\@holdpg\unskip}%
+ }%
+ \else
+ \global\setbox\@holdpg\vbox{%
+ \unvbox\@leftcolumn\unskip\unpenalty
+ \vskip\lastskip@d
+ \the\At@ViperColsBreak
+ \unvbox\@holdpg
+ \unskip
+ }%
+ \fi
+ \else
+ \global\setbox\@holdpg\vbox{%
+ \unvbox\@leftcolumn
+ \setbox\@tempboxa\lastbox
+ \on@stripcols@break
+ \the\At@ViperColsBreak
+ \unvbox\@holdpg
+ }%
+ \fi
+ \global\At@ViperColsBreak{}%
+ \ht@viper .5\ht\@holdpg
+ \ifdim \ht@viper>\@colht
+ \ht@viper \@colht
+ \fi
+ \ifvoid\hold@viper\@tempdima=\z@\else\@tempdima\ht\hold@viper\fi
+% \end{macrocode}
+%%
+% \begin{macrocode}
+ \@tempdimb \ht@viper
+ \loop
+ \setbox\v@aaa\copy\@holdpg
+ \setbox\v@ccc\vbox to\@tempdimb{%
+ \vsplit\v@aaa to\@tempdimb
+ \vss
+ \vsplit\v@aaa to\@tempdimb
+ }%
+ \wlog{Extra height:\the\ht\v@aaa\space when \the\@tempdimb}%
+ \ifvoid\v@aaa
+ \else
+ \advance\@tempdimb 1\p@
+ \repeat
+ \loop
+ \setbox\v@aaa\copy\@holdpg
+ \setbox\v@ccc\vbox to\@tempdimb{\vsplit\v@aaa to\@tempdimb\vss}%
+ \wlog{(2)Left:\the\ht\v@ccc\space
+ Right:\the\ht\v@aaa\space
+ Output:\the\@tempdimb
+ }%
+ \ifdim\ht\v@ccc<\ht\v@aaa
+ \@tempdimb \the\ht\v@aaa
+ \repeat
+ \wlog{- LAST -^^JLeft:\the\ht\v@ccc
+ ^^JRight:\the\ht\v@aaa
+ ^^JOutput:\the\@tempdimb
+ }%
+ \setbox\v@ccc\vbox to\@tempdimb{\vsplit\@holdpg to\@tempdimb\vss}%
+% \end{macrocode}
+%
+% \begin{macrocode}
+ \setbox\@tempboxa\vbox{%
+ \hb@xt@\textwidth {%
+ \hb@xt@\columnwidth{\vbox to\ht@viper{\box\v@ccc\vss} \hss}%
+ \hfil
+ \vrule \@width\columnseprule
+ \hfil
+ \hb@xt@\columnwidth {\vbox to\ht@viper{\box\@holdpg\vss} \hss}%
+ }%
+ }%
+ \ifvoid\hold@viper
+ \global\setbox\hold@viper \vbox {%
+ \unvbox\@tempboxa
+ \penalty\interlinepenalty
+ \vskip\stripsep
+ \ifnum\outputpenalty <-\@Mii \vskip -\parskip\fi
+ \outputpenalty \z@
+ }%
+ \else
+ \global\setbox\hold@viper \vbox {%
+ \unvbox\hold@viper
+ \unvbox\@tempboxa
+ \penalty\interlinepenalty
+ \vskip\stripsep
+ \ifnum\outputpenalty <-\@Mii \vskip -\parskip\fi
+ \outputpenalty \z@
+ }%
+ \fi
+ \ifdim \@colht>\@reqcolroom
+ \global\setbox\hold@viper \vbox {%
+ \unvbox\hold@viper
+ \box\@viper
+ \penalty\interlinepenalty
+ \vskip\stripsep
+ \ifnum\outputpenalty <-\@Mii \vskip -\parskip\fi
+ \outputpenalty \z@
+ }%
+ \@inserttrue
+ \global\@firstcolumntrue
+ \advance\@tempdima by-\ht\hold@viper
+ \global \advance \@colht \@tempdima
+ \ifdim \@colht<2.5\baselineskip
+ \@latex@warning@no@line {Optional argument of \noexpand\twocolumn
+ too tall on page \thepage (2 stulpelis)}%
+ \@emptycol
+ \if@firstcolumn
+ \else
+ \@emptycol
+ \fi
+ \global\@lastvipertrue
+ \else
+ \global \vsize \@colht
+ \global \@colroom \@colht
+ \check@floats
+ \ifdim\@tempdima>\z@
+ \global\advance\@colroom by-\@tempdima
+ \fi
+ \ifdim\@colroom<\z@
+ \global\@colroom 1pt
+ \ifdim\@tempdima>\@colht
+ \@latex@warning@no@line {TOP ir/ar BOT FLOAT's
+ netelpa lape \thepage (2 stulpelis)}%
+ \fi
+ \@emptycol
+ \if@firstcolumn
+ \else
+ \@emptycol
+ \fi
+ \global\@lastvipertrue
+ \fi
+ \fi
+ \fi
+ \fi
+ \if@insert
+ \else
+ \advance\@tempdima by-\ht\hold@viper
+ \global \advance \@colht \@tempdima
+ \global\setbox\hold@viper \vbox {%
+ \unvbox\hold@viper
+ \csname viper@top@hook\endcsname
+ \vsplit\@viper to \@colht
+ \vss
+ }%
+ \vbox{}%
+ \global\@firstcolumnfalse
+ \newpage
+ \fi
+ }
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\check@floats}
+% \begin{macrocode}
+
+\def\check@floats{%
+ \global\@tempdima\z@
+ \let\@elt\ht@comflelt
+ \ifx\@toplist\@empty \else \@toplist \fi
+ \ifx\@botlist\@empty \else \@botlist \fi
+ }
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\ht@comflelt}
+% \begin{macrocode}
+\def\ht@comflelt#1{%
+ \setbox\@tempboxa\vbox{\copy #1\vskip\floatsep}%
+ \global\advance\@tempdima by\ht\@tempboxa
+ }
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{output}
+% \begin{macrocode}
+\output {%
+ \let \par \@@par
+ \ifnum \outputpenalty<-\@M
+ \@specialoutput
+ \else
+ \@makecol
+ \@opcol
+ \@startcolumn
+ \@whilesw \if@fcolmade \fi
+ {%
+ \@opcol\@startcolumn}%
+ \fi
+ \ifnum \outputpenalty>-\@Miv
+ \ifdim \@colroom<1.5\baselineskip
+ \ifdim \@colroom<\textheight
+ \@latex@warning@no@line {Text page \thepage\space
+ contains only floats}%
+ \if@lastviper\else\@emptycol\fi
+ \if@twocolumn
+ \if@firstcolumn
+ \else
+ \@emptycol
+ \fi
+ \fi
+ \global\@lastviperfalse
+ \else
+ \global \vsize \@colroom
+ \fi
+ \else
+ \global \vsize \@colroom
+ \fi
+ \else
+ \ifnum\outputpenalty<-100005
+ \global \vsize \maxdimen
+ \else
+ \global \vsize \@colroom
+ \fi
+ \fi
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
+%\endinput
+% \end{macrocode}
+%
+% \iffalse
+%</package>
+% \fi
+%
+% \Finale
diff --git a/macros/latex/contrib/sttools/cuted.pdf b/macros/latex/contrib/sttools/cuted.pdf
new file mode 100644
index 0000000000..25cd7d49ad
--- /dev/null
+++ b/macros/latex/contrib/sttools/cuted.pdf
Binary files differ
diff --git a/macros/latex/contrib/sttools/floatpag.dtx b/macros/latex/contrib/sttools/floatpag.dtx
new file mode 100644
index 0000000000..95d732b665
--- /dev/null
+++ b/macros/latex/contrib/sttools/floatpag.dtx
@@ -0,0 +1,354 @@
+% \iffalse meta-comment
+%
+% Copyright (C) 1999-2012 by Vytas Statulevi\v{c}ius <vytas@vtex.lt>
+% ---------------------------------------------------------------------------
+% This work may be distributed and/or modified under the
+% conditions of the LaTeX Project Public License, either version 1.3
+% of this license or (at your option) any later version.
+% The latest version of this license is in
+% http://www.latex-project.org/lppl.txt
+% and version 1.3 or later is part of all distributions of LaTeX
+% version 2005/12/01 or later.
+%
+% This work has the LPPL maintenance status `maintained'.
+%
+% The Current Maintainer of this work is Sigitas Tolu\v{s}is.
+%
+% This work consists of the files floatpag.dtx and floatpag.ins
+% and the derived filebase floatpag.sty.
+%
+% \fi
+%
+% \iffalse
+%<*driver>
+\ProvidesFile{floatpag.dtx}
+%</driver>
+%% Copyright (C) 1999-2012 by Vytas Statulevi\v{c}ius <vytas@vtex.lt>
+%% VTeX Ltd., Akademijos 4, Vilnius, Lithuania
+%% http://www.vtex.lt/tex/download/macros/
+%% --------------------------------------------------------------------------
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3
+%% of this license or (at your option) any later version.
+%% The latest version of this license is in
+%% http://www.latex-project.org/lppl.txt
+%% and version 1.3 or later is part of all distributions of LaTeX
+%% version 2005/12/01 or later.
+%%
+%% The macros, developed by Sigitas Tolu\v{s}is <sigitas@vtex.lt>,
+%% were used in this package.
+%%
+%% The Current Maintainer of this work is Sigitas Tolu\v{s}is.
+%%
+%% PURPOSE: provides commands to apply different pagestyles
+%% to the full page floats.
+%%
+%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
+%<package>\ProvidesPackage{floatpag}
+%<*package>
+ [2012/05/29 v1.1 Different pagestyles on float pages]
+%</package>
+%
+%<*driver>
+\documentclass{ltxdoc}
+\usepackage{floatpag}[2012/05/29]
+\EnableCrossrefs
+\CodelineIndex
+\RecordChanges
+\begin{document}
+ \DocInput{floatpag.dtx}
+ \PrintChanges
+ \PrintIndex
+\end{document}
+%</driver>
+% \fi
+%
+% \CheckSum{304}
+%
+% \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
+% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
+% Digits \0\1\2\3\4\5\6\7\8\9
+% Exclamation \! Double quote \" Hash (number) \#
+% Dollar \$ Percent \% Ampersand \&
+% Acute accent \' Left paren \( Right paren \)
+% Asterisk \* Plus \+ Comma \,
+% Minus \- Point \. Solidus \/
+% Colon \: Semicolon \; Less than \<
+% Equals \= Greater than \> Question mark \?
+% Commercial at \@ Left bracket \[ Backslash \\
+% Right bracket \] Circumflex \^ Underscore \_
+% Grave accent \` Left brace \{ Vertical bar \|
+% Right brace \} Tilde \~}
+%
+%
+% \changes{v1.1}{2012/05/29}{Converted to DTX file}
+%
+% \DoNotIndex{\newcommand,\newenvironment}
+%
+% \providecommand*{\url}{\texttt}
+% \GetFileInfo{floatpag.dtx}
+% \title{The \textsf{floatpag} package}
+% \author{Vytas Statulevi\v{c}ius and Sigitas Tolu\v{s}is \\
+% \url{vytas@vtex.lt}, \url{sigitas@vtex.lt}}
+% \date{\fileversion~from \filedate}
+%
+% \maketitle
+%
+% \section{Introduction}
+%
+% Provides commands to apply different pagestyles to the full page floats.
+%
+% \section{Usage}
+%
+% \DescribeMacro{\floatpagestyle}
+% \marg{foo} will apply pagestyle \meta{foo} to all pages
+% occupied by full page floats.
+%
+% \medskip
+% \DescribeMacro{\rotfloatpagestyle}
+% \marg{foo} will apply pagestyle \meta{foo} to all pages
+% occupied by sideways figures and tables
+% produced with the help of |rotating|
+% package (Sebastian Rahtz and Leonor Barroca).
+%
+% \medskip
+% \DescribeMacro{\thisfloatpagestyle}
+% \marg{foo} will apply pagestyle \meta{foo} to a page where
+% this command was used inside figure or table
+% environment.
+%
+% \medskip
+% \textbf{Default:} |\floatpagestyle{headings}| and |\rotfloatpagestyle{plain}|.
+%
+% \medskip
+% The following commands from the LaTeX2e kernel were redefined:
+% |\@xfloat|, |\@vtryfc|.
+%
+% \medskip
+% The following command from the rotating.sty was redefined:
+% |\@xrotfloat|.
+%
+% \StopEventually{}
+%
+% \section{Implementation}
+%
+% \iffalse
+%<*package>
+% \fi
+%
+% \begin{macrocode}
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{floatpag}
+ [1999/04/29
+ FLOAT PAGESTYLE]
+% \end{macrocode}
+%
+% \begin{macro}{\floatpagestyle}
+% \begin{macrocode}
+\def\floatpagestyle#1{\gdef\at@float@page{\thispagestyle{#1}}}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\rotfloatpagestyle}
+% \begin{macrocode}
+\def\rotfloatpagestyle#1{%
+ \gdef\@r@f@pagestyle{#1}%
+ \gdef\at@rotfloat@page{\thispagestyle{#1}}%
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
+\floatpagestyle{headings}
+\rotfloatpagestyle{plain}
+% \end{macrocode}
+%
+% \begin{macro}{\thisfloatpagestyle}
+%
+% \begin{macrocode}
+\def\thisfloatpagestyle#1{%
+ \expandafter\expandafter\expandafter\gdef\expandafter
+ \csname\number\@currbox @float\endcsname{\thispagestyle{#1}}\relax
+ }
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\@xfloat}
+%
+%% Modify |\x@float| - ordinary floats
+%
+% \begin{macrocode}
+\def\@xfloat #1[#2]{%
+ \@nodocument
+ \def \@captype {#1}%
+ \def \@fps {#2}%
+ \@onelevel@sanitize \@fps
+ \def \reserved@b {!}%
+ \ifx \reserved@b \@fps
+ \@fpsadddefault
+ \else
+ \ifx \@fps \@empty
+ \@fpsadddefault
+ \fi
+ \fi
+ \ifhmode
+ \@bsphack
+ \@floatpenalty -\@Mii
+ \else
+ \@floatpenalty-\@Miii
+ \fi
+ \ifinner
+ \@parmoderr\@floatpenalty\z@
+ \else
+ \@next\@currbox\@freelist
+ {%
+ \@tempcnta \sixt@@n
+ \expandafter \@tfor \expandafter \reserved@a
+ \expandafter :\expandafter =\@fps
+ \do
+ {%
+ \if \reserved@a h%
+ \ifodd \@tempcnta
+ \else
+ \advance \@tempcnta \@ne
+ \fi
+ \fi
+ \if \reserved@a t%
+ \@setfpsbit \tw@
+ \fi
+ \if \reserved@a b%
+ \@setfpsbit 4%
+ \fi
+ \if \reserved@a p%
+ \@setfpsbit 8%
+ \fi
+ \if \reserved@a !%
+ \ifnum \@tempcnta>15
+ \advance\@tempcnta -\sixt@@n\relax
+ \fi
+ \fi
+ }%
+ \@tempcntb \csname ftype@\@captype \endcsname
+ \multiply \@tempcntb \@xxxii
+ \advance \@tempcnta \@tempcntb
+ \global \count\@currbox \@tempcnta
+ \expandafter\expandafter\expandafter\gdef\expandafter
+ \csname\number\@currbox @float\endcsname{\at@float@page}\relax
+ }%
+ \@fltovf
+ \fi
+ \global \setbox\@currbox
+ \color@vbox
+ \normalcolor
+ \vbox \bgroup
+ \hsize\columnwidth
+ \@parboxrestore
+ \@floatboxreset
+ }
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\e@xrotfloat}
+%
+%% 2e rotating.sty v. 2.10:
+% \begin{macrocode}
+\def\e@xrotfloat#1[#2]{%
+ \@float{#1}[#2]%
+ \thisfloatpagestyle{\@r@f@pagestyle}%
+ \begin{lrbox}\rot@float@box
+ \begin{minipage}\textheight
+ }
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\n@xrotfloat}
+%% 2.09 rotating.sty v. 1.6
+% \begin{macrocode}
+\def\n@xrotfloat#1[#2]{%
+ \ifhmode
+ \@bsphack
+ \@floatpenalty -\@Mii
+ \else
+ \@floatpenalty-\@Miii
+ \fi
+ \def\@captype{#1}%
+ \ifinner
+ \@parmoderr\@floatpenalty\z@
+ \else
+ \@next\@currbox\@freelist{\@tempcnta\csname ftype@#1\endcsname
+ \multiply\@tempcnta\@xxxii\advance\@tempcnta\sixt@@n
+ \@tfor \@tempa :=#2\do{%
+ \if\@tempa h\advance\@tempcnta \@ne\fi
+ \if\@tempa t\advance\@tempcnta \tw@\fi
+ \if\@tempa b\advance\@tempcnta 4\relax\fi
+ \if\@tempa p\advance\@tempcnta 8\relax\fi
+ }%
+ \global\count\@currbox\@tempcnta
+ }%
+ \@fltovf
+ \fi
+ \expandafter\expandafter\expandafter\gdef\expandafter
+ \csname\number\@currbox @float\endcsname{\at@rotfloat@page}\relax
+ \global\setbox\@currbox\vbox\bgroup
+ \hsize\textheight
+ \@parboxrestore
+ }
+% \end{macrocode}
+%
+%% Check for |rotating| version: 2e ar 209:
+%% 1999.02.08 To be sure check at begin document.
+% \begin{macrocode}
+\AtBeginDocument{%
+\@ifpackageloaded{rotating}%
+{\let\@xrotfloat\e@xrotfloat\let\n@xrotfloat\relax}%
+{\let\@xrotfloat\n@xrotfloat\let\e@xrotfloat\relax}}%
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\spec@float}
+%
+%% "Hook" in the output procedure.
+% \begin{macrocode}
+\def\spec@float#1{\expandafter\csname\number#1@float\endcsname
+ \expandafter\expandafter\expandafter\gdef\expandafter\csname\number#1@float\endcsname{}%
+ }
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\@vtryfc}
+% \begin{macrocode}
+\def\@vtryfc#1{%
+ \global\setbox\@outputbox\vbox{}%
+ \let\@elt\@wtryfc
+ \@flsucceed
+ \let\@elt\spec@float
+ \@flsucceed
+ \global\setbox\@outputbox \vbox to\@colht{%
+ \vskip \@fptop
+ \vskip -\@fpsep
+ \unvbox \@outputbox
+ \vskip \@fpbot
+ }%
+ \let\@elt\relax
+ \xdef#1{\@failedlist\@flfail}%
+ \xdef\@freelist{\@freelist\@flsucceed}%
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
+%\endinput
+% \end{macrocode}
+%
+% \iffalse
+%</package>
+% \fi
+%
+% \Finale
diff --git a/macros/latex/contrib/sttools/floatpag.pdf b/macros/latex/contrib/sttools/floatpag.pdf
new file mode 100644
index 0000000000..2e50df9411
--- /dev/null
+++ b/macros/latex/contrib/sttools/floatpag.pdf
Binary files differ
diff --git a/macros/latex/contrib/sttools/flushend.dtx b/macros/latex/contrib/sttools/flushend.dtx
new file mode 100644
index 0000000000..2634f02e80
--- /dev/null
+++ b/macros/latex/contrib/sttools/flushend.dtx
@@ -0,0 +1,1265 @@
+% \iffalse meta-comment/*% \end{macrocode}*/
+%
+% Copyright (C) 2017 by Sigitas Tolu\v{s}is <sigitas@vtex.lt>
+% ---------------------------------------------------------------------------
+% This work may be distributed and/or modified under the
+% conditions of the LaTeX Project Public License, either version 1.3
+% of this license or (at your option) any later version.
+% The latest version of this license is in
+% http://www.latex-project.org/lppl.txt
+% and version 1.3 or later is part of all distributions of LaTeX
+% version 2005/12/01 or later.
+%
+% This work has the LPPL maintenance status `maintained'.
+%
+% The Current Maintainer of this work is Sigitas Tolu\v{s}is.
+%
+% This work consists of the files flushend.dtx and flushend.ins
+% and the derived filebase flushend.sty.
+%
+% \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-2017 by Sigitas Tolu\v{s}is <sigitas@vtex.lt>
+%% VTeX Ltd., Mokslinink\k{u} 2a, Vilnius, Lithuania
+%% http://www.vtex.lt/tex/download/macros/
+%% --------------------------------------------------------------------------
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3
+%% of this license or (at your option) any later version.
+%% The latest version of this license is in
+%% http://www.latex-project.org/lppl.txt
+%% and version 1.3 or later is part of all distributions of LaTeX
+%% version 2005/12/01 or later.
+%%
+%% PURPOSE: Balanced columns on last page in twocolumn mode.
+%%
+%</package>
+%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
+%<package>\ProvidesPackage{flushend}
+%<*package>
+ [2017/03/27 v3.3 Balancing columns in twocolumn mode]
+%</package>
+%
+%<*driver>
+\documentclass{ltxdoc}
+\usepackage{flushend}[2016/06/21]
+\EnableCrossrefs
+\CodelineIndex
+%%\RecordChanges
+%\OnlyDescription
+\begin{document}
+ \DocInput{flushend.dtx}
+ %%\PrintChanges
+ %%\PrintIndex
+\end{document}
+%</driver>
+% \fi
+%
+% \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
+% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
+% Digits \0\1\2\3\4\5\6\7\8\9
+% Exclamation \! Double quote \" Hash (number) \#
+% Dollar \$ Percent \% Ampersand \&
+% Acute accent \' Left paren \( Right paren \)
+% Asterisk \* Plus \+ Comma \,
+% Minus \- Point \. Solidus \/
+% Colon \: Semicolon \; Less than \<
+% Equals \= Greater than \> Question mark \?
+% Commercial at \@ Left bracket \[ Backslash \\
+% Right bracket \] Circumflex \^ Underscore \_
+% Grave accent \` Left brace \{ Vertical bar \|
+% Right brace \} Tilde \~}
+%
+%
+% \changes{v0.1}{1997/05/16}{first version}
+% \changes{v0.2}{1997/09/09}{support for compatibility with cuted.sty}
+% \changes{v1.0}{1997/10/01}{\string\vipersep changed to \string\stripsep for compatibility with cuted.sty}
+% \changes{v1.1}{2012/05/29}{Converted to DTX file}
+% \changes{v2.0}{2014/03/03}{rewritten with new balance algorithm}
+% \changes{v2.1}{2014/03/18}{Switched debug option off}
+% \changes{v2.2}{2014/04/24}{bugfix version: removing empty box at the right column end}
+% \changes{v3.0}{2015/04/08}{bugfix version and extra options:
+% ancient/modern,
+% spread/nospread,
+% removelastbox/keeplastbox}
+% \changes{v3.1}{2015/04/14}{set debug option off by default; keeplastbox modified;}
+% \changes{v3.2}{2016/06/21}{bugfix compatibility with luatexja}
+% \changes{v3.3}{2017/03/27}{bugfix for get@@footnoterule@@box; options for some checks on/off}
+%
+% \DoNotIndex{\newcommand,\newenvironment}
+%
+% \providecommand*{\url}{\texttt}
+% \GetFileInfo{flushend.dtx}
+% \title{The \textsf{flushend} package}
+% \author{Sigitas Tolu\v{s}is \\ \url{sigitas@vtex.lt}}
+% \date{\fileversion~from \filedate}
+%
+% \maketitle
+%
+% \section{Introduction}
+%
+% The package is used to balance columns on any page in twocolumn
+% mode. By default it is switched on at the end of document. It is
+% expected to work with footnotes, top floats and column break
+% before one line section title.
+%
+% \section{Usage}
+%
+% Just load the package to balance the last page: that's all.
+% To balance some page in middle of document use command
+% \cs{flushcolsend} at that page.
+%
+% \medskip
+% \DescribeMacro{\flushend}
+%
+% This macro switches on column balancing on the last page. It is used
+% by default.
+%
+% \medskip
+% \DescribeMacro{\raggedend}
+%
+% This macro switches off column balancing on the last page.
+%
+% \medskip
+% \DescribeMacro{\flushcolsend}
+%
+% This macro switches on column balancing on the current page.
+%
+% \medskip
+% \DescribeMacro{\raggedcolsend}
+%
+% This macro switches off column balancing on the current page.
+%
+% \medskip
+% \DescribeMacro{\atColsBreak}
+% \marg{tokens}
+%
+% Adds \meta{tokens} in place of the original column break (made without balancing).
+%
+% \medskip
+% \textit{Example}: |\atColsBreak{\vskip-2pt}|
+%
+% \medskip
+% \DescribeMacro{\atColsEnd}
+% \marg{tokens}
+%
+% Adds \meta{tokens} at the end of right column.
+%
+% \medskip
+% \textit{Example}: |\atColsEnd{\vfil}|.
+%
+% \medskip
+% \DescribeMacro{\showcolsendrule}
+%
+% It can be used just for debugging: adds rule to the bottom of columns.
+%
+% \subsection{Package options}
+%
+% \medskip
+% \DescribeMacro{ancient}
+% It is used to switch on old version of balancing algorithm.
+% This version is not so accurate or "clever" but quite safe.
+%
+% \medskip
+% \DescribeMacro{modern}
+% [default] It is used to switch on new version of balancing algorithm.
+% This version has some heuristic guesses for footnotes, floats
+% and section like head skip. So it is more dangerous in the case
+% for text misplace or disappear.
+%
+% \medskip
+% \DescribeMacro{autobase}
+% [default] It is used to guess |\baselineskip| value on original columns
+% break. On failure just use |\atColsBreak{...}|.
+%
+% \medskip
+% \DescribeMacro{noautobase}
+% It is used to switch off the previous option behaviour.
+%
+% \medskip
+% \DescribeMacro{spread}
+% [default] It adds extra glue to the rightcolumn trying to balance.
+%
+% \medskip
+% \DescribeMacro{nospread}
+% It skips adding extra glue to the last column.
+%
+% \medskip
+% \DescribeMacro{removelastbox}
+% [default] It tries to remove an empty box (some more material) from the last column bottom.
+%
+% \medskip
+% \DescribeMacro{keeplastbox}
+% It skips removing anything from the last column. As example it is usefull and can be used
+% then document ends by reference item and last line of text should be with indend.
+%
+% \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.
+%
+% \medskip
+% \DescribeMacro{nodebug}
+% [default] Skips putting debuging lines.
+%
+% \StopEventually{}
+%
+% \section{Implementation}
+%
+% \iffalse
+%<*package>
+% \fi
+%
+%/*% \begin{macrocode}*/
+% \begin{macrocode}
+\newif\if@auto@baselineskip \@auto@baselineskiptrue
+\newif\if@ancient@balance@version \@ancient@balance@versionfalse
+\newif\if@right@column@spread \@right@column@spreadtrue
+\newif\if@remove@lastbox@at@balancing \@remove@lastbox@at@balancingtrue
+\newif\if@balance@debug \@balance@debugfalse
+\DeclareOption{autobase}{\global\@auto@baselineskiptrue}
+\DeclareOption{noautobase}{\global\@auto@baselineskipfalse}
+\DeclareOption{ancient}{\global\@ancient@balance@versiontrue}
+\DeclareOption{modern}{\global\@ancient@balance@versionfalse}
+\DeclareOption{spread}{\global\@right@column@spreadtrue}
+\DeclareOption{nospread}{\global\@right@column@spreadfalse}
+\DeclareOption{removelastbox}{\global\@remove@lastbox@at@balancingtrue}
+\DeclareOption{keeplastbox}{\global\@remove@lastbox@at@balancingfalse}
+\DeclareOption{checkfootnote}{%
+ \AtEndOfPackage{%
+ \let\check@@footnoterule@@box\initial@check@@footnoterule@@box
+ }%
+ }
+\DeclareOption{nocheckfootnote}{%
+ \AtEndOfPackage{%
+ \let\check@@footnoterule@@box\@gobblethree
+ }%
+ }
+\DeclareOption{checkfloat}{%
+ \AtEndOfPackage{%
+ \let\top@@floatbox@min\top@@floatbox@min@default
+ }%
+ }
+\DeclareOption{nocheckfloat}{%
+ \AtEndOfPackage{%
+ \let\top@@floatbox@min\maxdimen
+ }%
+ }
+\DeclareOption{debug}{\global\@balance@debugtrue}
+\DeclareOption{nodebug}{\global\@balance@debugfalse}
+\ProcessOptions
+% \end{macrocode}
+%
+% \begin{macrocode}
+\newskip\flushend@@lastskip@a
+\newskip\flushend@@lastskip@b
+\newskip\flushend@@lastskip@c
+\newcount\flushend@@penalty@a
+\newdimen\flushend@@lastkern@a
+\newdimen\var@@temp@spread
+\newdimen\var@@temp@a
+\def\top@@skip@@limit{.7\topskip}
+\newdimen\flushend@@page@rule \flushend@@page@rule\z@
+\def\showcolsendrule{\global\flushend@@page@rule=.4\p@}
+% \end{macrocode}
+%
+% \begin{macro}{\top@@floatbox@min}\marg{float size}
+% This value is used to catch possible float on right column top.
+% \begin{macrocode}
+\gdef\top@@floatbox@min@default{4\topskip}
+\let\top@@floatbox@min\top@@floatbox@min@default
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
+\newbox\flushend@@varbox@a
+\newbox\flushend@@varbox@c
+\newbox\flushend@@tempbox@a
+\newbox\flushend@@tempbox@c
+\@ifundefined{@viper}{\newbox\@viper}{}
+\@ifundefined{hold@viper}{\newbox\hold@viper}{}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\newtoks\atColsBreak \atColsBreak={}
+\newtoks\atColsEnd \atColsEnd={}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\@ifundefined{fmt@box@adds}{\def\fmt@box@adds#1{#1}}{}
+\@ifundefined{fmt@vbox@adds}{\def\fmt@vbox@adds[#1]#2{#2}}{}
+% \end{macrocode}
+%
+% \begin{macro}{\remove@lastbox@at@balancing}
+% It is used to remove empty box at the right column end.
+% \begin{macrocode}
+\def\unskip@three@kern@penalty{%
+ \unskip\unkern\unpenalty
+ \unskip\unkern\unpenalty
+ \unskip\unkern\unpenalty
+ }
+\gdef\remove@lastbox@at@balancing{%
+ \unskip@three@kern@penalty
+ \if@remove@lastbox@at@balancing
+ \else
+ \expandafter\null
+ \fi
+ \bgroup
+ \setbox\z@\lastbox
+ \ifdim\wd\z@>\z@
+ \box\z@
+ \else
+ \aftergroup\unskip@three@kern@penalty
+ \fi
+ \egroup
+ }
+\def\set@split@topskip@to#1{%
+ \splittopskip#1\relax \vfuzz\maxdimen \vbadness\maxdimen
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% Macros used in debug mode.
+%
+% \begin{macrocode}
+\def\show@@box#1{%
+ \bgroup
+ \showboxbreadth=20000\showboxdepth=20000%
+ \showbox#1\relax
+ \egroup
+ }
+\def\wlog@balance@debug#1{\if@balance@debug \wlog{#1}\fi}
+\def\log@box@info#1{<box\the#1>(\the\ht#1+\the\dp#1)x\the\wd#1}
+\let\show@@box@next\@gobble
+% \end{macrocode}
+%
+% To get more or less proper result we need to know about footnotes at
+% the left column end, top floats at the right column top, skips and
+% so on. This part of the package is responsible for such analysis.
+%
+% \begin{macrocode}
+\gdef\analyze@lastbox@box#1{%
+ \setbox\flushend@@varbox@a\vbox{%
+ \unvbox#1%
+ \global\flushend@@lastskip@a\lastskip
+ \unskip
+ \global\var@@temp@a\lastkern
+ \unkern
+ \global\flushend@@penalty@a\lastpenalty
+ \unpenalty
+ \ifdim\lastskip>\z@
+ \global\flushend@@lastskip@a\lastskip
+ \fi
+ \unskip
+ \ifdim\lastkern>\z@
+ \global\var@@temp@a\lastkern
+ \fi
+ \unkern
+ \ifnum\lastpenalty>\z@
+ \global\flushend@@penalty@a\lastpenalty
+ \fi
+ \unpenalty
+ \global\setbox\flushend@@tempbox@a\lastbox
+ }%
+ \wlog@balance@debug{^^J::analyze@lastbox@box::\log@box@info{#1}%
+ ^^J ::unvbox: \log@box@info{\flushend@@varbox@a}%
+ ^^J::lastbox: \log@box@info{\flushend@@tempbox@a}%
+ ^^J::lastskip: \the\flushend@@lastskip@a;
+ lastkern: \the\var@@temp@a;
+ lastpenalty: \the\flushend@@penalty@a
+ }%
+ }
+% \end{macrocode}
+%
+% \begin{macro}{\analyze@leftcolumn@box}\marg{box}
+%
+% Fills:
+% \begin{itemize}
+% \item baselineskip skip from the last boxes to |\flushend@@lastskip@c|
+% \item leftcolumn height without the footnote to |\main@box@height|
+% \item footnote skip to |\main@box@skip|
+% \end{itemize}
+%
+% \begin{macrocode}
+\gdef\analyze@leftcolumn@box#1{%
+ \set@split@topskip@to\z@
+ \flushend@@lastskip@b\ht#1%
+ \wlog@balance@debug{^^Jmainbox: \log@box@info{#1}}%
+ \setbox\flushend@@varbox@a\vbox{%
+ \unvbox#1%
+ \global\flushend@@lastskip@a\lastskip
+ \unskip
+ \global\flushend@@lastkern@a\lastkern
+ \unkern
+ \global\flushend@@penalty@a\lastpenalty
+ \unpenalty
+ \global\setbox\flushend@@tempbox@a\lastbox
+ }%
+ \advance\flushend@@lastskip@b -\ht\flushend@@varbox@a
+ \advance\flushend@@lastskip@b -\ht\flushend@@tempbox@a
+ \wlog@balance@debug{.-box: \log@box@info{\flushend@@varbox@a}%
+ ^^J.-lastbox: \log@box@info{\flushend@@tempbox@a}%
+ ^^J.-lastskip: \the\flushend@@lastskip@a;
+ lastkern: \the\flushend@@lastkern@a;
+ lastpenalty: \the\flushend@@penalty@a
+ ^^J.-diff: \the\flushend@@lastskip@b
+ }%
+ \check@@footnoterule@@box\flushend@@tempbox@a\flushend@@lastskip@b\flushend@@varbox@a
+ \check@@baselineskip@@skip
+ \flushend@@lastskip@a
+ \flushend@@lastskip@b
+ \flushend@@lastskip@c
+ \ifx\check@@footnoterule@@box\check@@baselineskip@@skip
+ \else
+ \ifvoid\flushend@@tempbox@a
+ \ifdim\ht\flushend@@varbox@a>\topskip
+ \flushend@@lastskip@b\ht\flushend@@varbox@a
+ \var@@temp@a\ht\flushend@@varbox@a
+ \loop
+ \setbox\flushend@@tempbox@c\vsplit\flushend@@varbox@a to\var@@temp@a
+ \ifvoid\flushend@@varbox@a
+ \setbox\flushend@@varbox@a\vbox{\unvbox\flushend@@tempbox@c}%
+ \advance \var@@temp@a -3\p@
+ \else
+ \var@@temp@a=-1\p@
+ \fi
+ \ifdim \var@@temp@a>\z@
+ \repeat
+ \setbox\flushend@@varbox@a\vbox{\unvbox\flushend@@varbox@a}%
+ \setbox\flushend@@tempbox@c\vbox{\unvbox\flushend@@tempbox@c}%
+ \advance\flushend@@lastskip@b -\ht\flushend@@varbox@a
+ \advance\flushend@@lastskip@b -\ht\flushend@@tempbox@c
+ \wlog@balance@debug{..--box: \log@box@info{\flushend@@tempbox@c}%
+ ^^J..--lastbox: \log@box@info{\flushend@@varbox@a}%
+ ^^J..--diff: \the\flushend@@lastskip@b
+ }%
+ \check@@footnoterule@@box\flushend@@varbox@a\flushend@@lastskip@b
+ \flushend@@tempbox@c
+ \check@@baselineskip@@skip\flushend@@lastskip@a\flushend@@lastskip@b
+ \flushend@@lastskip@c
+ \ifx\check@@footnoterule@@box\check@@baselineskip@@skip
+ \else
+ \ifdim\ht\flushend@@varbox@a>.5\topskip
+ \analyze@lastbox@box\flushend@@varbox@a
+ \fi
+ \setbox\flushend@@varbox@a\vbox{\unvbox\flushend@@tempbox@c}%
+ \fi
+ \else
+ \wlog@balance@debug{lastbox: \log@box@info{\flushend@@varbox@a}}%
+ \fi
+ \fi
+ \ifdim\ht\flushend@@varbox@a>\topskip
+ \expandafter\analyze@leftcolumn@box\expandafter\flushend@@varbox@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{%
+ \set@split@topskip@to\z@
+ \setbox\flushend@@varbox@a\vbox{\strut
+ \vskip\z@
+ \footnoterule
+ \unskip\unkern\unpenalty
+ \unskip\unkern\unpenalty
+ }%
+ \setbox\flushend@@tempbox@c\vsplit\flushend@@varbox@a to\p@
+ \xdef\footnoterule@@box@@ht{\the\ht\flushend@@varbox@a}%
+ \xdef\footnoterule@@box@@dp{\the\dp\flushend@@varbox@a}%
+ \xdef\footnoterule@@box@@wd{\the\wd\flushend@@varbox@a}%
+ \wlog@balance@debug{:footnoterule: \log@box@info{\flushend@@varbox@a}}%
+ \setbox\flushend@@tempbox@c\vbox{\unvbox\flushend@@varbox@a}%
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \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@box@height|. Skip from text to
+% footnote define as |\main@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
+ \else
+ \xdef\main@box@height{\the\ht#3}%
+ \xdef\main@box@skip{\the#2}%
+ \wlog@balance@debug{^^J:footnoterule found:
+ main@box <ht=\main@box@height,
+ skip=\main@box@skip>
+ }%
+ \global\let\check@@footnoterule@@box\@gobblethree
+ \global\let\check@@baselineskip@@skip\reset@check@@baselineskip@@skip
+ \fi
+ \fi
+ \fi
+ \fi
+ }
+\let\initial@check@@footnoterule@@box\check@@footnoterule@@box
+% \end{macrocode}
+% \end{macro}
+%
+% \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%
+ \global\let\check@@baselineskip@@skip\@gobblethree
+ \fi
+ \fi
+ }
+\let\initial@check@@baselineskip@@skip\check@@baselineskip@@skip
+% \end{macrocode}
+%
+% In the case we found footnote it is necessary to look for the last skip
+% between text lines again. For that we use
+% |\reset@check@@baselineskip@@skip|. It activates |\check@@baselineskip@@skip|.
+%
+% \begin{macrocode}
+\def\reset@check@@baselineskip@@skip#1#2#3{%
+ \global#3=\z@
+ \global\let\check@@baselineskip@@skip\initial@check@@baselineskip@@skip
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\analyze@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@ht|
+% \item float skip to |\top@@floatbox@skip|
+% \item head skip to |\top@@section@skip|
+% \end{itemize}
+%
+% \begin{macrocode}
+\def\analyze@rightcolumn@box#1{%
+ \bgroup
+ \xdef\top@@floatbox@ht{\z@}%
+ \xdef\top@@floatbox@skip{\z@}%
+ \xdef\top@@section@skip{\z@}%
+ \set@split@topskip@to\z@
+ \setbox\flushend@@varbox@a\vbox{\strut
+ \vskip\z@
+ \unvcopy#1%
+ }%
+ \setbox\flushend@@tempbox@c\vsplit\flushend@@varbox@a to\p@
+ \wlog@balance@debug{^^J(R)mainbox: \log@box@info{#1}}%
+ \flushend@@lastskip@a\ht\flushend@@varbox@a
+ \advance\flushend@@lastskip@a\dp\flushend@@varbox@a
+ \ifdim\flushend@@lastskip@a>\z@
+ \analyze@nonempty@rightcolumn@box
+ \fi
+ \egroup
+ }
+\def\analyze@nonempty@rightcolumn@box{%
+ \bgroup
+ \var@@temp@a3\p@
+ \loop
+ \flushend@@lastskip@b\ht\flushend@@varbox@a
+ \advance\flushend@@lastskip@b\dp\flushend@@varbox@a
+ \setbox\flushend@@tempbox@c\vsplit\flushend@@varbox@a to\var@@temp@a
+ \ifvoid\flushend@@tempbox@c
+ \advance \var@@temp@a 3\p@
+ \ifdim\var@@temp@a>\flushend@@lastskip@b
+ \var@@temp@a=-1\p@
+ \fi
+ \else
+ \setbox\flushend@@tempbox@c\vbox{\unvbox\flushend@@tempbox@c}%
+ \ifdim\ht\flushend@@tempbox@c>\top@@floatbox@min
+ \advance\flushend@@lastskip@b -\ht\flushend@@tempbox@c
+ \advance\flushend@@lastskip@b -\dp\flushend@@tempbox@c
+ \advance\flushend@@lastskip@b -\ht\flushend@@varbox@a
+ \advance\flushend@@lastskip@b -\dp\flushend@@varbox@a
+ \xdef\top@@floatbox@skip{\the\flushend@@lastskip@b}%
+ \flushend@@lastskip@b\flushend@@lastskip@a
+ \advance\flushend@@lastskip@b -\ht\flushend@@varbox@a
+ \advance\flushend@@lastskip@b -\top@@floatbox@skip
+ \xdef\top@@floatbox@ht{\the\flushend@@lastskip@b}%
+ \var@@temp@a=3\p@
+ \else
+ \advance\flushend@@lastskip@b -\ht\flushend@@tempbox@c
+ \advance\flushend@@lastskip@b -\dp\flushend@@tempbox@c
+ \advance\flushend@@lastskip@b -\ht\flushend@@varbox@a
+ \advance\flushend@@lastskip@b -\dp\flushend@@varbox@a
+ \ifdim\ht\flushend@@tempbox@c>\topskip
+ \else
+ \xdef\top@@section@skip{\the\flushend@@lastskip@b}%
+ \fi
+ \var@@temp@a=-1\p@
+ \fi
+ \fi
+ \ifdim \var@@temp@a>\z@
+ \repeat
+ \ifvoid\flushend@@tempbox@c
+ \else
+ \ifdim\top@@section@skip>\z@
+ \else
+ \ifdim\ht\flushend@@tempbox@c>\z@
+ \setbox\flushend@@varbox@a\vbox{\unvbox\flushend@@tempbox@c}%
+ \fi
+ \flushend@@lastskip@b\ht\flushend@@varbox@a
+ \var@@temp@a=3\p@
+ \loop
+ \setbox\flushend@@tempbox@c\vsplit\flushend@@varbox@a to\var@@temp@a
+ \ifvoid\flushend@@tempbox@c
+ \advance \var@@temp@a 3\p@
+ \ifdim\var@@temp@a>\flushend@@lastskip@b
+ \var@@temp@a=-1\p@
+ \fi
+ \else
+ \ifdim\ht\flushend@@tempbox@c<\z@
+ \else
+ \var@@temp@a=-1\p@
+ \fi
+ \fi
+ \ifdim \var@@temp@a>\z@
+ \repeat
+ \loop
+ \setbox\flushend@@varbox@a\vbox{%
+ \unvbox\flushend@@tempbox@c
+ \unskip\unkern\unpenalty
+ \unskip\unkern\unpenalty
+ \unskip\unkern\unpenalty
+ \setbox\flushend@@tempbox@c\lastbox
+ }%
+ \flushend@@lastskip@b\ht\flushend@@varbox@a
+ \setbox\flushend@@varbox@a\vbox{%
+ \unvbox\flushend@@varbox@a
+ \unskip\unkern\unpenalty
+ \unskip\unkern\unpenalty
+ \unskip\unkern\unpenalty
+ }%
+ \advance\flushend@@lastskip@b -\ht\flushend@@varbox@a
+ \ifdim\flushend@@lastskip@b>\topskip
+ \xdef\top@@section@skip{\the\flushend@@lastskip@b}%
+ \fi
+ \ifdim\ht\flushend@@varbox@a>2\topskip
+ \setbox\flushend@@tempbox@c\vbox{\unvbox\flushend@@varbox@a}%
+ \repeat
+ \fi
+ \fi
+ \egroup
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\combine@columns@for@balance}
+%
+% 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\combine@columns@for@balance{%
+ \setbox\@outputbox\vbox{\strut
+ \vskip\z@
+ \unvbox\@outputbox
+ }%
+ \set@split@topskip@to\z@
+ \setbox\flushend@@tempbox@c\vsplit\@outputbox to\p@
+ \if@auto@baselineskip
+ %% Trying guess baselineskip value on column break
+ \ifdim\top@@floatbox@skip>\z@
+ \setbox\flushend@@tempbox@c\vsplit\@outputbox to\top@@floatbox@ht
+ \setbox\flushend@@tempbox@c\vbox{\unvbox\flushend@@tempbox@c}%
+ \fi
+ \setbox\@tempboxa\vbox{%
+ \unvbox\flushend@@varbox@a
+ \unskip\unkern\unpenalty
+ \vskip\flushend@@lastskip@c
+ \the\atColsBreak
+ \hrule\@height\flushend@@page@rule width\columnwidth
+ \ifdim\top@@section@skip>\top@@skip@@limit
+ \vskip\top@@section@skip
+ \fi
+ \unvbox\@outputbox
+ \remove@lastbox@at@balancing
+ \the\atColsEnd
+ }%
+ \ifdim\top@@floatbox@skip>\z@
+ \setbox\@outputbox\vbox{\unvbox\flushend@@tempbox@c}%
+ \fi
+ \else
+ %% Ignore baselineskip value on column break
+ \setbox\@tempboxa\vbox{%
+ \unvbox\@leftcolumn
+ \setbox\z@\lastbox
+ \unskip\unkern\unpenalty
+ \the\atColsBreak
+ \hrule\@height\flushend@@page@rule width\columnwidth
+ \unvbox\@outputbox
+ \remove@lastbox@at@balancing
+ \the\atColsEnd
+ }%
+ \fi
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\set@outputbox@with@footnote}
+%
+% Calculates break position and formats balanced columns in the |\@outputbox|
+% with footnotes.
+%
+% \begin{macrocode}
+\def\set@outputbox@with@footnote{%
+ %% footnote in left column
+ \@tempdimb\ht\@tempboxa
+ \ifdim\top@@floatbox@skip>\z@
+ \advance\@tempdimb \top@@floatbox@skip
+ \advance\@tempdimb \top@@floatbox@ht
+ \fi
+ \advance\@tempdimb \main@box@skip
+ \advance\@tempdimb \ht\@leftcolumn
+ \@tempdimb .5\@tempdimb
+ \advance\@tempdimb -\main@box@skip
+ \advance\@tempdimb -\ht\@leftcolumn
+ \set@split@topskip@to\topskip
+ \loop
+ \setbox\flushend@@varbox@a\copy\@tempboxa
+ \setbox\flushend@@tempbox@a\vsplit\flushend@@varbox@a to\@tempdimb
+ \setbox\flushend@@tempbox@c\vbox{\unvcopy\flushend@@tempbox@a}%
+ \ifdim\top@@floatbox@skip>\z@
+ \setbox\flushend@@varbox@c\vbox{%
+ \unvcopy\@outputbox
+ \vskip\top@@floatbox@skip
+ \unvbox\flushend@@varbox@a
+ }%
+ \else
+ \setbox\flushend@@varbox@c\vbox{\unvbox\flushend@@varbox@a}%
+ \fi
+ \var@@temp@spread=\ht\flushend@@tempbox@c
+ \advance\var@@temp@spread by\dp\flushend@@tempbox@c
+ \advance\var@@temp@spread \main@box@skip
+ \advance\var@@temp@spread \ht\@leftcolumn
+ \advance\var@@temp@spread by-\ht\flushend@@varbox@c
+ \advance\var@@temp@spread by-\dp\flushend@@varbox@c
+ \wlog@balance@debug{Left x: \the\ht\flushend@@tempbox@a
+ +\the\dp\flushend@@tempbox@a=\the\ht\flushend@@varbox@a
+ +\the\dp\flushend@@varbox@a::\the\@tempdimb
+ ^^JLeft 0: \the\ht\flushend@@tempbox@c
+ +\the\dp\flushend@@tempbox@c::\the\@tempdimb
+ ^^JRight x: \the\ht\flushend@@varbox@c
+ +\the\dp\flushend@@varbox@c=\the\ht\flushend@@varbox@a
+ +\the\dp\flushend@@varbox@a::\the\@tempdimb
+ ^^JExtra height:\the\var@@temp@spread\space when \the\@tempdimb
+ }%
+ \ifdim\var@@temp@spread<\z@
+ \advance\@tempdimb 1\p@
+ \repeat
+ \flushend@@lastskip@a\the\ht\flushend@@tempbox@c
+ \advance\flushend@@lastskip@a \main@box@skip
+ \advance\flushend@@lastskip@a \ht\@leftcolumn
+ \flushend@@lastskip@b\the\@tempdimb
+ \setbox\flushend@@tempbox@a\vsplit\@tempboxa to\@tempdimb
+ \setbox\@leftcolumn\vbox to\@tempdima{%
+ \vbox to \flushend@@lastskip@a{%
+ \unvbox\flushend@@tempbox@a
+ \vskip\main@box@skip
+ \unvbox\@leftcolumn
+ \vss
+ }%
+ \hrule\@height\flushend@@page@rule width\textwidth
+ \vss
+ }%
+ \global\ht\@leftcolumn=\the\@tempdima
+ \wlog{- LAST -%
+ ^^JExtra skip:\the\var@@temp@spread
+ ^^JLeft:\the\ht\@leftcolumn/\the\dp\@leftcolumn
+ ^^JRight:\the\ht\@tempboxa/\the\dp\@tempboxa
+ ^^JOutput:\the\@tempdimb
+ }%
+ \ifdim\top@@floatbox@skip>\z@
+ \setbox\@outputbox\vbox to\@tempdima{%
+ \if@right@column@spread
+ \vbox spread\var@@temp@spread{%
+ \unvbox\@outputbox
+ \vskip\top@@floatbox@skip
+ \unvbox\@tempboxa
+ }%
+ \else
+ \vbox spread\var@@temp@spread{%
+ \unvbox\@outputbox
+ \vskip\top@@floatbox@skip
+ \unvbox\@tempboxa
+ \vss
+ }%
+ \fi
+ \vss
+ }%
+ \else
+ \setbox\@outputbox\vbox to\@tempdima{%
+ \if@right@column@spread
+ \vbox spread\var@@temp@spread{%
+ \unvbox\@tempboxa
+ }%
+ \else
+ \vbox spread\var@@temp@spread{%
+ \unvbox\@tempboxa
+ \vss
+ }%
+ \fi
+ \vss
+ }%
+ \fi
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\set@outputbox@without@footnote}
+%
+% Calculates break position and formats balanced columns in the |\@outputbox|
+% without footnotes.
+%
+% \begin{macrocode}
+\def\set@outputbox@without@footnote{%
+ %% no footnote in left column
+ \@tempdimb \ht\@tempboxa
+ \ifdim\top@@floatbox@skip>\z@
+ \advance\@tempdimb \top@@floatbox@skip
+ \advance\@tempdimb \top@@floatbox@ht
+ \fi
+ \@tempdimb .5\@tempdimb
+ \set@split@topskip@to\topskip
+ \loop
+ \setbox\flushend@@varbox@a\copy\@tempboxa
+ \setbox\flushend@@tempbox@a\vsplit\flushend@@varbox@a to\@tempdimb
+ \setbox\flushend@@tempbox@c\vbox{\unvcopy\flushend@@tempbox@a}%
+ \ifdim\top@@floatbox@skip>\z@
+ \setbox\flushend@@varbox@c\vbox{%
+ \unvcopy\@outputbox
+ \vskip\top@@floatbox@skip
+ \unvbox\flushend@@varbox@a
+ }%
+ \else
+ \setbox\flushend@@varbox@c\vbox{\unvbox\flushend@@varbox@a}%
+ \fi
+ \var@@temp@spread=\ht\flushend@@tempbox@c
+ \advance\var@@temp@spread by\dp\flushend@@tempbox@c
+ \advance\var@@temp@spread by-\ht\flushend@@varbox@c
+ \advance\var@@temp@spread by-\dp\flushend@@varbox@c
+ \wlog@balance@debug{Left x: \the\ht\flushend@@tempbox@a
+ +\the\dp\flushend@@tempbox@a=\the\ht\flushend@@varbox@a
+ +\the\dp\flushend@@varbox@a::\the\@tempdimb
+ ^^JLeft 0: \the\ht\flushend@@tempbox@c
+ +\the\dp\flushend@@tempbox@c::\the\@tempdimb
+ ^^JRight x: \the\ht\flushend@@varbox@c
+ +\the\dp\flushend@@varbox@c=\the\ht\flushend@@varbox@a
+ +\the\dp\flushend@@varbox@a::\the\@tempdimb
+ ^^JExtra height:\the\var@@temp@spread\space when \the\@tempdimb
+ }%
+ \ifdim\var@@temp@spread<\z@ \advance\@tempdimb 1\p@ \repeat
+ \wlog{- LAST -%
+ ^^JExtra skip:\the\var@@temp@spread
+ ^^JLeft:\the\ht\flushend@@tempbox@c/\the\dp\flushend@@tempbox@c
+ ^^JRight:\the\ht\flushend@@varbox@c/\the\dp\flushend@@varbox@c
+ ^^JOutput:\the\@tempdimb
+ }%
+ \setbox\flushend@@tempbox@c\vsplit\@tempboxa to\@tempdimb
+ \setbox\flushend@@varbox@c\vbox{\unvbox\flushend@@tempbox@c}%
+ \setbox\@leftcolumn\vbox to\@tempdima{%
+ \vbox to\@tempdimb{\unvbox\flushend@@varbox@c\vss}%
+ \hrule\@height\flushend@@page@rule width\textwidth
+ \vss
+ }%
+ \global\ht\@leftcolumn=\the\@tempdima
+ \ifdim\top@@floatbox@skip>\z@
+ \setbox\@outputbox\vbox to\@tempdima{%
+ \if@right@column@spread
+ \vbox spread\var@@temp@spread{%
+ \unvbox\@outputbox
+ \vskip\top@@floatbox@skip
+ \unvbox\@tempboxa
+ }%
+ \else
+ \vbox spread\var@@temp@spread{%
+ \unvbox\@outputbox
+ \vskip\top@@floatbox@skip
+ \unvbox\@tempboxa
+ \vss
+ }%
+ \fi
+ \vss
+ }%
+ \else
+ \setbox\@outputbox\vbox to\@tempdima{%
+ \if@right@column@spread
+ \vbox spread\var@@temp@spread{%
+ \unvbox\@tempboxa
+ }%
+ \else
+ \vbox spread\var@@temp@spread{%
+ \unvbox\@tempboxa
+ \vss
+ }%
+ \fi
+ \vss
+ }%
+ \fi
+ }
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\last@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@outputdblcol@modern{%
+ \if@firstcolumn
+ \global \@firstcolumnfalse
+ \global \setbox\@leftcolumn \box\@outputbox
+ \else
+ \global \@firstcolumntrue
+ \@tempdima\ht\@leftcolumn
+ \set@split@topskip@to\topskip
+ \var@@temp@spread=\wd\@outputbox
+ \get@@footnoterule@@box
+ \xdef\main@box@height{\the\ht\@leftcolumn}%
+ \xdef\main@box@skip{\z@}%
+ \global\flushend@@lastskip@c\z@
+ \setbox\flushend@@varbox@a\vbox{\unvcopy\@leftcolumn}%
+ \analyze@leftcolumn@box\flushend@@varbox@a
+ \setbox\flushend@@varbox@a\vbox{\unvcopy\@outputbox}%
+ \analyze@rightcolumn@box\flushend@@varbox@a
+ \ifdim\main@box@skip>\z@
+ %% footnote in left column
+ \set@split@topskip@to\z@
+ \setbox\flushend@@varbox@a\vsplit\@leftcolumn to\main@box@height
+ \else
+ %% no footnote in left column
+ \setbox\flushend@@varbox@a\box\@leftcolumn
+ \fi
+ \ifdim\var@@temp@spread>\z@
+ %% rightcolumn non empty
+ \combine@columns@for@balance
+ \else
+ %% rightcolumn empty
+ \setbox\@tempboxa\vbox{%
+ \unvbox\flushend@@varbox@a
+ \remove@lastbox@at@balancing
+ \the\atColsEnd
+ }%
+ \fi
+ \ifdim\main@box@skip>\z@
+ %% footnote in left column
+ \set@outputbox@with@footnote
+ \else
+ %% no footnote in left column
+ \set@outputbox@without@footnote
+ \fi
+ \setbox\@outputbox \vbox {%
+ \hb@xt@\textwidth {%
+ \hb@xt@\columnwidth {%
+ \fmt@box@adds{\box\@leftcolumn}\hss}%
+ \hfil
+ \vrule \@width\columnseprule
+ \hfil
+ \hb@xt@\columnwidth {%
+ \fmt@box@adds{\box\@outputbox}\hss}%
+ }%
+ }%
+ \global\let\@outputdblcol\saved@orig@@outputdblcol
+ \global\atColsEnd{}%
+ \ifvoid\hold@viper
+ \else
+ \setbox\@outputbox\vbox{\box\hold@viper\box\@outputbox}%
+ \fi
+ \@combinedblfloats
+ \@outputpage
+ \begingroup
+ \@dblfloatplacement
+ \@startdblcolumn
+ \@whilesw\if@fcolmade\fi
+ {\@outputpage\@startdblcolumn}%
+ \ifvoid\@viper
+ \else
+ \global\setbox\@viper\vbox{%
+ \vskip-\stripsep
+ \unvbox\@viper
+ }%
+ \csname @viperoutput\endcsname
+ \fi
+ \endgroup
+ \fi
+ }
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\last@outputdblcol@old}
+%
+% Columns balancing of the twocolumn mode page (ancient algorithm).
+% It is maybe not so good in some cases but maybe more safe for text
+% moving or missing at all.
+%
+% \begin{macrocode}
+\def\last@outputdblcol@ancient{%
+ \if@firstcolumn
+ \global\@firstcolumnfalse
+ \global\setbox\@leftcolumn\box\@outputbox
+ \else
+ \global\@firstcolumntrue
+ \@tempdima\ht\@leftcolumn
+ \set@split@topskip@to\topskip
+ \if@auto@baselineskip
+ \setbox\@tempboxa\vbox{%
+ \unvcopy\@leftcolumn
+ \global\flushend@@lastskip@c\lastskip
+ \global\flushend@@lastskip@b\lastskip
+ \loop
+ \global\flushend@@lastskip@a\flushend@@lastskip@b
+ \unskip\unpenalty
+ \global\flushend@@lastskip@b\lastskip
+ \global\advance\flushend@@lastskip@c by\lastskip
+ \ifdim\flushend@@lastskip@b=-\flushend@@lastskip@a
+ \global\advance\flushend@@lastskip@c by-\lastskip
+ \else
+ \repeat
+ \ifdim\flushend@@lastskip@b=-\flushend@@lastskip@a
+ \ifdim\flushend@@lastskip@b=\z@
+ \setbox\flushend@@varbox@a\lastbox
+ \global\advance\flushend@@lastskip@c by\ht\flushend@@varbox@a
+ \global\advance\flushend@@lastskip@c by\lastskip
+ \unskip\unpenalty
+ \setbox\flushend@@varbox@a\lastbox
+ \global\advance\flushend@@lastskip@c by\dp\flushend@@varbox@a
+ \else
+ \global\flushend@@lastskip@c\lastskip
+ \global\advance\flushend@@lastskip@c by\topskip
+ \fi
+ \fi
+ \global\advance\flushend@@lastskip@c by-\topskip
+ }%
+ \setbox\@tempboxa\vbox{%
+ \unvbox\@leftcolumn
+ \unskip\unpenalty
+ \vskip\flushend@@lastskip@c
+ \hrule\@height\flushend@@page@rule width\columnwidth
+ \the\atColsBreak
+ \unvbox\@outputbox
+ \remove@lastbox@at@balancing
+ \the\atColsEnd
+ }%
+ \else
+ \setbox\@tempboxa\vbox{%
+ \unvbox\@leftcolumn
+ \setbox\z@\lastbox
+ \unskip
+ \hrule\@height\flushend@@page@rule width\columnwidth
+ \the\atColsBreak
+ \unvbox\@outputbox
+ \remove@lastbox@at@balancing
+ \the\atColsEnd
+ }%
+ \fi
+ \@tempdimb .5\ht\@tempboxa
+ \loop
+ \setbox\flushend@@tempbox@a\copy\@tempboxa
+ \setbox\flushend@@tempbox@c\vbox to\@tempdimb{%
+ \vsplit\flushend@@tempbox@a to\@tempdimb
+ \vss
+ \vsplit\flushend@@tempbox@a to\@tempdimb
+ }%
+ \wlog{Extra height:\the\ht\flushend@@tempbox@a\space when \the\@tempdimb}%
+ \ifvoid\flushend@@tempbox@a
+ \else
+ \advance\@tempdimb 1\p@
+ \repeat
+ \loop
+ \setbox\flushend@@tempbox@a\copy\@tempboxa
+ \setbox\flushend@@tempbox@c\vbox to\@tempdimb{%
+ \vsplit\flushend@@tempbox@a to\@tempdimb
+ \vss
+ }%
+ \wlog{(2)Left:\the\ht\flushend@@tempbox@c\space
+ Right:\the\ht\flushend@@tempbox@a\space
+ Output:\the\@tempdimb
+ }%
+ \ifdim\ht\flushend@@tempbox@c<\ht\flushend@@tempbox@a
+ \@tempdimb=\the\ht\flushend@@tempbox@a
+ \repeat
+ \wlog{- LAST -^^JExtra skip: \the\z@
+ ^^JLeft:\the\ht\flushend@@tempbox@c
+ ^^JRight:\the\ht\flushend@@tempbox@a
+ ^^JOutput:\the\@tempdimb
+ }%
+ \setbox\flushend@@tempbox@c\vbox to\@tempdimb{%
+ \vsplit\@tempboxa to\@tempdimb
+ \vss
+ }%
+ \setbox\@leftcolumn\vbox to\@tempdima{%
+ \fmt@vbox@adds[\columnwidth]{%
+ \vbox to\@tempdimb{%
+ \unvbox
+ \flushend@@tempbox@c
+ }%
+ }%
+ \hrule\@height\flushend@@page@rule
+ \vss
+ }%
+ \setbox\@outputbox\vbox to\@tempdima{%
+ \fmt@vbox@adds[\columnwidth]{%
+ \vbox to\@tempdimb{%
+ \unvbox\@tempboxa
+ \vskip\z@
+ }%
+ }%
+ \hrule\@height\flushend@@page@rule
+ \vss
+ }%
+ \setbox\@outputbox\vbox{%
+ \hb@xt@\textwidth{%
+ \hb@xt@\columnwidth{\box\@leftcolumn\hss}%
+ \hfil
+ \vrule \@width\columnseprule
+ \hfil
+ \hb@xt@\columnwidth{\box\@outputbox\hss}%
+ }%
+ }%
+ \global\let\@outputdblcol\saved@orig@@outputdblcol
+ \global\atColsEnd{}%
+ \ifvoid\hold@viper
+ \else
+ \setbox\@outputbox\vbox{\box\hold@viper\box\@outputbox}%
+ \fi
+ \@combinedblfloats
+ \@outputpage
+ \begingroup
+ \@dblfloatplacement
+ \@startdblcolumn
+ \@whilesw\if@fcolmade\fi
+ {\@outputpage\@startdblcolumn}%
+ \ifvoid\@viper
+ \else
+ \global\setbox\@viper\vbox{%
+ \vskip-\stripsep
+ \unvbox\@viper
+ }%
+ \csname @viperoutput\endcsname
+ \fi
+ \endgroup
+ \fi
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% Adds default balancing of the last page at the end of document.
+%
+% \begin{macrocode}
+\usepackage{etoolbox}
+\AtBeginDocument{%
+ \global\let\saved@orig@@outputdblcol\@outputdblcol
+ \if@ancient@balance@version
+ \global\let\last@outputdblcol\last@outputdblcol@ancient
+ \else
+ \global\let\last@outputdblcol\last@outputdblcol@modern
+ \fi
+ \global\let\balanced@@outputdblcol\last@outputdblcol
+ \preto\enddocument{\let\@outputdblcol\balanced@@outputdblcol}%
+ \appto\footnoterule{\vskip\z@}%
+ }
+% \end{macrocode}
+%
+% 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@outputdblcol}
+% \end{macrocode}
+%
+% \cs{raggedcolsend} is used to switch off column balancing on the current page.
+%
+% \begin{macrocode}
+\def\raggedcolsend{\global\let\@outputdblcol\saved@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@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@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@balance@debug
+ \showcolsendrule
+\fi
+% \end{macrocode}
+%
+% \iffalse
+%</package>
+% \fi
+%
+% \Finale
diff --git a/macros/latex/contrib/sttools/flushend.pdf b/macros/latex/contrib/sttools/flushend.pdf
new file mode 100644
index 0000000000..00a66aa208
--- /dev/null
+++ b/macros/latex/contrib/sttools/flushend.pdf
Binary files differ
diff --git a/macros/latex/contrib/sttools/midfloat.dtx b/macros/latex/contrib/sttools/midfloat.dtx
new file mode 100644
index 0000000000..ba2f7d5872
--- /dev/null
+++ b/macros/latex/contrib/sttools/midfloat.dtx
@@ -0,0 +1,393 @@
+% \iffalse meta-comment
+%
+% Copyright (C) 2012 by Sigitas Tolu\v{s}is <sigitas@vtex.lt>
+% ---------------------------------------------------------------------------
+% This work may be distributed and/or modified under the
+% conditions of the LaTeX Project Public License, either version 1.3
+% of this license or (at your option) any later version.
+% The latest version of this license is in
+% http://www.latex-project.org/lppl.txt
+% and version 1.3 or later is part of all distributions of LaTeX
+% version 2005/12/01 or later.
+%
+% This work has the LPPL maintenance status `maintained'.
+%
+% The Current Maintainer of this work is Sigitas Tolu\v{s}is.
+%
+% This work consists of the files midfloat.dtx and midfloat.ins
+% and the derived filebase midfloat.sty.
+%
+% \fi
+%
+% \iffalse
+%<*driver>
+\ProvidesFile{midfloat.dtx}
+%</driver>
+%<*package>
+%% Copyright (C) 1997-2012 by Sigitas Tolu\v{s}is <sigitas@vtex.lt>
+%% VTeX Ltd., Akademijos 4, Vilnius, Lithuania
+%% http://www.vtex.lt/tex/download/macros/
+%% --------------------------------------------------------------------------
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3
+%% of this license or (at your option) any later version.
+%% The latest version of this license is in
+%% http://www.latex-project.org/lppl.txt
+%% and version 1.3 or later is part of all distributions of LaTeX
+%% version 2005/12/01 or later.
+%%
+%% PURPOSE: Insert some material in full-width on double-column page.
+%%
+%</package>
+%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
+%<package>\ProvidesPackage{midfloat}
+%<*package>
+ [2012/05/29 v1.1 Insert some material in full-width on double-column page]
+%</package>
+%
+%<*driver>
+\documentclass{ltxdoc}
+\usepackage{midfloat}[2012/05/29]
+\EnableCrossrefs
+\CodelineIndex
+\RecordChanges
+\begin{document}
+ \DocInput{midfloat.dtx}
+ \PrintChanges
+ \PrintIndex
+\end{document}
+%</driver>
+% \fi
+%
+% \CheckSum{439}
+%
+% \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
+% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
+% Digits \0\1\2\3\4\5\6\7\8\9
+% Exclamation \! Double quote \" Hash (number) \#
+% Dollar \$ Percent \% Ampersand \&
+% Acute accent \' Left paren \( Right paren \)
+% Asterisk \* Plus \+ Comma \,
+% Minus \- Point \. Solidus \/
+% Colon \: Semicolon \; Less than \<
+% Equals \= Greater than \> Question mark \?
+% Commercial at \@ Left bracket \[ Backslash \\
+% Right bracket \] Circumflex \^ Underscore \_
+% Grave accent \` Left brace \{ Vertical bar \|
+% Right brace \} Tilde \~}
+%
+%
+% \changes{v1.0}{1997/10/01}{some names}
+% \changes{v1.1}{2012/05/29}{Converted to DTX file}
+%
+% \DoNotIndex{\newcommand,\newenvironment}
+%
+% \providecommand*{\url}{\texttt}
+% \GetFileInfo{midfloat.dtx}
+% \title{The \textsf{midfloat} package}
+% \author{Sigitas Tolu\v{s}is \\ \url{sigitas@vtex.lt}}
+% \date{\fileversion~from \filedate}
+%
+% \maketitle
+%
+% \section{Introduction}
+%
+% It is denoted to place some material (from the left column)
+% in full-width at any place (but not at the top) on double-column
+% page (|\twocolumn| mode). Existing text remains as it was before
+% insert. Placement is restricted to one page. (It is some kind of
+% dbfloat intext).
+%
+% \section{Usage}
+%
+% \DescribeMacro{strip}
+% Provides new environment:
+%
+% \begin{verbatim}
+% \begin{strip}[<top strip stretch skip>/<bottom strip skip>]
+% <wide onecolumn material>
+% \end{strip}
+% \end{verbatim}
+%
+% Puts |\vbox|\marg{wide onecolumn material} in full-width on
+% double-column page.
+%
+% \medskip
+% Adds |\stripsep| glue before and after (by default: |15pt|).
+%
+% \medskip
+% It can be problems with floats and footnotes. In the case of
+% problems with footnotes it is possible to correct the situation
+% using commands |\footnotemark| and |\footnotetext|.
+%
+% \medskip
+% Parameters \meta{top strip stretch skip} and \meta{bottom strip skip} are optional.
+% By default \meta{top strip stretch skip}|=0pt| and \meta{bottom strip skip}|=0pt|.
+% The material on the right column under strip is stretched down
+% by \meta{top strip stretch skip} and below strip is moved down by \meta{bottom strip skip}.
+%
+%
+% \StopEventually{}
+%
+% \section{Implementation}
+%
+% \iffalse
+%<*package>
+% \fi
+%
+%
+% \begin{macrocode}
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{midfloat}[1997/10/01]
+% \end{macrocode}
+%
+% \begin{macrocode}
+\newif\if@vihproof \@vihprooftrue
+\newtoks\juo@sar \juo@sar={}
+\@ifundefined{stripsep}{\newskip\stripsep \stripsep 15\p@}{}
+\newskip\m@addvipersep \m@addvipersep\z@
+\newskip\c@addvipersep \c@addvipersep\z@
+\newdimen\ht@strip
+\newdimen\right@cor
+\newdimen\cor@height \cor@height=\z@
+\newdimen\juo@pr
+\newdimen\juo@ht
+\newdimen\c@colht
+\newbox\@viper
+\newbox\@rightcolumn
+\newcount\juo@sk
+\def\@ca#1#2#3#4{}
+% \end{macrocode}
+%
+% \begin{macro}{\add@strip}
+% \begin{macrocode}
+\def\add@strip#1#2#3#4{%
+ \begingroup
+ \xdef\ex@{\global\noexpand\juo@sar{\the\juo@sar\noexpand\@ca{#1}{#2}{#3}{#4}}}%
+ \ex@
+ \endgroup
+ }
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\remove@strip}
+% \begin{macrocode}
+\def\remove@strip#1{\ifx#1\@empty\global\juo@sk=0\else
+ \global\advance\juo@sk by-1\expandafter\next@item\the #1\@@#1\fi}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\next@item}
+% \begin{macrocode}
+\def\next@item \@ca #1#2#3#4#5\@@#6{\global #6={#5}\global\juo@pr=#1\global\juo@ht=#2%
+\global\cor@height=#3\global\m@addvipersep=#4}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\strip}
+% \begin{macrocode}
+\def\strip{\@ifnextsymb[{\@strip}{\@strip[0pt/0pt]}}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\@strip}
+% \begin{macrocode}
+\def\@strip[#1/#2]{\global\@tempdima=#1\global\@tempdimb=#2%
+ \global \setbox\@viper\vbox\bgroup%
+ \hsize\textwidth
+ \@parboxrestore
+ \col@number \@ne
+ \vrule height\topskip width0pt depth0pt
+}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\endstrip}
+% \begin{macrocode}
+\def\endstrip{%
+ \egroup
+ \if@firstcolumn
+ \ifdim\pagetotal>\z@
+ \vskip\stripsep
+ \global\ht@strip\pagegoal
+ \global\advance\ht@strip by-\pagetotal
+ \global\advance\ht@strip by-\stripsep
+ \global\advance\ht@strip by-\ht\@viper
+ \global\advance\ht@strip by-\stripsep
+ \global\juo@ht=\ht\@viper
+ \else
+ \global\ht@strip\z@
+ \fi
+ \ifdim\ht@strip>\z@
+ \unvbox\@viper
+ \vskip\stripsep
+ \add@strip{\the\pagetotal}{\the\juo@ht}{\the\@tempdima}{\the\@tempdimb}%
+ \global\advance\juo@sk by1
+ \else
+ \@latex@error{Strip needs more place!}\@ehc
+ \if@vihproof
+ \framebox[\columnwidth]{??? Strip ???}%
+ \fi
+ \fi
+ \else
+ \@latex@error{Strip is used only on left column!}\@ehc
+ \if@vihproof
+ \framebox[\columnwidth]{??? Strip ???}%
+ \fi
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\@outputdblcol}
+% \begin{macrocode}
+\def\@outputdblcol{%
+ \if@firstcolumn
+ \global \@firstcolumnfalse
+ \global \setbox\@leftcolumn \box\@outputbox
+ \global\c@colht\@colht\global\c@addvipersep\z@
+ \ifnum\juo@sk>0
+ \remove@strip\juo@sar
+ \global\@colht\the\juo@pr
+ \ifdim\right@cor>\z@
+ \global\advance\@colht by\right@cor
+ \fi
+ \global\advance\@colht by\cor@height
+ \global\cor@height=0pt
+ \fi
+ \global \setbox\@rightcolumn \vbox{}%
+ \else
+ \ifdim\c@colht>\@colht
+ \@tempdima\@colht
+ \ifdim\@colht>\z@
+ \global\setbox\@rightcolumn \vbox{%
+ \unvbox\@rightcolumn
+ \vbox to\@tempdima{%
+ \vskip\c@addvipersep\unvbox\@outputbox}%
+ \vskip\stripsep
+ \vrule height\the\juo@ht width 0pt depth 0pt
+ \vskip\stripsep
+ }%
+ \global\c@addvipersep\m@addvipersep
+ \else
+ \global\setbox\@rightcolumn \vbox{%
+ \unvbox\@rightcolumn
+ \vrule height\the\juo@ht width 0pt depth 0pt
+ \vskip\stripsep
+ }%
+ \fi
+ \ifnum\juo@sk>0
+ \remove@strip\juo@sar
+ \global\@colht\the\juo@pr
+ \global\advance\@colht by -\ht\@rightcolumn
+ \global\advance\@colht by\cor@height
+ \global\cor@height=0pt
+ \else
+ \global\advance\c@colht by-\ht\@rightcolumn
+ \global\@colht\c@colht
+ \fi
+ \else
+ \global \@firstcolumntrue
+ \global\setbox\@outputbox\vbox to\ht\@leftcolumn{%
+ \unvbox\@rightcolumn
+ \vskip\c@addvipersep
+ \unvbox\@outputbox
+ }%
+ \setbox\@outputbox \vbox {%
+ \hb@xt@\textwidth {%
+ \hb@xt@\columnwidth {%
+ \box\@leftcolumn \hss}%
+ \hfil
+ \vrule \@width\columnseprule
+ \hfil
+ \hb@xt@\columnwidth {%
+ \box\@outputbox \hss}%
+ }%
+ }%
+ \@combinedblfloats
+ \@outputpage
+ \begingroup
+ \@dblfloatplacement
+ \@startdblcolumn
+ \@whilesw\if@fcolmade \fi
+ {\@outputpage
+ \@startdblcolumn}%
+ \endgroup
+ \global\juo@sk=0\global\juo@sar={}%
+ \global\cor@height\z@\global\c@addvipersep\z@
+ \fi
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\@cflt}
+% \begin{macrocode}
+\def \@cflt{%
+ \let \@elt \@comflelt
+ \setbox\@tempboxa \vbox{}%
+ \@toplist
+ \global\right@cor\ht\@tempboxa
+ \ifdim\right@cor>\z@
+ \global\advance\right@cor by-\floatsep
+ \global\advance\right@cor by\textfloatsep
+ \fi
+ \setbox\@outputbox \vbox{%
+ \boxmaxdepth \maxdepth
+ \unvbox\@tempboxa
+ \vskip -\floatsep
+ \topfigrule
+ \vskip \textfloatsep
+ \unvbox\@outputbox
+ }%
+ \let\@elt\relax
+ \xdef\@freelist{\@freelist\@toplist}%
+ \global\let\@toplist\@empty
+}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\@ifnextsymb}
+% \begin{macrocode}
+\def\@ifnextsymb#1#2#3{%
+ \let\reserved@d=#1%
+ \def\reserved@a{#2}\def\reserved@b{#3}%
+ \futurelet\@let@token\@ifnsymb}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\@ifnsymb}
+% \begin{macrocode}
+\def\@ifnsymb{%
+ \ifx\@let@token\@sptoken
+ \let\reserved@c\reserved@b
+ \else
+ \ifx\@let@token\reserved@d
+ \let\reserved@c\reserved@a
+ \else
+ \let\reserved@c\reserved@b
+ \fi
+ \fi
+ \reserved@c}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
+%\endinput
+% \end{macrocode}
+%%
+% \iffalse
+%</package>
+% \fi
+%
+% \Finale
diff --git a/macros/latex/contrib/sttools/midfloat.pdf b/macros/latex/contrib/sttools/midfloat.pdf
new file mode 100644
index 0000000000..ea76eb2737
--- /dev/null
+++ b/macros/latex/contrib/sttools/midfloat.pdf
Binary files differ
diff --git a/macros/latex/contrib/sttools/stabular.dtx b/macros/latex/contrib/sttools/stabular.dtx
new file mode 100644
index 0000000000..f8044720b1
--- /dev/null
+++ b/macros/latex/contrib/sttools/stabular.dtx
@@ -0,0 +1,263 @@
+% \iffalse meta-comment
+%
+% Copyright (C) 2014 by Sigitas Tolu\v{s}is <sigitas@vtex.lt>
+% ---------------------------------------------------------------------------
+% This work may be distributed and/or modified under the
+% conditions of the LaTeX Project Public License, either version 1.3
+% of this license or (at your option) any later version.
+% The latest version of this license is in
+% http://www.latex-project.org/lppl.txt
+% and version 1.3 or later is part of all distributions of LaTeX
+% version 2005/12/01 or later.
+%
+% This work has the LPPL maintenance status `maintained'.
+%
+% The Current Maintainer of this work is Sigitas Tolu\v{s}is.
+%
+% This work consists of the files stabular.dtx and stabular.ins
+% and the derived filebase stabular.sty.
+%
+% \fi
+%
+% \iffalse
+%<*driver>
+\ProvidesFile{stabular.dtx}
+%</driver>
+%<*package>
+%% Copyright (C) 1998-2014 by Sigitas Tolu\v{s}is <sigitas@vtex.lt>
+%% VTeX Ltd., Akademijos 4, Vilnius, Lithuania
+%% http://www.vtex.lt/tex/download/macros/
+%% --------------------------------------------------------------------------
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3
+%% of this license or (at your option) any later version.
+%% The latest version of this license is in
+%% http://www.latex-project.org/lppl.txt
+%% and version 1.3 or later is part of all distributions of LaTeX
+%% version 2005/12/01 or later.
+%%
+%% PURPOSE: Improve tabular environment.
+%%
+%</package>
+%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
+%<package>\ProvidesPackage{stabular}
+%<*package>
+ [2014/03/20 v2.0 Improve tabular environment]
+%</package>
+%
+%<*driver>
+\documentclass{ltxdoc}
+\usepackage{stabular}[2014/03/20]
+\EnableCrossrefs
+\CodelineIndex
+\RecordChanges
+\begin{document}
+ \DocInput{stabular.dtx}
+ %%\PrintChanges
+ %%\PrintIndex
+\end{document}
+%</driver>
+% \fi
+%
+% \CheckSum{239}
+%
+% \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
+% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
+% Digits \0\1\2\3\4\5\6\7\8\9
+% Exclamation \! Double quote \" Hash (number) \#
+% Dollar \$ Percent \% Ampersand \&
+% Acute accent \' Left paren \( Right paren \)
+% Asterisk \* Plus \+ Comma \,
+% Minus \- Point \. Solidus \/
+% Colon \: Semicolon \; Less than \<
+% Equals \= Greater than \> Question mark \?
+% Commercial at \@ Left bracket \[ Backslash \\
+% Right bracket \] Circumflex \^ Underscore \_
+% Grave accent \` Left brace \{ Vertical bar \|
+% Right brace \} Tilde \~}
+%
+%
+% \changes{v1.1}{2012/05/29}{Converted to DTX file}
+% \changes{v1.2}{2014/01/13}{Fixed bug in the '@sarray' macro}
+% \changes{v2.0}{2014/03/20}{Minimized code and extra functionality}
+%
+% \DoNotIndex{\newcommand,\newenvironment}
+%
+% \providecommand*{\url}{\texttt}
+% \GetFileInfo{stabular.dtx}
+% \title{The \textsf{stabular} package}
+% \author{Sigitas Tolu\v{s}is \\ \url{sigitas@vtex.lt}}
+% \date{\fileversion~from \filedate}
+%
+% \maketitle
+%
+% \section{Introduction}
+%
+% \textbf{Purpose}: improve tabular environment by allowing page break.
+%
+% \section{Usage}
+%
+% Just insert |\noalign{\eject}| after command |\\| to do a page break inside
+% |stabular| environment.
+%
+% \DescribeMacro{stabular}
+% \DescribeMacro{stabular*}
+% Provides new environments: |stabular| and |stabular*|.
+% It is one more multi-page version of tabular.
+%
+% \subsection{Package options}
+%
+% \DescribeMacro{array}
+% \indent It is used to support tabular environment defined in array
+% package.
+%
+% \StopEventually{}
+%
+% \section{Implementation}
+%
+% \iffalse
+%<*package>
+% \fi
+%
+%
+% \begin{macrocode}
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{stabular}[2014/03/20]
+% \end{macrocode}
+%
+%
+% \begin{macrocode}
+\def\use@@pkg@@array@@variant{0}
+\DeclareOption{array}{\def\use@@pkg@@array@@variant{1}}
+\ProcessOptions*
+% \end{macrocode}
+%
+%
+% \begin{macro}{stabular}
+% \begin{macrocode}
+\def\stabular{\let\@halignto\@empty\@stabular}
+\def\endstabular{\crcr\egroup\egroup\egroup}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{stabular*}
+% \begin{macrocode}
+\@namedef{stabular*}#1{%
+ \setlength\dimen@{#1}%
+ \edef\@halignto{to\the\dimen@}%
+ \@tabular
+ }
+\expandafter\let\csname endstabular*\endcsname\endstabular
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\@stabular}
+% \begin{macrocode}
+\def\@stabular{\leavevmode
+ \bgroup
+ \let\@acol\@tabacol
+ \let\@classz\@tabclassz
+ \let\@classiv\@tabclassiv
+ \let\\\@tabularcr
+ \@stabarray
+ }
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\@stabarray}
+% \begin{macrocode}
+\def\@stabarray{\m@th\@ifnextchar[\@sarray{\@sarray[c]}}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\@sarray}
+% \begin{macrocode}
+\def\@sarray[#1]#2{%
+ \bgroup
+ \setbox\@arstrutbox\hbox{%
+ \vrule \@height\arraystretch\ht\strutbox
+ \@depth\arraystretch \dp\strutbox
+ \@width\z@
+ }%
+ \@mkpream{#2}%
+ \edef\@preamble{%
+ \ialign \noexpand\@halignto
+ \bgroup \@arstrut \@preamble \tabskip\z@skip \cr
+ }%
+ \let\@startpbox\@@startpbox \let\@endpbox\@@endpbox
+ \let\tabularnewline\\
+ %%\let\par\@empty
+ \let\@sharp##%
+ \set@typeset@protect
+ \lineskip\z@skip \baselineskip\z@skip
+ \@preamble
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% Definitions to provide |array| package support.
+%
+% \begin{macrocode}
+\def\pkgarray@@sarray[#1]#2{%
+ \@tempdima \ht \strutbox
+ \advance \@tempdima by\extrarowheight
+ \setbox \@arstrutbox \hbox{\vrule
+ \@height \arraystretch \@tempdima
+ \@depth \arraystretch \dp \strutbox
+ \@width \z@}%
+ \begingroup
+ \@mkpream{#2}%
+ \xdef\@preamble{\noexpand \ialign \@halignto
+ \bgroup \@arstrut \@preamble
+ \tabskip \z@ \cr}%
+ \endgroup
+ \@arrayleft
+ \bgroup
+ \let\@sharp##\let\protect\relax
+ \lineskip\z@ \baselineskip\z@
+ \m@th
+ \let\\\@arraycr \let\tabularnewline\\
+ %%\let\par\@empty
+ \@preamble
+ }
+\def\pkgarray@@stabarray{\@ifnextchar[{\pkgarray@@sarray}{\pkgarray@@sarray[c]}}
+\def\pkgarray@stabular{\gdef\@halignto{}\pkgarray@@stabular}
+\expandafter\def\csname pkgarray@stabular*\endcsname#1{%
+ \setlength\dimen@{#1}%
+ \xdef\@halignto{to\the\dimen@}\pkgarray@@stabular}
+\def\pkgarray@@stabular{%
+ \leavevmode
+ \bgroup
+ \col@sep\tabcolsep
+ \let\d@llarbegin\begingroup
+ \let\d@llarend\endgroup
+ \pkgarray@@stabarray
+ }
+\def\pkgarray@endstabular{\crcr\egroup\egroup\gdef\@preamble{}\egroup}
+\expandafter\let\csname pkgarray@endstabular*\endcsname\pkgarray@endstabular
+% \end{macrocode}
+%
+%
+% \begin{macrocode}
+\ifcase\use@@pkg@@array@@variant
+\else
+ \@ifpackageloaded{array}{}{\RequirePackage{array}}%
+ \let\stabular\pkgarray@stabular
+ \expandafter\let\csname stabular*\expandafter\endcsname
+ \csname pkgarray@stabular*\endcsname
+ \let\endstabular\pkgarray@endstabular
+ \expandafter\let\csname endstabular*\expandafter\endcsname
+ \csname pkgarray@endstabular*\endcsname
+\fi
+% \end{macrocode}
+%
+% \iffalse
+%</package>
+% \fi
+%
+% \Finale
diff --git a/macros/latex/contrib/sttools/stabular.pdf b/macros/latex/contrib/sttools/stabular.pdf
new file mode 100644
index 0000000000..353f0ea340
--- /dev/null
+++ b/macros/latex/contrib/sttools/stabular.pdf
Binary files differ
diff --git a/macros/latex/contrib/sttools/stfloats.dtx b/macros/latex/contrib/sttools/stfloats.dtx
new file mode 100644
index 0000000000..bf5ab362df
--- /dev/null
+++ b/macros/latex/contrib/sttools/stfloats.dtx
@@ -0,0 +1,923 @@
+% \iffalse meta-comment
+%
+% Copyright (C) 2016 by Sigitas Tolu\v{s}is <sigitas@vtex.lt>
+% ---------------------------------------------------------------------------
+% This work may be distributed and/or modified under the
+% conditions of the LaTeX Project Public License, either version 1.3
+% of this license or (at your option) any later version.
+% The latest version of this license is in
+% http://www.latex-project.org/lppl.txt
+% and version 1.3 or later is part of all distributions of LaTeX
+% version 2005/12/01 or later.
+%
+% This work has the LPPL maintenance status `maintained'.
+%
+% The Current Maintainer of this work is Sigitas Tolu\v{s}is.
+%
+% This work consists of the files stfloats.dtx and stfloats.ins
+% and the derived filebase stfloats.sty.
+%
+% \fi
+%
+% \iffalse
+%<*driver>
+\ProvidesFile{stfloats.dtx}
+%</driver>
+%<*package>
+%% Copyright (C) 1997-2017 by Sigitas Tolu\v{s}is <sigitas@vtex.lt>
+%% VTeX UAB, Mokslininku 2a, Vilnius, Lithuania
+%% --------------------------------------------------------------------------
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3
+%% of this license or (at your option) any later version.
+%% The latest version of this license is in
+%% http://www.latex-project.org/lppl.txt
+%% and version 1.3 or later is part of all distributions of LaTeX
+%% version 2005/12/01 or later.
+%%
+%% PURPOSE: Improve float mechanism and baselineskip settings
+%%
+%</package>
+%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
+%<package>\ProvidesPackage{stfloats}
+%<*package>
+ [2017/03/27 v3.3 Improve float mechanism and baselineskip settings]
+%</package>
+%
+%<*driver>
+\documentclass{ltxdoc}
+\usepackage{stfloats}[2017/03/27]
+\EnableCrossrefs
+\CodelineIndex
+\RecordChanges
+\begin{document}
+ \DocInput{stfloats.dtx}
+ %%\PrintChanges
+ %%\PrintIndex
+\end{document}
+%</driver>
+% \fi
+%
+% \CheckSum{1186}
+%
+% \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
+% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
+% Digits \0\1\2\3\4\5\6\7\8\9
+% Exclamation \! Double quote \" Hash (number) \#
+% Dollar \$ Percent \% Ampersand \&
+% Acute accent \' Left paren \( Right paren \)
+% Asterisk \* Plus \+ Comma \,
+% Minus \- Point \. Solidus \/
+% Colon \: Semicolon \; Less than \<
+% Equals \= Greater than \> Question mark \?
+% Commercial at \@ Left bracket \[ Backslash \\
+% Right bracket \] Circumflex \^ Underscore \_
+% Grave accent \` Left brace \{ Vertical bar \|
+% Right brace \} Tilde \~}
+%
+%
+% \changes{v0.1}{1997/08/25}{first version}
+% \changes{v0.2}{1997/09/10}{standard LaTeX2e macros are used for dblfloats at top}
+% \changes{v1.0}{1997/10/01}{new commands: \cs{fnbelowfloat} and \cs{fnunderfloat}}
+% \changes{v2.0}{1998/09/21}{new commands: \cs{setbaselinefloat} and \cs{setbaselinefixed}}
+% \changes{v2.1}{1999/10/04}{changed dblfloat's output}
+% \changes{v2.2}{1999/10/22}{changed cs{output} for older LaTeX distributions}
+% \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}
+%
+% \providecommand*{\url}{\texttt}
+% \GetFileInfo{stfloats.dtx}
+% \title{The \textsf{stfloats} package}
+% \author{Sigitas Tolu\v{s}is \\ \url{sigitas@vtex.lt}}
+% \date{\fileversion~from \filedate}
+%
+% \maketitle
+%
+% \section{Introduction}
+%
+% The package improves dblfloat(s) and footnotes placements mechanism and baselineskip
+% glue settings.
+%
+% With newer \LaTeX\ release from 2015/01/01 using this package two improvements are
+% available out of the box:
+% \begin{enumerate}
+% \item Float output keeps order for the
+% same type of floats even with top or bottom dblfloat items.
+% \item Dblfloats will appear on the same page where
+% they are defined if they are defined on left column and
+% enought free place is available on the current column/page.
+% \end{enumerate}
+%
+% \section{Usage}
+%
+% To place dblfloat(s) on top or bottom of the page just use optional
+% [t] or [b].
+%
+% \leftline{Example (to place figure at the page bottom):}
+%
+% \begin{verbatim}
+% \begin{figure*}[b]
+% ...
+% \end{figure*}
+% \end{verbatim}
+%
+% \DescribeMacro{\fnbelowfloat}
+% Puts footnotes below the bottom floats
+%
+% \medskip
+% \DescribeMacro{\fnunderfloat} (default and standard)
+% Puts footnotes under the bottom floats.
+%
+% \medskip
+% \DescribeMacro{\setbaselinefloat}
+% Allows |\baselineskip| to stretch and shrink if the |\baselineskip|
+% is set internally with command |\@setfontsize| (|\linespread| and
+% |\fontsize| at user level). The settings are calculated and activated
+% with command |\selectfont| (|\size@update|).
+%
+% \medskip
+% Example:
+%
+% \medskip
+% |\@setfontsize\normalsize\@xpt{12pt plus .1pt minus .1pt}| |\normalsize|%
+%
+% \medskip
+% \DescribeMacro{\setbaselinefixed} (default and standard)
+% Disables baselineskip to stretch and shrink even if the |\baselineskip|
+% is set with command |\@setfontsize| as in the previous example in case that
+% |\baselinestretch| is not empty.
+%
+% \medskip
+% Then line spreading is not used |\baselineskip| glue can be
+% controlled by ordinary |\baselinestretch| definition:
+%
+% \begin{itemize}
+% \item
+% |\def\baselinestretch{1}| - removes |\baselineskip| glue.
+% \item
+% |\def\baselinestretch{}| - keeps |\baselineskip| glue.
+% \end{itemize}
+%
+% \StopEventually{}
+%
+% \section{Implementation}
+%
+% \iffalse
+%<*package>
+% \fi
+%
+%
+% \begin{macro}{\@dblbotlist}
+% Used for dblfloat(s) to be placed at the page bottom.
+% \begin{macrocode}
+\gdef\@dblbotlist{}
+% \end{macrocode}
+% \end{macro}
+%
+% Additional counters for dblfloat(s) support at the page bottom.
+% \begin{macrocode}
+\newcount\@dblbotnum
+\newcount\c@dblbotnumber
+\setcounter{dblbotnumber}{2}
+% \end{macrocode}
+%
+% \begin{macro}{\@dbflt}
+% With extended set of default args: |[tp] -> [tbp]|
+% \begin{macrocode}
+\def\@dbflt#1{\@ifnextchar[{\@xdblfloat{#1}}{\@xdblfloat{#1}[tbp]}}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\@dblfloatplacement}
+% With adds to support dblfoat(s) placement at the page bottom.
+% From \LaTeX\ release 2015/01/01 |\f@depth| is used in |\@testwrongwidth| to look
+% for either column or dblcolumn floats. A value of 1sp signals the latter.
+% \begin{macrocode}
+\def\@dblfloatplacement{%
+ \global\@dbltopnum\c@dbltopnumber
+ \global\@dblbotnum\c@dblbotnumber
+ \global\@dbltoproom\dbltopfraction\@colht
+ \@textmin\@colht
+ \advance\@textmin -\@dbltoproom
+ \@fpmin\dblfloatpagefraction\textheight
+ \@fptop\@dblfptop
+ \@fpsep\@dblfpsep
+ \@fpbot\@dblfpbot
+ \def\f@depth{1sp}%
+ }
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\if@before@latex@release}
+% This conditional code is used to check the \LaTeX\ release age.
+% \begin{macrocode}
+\newif\if@before@latex@release
+\def\tmp@reserved@a#1#2#3#4#5\@nil{%
+ \ifnum #1#2#3#4<2015\relax
+ \@before@latex@releasetrue
+ \else
+ \@before@latex@releasefalse
+ \fi
+ }
+\expandafter\tmp@reserved@a\fmtversion\@nil
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \LaTeX\ release version before 2015/01/01 support goes here.
+%
+%
+% \begin{macro}{\@addtodblcol}
+% With adds to support dblfoat(s) placement at the page bottom.
+% \begin{macrocode}
+\if@before@latex@release
+ %%% < 2015 start
+ \def\@addtodblcol{%
+ \begingroup
+ \@insertfalse
+ \@setfloattypecounts
+ \@getfpsbit \tw@
+ \ifodd\@tempcnta
+ \@flsetnum \@dbltopnum
+ \ifnum \@dbltopnum>\z@
+ \@tempswafalse
+ \ifdim \@dbltoproom>\ht\@currbox
+ \@tempswatrue
+ \else
+ \ifnum \@fpstype<\sixt@@n
+ \advance\@dbltoproom \@textmin
+ \ifdim \@dbltoproom>\ht\@currbox
+ \@tempswatrue
+ \fi
+ \advance\@dbltoproom -\@textmin
+ \fi
+ \fi
+ \if@tempswa
+ \@bitor \@currtype \@dbldeferlist
+ \if@test
+ \else
+ \@bitor \@currtype \@dblbotlist
+ \if@test
+ \else
+ \@tempdima -\ht\@currbox
+ \advance\@tempdima
+ -\ifx \@dbltoplist\@empty \dbltextfloatsep \else
+ \dblfloatsep \fi
+ \global \advance \@dbltoproom \@tempdima
+ \global \advance \@colht \@tempdima
+ \global \advance \@dbltopnum \m@ne
+ \@cons \@dbltoplist \@currbox
+ \@inserttrue
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+ \if@insert
+ \else
+ \@getfpsbit 4\relax
+ \ifodd\@tempcnta
+ \@flsetnum \@dblbotnum
+ \ifnum \@dblbotnum>\z@
+ \@tempswafalse
+ \ifdim \@dbltoproom>\ht\@currbox
+ \@tempswatrue
+ \else
+ \ifnum \@fpstype<\sixt@@n
+ \advance \@dbltoproom \@textmin
+ \ifdim \@dbltoproom>\ht\@currbox
+ \@tempswatrue
+ \fi
+ \advance \@dbltoproom -\@textmin
+ \fi
+ \fi
+ \if@tempswa
+ \@bitor \@currtype \@dbldeferlist
+ \if@test
+ \else
+ \@tempdima -\ht\@currbox
+ \advance\@tempdima
+ -\ifx \@dblbotlist\@empty \dbltextfloatsep \else
+ \dblfloatsep \fi
+ \global \advance \@dbltoproom \@tempdima
+ \global \advance \@colht \@tempdima
+ \global \advance \@dblbotnum \m@ne
+ \@cons \@dblbotlist \@currbox
+ \@inserttrue
+ \fi
+ \fi
+ \fi
+ \fi
+ \if@insert
+ \else
+ \@cons\@dbldeferlist\@currbox
+ \fi
+ \fi
+ \endgroup
+ }
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\@doclearpage}
+% With adds to support dblfoat(s) placement at the page bottom.
+% \begin{macrocode}
+ \def\@doclearpage{%
+ \ifvoid\footins
+ \ifvbox\@kludgeins
+ {\setbox \@tempboxa \box \@kludgeins}%
+ \fi
+ \setbox\@tempboxa\vsplit\@cclv to\z@ \unvbox\@tempboxa
+ \setbox\@tempboxa\box\@cclv
+ \xdef\@deferlist{\@toplist\@botlist\@deferlist}%
+ \global \let \@toplist \@empty
+ \global \let \@botlist \@empty
+ \global \@colroom \@colht
+ \ifx \@currlist\@empty
+ \else
+ \@latexerr{Float(s) lost}\@ehb
+ \global \let \@currlist \@empty
+ \fi
+ \@makefcolumn\@deferlist
+ \@whilesw\if@fcolmade \fi{\@opcol\@makefcolumn\@deferlist}%
+ \if@twocolumn
+ \if@firstcolumn
+ \xdef\@dbldeferlist{\@dbltoplist\@dblbotlist\@dbldeferlist}%
+ \global \let \@dbltoplist \@empty
+ \global \let \@dblbotlist \@empty
+ \global \@colht \textheight
+ \begingroup
+ \@dblfloatplacement
+ \@makefcolumn\@dbldeferlist
+ \@whilesw\if@fcolmade \fi{\@outputpage
+ \@makefcolumn\@dbldeferlist}%
+ \endgroup
+ \else
+ \vbox{}\clearpage
+ \fi
+ \fi
+ \else
+ \setbox\@cclv\vbox{\box\@cclv\vfil}%
+ \@makecol\@opcol
+ \clearpage
+ \fi
+ }
+ %%% < 2015 end
+\else
+% \end{macrocode}
+% \end{macro}
+%
+% Newer \LaTeX\ release version from 2015/01/01 support goes here.
+%
+% \begin{macrocode}
+ %%% > 2015 start
+% \end{macrocode}
+%
+%
+% \begin{macro}{\@addtodblcol}
+% With adds to support dblfoat(s) placement on the current page and at the page bottom.
+% \begin{macrocode}
+ \def\@addtodblcol{%
+ \begingroup
+ \@insertfalse
+ \@setfloattypecounts
+ \@getfpsbit \tw@
+ \ifodd\@tempcnta
+ \@flsetnum \@dbltopnum
+ \ifnum \@dbltopnum>\z@
+ \@tempswafalse
+ \ifdim \@dbltoproom>\ht\@currbox
+ \@tempswatrue
+ \else
+ \ifnum \@fpstype<\sixt@@n
+ \advance \@dbltoproom \@textmin
+ \ifdim \@dbltoproom>\ht\@currbox
+ \@tempswatrue
+ \fi
+ \advance \@dbltoproom -\@textmin
+ \fi
+ \fi
+ \if@tempswa
+ \@bitor \@currtype \@deferlist
+ \@testwrongwidth\@currbox
+ \if@test
+ \else
+ \@bitor \@currtype \@dblbotlist
+ \if@test
+ \else
+ \@tempdima -\ht\@currbox
+ \advance\@tempdima
+ -\ifx \@dbltoplist\@empty \dbltextfloatsep \else
+ \dblfloatsep \fi
+ \global \advance \@dbltoproom \@tempdima
+ \global \advance \@colht \@tempdima
+ \global \advance \@dbltopnum \m@ne
+ \@cons \@dbltoplist \@currbox
+ \@inserttrue
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+ \if@insert
+ \else
+ \@getfpsbit 4\relax
+ \ifodd\@tempcnta
+ \@flsetnum \@dblbotnum
+ \ifnum \@dblbotnum>\z@
+ \@tempswafalse
+ \ifdim \@dbltoproom>\ht\@currbox
+ \@tempswatrue
+ \else
+ \ifnum \@fpstype<\sixt@@n
+ \advance \@dbltoproom \@textmin
+ \ifdim \@dbltoproom>\ht\@currbox
+ \@tempswatrue
+ \fi
+ \advance \@dbltoproom -\@textmin
+ \fi
+ \fi
+ \if@tempswa
+ \@bitor \@currtype \@deferlist
+ \@testwrongwidth\@currbox
+ \if@test
+ \else
+ \@tempdima -\ht\@currbox
+ \advance\@tempdima
+ -\ifx \@dblbotlist\@empty \dbltextfloatsep \else
+ \dblfloatsep \fi
+ \global \advance \@dbltoproom \@tempdima
+ \global \advance \@colht \@tempdima
+ \global \advance \@dblbotnum \m@ne
+ \@cons \@dblbotlist \@currbox
+ \@inserttrue
+ \fi
+ \fi
+ \fi
+ \fi
+ \if@insert
+ \else
+ \@cons\@deferlist\@currbox
+ \fi
+ \fi
+ \endgroup
+ }
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\@addtocurcol}
+% With adds to support dblfoat(s) placement on the current page and at the page bottom.
+% \begin{macrocode}
+ \def\@addtocurcol{%
+ \@insertfalse
+ \@setfloattypecounts
+ \ifnum \@fpstype=8
+ \else
+ \ifnum \@fpstype=24
+ \else
+ \@flsettextmin
+ \advance \@textmin \@textfloatsheight
+ \@reqcolroom \@pageht
+ \ifdim \@textmin>\@reqcolroom
+ \@reqcolroom \@textmin
+ \fi
+ \advance \@reqcolroom \ht\@currbox
+ \ifdim \@colroom>\@reqcolroom
+ \@flsetnum \@colnum
+ \ifnum \@colnum>\z@
+ \@bitor\@currtype\@deferlist
+ \if@test
+ \else
+ \@testwrongwidth\@currbox
+ \if@test
+ \if@firstcolumn
+ \@getfpsbit \tw@
+ \ifodd\@tempcnta
+ \@flsetnum \@dbltopnum
+ \ifnum \@dbltopnum>\z@
+ \@tempswafalse
+ \ifdim \@dbltoproom>\ht\@currbox
+ \@tempswatrue
+ \else
+ \ifnum \@fpstype<\sixt@@n
+ \advance \@dbltoproom \@textmin
+ \ifdim \@dbltoproom>\ht\@currbox
+ \@tempswatrue
+ \fi
+ \advance \@dbltoproom -\@textmin
+ \fi
+ \fi
+ \if@tempswa
+ \@bitor\@currtype{\@toplist\@midlist\@botlist\@dblbotlist}%
+ \if@test
+ \else
+ \@tempdima -\ht\@currbox
+ \advance\@tempdima
+ -\ifx \@dbltoplist\@empty \dbltextfloatsep \else
+ \dblfloatsep \fi
+ \global \advance \@dbltoproom \@tempdima
+ \global \advance \@colht \@tempdima
+ \global \advance \@colroom \@tempdima
+ \global \advance \@dbltopnum \m@ne
+ \@cons \@dbltoplist \@currbox
+ \@inserttrue
+ \fi
+ \fi
+ \fi
+ \else
+ \@getfpsbit 4\relax
+ \ifodd\@tempcnta
+ \@flsetnum \@dblbotnum
+ \ifnum \@dblbotnum>\z@
+ \@tempswafalse
+ \ifdim \@dbltoproom>\ht\@currbox
+ \@tempswatrue
+ \else
+ \ifnum \@fpstype<\sixt@@n
+ \advance \@dbltoproom \@textmin
+ \ifdim \@dbltoproom>\ht\@currbox
+ \@tempswatrue
+ \fi
+ \advance \@dbltoproom -\@textmin
+ \fi
+ \fi
+ \if@tempswa
+ \@tempdima -\ht\@currbox
+ \advance\@tempdima
+ -\ifx \@dblbotlist\@empty \dbltextfloatsep \else
+ \dblfloatsep \fi
+ \global \advance \@dbltoproom \@tempdima
+ \global \advance \@colht \@tempdima
+ \global \advance \@colroom \@tempdima
+ \global \advance \@dblbotnum \m@ne
+ \@cons \@dblbotlist \@currbox
+ \@inserttrue
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+ \else
+ \@bitor\@currtype\@botlist
+ \if@test
+ \@addtobot
+ \else
+ \ifodd \count\@currbox
+ \advance \@reqcolroom \intextsep
+ \ifdim \@colroom>\@reqcolroom
+ \global \advance \@colnum \m@ne
+ \global \advance \@textfloatsheight \ht\@currbox
+ \global \advance \@textfloatsheight 2\intextsep
+ \@cons \@midlist \@currbox
+ \if@nobreak
+ \nobreak
+ \@nobreakfalse
+ \everypar{}%
+ \else
+ \addpenalty \interlinepenalty
+ \fi
+ \vskip \intextsep
+ \box\@currbox
+ \penalty\interlinepenalty
+ \vskip\intextsep
+ \ifnum\outputpenalty <-\@Mii \vskip -\parskip\fi
+ \outputpenalty \z@
+ \@inserttrue
+ \fi
+ \fi
+ \if@insert
+ \else
+ \@addtotoporbot
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+ \if@insert
+ \else
+ \@resethfps
+ \@cons\@deferlist\@currbox
+ \fi
+ }%
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\@addtotoporbot}
+% With adds to support dblfoat(s) placement on the current page and at the page bottom.
+% \begin{macrocode}
+ \def\@addtotoporbot{%
+ \@getfpsbit \tw@
+ \ifodd \@tempcnta
+ \@flsetnum \@topnum
+ \ifnum \@topnum>\z@
+ \@tempswafalse
+ \@flcheckspace \@toproom \@toplist
+ \if@tempswa
+ \@bitor\@currtype{\@midlist\@botlist\@dblbotlist}%
+ \if@test
+ \else
+ \@flupdates \@topnum \@toproom \@toplist
+ \@inserttrue
+ \fi
+ \fi
+ \fi
+ \fi
+ \if@insert
+ \else
+ \@addtobot
+ \fi
+ }
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\@addtobot}
+% With adds to support dblfoat(s) placement on the current page and at the page bottom.
+% \begin{macrocode}
+ \def\@addtobot{%
+ \@getfpsbit 4\relax
+ \ifodd \@tempcnta
+ \@flsetnum \@botnum
+ \ifnum \@botnum>\z@
+ \@tempswafalse
+ \@flcheckspace \@botroom \@botlist
+ \if@tempswa
+ \@bitor\@currtype{\@dblbotlist}%
+ \if@test
+ \else
+ \global \maxdepth \z@
+ \@flupdates \@botnum \@botroom \@botlist
+ \@inserttrue
+ \fi
+ \fi
+ \fi
+ \fi
+ }
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\@doclearpage}
+% With adds to support dblfoat(s) placement on the current page and at the page bottom.
+% \begin{macrocode}
+ \def\@doclearpage{%
+ \ifvoid\footins
+ \ifvbox\@kludgeins
+ {\setbox \@tempboxa \box \@kludgeins}%
+ \fi
+ \setbox\@tempboxa\vsplit\@cclv to\z@ \unvbox\@tempboxa
+ \setbox\@tempboxa\box\@cclv
+ \xdef\@deferlist{\@toplist\@botlist\@deferlist}%
+ \global \let \@toplist \@empty
+ \global \let \@botlist \@empty
+ \global \@colroom \@colht
+ \ifx \@currlist\@empty
+ \else
+ \@latexerr{Float(s) lost}\@ehb
+ \global \let \@currlist \@empty
+ \fi
+ \@makefcolumn\@deferlist
+ \@whilesw\if@fcolmade \fi{\@opcol\@makefcolumn\@deferlist}%
+ \if@twocolumn
+ \if@firstcolumn
+ \xdef\@deferlist{\@dbltoplist\@dblbotlist\@deferlist}%
+ \global \let \@dbltoplist \@empty
+ \global \let \@dblbotlist \@empty
+ \global \@colht \textheight
+ \begingroup
+ \@dblfloatplacement
+ \@makefcolumn\@deferlist
+ \@whilesw\if@fcolmade \fi{\@outputpage
+ \@makefcolumn\@deferlist}%
+ \endgroup
+ \else
+ \vbox{}\clearpage
+ \fi
+ \fi
+ \ifx\@deferlist\@empty \else\clearpage \fi
+ \else
+ \setbox\@cclv\vbox{\box\@cclv\vfil}%
+ \@makecol\@opcol
+ \clearpage
+ \fi
+ }
+ %%% > 2015 end
+\fi
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\@combinedblfloats}
+% Combines outputbox with top and bottom placed dblfloat(s).
+% \begin{macrocode}
+\def\@combinedblfloats{%
+ \ifx \@dbltoplist\@empty \else \@cdblflt \fi
+ \ifx \@dblbotlist\@empty \else \@cdblflb \fi
+ }
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\@cdblflt}
+% Combines outputbox with top placed dblfloat(s).
+% \begin{macrocode}
+\def\@cdblflt{%
+ \setbox\@tempboxa \vbox{}%
+ \let \@elt \@comdblflelt
+ \@dbltoplist
+ \let \@elt \relax
+ \xdef \@freelist {\@freelist\@dbltoplist}%
+ \global\let \@dbltoplist \@empty
+ \setbox\@outputbox \vbox% to\textheight
+ {%\boxmaxdepth\maxdepth %% probably not needed, CAR
+ \unvbox\@tempboxa\vskip-\dblfloatsep
+ \ifnum \@dbltopnum>\m@ne
+ \dblfigrule
+ \fi
+ \vskip \dbltextfloatsep
+ \unvbox \@outputbox
+ }%
+ }
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\@cdblflb}
+% Combines outputbox with bottom placed dblfloat(s).
+% \begin{macrocode}
+\def\@cdblflb{%
+ \setbox\@tempboxa \vbox{}%
+ \let \@elt \@comdblflelt
+ \@dblbotlist
+ \let \@elt \relax
+ \xdef \@freelist {\@freelist\@dblbotlist}%
+ \global\let \@dblbotlist \@empty
+ \setbox\@outputbox \vbox% to\textheight
+ {%\boxmaxdepth\maxdepth %% probably not needed, CAR
+ \unvbox\@outputbox
+ \vskip \dbltextfloatsep
+ \ifnum \@dblbotnum>\m@ne
+ \dblfigrule
+ \fi
+ \unvbox\@tempboxa
+ \vskip -\dblfloatsep
+ }%
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% Makes |\@makecol| current definition copy to |\org@makecol|.
+% \begin{macrocode}
+\global\let\org@makecol\@makecol
+% \end{macrocode}
+%
+% \begin{macro}{\fn@makecol}
+% Redefined macro |\@makecol| which puts footnotes below the bottom floats.
+% \begin{macrocode}
+\gdef\fn@makecol{%
+ \setbox\@outputbox \box\@cclv
+ \let\@elt\relax
+ \xdef\@freelist{\@freelist\@midlist}%
+ \global \let \@midlist \@empty
+ \@combinefloats
+ \ifvoid\footins
+ \else
+ \setbox\@outputbox \vbox {%
+ \boxmaxdepth \@maxdepth
+ \unvbox \@outputbox
+ \vskip \skip\footins
+ \color@begingroup
+ \normalcolor
+ \footnoterule
+ \unvbox \footins
+ \color@endgroup
+ }%
+ \fi
+ \ifvbox\@kludgeins
+ \@makespecialcolbox
+ \else
+ \setbox\@outputbox \vbox to\@colht {%
+ \@texttop
+ \dimen@ \dp\@outputbox
+ \unvbox \@outputbox
+ \vskip -\dimen@
+ \@textbottom
+ }%
+ \fi
+ \global \maxdepth \@maxdepth
+ }
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\fnbelowfloat}
+% Switch to put footnotes below the bottom floats.
+% \begin{macrocode}
+\def\fnbelowfloat{\global\let\@makecol\fn@makecol}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\fnunderfloat}
+% Switch to put footnotes under the bottom floats.
+% \begin{macrocode}
+\def\fnunderfloat{\global\let\@makecol\org@makecol}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\set@floatfontsize}
+% Such definition |\baselineskip\f@linespread\baselineskip| removes
+% any glue from the |\baselineskip| in the case |\f@linespread| is
+% not empty. To prevent this |\size@update| is redefined.
+% \begin{macrocode}
+\def\set@floatfontsize#1#2#3{%
+ \@defaultunits\@tempdimb#2\p@\relax\@nnil
+ \edef\f@size{\strip@pt\@tempdimb}%
+ \@defaultunits\@tempskipa#3\p@\relax\@nnil
+ \edef\f@baselineskip{\the\@tempskipa}%
+ \edef\f@linespread{#1}%
+ \let\baselinestretch\f@linespread
+ \def\size@update{%
+% \end{macrocode}
+% Saving of the |\baselineskip| glue.
+% \begin{macrocode}
+ \baselineskip\f@baselineskip
+ \@tempskipa\baselineskip\relax\baselineskip=1\baselineskip
+ \advance\@tempskipa by-\baselineskip\baselineskip\f@baselineskip
+% \end{macrocode}
+% Removes the |\baselineskip| glue in case |\f@linespread| not empty.
+% \begin{macrocode}
+ \baselineskip\f@linespread\baselineskip
+% \end{macrocode}
+% Restoring of the |\baselineskip| glue.
+% \begin{macrocode}
+ \advance\@tempskipa by\baselineskip\baselineskip\@tempskipa
+ \normalbaselineskip\baselineskip
+ \setbox\strutbox\hbox{%
+ \vrule\@height.7\baselineskip
+ \@depth.3\baselineskip
+ \@width\z@}%
+ \let\size@update\relax
+ }%
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% Simple copy of the previous original |\set@fontsize| definition in |\set@@@fontsize|.
+%
+% \begin{macrocode}
+\let\set@@@fontsize\set@fontsize
+% \end{macrocode}
+%
+%
+% \begin{macro}{\setbaselinefloat}
+% It allows |\baselineskip| to be set to the value with glue.
+% \begin{macrocode}
+\def\setbaselinefloat{\let\set@fontsize\set@floatfontsize}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\setbaselinefixed}
+% It is used to restore macro definition |\set@fontsize| to the
+% original one. It means that |\baselineskip| is set to the value
+% without glue in the case |\baselinestretch| is not empty.
+% \begin{macrocode}
+\def\setbaselinefixed{%
+ \@tempdima=\baselinestretch\p@
+ \edef\baselinestretch{\strip@pt\@tempdima}%
+ \let\set@fontsize\set@@@fontsize
+ }
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\output}
+% It is removed from this package as the duplicate of the same
+% definition in kernel since the macro definition change
+% v.1.2c at 1997/11/09 in |ltoutput|.
+% \end{macro}
+%
+%
+% \begin{macrocode}
+%\endinput
+% \end{macrocode}
+%
+% \iffalse
+%</package>
+% \fi
+%
+% \Finale
diff --git a/macros/latex/contrib/sttools/stfloats.pdf b/macros/latex/contrib/sttools/stfloats.pdf
new file mode 100644
index 0000000000..ee3ca96e81
--- /dev/null
+++ b/macros/latex/contrib/sttools/stfloats.pdf
Binary files differ
diff --git a/macros/latex/contrib/sttools/sttools.dtx b/macros/latex/contrib/sttools/sttools.dtx
new file mode 100644
index 0000000000..64cc03bad1
--- /dev/null
+++ b/macros/latex/contrib/sttools/sttools.dtx
@@ -0,0 +1,113 @@
+% \iffalse meta-comment
+%
+% Copyright (C) 2016 by Sigitas Tolu\v{s}is <sigitas@vtex.lt>
+% ---------------------------------------------------------------------------
+% This work may be distributed and/or modified under the
+% conditions of the LaTeX Project Public License, either version 1.3
+% of this license or (at your option) any later version.
+% The latest version of this license is in
+% http://www.latex-project.org/lppl.txt
+% and version 1.3 or later is part of all distributions of LaTeX
+% version 2005/12/01 or later.
+%
+% This work has the LPPL maintenance status `maintained'.
+%
+% The Current Maintainer of this work is Sigitas Tolu\v{s}is.
+%
+% This work consists of the files sttools.dtx and sttools.ins
+% and the derived filebases: boundbox.sty, cuted.sty, floatpag.sty,
+% flushend.sty, marginal.sty, midfloat.sty, stabular.sty,
+% stfloats.sty, texsort.sty.
+%
+% Also available from:
+% http://www.vtex.lt/tex/download/macros/
+%
+% \fi
+%
+% \iffalse
+%<*driver>
+\ProvidesFile{sttools.dtx}
+%</driver>
+%
+%<*driver>
+\documentclass{ltxdoc}
+\begin{document}
+ \DocInput{sttools.dtx}
+\end{document}
+%</driver>
+% \fi
+%
+% \CheckSum{0}
+%
+% \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
+% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
+% Digits \0\1\2\3\4\5\6\7\8\9
+% Exclamation \! Double quote \" Hash (number) \#
+% Dollar \$ Percent \% Ampersand \&
+% Acute accent \' Left paren \( Right paren \)
+% Asterisk \* Plus \+ Comma \,
+% Minus \- Point \. Solidus \/
+% Colon \: Semicolon \; Less than \<
+% Equals \= Greater than \> Question mark \?
+% Commercial at \@ Left bracket \[ Backslash \\
+% Right bracket \] Circumflex \^ Underscore \_
+% Grave accent \` Left brace \{ Vertical bar \|
+% Right brace \} Tilde \~}
+%
+%
+% \DoNotIndex{\newcommand,\newenvironment}
+%
+% \providecommand*{\url}{\texttt}
+% \GetFileInfo{sttools.dtx}
+% \title{The \textsf{sttools} collection}
+% \author{Sigitas Tolu\v{s}is \\ \url{sigitas@vtex.lt}}
+% \date{2016.06.28}
+%
+% \maketitle
+%
+% \section{Introduction}
+%
+% This is collection of various
+% packages historically placed in a bundle and maintained by Sigitas Tolu\v{s}is.
+%
+% \section{Usage}
+%
+% \begin{itemize}
+% \item \textbf{cuted.sty, v1.5 2012/10/04} -- place some material
+% page width wide at any
+% place on twocolumn page with existing text reformatted under inserted
+% material; \\\texttt{TODO: add optional rules to separate from text};
+% \item \textbf{floatpag.sty, v1.1 2012/05/29} -- set pagestyle for floats page;
+% \item \textbf{flushend.sty, v3.2 2016/06/21} -- balance page in twocolumn mode;
+% \\\texttt{(2014/03/03): totally rewritten with new algorithm to support footnotes,
+% top floats and column break before one line section title.
+% \\(2014/04/24): bugfix version;
+% \\(2015/03/27): bugfix version with improved funcionality:
+% \\ - spreaded or fixed right column height;
+% \\ - 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};
+% \item \textbf{midfloat.sty, v1.1 2012/05/29} -- insert onecolumn stuff in twocolumn
+% page; \\\texttt{TODO: extend to work on both columns};
+% \item \textbf{stabular.sty, v2.0 2014/03/20} -- use modified tabular environment;
+% \\\texttt{(2014/03/20): removed extra stuff and left only possibility to break
+% on page boundary;
+% \\added tabular variant from array package};
+% \item \textbf{stfloats.sty, v3.2 2016/06/28} -- enable enriched floats output mechanism;
+% \\\texttt{(2016/06/28): compatibility bugfix with 2015 latexrelease};
+% \item \textbf{texsort.sty, v1.1 2012/05/29} -- sort numerical values; \\\texttt{TODO:
+% extend (rewrite) to support alphnanumerical values for sorting}.
+% \end{itemize}
+%
+% Just load any of the provided packages in the standard way:
+% |\usepackage{|\meta{package}|}| or
+% |\RequirePackage{|\meta{package}|}|.
+%
+% \medskip
+% To read documentation: |texdoc |\meta{package}.
+%
+% \StopEventually{}
+%
+% \Finale
+\endinput
diff --git a/macros/latex/contrib/sttools/sttools.ins b/macros/latex/contrib/sttools/sttools.ins
new file mode 100644
index 0000000000..9c32a854d9
--- /dev/null
+++ b/macros/latex/contrib/sttools/sttools.ins
@@ -0,0 +1,55 @@
+%% Copyright (C) 2016 by Sigitas Tolu\v{s}is <sigitas@vtex.lt>
+%% --------------------------------------------------------------------------
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3
+%% of this license or (at your option) any later version.
+%% The latest version of this license is in
+%% http://www.latex-project.org/lppl.txt
+%% and version 1.3 or later is part of all distributions of LaTeX
+%% version 2005/12/01 or later.
+%%
+%% This work has the LPPL maintenance status `maintained'.
+%%
+%% The Current Maintainer of this work is Sigitas Tolu\v{s}is.
+%%
+%% This work consists of the files boundbox.dtx and boundbox.ins
+%% and the derived filebase boundbox.sty.
+%%
+
+\input docstrip.tex
+
+\def\SimplePackage#1{%
+ \generate{\file{#1.sty}{\from{#1.dtx}{package}}}}
+
+\keepsilent
+
+\usedir{tex/latex/sttools}
+
+\preamble
+\endpreamble
+
+\askforoverwritefalse
+\SimplePackage{cuted}
+\SimplePackage{floatpag}
+\SimplePackage{flushend}
+\SimplePackage{midfloat}
+\SimplePackage{stabular}
+\SimplePackage{stfloats}
+\SimplePackage{texsort}
+
+\obeyspaces
+\Msg{*************************************************************}
+\Msg{* *}
+\Msg{* To finish the installation you have to move the following *}
+\Msg{* file into a directory searched by TeX: *}
+\Msg{* *}
+\Msg{* All the files with extension `.sty' *}
+\Msg{* *}
+\Msg{* To produce the documentation run the files with extension *}
+\Msg{* '.dtx' through LaTeX. *}
+\Msg{* *}
+\Msg{* Happy TeXing! *}
+\Msg{* *}
+\Msg{*************************************************************}
+
+\endbatchfile
diff --git a/macros/latex/contrib/sttools/sttools.pdf b/macros/latex/contrib/sttools/sttools.pdf
new file mode 100644
index 0000000000..1bbf744965
--- /dev/null
+++ b/macros/latex/contrib/sttools/sttools.pdf
Binary files differ
diff --git a/macros/latex/contrib/sttools/texsort.dtx b/macros/latex/contrib/sttools/texsort.dtx
new file mode 100644
index 0000000000..cc21e6147d
--- /dev/null
+++ b/macros/latex/contrib/sttools/texsort.dtx
@@ -0,0 +1,556 @@
+% \iffalse meta-comment
+%
+% Copyright (C) 2012 by Sigitas Tolu\v{s}is <sigitas@vtex.lt>
+% ---------------------------------------------------------------------------
+% This work may be distributed and/or modified under the
+% conditions of the LaTeX Project Public License, either version 1.3
+% of this license or (at your option) any later version.
+% The latest version of this license is in
+% http://www.latex-project.org/lppl.txt
+% and version 1.3 or later is part of all distributions of LaTeX
+% version 2005/12/01 or later.
+%
+% This work has the LPPL maintenance status `maintained'.
+%
+% The Current Maintainer of this work is Sigitas Tolu\v{s}is.
+%
+% This work consists of the files texsort.dtx and texsort.ins
+% and the derived filebase texsort.sty.
+%
+% Also available from:
+% http://www.vtex.lt/tex/download/macros/
+%
+% \fi
+%
+% \iffalse
+%<*driver>
+\ProvidesFile{texsort.dtx}
+%</driver>
+%<*package>
+%% Copyright (C) 2000-2012 by Sigitas Tolu\v{s}is <sigitas@vtex.lt>
+%% VTeX Ltd., Akademijos 4, Vilnius, Lithuania
+%% http://www.vtex.lt/tex/download/macros/
+%% --------------------------------------------------------------------------
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3
+%% of this license or (at your option) any later version.
+%% The latest version of this license is in
+%% http://www.latex-project.org/lppl.txt
+%% and version 1.3 or later is part of all distributions of LaTeX
+%% version 2005/12/01 or later.
+%%
+%% PURPOSE: Sort/compress numerical lists
+%%
+%</package>
+%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
+%<package>\ProvidesPackage{texsort}
+%<*package>
+ [2012/05/29 v1.1 Sort/compress alphanumerical list]
+%</package>
+%
+%<*driver>
+\documentclass{ltxdoc}
+\usepackage{texsort}[2012/05/29]
+%%\EnableCrossrefs
+%%\CodelineIndex
+%%\RecordChanges
+\begin{document}
+ \DocInput{texsort.dtx}
+ %%\PrintChanges
+ %%\PrintIndex
+\end{document}
+%</driver>
+% \fi
+%
+% \CheckSum{629}
+%
+% \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
+% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
+% Digits \0\1\2\3\4\5\6\7\8\9
+% Exclamation \! Double quote \" Hash (number) \#
+% Dollar \$ Percent \% Ampersand \&
+% Acute accent \' Left paren \( Right paren \)
+% Asterisk \* Plus \+ Comma \,
+% Minus \- Point \. Solidus \/
+% Colon \: Semicolon \; Less than \<
+% Equals \= Greater than \> Question mark \?
+% Commercial at \@ Left bracket \[ Backslash \\
+% Right bracket \] Circumflex \^ Underscore \_
+% Grave accent \` Left brace \{ Vertical bar \|
+% Right brace \} Tilde \~}
+%
+%
+% \changes{v0.1a}{2000/06/06}{Created alfa version}
+% \changes{v1.0}{2000/06/08}{Added compression}
+% \changes{v1.1}{2012/05/29}{Converted to DTX file}
+%
+% \DoNotIndex{\newcommand,\newenvironment}
+%
+% \providecommand*{\url}{\texttt}
+% \GetFileInfo{texsort.dtx}
+% \title{The \textsf{texsort} package}
+% \author{Sigitas Tolu\v{s}is \\ \url{sigitas@vtex.lt}}
+% \date{\fileversion~from \filedate}
+%
+% \maketitle
+%
+% \section{Introduction}
+%
+% Purpose: sort/compress numerical lists.
+%
+% \section{Usage}
+%
+% \DescribeMacro{\sortlist}
+%
+% \leftline{Sort list:}
+%
+% \verb|\sortlist{1,5,20,6,23,2,1,4000,4}\to{mylist}\sep{,}|
+%
+% \medskip
+% \leftline{Result:}
+%
+% \sortlist{1,5,20,6,23,2,1,4000,4}\to{mylist}\sep{,}
+% \verb|\mylist->|\mylist
+%
+% \bigskip
+% \DescribeMacro{\compresslist}
+%
+% \leftline{Compress list:}
+%
+% \verb|\compresslist{\mylist}\to{clist}\sep{,}{-}|
+%
+% \medskip
+% \leftline{Result:}
+% \compresslist{\mylist}\to{clist}\sep{,}{-}%
+% \verb|\clist->|\clist
+%
+% \StopEventually{}
+%
+% \section{Implementation}
+%
+% \iffalse
+%<*package>
+% \fi
+%
+% \begin{macrocode}
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{texsort}[2012/05/29]
+% \end{macrocode}
+%
+% \begin{macrocode}
+\newcount\t@mp@r@a
+\newcount\t@mp@r@b
+\newcount\t@mp@r@c
+% \end{macrocode}
+%
+% \begin{macro}{\initarray}
+% \marg{list}\marg{array}
+%
+% \medskip
+% Converts \meta{list} to \meta{array}.
+% \medskip
+% \begin{macrocode}
+\def\initarray#1#2{%
+ \bgroup
+ \@tempcnta=\z@
+ \@for\@@refb:=#2\do{%
+ \advance\@tempcnta by\@ne
+ \bgroup
+ \setbox\z@\hbox{%
+ \expandafter\global\expandafter\t@mp@r@a\expandafter\add@zero\@@refb\relax
+ }%
+ \ifdim\wd0>\z@\relax
+ \@latex@warning{Not number \@@refb!}%
+ \fi
+ \expandafter\edef\csname @a@\endcsname{\expandafter\xdef\expandafter
+ \noexpand\csname#1@\the\@tempcnta\endcsname{\the\t@mp@r@a}}\@a@
+ \egroup
+ }%
+ \expandafter\xdef\csname #1@lenght\endcsname{\the\@tempcnta}%
+ \egroup
+ }
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\outarray}
+% \marg{array}\marg{sep}
+%
+% \medskip
+% Outputs \meta{array} elements separated by \meta{sep}.
+% \medskip
+% \begin{macrocode}
+\def\outarray#1\sep#2{%
+ \bgroup
+ \@tempcnta=\z@\relax
+ \@tempcntb=\getarraylenght{#1}%
+ \loop
+ \ifnum\@tempcnta<\@tempcntb
+ \advance\@tempcnta by\@ne\relax
+ \ifnum\@tempcnta>\@ne\relax#2\fi
+ \csname#1@\the\@tempcnta\endcsname
+ \repeat
+ \egroup
+ }
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\add@zero}
+% \marg{arg}
+%
+% \medskip
+% Adds 0 before \meta{arg}.
+% \medskip
+% \begin{macrocode}
+\def\add@zero#1{0#1}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\getarrayitem}
+% \marg{array}\marg{index}\verb|\to|\marg{command}
+%
+% \medskip
+% Gets \meta{array} element by \meta{index} to \verb|\|\meta{command}.
+% \medskip
+% \begin{macrocode}
+\def\getarrayitem#1#2\to#3{\expandafter\xdef\csname#3\endcsname{\csname#1@#2\endcsname}}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\setarrayitem}
+% \marg{array}\marg{index}\marg{value}
+%
+% \medskip
+% Sets \meta{array} element by \meta{index} to \meta{value}.
+% \medskip
+% \begin{macrocode}
+\def\setarrayitem#1#2#3{%
+ \bgroup
+ \setbox0\hbox{%
+ \expandafter\global\expandafter\t@mp@r@a\expandafter\add@zero#3\relax
+ }%
+ \ifdim\wd0>\z@\relax
+ \@latex@warning{Not number #3!}%
+ \fi
+ \expandafter\xdef\csname#1@#2\endcsname{\the\t@mp@r@a}%
+ \egroup
+ }
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\getarraylenght}
+% \marg{array}
+%
+% \medskip
+% Gets \meta{array} elements count.
+% \medskip
+% \begin{macrocode}
+\def\getarraylenght#1{\@ifundefined{#1@lenght}{0}{\csname #1@lenght\endcsname}}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\setarraylenght}
+% \marg{array}\marg{value}
+%
+% \medskip
+% Sets \meta{array} elements count to \meta{value}.
+% \medskip
+% \begin{macrocode}
+\def\setarraylenght#1#2{\expandafter\xdef\csname #1@lenght\endcsname{#2}}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\upheap}
+% \marg{array}\marg{index}
+%
+% \medskip
+% Internal macro of sort algorithm.
+% \medskip
+% \begin{macrocode}
+\def\upheap#1#2{%
+ \bgroup
+ \getarrayitem{#1}{#2}\to{vara}%
+ \@namedef{#1@0}{\maxdimen}%
+ \@tempcntb=#2\relax
+ \loop
+ \@tempcnta=\@tempcntb
+ \divide\@tempcnta by2\getarrayitem{#1}{\the\@tempcnta}\to{varb}%
+ \ifnum\varb>\vara\relax
+ \else
+ \getarrayitem{#1}{\the\@tempcnta}\to{varb}%
+ \setarrayitem{#1}{\the\@tempcntb}{\varb}%
+ \divide\@tempcntb by2\relax
+ \repeat
+ \setarrayitem{#1}{\the\@tempcntb}{\vara}%
+ \egroup
+ }
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\insertheapelem}
+% \marg{array}\marg{value}
+%
+% \medskip
+% Internal macro of sort algorithm.
+% \medskip
+% \begin{macrocode}
+\def\insertheapelem#1#2{%
+ \bgroup
+ \@tempcnta=\getarraylenght{#1}\relax
+ \advance\@tempcnta by1\relax
+ \setarraylenght{#1}{\the\@tempcnta}\relax
+ \setarrayitem{#1}{\the\@tempcnta}{#2}%
+ \upheap{#1}{\the\@tempcnta}%
+ \egroup
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
+\newcount\@tempcntd
+% \end{macrocode}
+%
+% \begin{macro}{\downheap}
+% \marg{array}\marg{index}
+%
+% \medskip
+% Internal macro of sort algorithm.
+% \medskip
+% \begin{macrocode}
+\def\downheap#1#2{%
+ \bgroup
+ \getarrayitem{#1}{#2}\to{vara}%
+ \@tempcntb=\getarraylenght{#1}%
+ \t@mp@r@c=\@tempcntb\relax
+ \divide\@tempcntb by2\relax
+ \t@mp@r@b=\@tempcntb\relax
+ \@tempcntb=#2\relax
+ \ifnum\@tempcntb>\t@mp@r@b\relax
+ \else
+ \loop
+ \@tempcnta=\@tempcntb \advance\@tempcnta by\@tempcntb\relax
+ \@tempcntd=\@tempcnta \advance\@tempcntd by1\relax
+ \ifnum\@tempcnta<\t@mp@r@c\relax
+ \getarrayitem{#1}{\the\@tempcnta}\to{temp@@a}%
+ \getarrayitem{#1}{\the\@tempcntd}\to{temp@@b}%
+ \ifnum\temp@@a<\temp@@b\relax
+ \@tempcnta=\@tempcntd
+ \fi
+ \fi
+ \getarrayitem{#1}{\the\@tempcnta}\to{temp@@a}%
+ \ifnum\vara>\temp@@a\relax
+ \t@mp@r@b=-1\relax
+ \else
+ \getarrayitem{#1}{\the\@tempcnta}\to{temp@@a}%
+ \setarrayitem{#1}{\the\@tempcntb}{\temp@@a}%
+ \@tempcntb=\@tempcnta
+ \fi
+ \ifnum\@tempcntb>\t@mp@r@b\relax
+ \else
+ \repeat
+ \fi
+ \setarrayitem{#1}{\the\@tempcntb}{\vara}%
+ \egroup
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
+
+% \end{macrocode}
+%
+% \begin{macro}{\removetop}
+% \marg{array}\verb|\to|\marg{command}
+%
+% \medskip
+% Internal macro of sort algorithm.
+% \medskip
+% \begin{macrocode}
+\def\removetop#1\to#2{%
+ \bgroup
+ \getarrayitem{#1}{1}\to{temp@@c}%
+ \expandafter\xdef\csname #2\endcsname{\temp@@c}%
+ \@tempcnta=\getarraylenght{#1}%
+ \getarrayitem{#1}{\the\@tempcnta}\to{temp@@a}%
+ \setarrayitem{#1}{1}{\temp@@a}%
+ \setarrayitem{#1}{\the\@tempcnta}{}%
+ \advance\@tempcnta by-1\relax
+ \setarraylenght{#1}{\the\@tempcnta}%
+ \downheap{#1}{1}%
+ \egroup
+ }
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\g@addto@macrobeg}
+% \marg{macro}\marg{definition}
+%
+% \medskip
+% Adds some more \meta{definition} to \meta{macro} begining.
+% \medskip
+% \begin{macrocode}
+\long\def\g@addto@macrobeg#1#2{%
+ \begingroup
+ \def\@a@{#2}%
+ \toks@\expandafter\expandafter\expandafter{\expandafter\@a@#1}%
+ \xdef#1{\the\toks@}%
+ \endgroup
+ }
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\sortlistarray}
+% \marg{array}\marg{sorted array}
+%
+% \medskip
+% Sorts \meta{array} and puts result to \meta{sorted array}.
+% \begin{macrocode}
+\def\sortlistarray#1\to#2{%
+ \bgroup
+ \@for\@@refb:=#1\do{%
+ \insertheapelem{@tempa@}{\@@refb}%
+ }%
+ \@tempcntb=\getarraylenght{@tempa@}%
+ \setarraylenght{#2}{\the\@tempcntb}%
+ \@for\@@refb:=#1\do{%
+ \removetop{@tempa@}\to{aka}%
+ \setarrayitem{#2}{\the\@tempcntb}{\aka}%
+ \advance\@tempcntb by-1\relax
+ }%
+ \egroup
+ }
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\sortlist}
+% \marg{list}\verb|\to|\marg{macro}\verb|\sep|\marg{sep}
+%
+% \medskip
+% Sorts \meta{list} and puts elements separated by \meta{sep} to \meta{macro}.
+% \medskip
+% \begin{macrocode}
+\def\sortlist#1\to#2\sep#3{%
+ \bgroup
+ \@for\@@refb:=#1\do{%
+ \insertheapelem{@tempa@}{\@@refb}%
+ }%
+ \@tempcntb=\getarraylenght{@tempa@}%
+ \expandafter\def\csname#2\endcsname{}%
+ \expandafter\def\expandafter\@a@\expandafter{\csname#2\endcsname}%
+ \@for\@@refb:=#1\do{%
+ \removetop{@tempa@}\to{aka}%
+ \advance\@tempcntb by-1\relax
+ \expandafter\expandafter\expandafter
+ \g@addto@macrobeg\expandafter\@a@\expandafter{\aka}%
+ \ifnum\@tempcntb>0\relax
+ \expandafter\expandafter\expandafter
+ \g@addto@macrobeg\expandafter\@a@\expandafter{#3}%
+ \fi
+ }%
+ \egroup
+ }
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\compresslist}
+% \marg{list}\verb|\to|\marg{macro}\verb|\sep|\marg{single}\marg{multi}
+%
+% \medskip
+% Compress \meta{list} and puts result to \marg{macro};
+% single elements separated by \meta{single}, multi by \meta{multi}.
+% \medskip
+% \begin{macrocode}
+\def\compresslist#1\to#2\sep#3#4{%
+ \bgroup
+ \expandafter\def\csname#2\endcsname{}%
+ \expandafter\def\expandafter\@a@\expandafter{\csname#2\endcsname}%
+ \t@mp@r@a=-1\relax
+ \@tempcnta=-2\relax
+ \expandafter\@for\expandafter\@@refb\expandafter:\expandafter=#1\do{%
+ \ifnum\t@mp@r@a=-1\relax
+ \t@mp@r@a=\@@refb\relax
+ \t@mp@r@b=\@@refb\relax
+ \t@mp@r@c=\@@refb\relax
+ \expandafter\expandafter\expandafter
+ \g@addto@macro\expandafter\@a@\expandafter{\the\t@mp@r@a}%
+ \else
+ \t@mp@r@c=\@@refb\relax
+ \ifnum\t@mp@r@c=\t@mp@r@a\relax
+ \expandafter\expandafter\expandafter
+ \g@addto@macro\expandafter\@a@\expandafter{#3}%
+ \expandafter\expandafter\expandafter
+ \g@addto@macro\expandafter\@a@\expandafter{\the\t@mp@r@c}%
+ \t@mp@r@b=\t@mp@r@c\relax
+ \else
+ \@tempcnta=\t@mp@r@b\relax
+ \advance\@tempcnta by1\relax
+ \ifnum\@tempcnta=\t@mp@r@c\relax
+ \t@mp@r@b=\t@mp@r@c\relax
+ \else
+ \@tempcnta=\t@mp@r@a\relax
+ \advance\@tempcnta by-\t@mp@r@b\relax
+ \ifnum\@tempcnta<-1\relax
+ \expandafter\expandafter\expandafter
+ \g@addto@macro\expandafter\@a@\expandafter{#4}%
+ \expandafter\expandafter\expandafter
+ \g@addto@macro\expandafter\@a@\expandafter{\the\t@mp@r@b}%
+ \expandafter\expandafter\expandafter
+ \g@addto@macro\expandafter\@a@\expandafter{#3}%
+ \expandafter\expandafter\expandafter
+ \g@addto@macro\expandafter\@a@\expandafter{\the\t@mp@r@c}%
+ \else
+ \ifnum\t@mp@r@a<\t@mp@r@b
+ \expandafter\expandafter\expandafter
+ \g@addto@macro\expandafter\@a@\expandafter{#3}%
+ \expandafter\expandafter\expandafter
+ \g@addto@macro\expandafter\@a@\expandafter{\the\t@mp@r@b}%
+ \fi
+ \expandafter\expandafter\expandafter
+ \g@addto@macro\expandafter\@a@\expandafter{#3}%
+ \expandafter\expandafter\expandafter
+ \g@addto@macro\expandafter\@a@\expandafter{\the\t@mp@r@c}%
+ \fi
+ \t@mp@r@a=\t@mp@r@c\relax
+ \t@mp@r@b=\t@mp@r@c\relax
+ \fi
+ \fi
+ \fi
+ }%
+ \ifnum\t@mp@r@a<\t@mp@r@c\relax
+ \advance\t@mp@r@a by-\t@mp@r@c\relax
+ \ifnum\t@mp@r@a<-1\relax
+ \expandafter\expandafter\expandafter
+ \g@addto@macro\expandafter\@a@\expandafter{#4}%
+ \else
+ \expandafter\expandafter\expandafter
+ \g@addto@macro\expandafter\@a@\expandafter{#3}%
+ \fi
+ \expandafter\expandafter\expandafter
+ \g@addto@macro\expandafter\@a@\expandafter{\the\t@mp@r@c}%
+ \fi
+ \egroup
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
+%\endinput
+% \end{macrocode}
+%
+% \iffalse
+%</package>
+% \fi
+%
+% \Finale \ No newline at end of file
diff --git a/macros/latex/contrib/sttools/texsort.pdf b/macros/latex/contrib/sttools/texsort.pdf
new file mode 100644
index 0000000000..9346b39fd3
--- /dev/null
+++ b/macros/latex/contrib/sttools/texsort.pdf
Binary files differ