1
2
3
4
5
6
7
8
9
10
11
12
13
14\writestatus{loading}{ConTeXt Structure Macros Labels}
15
16\unprotect
17
18
19
20
21
22
23
24\installcorenamespace{labels}
25
26\installcommandhandler \??labels {label} \??labels
27
28\installcounterassociation{label}
29
30\let\setuplabels\setuplabel
31
32\setuplabel
33 [\c!alternative=\v!intext,
34 \c!headstyle=\v!bold,
35 \c!titlestyle=\v!bold,
36 \c!distance=\zeropoint,
37 \c!width=\v!fit,
38 \c!titledistance=.5\emwidth,
39 \c!margin=\v!no,
40 \c!titleleft=(,
41 \c!titleright=),
42 \c!display=\v!no,
43 \c!titlecommand=,
44 \c!expansion=\v!no,
45 \c!way=\v!by\v!text,
46 \c!prefix=\v!no,
47 \c!prefixconnector=.,
48 \c!text=\currentlabel,
49 \c!number=\v!yes,
50 \c!start=0,
51 \c!state=\v!start,
52 \c!levels=3]
53
54\protected\def\strc_define_commands_label#1#2#3
55 {\ifempty{#3}
56 \normalexpanded{\defineconstruction[#1][\s!handler=\v!label,\c!level=#2]}
57 \edefcsname\??label#1:\s!parent\endcsname{\??label}
58 \else
59 \normalexpanded{\defineconstruction[#1][#3][\s!handler=\v!label,\c!level=#2]}
60 \edefcsname\??label#1:\s!parent\endcsname{\??label#3}
61 \fi
62 \ifconditional\c_strc_constructions_define_commands
63 \frozen\instance\protected\edefcsname\e!next #1\endcsname{\strc_labels_next {#1}{\number#2}}
64 \frozen\instance\protected\edefcsname\v!reset#1\endcsname{\strc_labels_reset{#1}{\number#2}}
65
66 \ifcsname\v!current#1\endcsname
67
68 \else
69 \protected\edefcsname\v!current#1\endcsname{\strc_labels_current{#1}}
70 \fi
71 \frozen\instance\protected\edefcsname#1\endcsname{\strc_labels_command[#1]}
72 \fi}
73
74
75
76\lettonothing\m_strc_labels_sub
77
78\appendtoks
79 \lettonothing\m_strc_labels_sub
80 \ifempty\currentlabelparent
81
82 \strc_define_commands_label
83 {\m_strc_labels_sub\currentlabel}
84 \plusone
85 \empty
86 \edef\p_levels{\labelparameter\c!levels}
87 \dostepwiserecurse\plustwo\p_levels\plusone
88 {\strc_define_commands_label
89 {\v!sub\m_strc_labels_sub\currentlabel}
90 \recurselevel
91 {\m_strc_labels_sub\currentlabel}
92 \edef\m_strc_labels_sub{\v!sub\m_strc_labels_sub}}
93 \else
94
95 \edef\p_levels{\labelparameter\c!levels}
96 \dorecurse\p_levels
97 {\strc_define_commands_label
98 {\m_strc_labels_sub\currentlabel}
99 \recurselevel
100 {\m_strc_labels_sub\currentlabelparent}
101 \edef\m_strc_labels_sub{\v!sub\m_strc_labels_sub}}
102 \fi
103 \edef\p_counter{\labelparameter\s!counter}
104 \ifempty\p_counter
105 \let\p_counter\currentlabel
106 \fi
107 \doifelsecounter\p_counter\donothing{\strc_labels_define_counter\p_counter}
108 \letlabelparameter\s!counter\p_counter
109\to \everydefinelabel
110
111\newconditional\c_strc_constructions_number_keep
112
113\defcsname\??constructioninitializer\v!label\endcsname
114 {\let \currentlabel \currentconstruction
115 \enforced\let\constructionparameter \labelparameter
116 \enforced\let\constructionnamespace \??label
117 \enforced\let\detokenizedconstructionparameter\detokenizedlabelparameter
118 \enforced\let\letconstructionparameter \letlabelparameter
119 \enforced\let\useconstructionstyleandcolor \uselabelstyleandcolor
120 \enforced\let\setupcurrentconstruction \setupcurrentlabel
121
122 \ifcstok{\constructionparameter\c!number}\v!yes
123 \c_strc_constructions_number_state\conditionaltrue
124 \iftrialtypesetting
125 \strc_counters_save\currentconstructionnumber
126 \fi
127 \ifconditional\c_strc_constructions_number_keep \else
128 \strc_counters_increment_sub\currentconstructionnumber\currentconstructionlevel
129 \fi
130 \else
131 \c_strc_constructions_number_state\conditionalfalse
132 \fi
133 \ifcstok{\constructionparameter\c!title}\v!yes
134 \c_strc_constructions_title_state\conditionaltrue
135 \else
136 \c_strc_constructions_title_state\conditionalfalse
137 \fi}
138
139\defcsname\??constructionfinalizer\v!label\endcsname
140 {\ifconditional\c_strc_constructions_number_state
141 \iftrialtypesetting
142 \strc_counters_restore\currentconstructionnumber
143 \fi
144 \fi}
145
146
147
148\protected\def\strc_labels_command{\c_strc_constructions_number_keep\conditionalfalse\nameddescription}
149\protected\def\strc_labels_current{\c_strc_constructions_number_keep\conditionaltrue\nameddescription}
150
151\protected\def\strc_labels_next {\strc_constructions_next_indeed \namedlabelparameter}
152\protected\def\strc_labels_reset {\strc_constructions_reset_indeed\namedlabelparameter}
153
154
155
156
157\def\strc_labels_define_counter#1
158 {\definecounter[#1]
159 \registerlabelcounter{#1}}
160
161\appendtoks
162 \synchronizelabelcounters
163\to \everysetuplabel
164
165\appendtoks
166 \synchronizelabelcounters
167\to \everydefinelabel
168
169
170
171\letcsname\??constructionmainhandler\v!label\expandafter\endcsname\csname\??constructionmainhandler\v!description\endcsname
172
173\protected\edefcsname\??constructioncommandhandler\v!label\endcsname
174 {\csname\??constructionstarthandler\v!construction\endcsname
175 \csname\??constructionstophandler \v!construction\endcsname
176 \endgroup}
177
178\protected\defcsname\??constructiontexthandler\v!label\endcsname
179 {\begingroup
180 \useconstructionstyleandcolor\c!headstyle\c!headcolor
181 \strc_labels_text
182 \endgroup}
183
184\let\strc_labels_text\strc_enumerations_text
185
186
187
188\defineconstructionalternative
189 [\v!intext]
190 [\c!renderingsetup=\??constructionrenderings:\v!intext]
191
192\startsetups[\??constructionrenderings:\v!intext]
193 \dontleavehmode\box\constructionheadbox
194\stopsetups
195
196\protect \endinput
197 |