1
2
3
4
5
6
7
8
9
10
11
12
13
14\writestatus{loading}{ConTeXt Structure Macros Enumerations}
15
16\unprotect
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\installcorenamespace{enumeration}
75
76\installcommandhandler \??enumeration {enumeration} \??enumeration
77
78\installcounterassociation{enumeration}
79
80\let\setupenumerations\setupenumeration
81
82\setupenumeration
83 [\c!alternative=\v!top,
84 \c!headstyle=\v!bold,
85 \c!titlestyle=\v!bold,
86
87
88
89
90 \c!width=8\emwidth,
91
92 \c!distance=\emwidth,
93 \c!titledistance=.5\emwidth,
94
95
96
97
98 \c!margin=\v!no,
99 \c!before=\blank,
100 \c!inbetween=\blank,
101 \c!after=\blank,
102 \c!indentnext=\v!yes,
103 \c!indenting=\v!never,
104 \c!titleleft=(,
105 \c!titleright=),
106
107 \c!closecommand=\wordright,
108 \c!display=\v!yes,
109
110 \c!titlecommand=,
111 \c!expansion=\v!no,
112
113
114 \c!way=\v!by\v!text,
115 \c!prefix=\v!no,
116 \c!prefixconnector=.,
117
118
119 \c!text=\currentenumeration,
120 \c!number=\v!yes,
121 \c!start=0,
122 \c!state=\v!start,
123 \c!levels=4]
124
125
126
127
128
129
130
131\unexpanded\def\strc_define_commands_enumeration#tag#level#parent
132 {\doifelsenothing{#parent}
133 {\normalexpanded{\defineconstruction[#tag][\s!handler=\v!enumeration,\c!level=#level]}
134 \setevalue{\??enumeration#tag:\s!parent}{\??enumeration}}
135 {\normalexpanded{\defineconstruction[#tag][#parent][\s!handler=\v!enumeration,\c!level=#level]}
136 \setevalue{\??enumeration#tag:\s!parent}{\??enumeration#parent}}
137 \setuevalue{\e!next #tag}{\strc_enumerations_next {#tag}{\number#level}}
138 \setuevalue{\c!reset#tag}{\strc_enumerations_reset {#tag}{\number#level}}
139
140 \setuevalue {#tag}{\strc_enumerations_command{#tag}}
141 \setuevalue{\e!start#tag}{\strc_enumerations_start {#tag}}
142 \setuevalue{\e!stop #tag}{\strc_enumerations_stop }}
143
144\appendtoks
145 \ifx\currentenumerationparent\empty
146
147 \let\currentenumerationsub\empty
148 \strc_define_commands_enumeration
149 {\currentenumerationsub\currentenumeration}
150 \plusone
151 \empty
152 \edef\p_levels{\enumerationparameter\c!levels}
153 \dostepwiserecurse\plustwo\p_levels\plusone
154 {\strc_define_commands_enumeration
155 {\v!sub\currentenumerationsub\currentenumeration}
156 \recurselevel
157 {\currentenumerationsub\currentenumeration}
158 \edef\currentenumerationsub{\v!sub\currentenumerationsub}}
159 \else
160
161 \let\currentenumerationsub\empty
162 \edef\p_levels{\enumerationparameter\c!levels}
163 \dorecurse\p_levels
164 {\strc_define_commands_enumeration
165 {\currentenumerationsub\currentenumeration}
166 \recurselevel
167 {\currentenumerationsub\currentenumerationparent}
168 \edef\currentenumerationsub{\v!sub\currentenumerationsub}}
169 \fi
170 \edef\p_counter{\enumerationparameter\s!counter}
171 \ifx\p_counter\empty
172 \let\p_counter\currentenumeration
173 \fi
174 \doifelsecounter\p_counter\donothing{\strc_enumerations_define_counter\p_counter}
175 \letenumerationparameter\s!counter\p_counter
176
177\to \everydefineenumeration
178
179\let\p_strc_constructions_title \empty
180\let\p_strc_constructions_number\empty
181
182\unexpanded\setvalue{\??constructioninitializer\v!enumeration}
183 {\let\currentenumeration \currentconstruction
184 \let\constructionparameter \enumerationparameter
185 \let\constructionnamespace \??enumeration
186 \let\detokenizedconstructionparameter\detokenizedenumerationparameter
187 \let\letconstructionparameter \letenumerationparameter
188 \let\useconstructionstyleandcolor \useenumerationstyleandcolor
189 \let\setupcurrentconstruction \setupcurrentenumeration
190 \edef\p_strc_constructions_number{\constructionparameter\c!number}
191 \ifx\p_strc_constructions_number\v!yes
192 \settrue\c_strc_constructions_number_state
193 \iftrialtypesetting
194 \strc_counters_save\currentconstructionnumber
195 \fi
196 \strc_counters_increment_sub\currentconstructionnumber\currentconstructionlevel
197 \else
198 \setfalse\c_strc_constructions_number_state
199 \fi
200 \edef\p_strc_constructions_title{\constructionparameter\c!title}
201 \ifx\p_strc_constructions_title\v!yes
202 \settrue\c_strc_constructions_title_state
203 \else
204 \setfalse\c_strc_constructions_title_state
205 \fi}
206
207\unexpanded\setvalue{\??constructionfinalizer\v!enumeration}
208 {\ifconditional\c_strc_constructions_number_state
209 \iftrialtypesetting
210 \strc_counters_restore\currentconstructionnumber
211 \fi
212 \fi}
213
214
215
216\let\strc_enumerations_command\strc_descriptions_command
217\let\strc_enumerations_start \strc_descriptions_start
218\let\strc_enumerations_stop \strc_descriptions_stop
219
220\unexpanded\def\strc_enumerations_next {\strc_constructions_next_indeed \namedenumerationparameter}
221\unexpanded\def\strc_enumerations_reset{\strc_constructions_reset_indeed\namedenumerationparameter}
222
223
224
225
226
227
228
229\def\strc_enumerations_define_counter#tag
230 {\definecounter[#tag]
231 \registerenumerationcounter{#tag}}
232
233\appendtoks
234 \synchronizeenumerationcounters
235\to \everysetupenumeration
236
237\appendtoks
238 \synchronizeenumerationcounters
239\to \everydefineenumeration
240
241
242
243
244
245\newtoks\everyenumeration
246
247\appendtoks
248 \disablepseudocaps
249\to \everyenumeration
250
251\expandafter\let\csname\??constructionmainhandler \v!enumeration\expandafter\endcsname\csname\??constructionmainhandler \v!description\endcsname
252\expandafter\let\csname\??constructioncommandhandler\v!enumeration\expandafter\endcsname\csname\??constructioncommandhandler\v!description\endcsname
253\expandafter\let\csname\??constructionstarthandler \v!enumeration\expandafter\endcsname\csname\??constructionstarthandler \v!description\endcsname
254\expandafter\let\csname\??constructionstophandler \v!enumeration\expandafter\endcsname\csname\??constructionstophandler \v!description\endcsname
255
256\unexpanded\setvalue{\??constructiontexthandler\v!enumeration}
257 {\begingroup
258 \useconstructionstyleandcolor\c!headstyle\c!headcolor
259 \strc_enumerations_text
260 \endgroup}
261
262\unexpanded\def\strc_enumerations_text
263 {\the\everyenumeration
264 \ifconditional\c_strc_constructions_number_state
265 \ifx\currentconstructionreference\!!plustoken
266 \strc_enumerations_full_number_symbol
267 \else\ifx\currentconstructionreference\!!minustoken
268 \strc_enumerations_full_number_nop
269 \else
270 \strc_enumerations_full_number_coupling
271 \fi\fi
272 \else
273 \strc_enumerations_full_number_nop
274 \fi}
275
276\unexpanded\def\strc_enumerations_inject_text_with_space
277 {\edef\p_text{\constructionparameter\c!text}
278 \ifx\p_text\empty \else
279 \p_text
280 \removeunwantedspaces
281 \nobreakspace
282 \fi}
283
284\unexpanded\def\strc_enumerations_inject_extra_text
285 {\ifconditional\c_strc_constructions_title_state
286 \clf_doifelselisthastitle{\currentconstructionmain}\numexpr\currentconstructionlistentry\relax
287 \strc_enumerations_inject_extra_text_indeed
288 \donothing
289 \fi}
290
291\unexpanded\def\strc_enumerations_inject_text
292 {\constructionparameter\c!numbercommand
293 {\constructionparameter\c!text}}
294
295
296
297\unexpanded\def\strc_enumerations_inject_extra_text_indeed
298 {\begingroup
299 \hskip\constructionparameter\c!titledistance
300 \useconstructionstyleandcolor\c!titlestyle\c!titlecolor
301 \constructionparameter\c!titlecommand
302 {\constructionparameter\c!titleleft
303 \clf_savedlisttitle{\currentconstructionmain}\currentconstructionlistentry\relax
304 \constructionparameter\c!titleright}
305 \endgroup}
306
307\unexpanded\def\strc_enumerations_inject_symbol
308 {\begingroup
309 \useconstructionstyleandcolor\c!numberstyle\c!numbercolor
310 \constructionparameter\c!left
311 \constructionparameter\c!symbol
312 \constructionparameter\c!right
313 \endgroup}
314
315\unexpanded\def\strc_enumerations_inject_number
316 {\begingroup
317 \useconstructionstyleandcolor\c!numberstyle\c!numbercolor
318 \constructionparameter\c!left
319 \constructionparameter\c!starter
320 \clf_savedlistprefixednumber{\currentconstructionmain}\currentconstructionlistentry\relax
321 \constructionparameter\c!stopper
322 \constructionparameter\c!right
323 \endgroup}
324
325\unexpanded\def\strc_enumerations_inject_text_and_number
326 {\constructionparameter\c!numbercommand
327 {\strc_enumerations_inject_text_with_space
328 \strc_enumerations_inject_number}}
329
330\unexpanded\def\strc_enumerations_inject_text_and_symbol
331 {\constructionparameter\c!numbercommand
332 {\strc_enumerations_inject_text_with_space
333 \strc_enumerations_inject_symbol}}
334
335\unexpanded\def\strc_enumerations_full_number_yes
336 {\constructionparameter\c!headcommand
337 {\begstrut
338 \strc_enumerations_inject_text_and_number
339 \strc_enumerations_inject_extra_text
340 \endstrut}}
341
342\unexpanded\def\strc_enumerations_full_number_nop
343 {\constructionparameter\c!headcommand
344 {\begstrut
345 \strc_enumerations_inject_text
346 \strc_enumerations_inject_extra_text
347 \endstrut}}
348
349\unexpanded\def\strc_enumerations_full_number_symbol
350 {\constructionparameter\c!headcommand
351 {\begstrut
352 \strc_enumerations_inject_text_and_symbol
353 \strc_enumerations_inject_extra_text
354 \endstrut}}
355
356
357
358
359
360
361
362
363
364\unexpanded\def\strc_enumerations_full_number_coupling
365 {\iflocation
366 \strc_enumerations_full_number_yes
367 \else
368 \iftrialtypesetting \else
369
370 \fi
371 \strc_enumerations_full_number_yes
372 \edef\p_coupling{\constructionparameter\c!coupling}
373 \ifx\p_coupling\empty \else
374 \symbolreference[order(construction:\p_coupling:\the\locationorder)]
375 \fi
376 \fi}
377
378\unexpanded\def\strc_enumerations_skip_number_coupling[#tag]
379 {\clf_setnextreferenceorder{construction}{#tag}}
380
381\protect \endinput
382 |