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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
%D \module
%D [ file=strc-num,
%D version=1997.03.31,
%D title=\CONTEXT\ Structure Macros,
%D subtitle=Numbering,
%D author=Hans Hagen,
%D date=\currentdate,
%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
\writestatus{loading}{ConTeXt Structure Macros / Numbering}
\unprotect
% Commando's ten behoeve van nummeren:
%
% \definenumber[name]
% \setupnumber[name][wijze=,blok=,tekst=,plaats=,conversie=,start=]
% \setnumber[name]{value}
% \resetnumber[name]
% \incrementnumber[name]
% \decrementnumber[name]
% \convertednumber[name] % getnumber
% \savenumber[name]
% \restorenumber[name]
% \convertednumber[name]
% \rawnumber[name]
% private (defined in core-des.tex)
%
% \nextnumber[name][tag][reference]
% \currentnumber[name]
\def\@@thenumber#1{\s!number\csname\s!number#1\c!number\endcsname}
% this will be the new (public) one: \let\numberparameterprefix\@@thenumber
\def\numberparameter#1#2{\csname\@@thenumber{#1}#2\endcsname} % sort of public
\def\dosetupnumber[#1][#2]%
{\@EA\let\@EA\savedstartnumber\csname\@@thenumber{#1}\c!start\endcsname
\getparameters[\@@thenumber{#1}][\c!start=,#2]%
\doifelsenothing{\numberparameter{#1}\c!start}
{\letvalue{\@@thenumber{#1}\c!start}\savedstartnumber}
{\setcounter{\@@thenumber{#1}}{\numberparameter{#1}\c!start}}}
\def\setupnumber
{\dodoubleargument\dosetupnumber}
\def\definenumber
{\dodoubleempty\dodefinenumber}
\def\dodefinenumber[#1][#2]% ook overal class als localframed
{\doifassignmentelse{#2}
{\dododefinenumber[#1][#2]}
{\doifelsenothing{#2} % can break on not yet defined macros in #2
{\dododefinenumber[#1][#2]}
{\setvalue{\s!number#1\c!number}{#2}}}}
\def\dododefinenumber[#1][#2]%
{\getparameters
[\s!number#1]
[\c!number=#1,
\s!check=,
\c!way=\@@nrway,
\c!way\c!local=\numberparameter{#1}\c!way,
\c!sectionnumber=\v!yes,
\c!text=, % no longer used here, will go away
\c!location=, % no longer used here, will go away (was ooit \c!zetwijze)
\c!conversion=\v!numbers,
\c!start=0,
\c!state=\v!start,
#2]%
\makecounter{\@@thenumber{#1}}%
\setxvalue{\@@thenumber{#1}\c!n}{\countervalue{\@@thenumber{#1}}}%
\setcounter{\@@thenumber{#1}}{\numberparameter{#1}\c!start}}
\def\setnumber[#1]#2%
{\setcounter{\@@thenumber{#1}}{#2}}
\def\resetnumber[#1]%
{\setcounter{\@@thenumber{#1}}{0\numberparameter{#1}\c!start}}
\def\savenumber[#1]%
{\savecounter{\@@thenumber{#1}}}
\def\restorenumber[#1]%
{\restorecounter{\@@thenumber{#1}}}
%D Bonus macro (we need to keep this one for downward
%D compatibility reasons).
\def\doreset[#1]%
{\processcommalist[#1]\dodoreset}
\def\dodoreset#1%
{\getvalue{\s!reset#1}}%
\def\reset
{\dosingleargument\doreset}
\def\incrementnumber[#1]% bypage tricky: needs a
{\doifelse{\numberparameter{#1}\c!way}{\v!by\v!page}
{\checkpagechange{#1}%
\ifpagechanged\resetcounter{\@@thenumber{#1}}\fi}
{\checknumber[#1]}%
\doifelse\@@nrstate\v!start % only here
{\doif{\numberparameter{#1}\c!state}\v!start{\pluscounter{\@@thenumber{#1}}}}
{\setcounter{\@@thenumber{#1}}{0\numberparameter{#1}\c!start}}}
% \defineenumeration [test] [way=bypage,text=\lastchangedpage]
%
% \starttext \dorecurse{10}{\test \input tufte \par} \stoptext
\def\decrementnumber[#1]%
{\minuscounter{\@@thenumber{#1}}}
\def\convertednumber[#1]%
{\convertnumber
{\numberparameter{#1}\c!conversion}
{\countervalue{\@@thenumber{#1}}}}
\def\rawnumber[#1]%
{\countervalue{\@@thenumber{#1}}}
\def\accumulatednumber[#1]%
{\getvalue{\@@thenumber{#1}\c!n}}
\let\getnumber\convertednumber
\def\doifdefinednumber #1{\doifdefined {\csname\s!number#1\c!number\endcsname}}
\def\doifundefinednumber #1{\doifundefined {\csname\s!number#1\c!number\endcsname}}
\def\doifdefinednumberelse#1{\doifdefinedelse{\csname\s!number#1\c!number\endcsname}}
\ifx\checknumber\undefined \def\checknumber[#1]{} \fi
% ook de pag nummers hierheen halen ivm \@@nrwijze
\def\setupnumbering
{\dodoubleempty\getparameters[\??nr]}
\setupnumbering
[\c!way=\v!by\v!chapter,
\c!blockway=,
\c!sectionnumber=\v!yes,
\c!state=\v!start]
\protect \endinput
|