diff options
author | Karl Berry <karl@freefriends.org> | 2014-03-05 23:17:30 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2014-03-05 23:17:30 +0000 |
commit | 5d7310e773402ac7823bf14a692676781b062ab8 (patch) | |
tree | ae3dc241e4c89814c979db993a0e31012fda857d /Master/texmf-dist/source | |
parent | ee3cc15a5b3f684ee33aabd314448c5343ac8df6 (diff) |
sttools (4mar14)
git-svn-id: svn://tug.org/texlive/trunk@33098 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source')
-rw-r--r-- | Master/texmf-dist/source/latex/sttools/boundbox.dtx | 312 | ||||
-rw-r--r-- | Master/texmf-dist/source/latex/sttools/flushend.dtx | 756 | ||||
-rw-r--r-- | Master/texmf-dist/source/latex/sttools/sttools.dtx | 11 | ||||
-rw-r--r-- | Master/texmf-dist/source/latex/sttools/sttools.ins | 3 |
4 files changed, 617 insertions, 465 deletions
diff --git a/Master/texmf-dist/source/latex/sttools/boundbox.dtx b/Master/texmf-dist/source/latex/sttools/boundbox.dtx deleted file mode 100644 index 3453b2128c6..00000000000 --- a/Master/texmf-dist/source/latex/sttools/boundbox.dtx +++ /dev/null @@ -1,312 +0,0 @@ -% \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 boundbox.dtx and boundbox.ins -% and the derived filebase boundbox.sty. -% -% \fi -% -% \iffalse -%<*driver> -\ProvidesFile{boundbox.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: Calculate TeX bounding box in rounded points (LaTeX2e) -%% from left top corner of the paper -%% -%</package> -%<package>\NeedsTeXFormat{LaTeX2e} -%<package>\ProvidesPackage{boundbox} -%<*package> - [2012/05/29 v1.3 Calculate TeX bounding box in points] -%</package> -% -%<*driver> -\documentclass{ltxdoc} -\usepackage{boundbox}[2012/05/29] -\EnableCrossrefs -\CodelineIndex -\RecordChanges -\begin{document} - \DocInput{boundbox.dtx} - %%\PrintChanges - %%\PrintIndex -\end{document} -%</driver> -% \fi -% -% \CheckSum{186} -% -% \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.3}{2012/05/29}{Source converted to DTX file} -% \changes{v1.3}{2012/05/29}{Added package option nospec} -% -% \DoNotIndex{\newcommand,\newenvironment} -% -% \providecommand*{\url}{\texttt} -% \GetFileInfo{boundbox.dtx} -% \title{The \textsf{boundbox} package} -% \author{Sigitas Tolu\v{s}is \\ \url{sigitas@vtex.lt}} -% \date{\fileversion~from \filedate} -% -% \maketitle -% -% \section{Introduction} -% -% The package is used to calculate textbox coordinates on the page. -% I guess that the most useable part of this package can be internal -% macro \verb|\roundtexdim| for rounding pt values to int numbers. -% -% \section{Usage} -% -% Just add package to the tex file as: \verb|\usepackage{boundbox}|. -% \\\medskip -% Rounding tex dimension values: -% -% \newdimen\testdim \testdim=1in\verb|\newdimen\testdim| -% -% \verb|\testdim=1in \the\testdim ->| -% \the\testdim -% -% \medskip -% \roundtexdim{\testdim}\foo\verb|\roundtexdim{\testdim}\foo \number\foo->|\number\foo -% -% \medskip -% \roundtexdim floor{\testdim}\foo\verb|\roundtexdim floor{\testdim}\foo \number\foo->|\number\foo -% -% \medskip -% \roundtexdim ceil{\testdim}\foo\verb|\roundtexdim ceil{\testdim}\foo \number\foo->|\number\foo -% -% \StopEventually{} -% -% \section{Implementation} -% -% \iffalse -%<*package> -% \fi -% -% The package contains two options: -% -% \meta{nofoot} -- do not include foot to the bbox. -% -% \meta{nospec} -- do not write specials with bbox info. -% -% \begin{macrocode} -% -%% -\newif\if@withfoot \@withfoottrue -\newif\if@output@bbox@special \@output@bbox@specialtrue -\DeclareOption{nofoot}{\global\@withfootfalse} -\DeclareOption{nospec}{\global\@output@bbox@specialfalse} -\ProcessOptions -%% -% -% \end{macrocode} -% -% Definitions of special prefixes. -% -% \begin{macrocode} -\def\special@bbox@odd@prefix{mt:TeXBBox:odd} -\def\special@bbox@even@prefix{mt:TeXBBox:even} -% \end{macrocode} -% -% \begin{macro}{\roundtexdim} -% \marg{round type}\marg{tex dimension}\marg{command} -% -% \meta{tex dimension} value in pt rounded with \meta{round type} -% is defined as \meta{command}. -% -% \begin{macrocode} -% -%% -\def\roundtexdim#1#{\round@tex@dim{#1}} -\def\round@tex@dim#1#2#3{% - \expandafter\expandafter\csname get@#1@pt@data\endcsname\the#2\to#3\relax - } -% \end{macrocode} -% \end{macro} -% -% -% Internal macro for calculating rounded value to the floor. -% -% -% \begin{macro}{\get@floor@pt@data} -% -% \begin{macrocode} -\def\get@floor@pt@data#1.#2#3\to#4{% - \bgroup - \@tempcnta=#1\relax - \xdef#4{\the\@tempcnta}% - \egroup - } -% \end{macrocode} -% \end{macro} -% -% -% Internal macro for calculating rounded value by first number after point. -% -% -% \begin{macro}{\get@round@pt@data} -% -% \begin{macrocode} -\def\get@round@pt@data#1.#2#3\to#4{% - \bgroup - \@tempcnta=#1\relax - \ifnum#2>4\relax - \advance\@tempcnta by\@ne - \fi - \xdef#4{\the\@tempcnta}% - \egroup - } -\let\get@@pt@data\get@round@pt@data -% \end{macrocode} -% \end{macro} -% -% -% Internal macro for calculating rounded value to the ceiling. -% -% -% \begin{macro}{\get@ceil@pt@data} -% -% \begin{macrocode} -\def\get@ceil@pt@data#1.#2#3\to#4{% - \bgroup - \@tempcnta=#1\relax - \afterassignment\@gobbletwo - \@tempcntb=#2#3\relax - \ifnum\@tempcntb>0\relax - \advance\@tempcnta by\@ne - \fi - \xdef#4{\the\@tempcnta}% - \egroup - } -% \end{macrocode} -% \end{macro} -% -% -% \begin{macro}{\@calculate@bbox} -% -% Internal macro \verb|\@calculate@bbox| calculates TeX box dimensions: -% -% \begin{itemize} -% \item \verb|\bbox@odd@top@pt| and \verb|\bbox@even@top@pt|: -% distance in rounded ``floor'' points from the top of paper to the top of TeX box -% (including head) (the same for odd and even pages); -% \item \verb|\bbox@odd@left@pt| and \verb|\bbox@even@left@pt|: -% distance in rounded ``floor'' points from the left side of paper -% to the left side of TeX box for odd and even pages; -% \item \verb|\bbox@odd@right@pt| and \verb|\bbox@even@right@pt|: -% distance in rounded ``ceil'' points from the left side of paper to the right -% side of TeX box accordingly for odd and even pages; -% \item \verb|\bbox@odd@bottom@pt| and \verb|\bbox@even@bottom@pt|: -% distance in rounded ``ceil'' points from the top of paper to the bottom of TeX -% box (including foot by default; with option "nofoot" without -% foot) (the same for odd and even pages). -% \end{itemize} -% -% \begin{macrocode} -\def\@calculate@bbox{% - \bgroup - \@tempdima=1in\relax - \advance\@tempdima by\hoffset - \advance\@tempdima by\oddsidemargin - \roundtexdim floor{\@tempdima}\bbox@odd@left@pt - \advance\@tempdima\textwidth - \roundtexdim ceil{\@tempdima}\bbox@odd@right@pt - \@tempdima=1in\relax - \advance\@tempdima by\hoffset - \advance\@tempdima by\evensidemargin - \roundtexdim floor{\@tempdima}\bbox@even@left@pt - \advance\@tempdima\textwidth - \roundtexdim ceil{\@tempdima}\bbox@even@right@pt - \@tempdima=1in\relax - \advance\@tempdima by\voffset - \advance\@tempdima by\topmargin - \roundtexdim floor{\@tempdima}\bbox@odd@top@pt - \global\let\bbox@even@top@pt\bbox@odd@top@pt - \advance\@tempdima by\headheight - \advance\@tempdima by\headsep - \advance\@tempdima\textheight - \if@withfoot - \advance\@tempdima\footskip - \fi - \roundtexdim ceil{\@tempdima}\bbox@odd@bottom@pt - \global\let\bbox@even@bottom@pt\bbox@odd@bottom@pt - \egroup - } -% \end{macrocode} -% \end{macro} -% -% Without package option \meta{nospec} two specials are written to the -% output file. Prefix of particular special is defined by: -% \verb|\special@bbox@odd@prefix| and \verb|\special@bbox@even@prefix|. -% -% \begin{macrocode} -% -%% -\AtBeginDocument{% - \@calculate@bbox - \if@output@bbox@special - \special{\special@bbox@odd@prefix\space - left=\csname bbox@odd@left@pt\endcsname\space - top=\csname bbox@odd@top@pt\endcsname\space - right=\csname bbox@odd@right@pt\endcsname\space - bottom=\csname bbox@odd@bottom@pt\endcsname - }% - \special{\special@bbox@even@prefix\space - left=\csname bbox@even@left@pt\endcsname\space - top=\csname bbox@even@top@pt\endcsname\space - right=\csname bbox@even@right@pt\endcsname\space - bottom=\csname bbox@even@bottom@pt\endcsname - }% - \fi - } -\endinput -% \end{macrocode} -% -% \iffalse -%</package> -% \fi -% -% \Finale diff --git a/Master/texmf-dist/source/latex/sttools/flushend.dtx b/Master/texmf-dist/source/latex/sttools/flushend.dtx index 6e5327ee4df..85bd869d005 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) 2012 by Sigitas Tolu\v{s}is <sigitas@vtex.lt> +% 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 @@ -24,7 +24,7 @@ \ProvidesFile{flushend.dtx} %</driver> %<*package> -%% Copyright (C) 1997-2012 by Sigitas Tolu\v{s}is <sigitas@vtex.lt> +%% Copyright (C) 1997-2014 by Sigitas Tolu\v{s}is <sigitas@vtex.lt> %% VTeX Ltd., Akademijos 4, Vilnius, Lithuania %% http://www.vtex.lt/tex/download/macros/ %% -------------------------------------------------------------------------- @@ -42,12 +42,12 @@ %<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01] %<package>\ProvidesPackage{flushend} %<*package> - [2012/05/29 v1.1 Balancing columns at last page] + [2014/03/03 v2.0 Balancing columns in twocolumn mode] %</package> % %<*driver> \documentclass{ltxdoc} -\usepackage{flushend}[2012/05/29] +\usepackage{flushend}[2014/02/29] \EnableCrossrefs \CodelineIndex %%\RecordChanges @@ -59,7 +59,7 @@ %</driver> % \fi % -% \CheckSum{285} +% \CheckSum{1305} % % \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 @@ -82,6 +82,7 @@ % \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} % % \DoNotIndex{\newcommand,\newenvironment} % @@ -95,12 +96,18 @@ % % \section{Introduction} % -% The package is used to balance columns on the last page in twocolumn mode. +% 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: that's all. +% Just load the package to balance the last page: that's all. +% To balance some page in middle of document use command +% \cs{flushcolsend} at that page. % +% \medskip % \DescribeMacro{\flushend} % % This macro switches on column balancing on the last page. It is used @@ -112,6 +119,16 @@ % 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} % @@ -121,25 +138,36 @@ % \textit{Example}: |\atColsBreak{\vskip-2pt}| % % \medskip -% \DescribeMacro{\showcolsendrule} +% \DescribeMacro{\atColsEnd} +% \marg{tokens} % -% It can be used just for debugging: adds rule to the bottom of columns. +% Adds \meta{tokens} at the end of right column. % -% \section{Tips} +% \medskip +% \textit{Example}: |\atColsEnd{\vfil}| % -% Sometimes the balancing can be not so good. In that case to stretch -% right column by \meta{tex dimension} add command |\vskip-|\meta{tex dimension} just before -% |\end{document}|. To shrink right column use |\vskip|\meta{tex dimension}. +% \medskip +% \DescribeMacro{\showcolsendrule} % +% It can be used just for debugging: adds rule to the bottom of columns. +% +% \subsection{Package options} +% % \medskip -% \textit{Example}: +% \DescribeMacro{autobase} +% It is used to guess |\baselineskip| value on original columns break. % -% |\vskip-10pt%| +% \medskip +% \DescribeMacro{noauto} +% It is used to switch off the previous option behaviour. % -% |\end{document}| +% \medskip +% \DescribeMacro{debug} +% Adds rules to the bottom of columns (just for debugging) and leftcolumn break place. +% Adds some additional log info. % % \StopEventually{} -% +% % \section{Implementation} % % \iffalse @@ -148,173 +176,611 @@ % % \begin{macrocode} \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{flushend}[1997/10/01] +\ProvidesPackage{flushend}[2014/03/03 v2.0 Balancing columns in twocolumn mode] +% \end{macrocode} +% +% \begin{macrocode} +\newif\if@auto@baselineskip \@auto@baselineskiptrue +\newif\if@balance@debug \@balance@debugtrue +\DeclareOption{autobase}{\global\@auto@baselineskiptrue} +\DeclareOption{noauto}{\global\@auto@baselineskipfalse} +\DeclareOption{debug}{\global\@balance@debugtrue} +\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 +\newdimen\flushend@@page@rule \flushend@@page@rule\z@ +\def\showcolsendrule{\global\flushend@@page@rule=.4pt} +% \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{4\topskip} % \end{macrocode} +% \end{macro} % % \begin{macrocode} -\newbox\@aaa -\newbox\@ccc +\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={} -\newdimen\@extra@skip \@extra@skip\z@ -\newdimen\@nd@page@rule \@nd@page@rule\z@ +\newtoks\atColsEnd \atColsEnd={} % \end{macrocode} % -% \begin{macro}{\last@outputdblcol} % \begin{macrocode} -\def\last@outputdblcol{% - \if@firstcolumn - \global \@firstcolumnfalse - \global \setbox\@leftcolumn \box\@outputbox - \else - \global \@firstcolumntrue - \if@lastpage - \@tempdima\ht\@leftcolumn - \splittopskip\topskip\splitmaxdepth\maxdepth - \setbox\@tempboxa\vbox{% - \unvbox\@leftcolumn\setbox0\lastbox\unskip - \the\atColsBreak - \unvbox\@outputbox\setbox0\lastbox\unskip - }% - \@tempdimb .5\ht\@tempboxa - \loop - \setbox\@aaa\copy\@tempboxa - \setbox\@ccc\vbox to\@tempdimb{% - \vsplit\@aaa to\@tempdimb - \vss - \vsplit\@aaa to\@tempdimb - }% - \wlog{Extra height:\the\ht\@aaa\space when \the\@tempdimb}% - \ifvoid\@aaa - \else - \advance\@tempdimb 1\p@ - \repeat - \loop - \setbox\@aaa\copy\@tempboxa - \setbox\@ccc\vbox to\@tempdimb{% - \vsplit\@aaa to\@tempdimb - \vss - }% - \wlog{(2)Left:\the\ht\@ccc\space - Right:\the\ht\@aaa\space - Output:\the\@tempdimb - }% - \ifdim \ht\@ccc<\ht\@aaa - \@tempdimb \the\ht\@aaa - \repeat - \wlog{- LAST -^^JExtra skip:\the\@extra@skip - ^^JLeft:\the\ht\@ccc - ^^JRight:\the\ht\@aaa - ^^JOutput:\the\@tempdimb - }% - \setbox\@ccc\vbox to\@tempdimb{% - \vsplit\@tempboxa to\@tempdimb - \vss - }% - \setbox\@leftcolumn\vbox to\@tempdima{% - \vbox to\@tempdimb{\unvbox\@ccc}% - \hrule\@height\@nd@page@rule - \vss - }% - \setbox\@outputbox\vbox to\@tempdima{% - \vbox to\@tempdimb{% - \unvbox\@tempboxa - \vfilneg - \vskip\@extra@skip - }% - \hrule\@height\@nd@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}% - }% - }% - \else - \setbox\@outputbox \vbox {% - \hb@xt@\textwidth {% - \hb@xt@\columnwidth {\box\@leftcolumn \hss}% - \hfil - \vrule \@width\columnseprule - \hfil - \hb@xt@\columnwidth {\box\@outputbox \hss}% - }% - }% - \fi - \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 +\@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} +\gdef\remove@lastbox@at@balancing{% + \unskip\unkern\unpenalty + \unskip\unkern\unpenalty + \unskip\unkern\unpenalty + {\setbox\z@\lastbox}% + \unskip\unkern\unpenalty + \unskip\unkern\unpenalty + \unskip\unkern\unpenalty + } +% \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} +% \begin{macrocode} +\gdef\analyze@leftcolumn@box#1{% + \splittopskip\z@ \vfuzz\maxdimen \vbadness\maxdimen + \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 + \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 + \ifdim\ht\flushend@@varbox@a>.5\topskip + \analyze@lastbox@box\flushend@@varbox@a + \fi + \setbox\flushend@@varbox@a\vbox{\unvbox\flushend@@tempbox@c}% \else - \global\setbox\@viper\vbox{% - \vskip-\stripsep - \unvbox\@viper - }% - \@viperoutput + \wlog@balance@debug{lastbox: \log@box@info{\flushend@@varbox@a}}% \fi - \endgroup \fi -} + \ifdim\ht\flushend@@varbox@a>\topskip + \expandafter\analyze@leftcolumn@box\expandafter\flushend@@varbox@a + \fi + } % \end{macrocode} % \end{macro} % +% \begin{macro}{\get@@footnoterule@@box} % \begin{macrocode} -\let\prev@enddocument\enddocument -\newif\if@lastpage \@lastpagefalse +\def\get@@footnoterule@@box{% + \splittopskip\z@ \vfuzz\maxdimen \vbadness\maxdimen + \setbox\flushend@@varbox@a\vbox{\strut + \vskip\z@ + \footnoterule + \unskip\unkern\unpenalty + \unskip\unkern\unpenalty + }% + \setbox\flushend@@tempbox@c\vsplit\flushend@@varbox@a to\ht\strutbox + \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}}% + } % \end{macrocode} +% \end{macro} % -% \begin{macro}{\enddocument} +% \begin{macro}{\check@@footnoterule@@box}\marg{box}\marg{skip}\marg{box} % \begin{macrocode} -\def\enddocument{% - \global\@lastpagetrue - \let\@outputdblcol\last@outputdblcol - \prev@enddocument +\def\check@@footnoterule@@box#1#2#3{% + \ifdim\ht#1=\footnoterule@@box@@ht + \ifdim\dp#1=\footnoterule@@box@@dp + \ifdim\wd#1=\footnoterule@@box@@wd + \ifdim#2>\topskip + \xdef\main@box@height{\the\ht#3}% + \xdef\main@box@skip{\the#2}% + \fi + \fi + \fi + \fi } % \end{macrocode} % \end{macro} % +% \begin{macro}{\check@@baselineskip@@skip}\marg{dimension}\marg{dimension}\marg{var} +% \begin{macrocode} +\def\check@@baselineskip@@skip#1#2#3{% + \ifdim#1>\z@ + \ifdim#2>\z@ + \global#3=\the#1% + \gdef\check@@baselineskip@@skip##1##2##3{}% + \fi + \fi + } +% \end{macrocode} +% \end{macro} % -% \begin{macro}{\raggedend} +% \begin{macro}{\analyze@rightcolumn@box}\marg{box} % \begin{macrocode} -\def\raggedend{\global\let\enddocument\prev@enddocument} +\def\analyze@rightcolumn@box#1{% + \bgroup + \xdef\top@@floatbox@ht{\z@}% + \xdef\top@@floatbox@skip{\z@}% + \xdef\top@@section@skip{\z@}% + \splittopskip\z@ \vfuzz\maxdimen \vbadness\maxdimen + \wlog@balance@debug{^^J(R)mainbox: \log@box@info{#1}}% + \var@@temp@a3\p@ + \setbox\flushend@@varbox@a\vbox{\strut + \vskip\z@ + \unvcopy#1% + }% + \splittopskip\z@ + \setbox\flushend@@tempbox@c\vsplit\flushend@@varbox@a to\ht\strutbox + \flushend@@lastskip@a\ht\flushend@@varbox@a + \loop + \flushend@@lastskip@b\ht\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 -\ht\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 -\ht\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@ + \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}{\last@outputdblcol} +% +% Columns balancing of the twocolumn mode page. % -% \begin{macro}{\flushend} % \begin{macrocode} -\def\flushend{% - \gdef\enddocument{% - \global\@lastpagetrue - \let\@outputdblcol\last@outputdblcol - \prev@enddocument - }% +\def\last@outputdblcol{% + \if@firstcolumn + \global \@firstcolumnfalse + \global \setbox\@leftcolumn \box\@outputbox + \else + \global \@firstcolumntrue + \@tempdima\ht\@leftcolumn + \splittopskip\topskip \splitmaxdepth\maxdepth + \var@@temp@spread=\wd\@outputbox + \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 + \else + \setbox\flushend@@varbox@a\box\@leftcolumn + \fi + \ifdim\var@@temp@spread>\z@ + \setbox\@outputbox\vbox{\strut + \vskip\z@ + \unvbox\@outputbox + }% + \splittopskip\z@ + \setbox\flushend@@tempbox@c\vsplit\@outputbox to\ht\strutbox + \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>\topskip + \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 %% rightcolumn empty + \setbox\@tempboxa\vbox{% + \unvbox\flushend@@varbox@a + \remove@lastbox@at@balancing + \the\atColsEnd + }% + \fi + \else + %% Ignore baselineskip value on column break + \ifdim\var@@temp@spread>\z@ + \setbox\@outputbox\vbox{\strut + \vskip\z@ + \unvbox\@outputbox + }% + \splittopskip\z@ + \setbox\flushend@@tempbox@c\vsplit\@outputbox to\ht\strutbox + \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 + }% + \else + \setbox\@tempboxa\vbox{% + \unvbox\@leftcolumn + \remove@lastbox@at@balancing + \the\atColsEnd + }% + \fi + \fi + \ifdim\main@box@skip>\z@ + \@tempdimb\ht\@tempboxa + \advance\@tempdimb -\main@box@skip + \advance\@tempdimb -\ht\@leftcolumn + \@tempdimb .5\@tempdimb + \splittopskip\topskip \splitmaxdepth\maxdepth + \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 + \vskip\main@box@skip + \unvcopy\@leftcolumn + }% + \setbox\flushend@@varbox@c\vbox{\unvbox\flushend@@varbox@a}% + \var@@temp@spread=\ht\flushend@@tempbox@c + \advance\var@@temp@spread by-\ht\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 + \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 + }% + \setbox\@outputbox\vbox to\@tempdima{% + \vbox spread\var@@temp@spread{\unvbox\@tempboxa}% + \vss + }% + \else + \@tempdimb \ht\@tempboxa + \ifdim\top@@floatbox@skip>\z@ + \advance\@tempdimb \top@@floatbox@skip + \advance\@tempdimb \top@@floatbox@ht + \fi + \@tempdimb .5\@tempdimb + \splittopskip\topskip \splitmaxdepth\maxdepth + \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-\ht\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 + \@tempdimb\ht\flushend@@tempbox@c + \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@a}% + \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{% + \vbox spread\var@@temp@spread{% + \unvbox\@outputbox + \vskip\top@@floatbox@skip + \unvbox\@tempboxa + }% + \vss + }% + \else + \setbox\@outputbox\vbox to\@tempdima{% + \vbox spread\var@@temp@spread{\unvbox\@tempboxa}% + \vss + }% + \fi + \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} % +% Adds default balancing of the last page at the end of document. % -% \begin{macro}{\showcolsendrule} % \begin{macrocode} -\def\showcolsendrule{\global\@nd@page@rule=.4pt} +\usepackage{etoolbox} +\AtBeginDocument{% + \global\let\saved@orig@@outputdblcol\@outputdblcol + \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. +% +% \begin{macrocode} +\def\flushcolsend{\global\let\@outputdblcol\last@outputdblcol} +\def\raggedcolsend{\global\let\@outputdblcol\saved@orig@@outputdblcol} +\def\flushend{\global\let\balanced@@outputdblcol\last@outputdblcol} +\def\raggedend{\global\let\balanced@@outputdblcol\saved@orig@@outputdblcol} % \end{macrocode} -% \end{macro} % % \begin{macrocode} -%\endinput +\if@balance@debug + \showcolsendrule +\fi % \end{macrocode} % % \iffalse diff --git a/Master/texmf-dist/source/latex/sttools/sttools.dtx b/Master/texmf-dist/source/latex/sttools/sttools.dtx index fd1e017e55a..c035680a0d1 100644 --- a/Master/texmf-dist/source/latex/sttools/sttools.dtx +++ b/Master/texmf-dist/source/latex/sttools/sttools.dtx @@ -1,6 +1,6 @@ % \iffalse meta-comment % -% Copyright (C) 2012 by Sigitas Tolu\v{s}is <sigitas@vtex.lt> +% 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 @@ -62,7 +62,7 @@ % \GetFileInfo{sttools.dtx} % \title{The \textsf{sttools} collection} % \author{Sigitas Tolu\v{s}is \\ \url{sigitas@vtex.lt}} -% \date{2012.10.17} +% \date{2014.03.03} % % \maketitle % @@ -74,14 +74,13 @@ % \section{Usage} % % \begin{itemize} -% \item \textbf{boundbox.sty} -- calculate textbox coordinates on the page; -% \\\texttt{TODO: remove from bundle}; % \item \textbf{cuted.sty} -- 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} -- set pagestyle for floats page; -% \item \textbf{flushend.sty} -- balance twocolumn page; \\\texttt{TODO: -% extend to balance any page}; +% \item \textbf{flushend.sty, v2.0} -- balance page in twocolumn mode; +% \\\texttt{NEW: totally rewritten with new algorithm to support footnotes, +% top floats and column break before one line section title}. % \item \textbf{marginal.sty} -- use enlarged room for marginal inserts; % \item \textbf{midfloat.sty} -- insert onecolumn stuff in twocolumn % page; \\\texttt{TODO: extend to work on both columns}; diff --git a/Master/texmf-dist/source/latex/sttools/sttools.ins b/Master/texmf-dist/source/latex/sttools/sttools.ins index 4b537051fd1..1395ad08617 100644 --- a/Master/texmf-dist/source/latex/sttools/sttools.ins +++ b/Master/texmf-dist/source/latex/sttools/sttools.ins @@ -1,4 +1,4 @@ -%% Copyright (C) 2012 by Sigitas Tolu\v{s}is <sigitas@vtex.lt> +%% 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 @@ -29,7 +29,6 @@ \endpreamble \askforoverwritefalse -\SimplePackage{boundbox} \SimplePackage{cuted} \SimplePackage{floatpag} \SimplePackage{flushend} |