diff options
author | Karl Berry <karl@freefriends.org> | 2014-11-02 21:50:27 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2014-11-02 21:50:27 +0000 |
commit | 4443aa712503e8404b2152c761c2ab5e1a98d197 (patch) | |
tree | c387f072c69b1415bca5a9878ce161eb50cad9ce /Master/texmf-dist/source/latex/bigfoot/perpage.dtx | |
parent | 5c146a8c39f3d52b9b6aba7423a0984e5830f407 (diff) |
bigfoot (2nov14)
git-svn-id: svn://tug.org/texlive/trunk@35482 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/bigfoot/perpage.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/bigfoot/perpage.dtx | 156 |
1 files changed, 110 insertions, 46 deletions
diff --git a/Master/texmf-dist/source/latex/bigfoot/perpage.dtx b/Master/texmf-dist/source/latex/bigfoot/perpage.dtx index 0209aa9e5d2..ad4be3ad782 100644 --- a/Master/texmf-dist/source/latex/bigfoot/perpage.dtx +++ b/Master/texmf-dist/source/latex/bigfoot/perpage.dtx @@ -1,7 +1,10 @@ % \iffalse %% %% perpage is part of the bigfoot bundle for critical typesetting -%% Copyright 2002, 03, 04, 05, 06 David Kastrup <dak@gnu.org> +%% Copyright 2002--2014 David Kastrup <dak@gnu.org> +%% +%% The license notice and corresponding source code for this file are +%% contained in perpage.dtx. %% % This program is free software; you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by @@ -17,7 +20,7 @@ % along with this program; if not, write to the Free Software % Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA % \fi -% \CheckSum{363} +% \CheckSum{396} % \GetFileInfo{perpage.sty} % \date{\filedate} % \author{David Kastrup\thanks{\texttt{dak@gnu.org}}} @@ -63,15 +66,15 @@ % \begin{quote} % |\renewcommand{\thefigure}{\thepage-\arabic{figure}}| % \end{quote} -% you'll have the problem that \thepage is updated asynchronously with -% the real page, since \TeX\ does not know which page the figure will -% end up. If you have used the |perpage| package for modifying the -% figure counter, however, at the point where the counter is -% incremented, the macro \cmd{\theperpage} will be set to the correct -% value corresponding to the actual page location. Note that this -% macro is shared between all counters, so advancing a different -% counter under control of |perpage| will render \cmd{\thefigure} -% incorrect. +% you'll have the problem that \cmd{\thepage} is updated +% asynchronously with the real page, since \TeX\ does not know which +% page the figure will end up. If you have used the |perpage| package +% for modifying the figure counter, however, at the point where the +% counter is incremented, the macro \cmd{\theperpage} will be set to +% the correct value corresponding to the actual page location. Note +% that this macro is shared between all counters, so advancing a +% different counter under control of |perpage| will render +% \cmd{\thefigure} incorrect. % % \DescribeMacro{\MakeSorted} % \begin{quote} @@ -152,18 +155,58 @@ % \end{macrocode} % % \section{The package interfaces} -% First identification. We just use date and version from CVS. +% First identification. % \begin{macrocode} %<*style> \NeedsTeXFormat{LaTeX2e} -\def\next$#1: #2 #3${#2} -\ProvidesPackage{perpage}[\next$Date: 2006/07/15 21:43:23 $ - \next$Revision: 1.12 $ Reset/sort counters per page] +\ProvidesPackage{perpage}[2014/10/25 2.0 Reset/sort counters per page] +% \end{macrocode} +% \begin{macro}{\pp@cl@begin} +% \begin{macro}{\pp@cl@end} +% These macros are considerable tricky. They are called as +% artificial `dependent' counters when the counter they are hooked +% into is advanced. The way in which those counters are called are +% one of the following: +% \begin{quote} +% \begin{verbatim} +% \def\@stpelt#1{\global\csname c@#1\endcsname \z@} +% \end{verbatim} +% \end{quote} +% which is the default way of resetting a subordinate counter used +% in \LaTeX, or +% \begin{quote} +% \begin{verbatim} +% \def\@stpelt#1{\global\csname c@#1\endcsname \m@ne\stepcounter{#1}} +% \end{verbatim} +% \end{quote} +% which is a little present from |fixltx2e.sty| as of 2014/05/01, +% quite complicating this feat. +% +% The startup code swallows either |\global \advance| or |\global|. +% \begin{macrocode} +\def\pp@cl@begin{\z@\z@ \begingroup} % \end{macrocode} +% The command used for ending our fake counters checks for the +% |\m@ne| condition. We don't want to bump our auxiliary counters +% twice, so we remove the following |\stepcounter| command. Things +% will go haywire if there is none, of course. +% \begin{macrocode} +\def\pp@cl@end{\afterassignment\pp@cl@end@ii \count@} +\def\pp@cl@end@ii{% + \relax + \expandafter\endgroup + \ifnum\count@<\z@ + \expandafter\pp@cl@end@iii + \fi} +\def\pp@cl@end@iii\stepcounter#1{} +% \end{macrocode} +% \end{macro} +% \end{macro} +% % \begin{macro}{\AddAbsoluteCounter} -% adds a counter with prefix |abs| to a given counter. It typesets as -% an arabic number and never gets reset. And it is advanced with the -% unprefixed counter. +% adds a counter with prefix |abs| to a given counter. It typesets +% as an arabic number and never gets reset. And it is advanced +% whenever the unprefixed counter gets advanced. % \begin{macrocode} \newcommand\AddAbsoluteCounter[1] {\@ifundefined{c@abs#1}{% @@ -172,9 +215,9 @@ \global\expandafter\let\csname cl@abs#1\endcsname\@empty \expandafter\xdef\csname theabs#1\endcsname{% \noexpand\number \csname c@abs#1\endcsname}% - \global\@namedef{c@pabs@#1}{\z@=\z@{% - \stepcounter{abs#1}% - \afterassignment}\count@}% + \global\@namedef{c@pabs@#1}{\pp@cl@begin + \stepcounter{abs#1}% + \pp@cl@end}% \@addtoreset{pabs@#1}{#1}}{}} % \end{macrocode} % \end{macro} @@ -294,7 +337,8 @@ \addtocounter{pp@a@#1}\m@ne \@addtoreset{pchk@#1}{#1}% \AtBeginDocument{\setcounter{pp@a@#1}\z@}% - \edef\next{\noexpand\AtEndDocument{\noexpand\setcounter{pp@a@#1}{% + \edef\next{\noexpand\AtEndDocument + {\noexpand\setcounter{pp@a@#1}{% \number\value{pp@a@#1}}}}\next} \@onlypreamble\pp@makeperpage % \end{macrocode} @@ -329,12 +373,12 @@ % \begin{macrocode} \def\pp@fetchctr#1{\expandafter\expandafter\expandafter\pp@fetchctrii \csname pp@r@#1@\number\value{pp@a@#1}\endcsname - \@empty\@empty} + {}{}} \global\let\theperpage\@empty -\def\pp@fetchctrii#1#2#3{\edef\pp@label{#1}% - \edef\pp@page{#2}% +\def\pp@fetchctrii#1#2#3{\def\pp@label{#1}% + \def\pp@page{#2}% \gdef\theperpage{#3}} % \end{macrocode} % \end{macro} @@ -352,8 +396,7 @@ % generic command. That is the reason we start off this command by % giving \cmd{\global} something to chew on. % \begin{macrocode} -\def\c@pchk@#1{\z@=\z@ - \begingroup +\def\c@pchk@#1{\pp@cl@begin % \end{macrocode} % Now we fetch the page value corresponding to the not yet adjusted % value of the absolute counter to see whether the previous counter @@ -379,18 +422,28 @@ % \begin{macro}{\pp@writectr} % This is the common ending of all pseudo reset counters. It writes % out an appropriate command to the |.aux| file with all required -% information. +% information. We try to replicate any sentinel kerns or penalties. % \begin{macrocode} \def\pp@writectr#1#2#3{\edef\next{% \string#1{#2}{\number\value{pp@a@#2}}{#3}{\noexpand\thepage}}% \pp@chkvlist \dimen@=\lastkern \ifdim\dimen@=\z@ \else \unkern\fi + \count@=\lastpenalty \protected@write\@auxout{}{\next}% - \ifdim\dimen@=\z@ \nobreak \else \kern\dimen@\fi - \afterassignment\endgroup\count@} + \ifdim\dimen@=\z@ + \penalty \ifnum\count@<\@M \@M \else \count@ \fi + \else \kern\dimen@\fi + \pp@cl@end} % \end{macrocode} % \end{macro} +% \begin{macro}{\pp@labeldef} +% This is a helper macro. +% \begin{macrocode} +\def\pp@labeldef#1#2#3#4#5{\@newl@bel{pp@r@#2}{#3}{{#1}{#4}{#5}}} +% \end{macrocode} +% \end{macro} +% % \begin{macro}{\pp@pagectr} % This is the workhorse for normal per page counters. It is called % whenever the |.aux| file is read in and establishes the @@ -399,9 +452,8 @@ % \begin{macrocode} \def\pp@pagectr#1#2#3#4{\@ifundefined{c@pp@a@#1}{}{% \addtocounter{pp@a@#1}\@ne - \edef\next{\noexpand - \@newl@bel{pp@r@#1}{#2}{{\number\value{pp@a@#1}}{#3}% - {#4}}}\next}} + \expandafter\pp@labeldef\expandafter + {\number\value{pp@a@#1}}{#1}{#2}{#3}{#4}}} % \end{macrocode} % \end{macro} % \begin{macro}{\c@schk@} @@ -413,8 +465,7 @@ % get reset, too, so that the check for changed |.aux| files will % still work. % \begin{macrocode} -\def\c@schk@#1{\z@=\z@ - \begingroup +\def\c@schk@#1{\pp@cl@begin \addtocounter{pp@a@#1}\@ne \ifnum\value{#1}=\@ne \expandafter\xdef\csname pp@g@#1\endcsname{\number\value{pp@a@#1}}% @@ -436,9 +487,8 @@ \count@0\csname pp@g@#1@#3\endcsname \advance\count@\@ne \expandafter\xdef\csname pp@g@#1@#3\endcsname{\number\count@}% - \edef\next{\noexpand - \@newl@bel{pp@r@#1}{#2}{{\number\count@}{#3}% - {#4}}}\next}} + \expandafter\pp@labeldef\expandafter + {\number\count@}{#1}{#2}{#3}{#4}}} % \end{macrocode} % \end{macro} % \begin{macro}{\c@spchk@} @@ -448,14 +498,12 @@ % and it would be hard to decide what to do in case count groups and % page positions overlap. % \begin{macrocode} -\def\c@spchk@#1{\z@=\z@ - \begingroup +\def\c@spchk@#1{\pp@cl@begin \addtocounter{pp@a@#1}\@ne \pp@fetchctr{#1}% \ifx\pp@page\@empty \else \setcounter{#1}{\pp@label}\fi \pp@writectr\pp@ppagectr{#1}{\noexpand\theabspage}} -%</style> % \end{macrocode} % \end{macro} % \begin{macro}{\pp@ppagectr} @@ -468,16 +516,32 @@ \setcounter{pp@a@#1}{\value{pp@r@#1}}% \fi \global\expandafter\let\csname pp@page@#1\endcsname\next - \edef\next{\noexpand - \@newl@bel{pp@r@#1}{#2}{{\number\value{pp@a@#1}}{#3}% - {#4}}}\next}} + \expandafter\pp@labeldef\expandafter + {\number\value{pp@a@#1}}{#1}{#2}{#3}{#4}}} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\@testdef} +% \LaTeX's current (2007) definition of this macro causes save stack +% overflow. We fix this by an additional grouping. Delay to the +% beginning of document to keep Babel happy. +% \begin{macrocode} +\AtBeginDocument{% + \begingroup + \@testdef{}{undefined}{}% + \expandafter + \endgroup + \ifx\@undefined\relax + \let\pp@@testdef\@testdef + \def\@testdef#1#2#3{{\pp@@testdef{#1}{#2}{#3}% + \if@tempswa\aftergroup\@tempswatrue\fi}}% + \fi} +%</style> % \end{macrocode} % \end{macro} % -% \Finale{} +% \Finale % \endinput % Local Variables: % mode: doctex % TeX-master: "perpage.drv" % End: - |