diff options
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r-- | Master/texmf-dist/tex/latex/pbalance/pbalance.sty | 99 |
1 files changed, 61 insertions, 38 deletions
diff --git a/Master/texmf-dist/tex/latex/pbalance/pbalance.sty b/Master/texmf-dist/tex/latex/pbalance/pbalance.sty index 44e13db92fd..43cdab7bfc7 100644 --- a/Master/texmf-dist/tex/latex/pbalance/pbalance.sty +++ b/Master/texmf-dist/tex/latex/pbalance/pbalance.sty @@ -5,10 +5,10 @@ %% The original source files were: %% %% pbalance.dtx (with options: `package') -%% Copyright 2020 Nelson Lago <lago@ime.usp.br> +%% Copyright 2020-2021 Nelson Lago <lago@ime.usp.br> %% %% 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 +%% LaTeX Project Public License, either version 1.3c of this license or (at %% your option) any later version. The latest version of this license can be %% found at 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. @@ -18,7 +18,7 @@ %% The Current Maintainer of this work is Nelson Lago <lago@ime.usp.br>. %% \NeedsTeXFormat{LaTeX2e}[2015/01/01] -\ProvidesPackage{pbalance}[2020/12/16 v1.0.1 Poor man's balance] +\ProvidesPackage{pbalance}[2021/04/26 v1.1.0 Poor man's balance] \RequirePackage{etoolbox} \RequirePackage{expl3} @@ -290,25 +290,30 @@ \ExplSyntaxOn \AtBeginShipout{ - \ifboolexpr - { - % A float page is not the last text page, ignore - togl {@PBtmpIsFloatPage} - or - % A page with a float column on the left and an empty - % column on the right is not the last text page, ignore - ( - togl {@PBtmpHasFloatcol} - and - test {\ifdimcomp{\@PBtmpUsedRight}{=}{\topskip}} - ) - } - {} - { - % This page is a candidate to be the last page - \xdef\@PBlastPage{\the\value{abspage}} - \@PBcopyPageData{tmp}{candidate} - } + % It only makes sense to consider pages that actually have two + % columns. LaTeX3 does not do short-circuit evaluation, so we + % cannot add this test to the ifboolexpr below. + \if@twocolumn + \ifboolexpr + { + % A float page is not the last text page, ignore + togl {@PBtmpIsFloatPage} + or + % A page with a float column on the left and an empty + % column on the right is not the last text page, ignore + ( + togl {@PBtmpHasFloatcol} + and + test {\ifdimcomp{\@PBtmpUsedRight}{=}{\topskip}} + ) + } + {} + { + % This page is a candidate to be the last two-column text page + \xdef\@PBlastPage{\the\value{abspage}} + \@PBcopyPageData{tmp}{candidate} + } + \fi % Reset before processing next page \global\togglefalse{@PBtmpHasFloats} @@ -323,7 +328,13 @@ \ExplSyntaxOff -\AfterLastShipout{\@PBcopyPageData{candidate}{pg\@Roman{\@PBlastPage}}} +\AfterLastShipout{ + % If there are no two-column pages in the + % document, there is no candidate page. + \ifcsdef{@PBlastPage} + {\@PBcopyPageData{candidate}{pg\@Roman{\@PBlastPage}}} + {} +} \AfterLastShipout{ @@ -544,19 +555,25 @@ \newcommand\@PBsaveUnbalancedInfo[1][]{ - \immediate\write\@mainaux{\gdef\string\@PBprevLastPage{\@PBlastPage}} - - \ifboolexpr{test {\ifdefvoid{\@PBprevLastPage}} or test {\ifstrequal{#1}{update}}} - % Columns are currently unbalanced, either because this is - % the first pass (we do not have any previous information) - % or because the document has not stabilized yet, so any - % previous information is unreliable. Save the information - % we just collected as ``unbalanced''. - {\@PBsavePageDataAs{pg\@Roman{\@PBlastPage}}{unbalpg\@Roman{\@PBlastPage}}} - % Not the first pass, so columns are possibly balanced; - % to save the unbalanced information, repeat what was - % gathered during the first pass. - {\@PBsavePageData{unbalpg\@Roman{\@PBprevLastPage}}} + % If there are no two-column pages in the + % document, there is nothing to save. + \ifcsdef{@PBlastPage} + { + \immediate\write\@mainaux{\gdef\string\@PBprevLastPage{\@PBlastPage}} + + \ifboolexpr{test {\ifdefvoid{\@PBprevLastPage}} or test {\ifstrequal{#1}{update}}} + % Columns are currently unbalanced, either because this is + % the first pass (we do not have any previous information) + % or because the document has not stabilized yet, so any + % previous information is unreliable. Save the information + % we just collected as ``unbalanced''. + {\@PBsavePageDataAs{pg\@Roman{\@PBlastPage}}{unbalpg\@Roman{\@PBlastPage}}} + % Not the first pass, so columns are possibly balanced; + % to save the unbalanced information, repeat what was + % gathered during the first pass. + {\@PBsavePageData{unbalpg\@Roman{\@PBprevLastPage}}} + } + {} } \def\@PBsaveBalancedInfo{ @@ -568,8 +585,14 @@ \def\@PBnotifyRerun{ \AtVeryEndDocument{ - \PackageWarningNoLine{pbalance} - {Last page columns not balanced. Rerun LaTeX} + % If there are no two-column pages in the document, + % it makes no sense to emit this warning. + \ifcsdef{@PBlastPage} + { + \PackageWarningNoLine{pbalance} + {Last two-column page cols not balanced. Rerun LaTeX} + } + {} } } |