summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/ltxmisc/perpage.sty
blob: a9412b77c17a318a3f823ad447cd66b458cdd0db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
% $Id: perpage.sty,v 1.2 2002/12/20 19:25:34 dak Exp $
% The following package adds the ability to reset counters per page.
% Usage example:
% \MakePerPage[2]{footnote}
% will start footnote numbers with 2 on each page (the optional
% argument defaults to 1).  2 might be a strange number, unless
% you have \renewcommand\thefootnote{\fnsymbol{footnote}} and
% want to start off with a dagger.  This may need multiple passes
% to work: LaTeX will complain about changed labels if you need
% another pass.
% Copyright 2002 David Kastrup, <David.Kastrup@t-online.de>
% distributable under the LPPL

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{perpage}[2002/12/20 v1.0 Reset counters per page]
\newcommand*\MakePerPage[2][\@ne]{%
  \expandafter\def\csname c@pchk@#2\endcsname{\c@pchk@{#2}{#1}}%
  \newcounter{pcabs@#2}%
  \@addtoreset{pchk@#2}{#2}}

\def\new@pagectr#1{\@newl@bel{pchk@#1}}

\def\c@pchk@#1#2{\z@=\z@
  \begingroup
  \expandafter\let\expandafter\next\csname pchk@#1@\arabic{pcabs@#1}\endcsname
  \addtocounter{pcabs@#1}\@ne
  \expandafter\ifx\csname pchk@#1@\arabic{pcabs@#1}\endcsname\next
  \else \setcounter{#1}{#2}\fi
  \protected@edef\next{%
    \string\new@pagectr{#1}{\arabic{pcabs@#1}}{\noexpand\thepage}}%
  \protected@write\@auxout{}{\next}%
  \endgroup\global\z@}
\endinput