From f2c2457997e4318b60a659d59a9814ed967aa0be Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Thu, 9 Apr 2015 22:39:38 +0000 Subject: sttools (9apr15) git-svn-id: svn://tug.org/texlive/trunk@36753 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/tex/latex/sttools/flushend.sty | 238 ++++++++++++++++++++--- 1 file changed, 213 insertions(+), 25 deletions(-) (limited to 'Master/texmf-dist/tex') diff --git a/Master/texmf-dist/tex/latex/sttools/flushend.sty b/Master/texmf-dist/tex/latex/sttools/flushend.sty index 68e6fad9213..72f24701f98 100644 --- a/Master/texmf-dist/tex/latex/sttools/flushend.sty +++ b/Master/texmf-dist/tex/latex/sttools/flushend.sty @@ -6,8 +6,8 @@ %% %% flushend.dtx (with options: `package') %% -%% Copyright (C) 1997-2014 by Sigitas Tolu\v{s}is -%% VTeX Ltd., Akademijos 4, Vilnius, Lithuania +%% Copyright (C) 1997-2015 by Sigitas Tolu\v{s}is +%% 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 @@ -22,11 +22,20 @@ %% \NeedsTeXFormat{LaTeX2e}[1999/12/01] \ProvidesPackage{flushend} - [2014/04/24 v2.2 Balancing columns in twocolumn mode] + [2015/04/08 v3.0 Balancing columns in twocolumn mode] \newif\if@auto@baselineskip \@auto@baselineskiptrue -\newif\if@balance@debug \@balance@debugfalse +\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@debugtrue \DeclareOption{autobase}{\global\@auto@baselineskiptrue} -\DeclareOption{noauto}{\global\@auto@baselineskipfalse} +\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{debug}{\global\@balance@debugtrue} \DeclareOption{nodebug}{\global\@balance@debugfalse} \ProcessOptions @@ -37,6 +46,7 @@ \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=.4pt} \gdef\top@@floatbox@min{4\topskip} @@ -66,6 +76,12 @@ \fi \egroup } +\AtBeginDocument{% + \if@remove@lastbox@at@balancing + \else + \let\remove@lastbox@at@balancing\relax + \fi + } \def\show@@box#1{% \bgroup \showboxbreadth=20000\showboxdepth=20000% @@ -217,8 +233,10 @@ \splittopskip\z@ \setbox\flushend@@tempbox@c\vsplit\flushend@@varbox@a to\ht\strutbox \flushend@@lastskip@a\ht\flushend@@varbox@a + \advance\flushend@@lastskip@a\dp\flushend@@varbox@a \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@ @@ -229,7 +247,9 @@ \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 @@ -238,7 +258,9 @@ \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}% @@ -297,7 +319,7 @@ \fi \egroup } -\def\last@outputdblcol{% +\def\last@outputdblcol@modern{% \if@firstcolumn \global \@firstcolumnfalse \global \setbox\@leftcolumn \box\@outputbox @@ -306,16 +328,16 @@ \@tempdima\ht\@leftcolumn \splittopskip\topskip \splitmaxdepth\maxdepth \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 \if@auto@baselineskip %% Trying guess baselineskip value on column break - \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@ \splittopskip\z@ \setbox\flushend@@varbox@a\vsplit\@leftcolumn to\main@box@height @@ -339,8 +361,8 @@ \vskip\flushend@@lastskip@c \the\atColsBreak \hrule\@height\flushend@@page@rule width\columnwidth - \ifdim\top@@section@skip>\topskip - \vskip\top@@section@skip + \ifdim\top@@section@skip>\top@@skip@@limit + \vskip\top@@section@skip \fi \unvbox\@outputbox \remove@lastbox@at@balancing @@ -432,7 +454,9 @@ ^^JOutput:\the\@tempdimb }% \setbox\@outputbox\vbox to\@tempdima{% - \vbox spread\var@@temp@spread{\unvbox\@tempboxa}% + \vbox spread\var@@temp@spread{% + \unvbox\@tempboxa + }% \vss }% \else @@ -457,7 +481,9 @@ \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 @@ -469,7 +495,8 @@ ^^JExtra height:\the\var@@temp@spread\space when \the\@tempdimb }% \ifdim\var@@temp@spread<\z@ \advance\@tempdimb 1\p@ \repeat - \@tempdimb\ht\flushend@@tempbox@c + %\@tempdimb\ht\flushend@@tempbox@c + %\advance\@tempdimb by\dp\flushend@@tempbox@c \wlog{- LAST -% ^^JExtra skip:\the\var@@temp@spread ^^JLeft:\the\ht\flushend@@tempbox@c/\the\dp\flushend@@tempbox@c @@ -477,7 +504,7 @@ ^^JOutput:\the\@tempdimb }% \setbox\flushend@@tempbox@c\vsplit\@tempboxa to\@tempdimb - \setbox\flushend@@varbox@c\vbox{\unvbox\flushend@@tempbox@a}% + \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 @@ -486,16 +513,34 @@ \global\ht\@leftcolumn=\the\@tempdima \ifdim\top@@floatbox@skip>\z@ \setbox\@outputbox\vbox to\@tempdima{% - \vbox spread\var@@temp@spread{% - \unvbox\@outputbox - \vskip\top@@floatbox@skip - \unvbox\@tempboxa - }% + \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{% - \vbox spread\var@@temp@spread{\unvbox\@tempboxa}% + \if@right@column@spread + \vbox spread\var@@temp@spread{% + \unvbox\@tempboxa + }% + \else + \vbox spread\var@@temp@spread{% + \unvbox\@tempboxa + \vss + }% + \fi \vss }% \fi @@ -535,9 +580,152 @@ \endgroup \fi } +\def\last@outputdblcol@ancient{% + \if@firstcolumn + \global\@firstcolumnfalse + \global\setbox\@leftcolumn\box\@outputbox + \else + \global\@firstcolumntrue + \@tempdima\ht\@leftcolumn + \splittopskip\topskip\splitmaxdepth\maxdepth + \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 + %%\unskip + \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 + %%\setbox\z@\lastbox + %%\unskip + \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 + %\vfilneg + \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 + } \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@}% -- cgit v1.2.3