summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/pbalance
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2021-05-06 20:24:08 +0000
committerKarl Berry <karl@freefriends.org>2021-05-06 20:24:08 +0000
commitcbb05795040a0c9560099c429f37134fd14559eb (patch)
tree29efe53acdc508587ed052b0486b7f6b07e89d9d /Master/texmf-dist/tex/latex/pbalance
parentd23ce5cb0bb42ef0380b13d2d43d48afcc51b897 (diff)
pbalance (6may21)
git-svn-id: svn://tug.org/texlive/trunk@59106 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/pbalance')
-rw-r--r--Master/texmf-dist/tex/latex/pbalance/pbalance.sty99
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}
+ }
+ {}
}
}