diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/sttools/flushend.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/sttools/flushend.dtx | 292 |
1 files changed, 260 insertions, 32 deletions
diff --git a/Master/texmf-dist/source/latex/sttools/flushend.dtx b/Master/texmf-dist/source/latex/sttools/flushend.dtx index 21aacf2b6a4..8bcf181d193 100644 --- a/Master/texmf-dist/source/latex/sttools/flushend.dtx +++ b/Master/texmf-dist/source/latex/sttools/flushend.dtx @@ -1,6 +1,6 @@ % \iffalse meta-comment % -% Copyright (C) 2014 by Sigitas Tolu\v{s}is <sigitas@vtex.lt> +% Copyright (C) 2015 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 @@ -24,8 +24,8 @@ \ProvidesFile{flushend.dtx} %</driver> %<*package> -%% Copyright (C) 1997-2014 by Sigitas Tolu\v{s}is <sigitas@vtex.lt> -%% VTeX Ltd., Akademijos 4, Vilnius, Lithuania +%% Copyright (C) 1997-2015 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 @@ -42,12 +42,12 @@ %<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01] %<package>\ProvidesPackage{flushend} %<*package> - [2014/04/24 v2.2 Balancing columns in twocolumn mode] + [2015/04/08 v3.0 Balancing columns in twocolumn mode] %</package> % %<*driver> \documentclass{ltxdoc} -\usepackage{flushend}[2014/03/18] +\usepackage{flushend}[2015/04/08] \EnableCrossrefs \CodelineIndex %%\RecordChanges @@ -59,7 +59,7 @@ %</driver> % \fi % -% \CheckSum{1312} +% \CheckSum{1739} % % \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 @@ -85,6 +85,10 @@ % \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} % % \DoNotIndex{\newcommand,\newenvironment} % @@ -146,7 +150,7 @@ % Adds \meta{tokens} at the end of right column. % % \medskip -% \textit{Example}: |\atColsEnd{\vfil}| +% \textit{Example}: |\atColsEnd{\vfil}|. % % \medskip % \DescribeMacro{\showcolsendrule} @@ -156,18 +160,47 @@ % \subsection{Package options} % % \medskip +% \DescribeMacro{ancient} +% It is used to switch on old version of balancing algorithm. +% +% \medskip +% \DescribeMacro{modern} +% It is used to switch on new version of balancing algorithm. +% +% \medskip % \DescribeMacro{autobase} -% It is used to guess |\baselineskip| value on original columns break. +% It is used to guess |\baselineskip| value on original columns +% break. On failure just use |\atColsBreak{...}|. % % \medskip -% \DescribeMacro{noauto} +% \DescribeMacro{noautobase} % It is used to switch off the previous option behaviour. % % \medskip +% \DescribeMacro{spread} +% 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} +% 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. +% +% \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} +% Skips putting debuging lines. +% % \StopEventually{} % % \section{Implementation} @@ -179,9 +212,18 @@ % % \begin{macrocode} \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 @@ -196,6 +238,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} % \end{macrocode} @@ -246,6 +289,12 @@ \fi \egroup } +\AtBeginDocument{% + \if@remove@lastbox@at@balancing + \else + \let\remove@lastbox@at@balancing\relax + \fi + } % \end{macrocode} % \end{macro} % @@ -434,8 +483,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@ @@ -446,7 +497,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 @@ -455,7 +508,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}% @@ -519,10 +574,10 @@ % % \begin{macro}{\last@outputdblcol} % -% Columns balancing of the twocolumn mode page. +% Columns balancing of the twocolumn mode page (modern variant). % % \begin{macrocode} -\def\last@outputdblcol{% +\def\last@outputdblcol@modern{% \if@firstcolumn \global \@firstcolumnfalse \global \setbox\@leftcolumn \box\@outputbox @@ -531,16 +586,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 @@ -564,8 +619,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 @@ -657,7 +712,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 @@ -682,7 +739,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 @@ -694,7 +753,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 @@ -702,7 +762,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 @@ -711,16 +771,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 @@ -762,6 +840,151 @@ } % \end{macrocode} % \end{macro} +% \begin{macro}{\last@outputdblcol@old} +% +% Columns balancing of the twocolumn mode page (ancient algorithm). +% +% \begin{macrocode} +\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 + } +% \end{macrocode} +% \end{macro} % % Adds default balancing of the last page at the end of document. % @@ -769,6 +992,11 @@ \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@}% |