blob: ab49913d497de304b8334f79ae02da1bd04819cc (
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
%%
%% This is file `dcounter.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% dcounter.dtx (with options: `package')
%%
%% IMPORTANT NOTICE:
%%
%% This file is a generated file from the sources of the `ncctools'
%% bundle.
%%
%% You are not allowed to modify this file.
%%
%% You are allowed to distribute this file if and only if
%% it is distributed with the corresponding source files in
%% the `ncctools' bundle.
%%
%% For the copying and distribution conditions of the source files,
%% see the README file distributed with the ncctools bundle.
%%
%% File: dcounter.dtx Copyright (C) 1998-2005 by Alexander I. Rozhenko
%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{dcounter}
[2005/04/25 v1.2 Dynamic Counters (NCC)]
\def\DCNT@list{}
\def\DCNT@elist{}
\@onlypreamble\DCNT@elist
\def\DCNT@in#1#2#3{\@tempswafalse
\let\@elt\DCNT@elt #1%
\if@tempswa #2\else #3\fi
}
\def\DCNT@elt#1{\def\DCNT@name{#1}%
\ifx\DCNT@name\DCNT@foo \@tempswatrue \else \DCNT@noteq{#1}\fi
}
\def\DCNT@define#1#2{%
\@ifundefined{c@#2}%
{{\edef\DCNT@foo{#2}\let\DCNT@noteq\@gobble
\DCNT@in\DCNT@list{\newcounter{#2}\DCNT@the{#2}}{}%
}}{}%
#1{#2}%
}
\def\DCNT@the#1{%
\ifx\DCNT@main\@empty
\expandafter\xdef\csname the#1\endcsname
{\noexpand\@arabic \expandafter\noexpand \csname c@#1\endcsname}%
\else
\expandafter\xdef\csname the#1\endcsname
{\expandafter\noexpand \csname the\DCNT@main\endcsname
.\noexpand\@arabic \expandafter\noexpand \csname c@#1\endcsname}%
\@addtoreset{#1}\DCNT@main
\fi
}
\let\DCNT@main\@empty
\newcommand*{\DeclareDynamicCounter}[1]{%
\begingroup
\edef\DCNT@foo{#1}%
\ifx\DCNT@foo\@empty
\PackageError{dcounter}%
{Cannot declare a dynamic counter with empty name}{}%
\fi
\let\DCNT@noteq\@gobble
\@ifundefined{c@#1}%
{\DCNT@in\DCNT@list{}{\@cons\DCNT@list{{#1}}}}%
{\DCNT@in\DCNT@elist{}{\@cons\DCNT@elist{{#1}}}%
\expandafter\global\expandafter\let
\csname the#1\endcsname\@empty}%
\endgroup
}
\@onlypreamble\DeclareDynamicCounter
\newcommand{\countstyle}{\@ifnextchar[{\DCNT@lcstyle}{\DCNT@cstyle}}
\@onlypreamble\countstyle
\def\DCNT@cstyle#1{\edef\DCNT@foo{#1}%
\ifx\DCNT@foo\@empty \else
\DCNT@define\@gobble{#1}%
\@ifundefined{c@#1}{\@nocounterr{#1}}{}%
\fi
\let\DCNT@main\DCNT@foo
}
\@onlypreamble\DCNT@cstyle
\def\DCNT@lcstyle[#1]#2{%
{\DCNT@cstyle{#2}\@for\@tempa:=#1\do{\DynamicCount\@tempa}}%
}
\@onlypreamble\DCNT@lcstyle
\newcommand*{\DynamicCount}[1]{%
\@ifundefined{c@#1}%
{\newcounter{#1}}%
{{\edef\DCNT@foo{#1}\let\DCNT@noteq\DCNT@add
\let\@elt\DCNT@remove \cl@@ckpt
}}%
\DCNT@the{#1}%
}
\@onlypreamble\DynamicCount
\def\DCNT@remove#1{\expandafter\DCNT@remlist\csname cl@#1\endcsname}
\def\DCNT@remlist#1{%
{\let\@tempa\@empty \DCNT@in#1{\global\let#1\@tempa}{}}%
}
\@onlypreamble\DCNT@remove
\@onlypreamble\DCNT@remlist
\def\DCNT@add#1{%
\let\@elt\relax\edef\@tempa{\@tempa\@elt{#1}}\let\@elt\DCNT@elt
}
\@onlypreamble\DCNT@add
\def\DCNT@emu#1{%
\expandafter\ifx\csname the#1\endcsname\@empty
\DynamicCount{#1}\fi
}
\@onlypreamble\DCNT@emu
\AtBeginDocument{%
\ifx\DCNT@list\@empty
\@onlypreamble\DCNT@list
\@onlypreamble\DCNT@in
\@onlypreamble\DCNT@elt
\@onlypreamble\DCNT@define
\@onlypreamble\DCNT@the
\@onlypreamble\DCNT@main
\@onlypreamble\DCNT@name
\@onlypreamble\DCNT@foo
\@onlypreamble\DCNT@noteq
\else
\let\DCNT@setcounter\setcounter
\def\setcounter{\DCNT@define\DCNT@setcounter}
\let\DCNT@addtocounter\addtocounter
\def\addtocounter{\DCNT@define\DCNT@addtocounter}
\fi
{\let\@elt\DCNT@emu \DCNT@elist}%
}
\endinput
%%
%% End of file `dcounter.sty'.
|