1
2
3
4
5
6
7
8
9
10
11
12
13
14\writestatus{loading}{ConTeXt Anchoring Macros Table Extensions}
15
16
17
18
19\unprotect
20
21\newcount\c_anch_tabs
22
23\unexpanded\def\tabl_tabulate_hook_b
24 {\iftrialtypesetting\else
25 \ifpositioning
26\ifconditional\tablehaspositions
27 \ifcase\c_tabl_tabulate_noflines
28 \tabl_tabulate_hook_b_first
29 \else
30 \tabl_tabulate_hook_b_next
31 \fi
32\fi
33 \fi
34 \fi}
35
36\unexpanded\def\tabl_tabulate_hook_e
37 {\iftrialtypesetting\else
38 \ifpositioning
39\ifconditional\tablehaspositions
40 \ifcase\c_tabl_tabulate_noflines
41 \tabl_tabulate_hook_e_first
42 \else
43 \tabl_tabulate_hook_e_next
44 \fi
45\fi
46 \fi
47 \fi}
48
49\unexpanded\def\tabl_tabulate_hook_b_first
50 {\clf_bposcolumnregistered{tabulate:\the\c_anch_tabs:\the\c_tabl_tabulate_column}}
51
52\unexpanded\def\tabl_tabulate_hook_b_next
53 {\clf_bposcolumn{tabulate:\the\c_anch_tabs:\the\c_tabl_tabulate_column}}
54
55\unexpanded\def\tabl_tabulate_hook_e_first
56 {\clf_eposcolumnregistered}
57
58\unexpanded\def\tabl_tabulate_hook_e_next
59 {\clf_eposcolumn}
60
61
62
63\appendtoks
64 \global\advance\c_anch_tabs\plusone
65\to \everytabulate
66
67
68
69\appendtoks
70 \settrue\c_anch_backgrounds_pos_no_shape
71\to \everytabulate
72
73
74
75
76
77
78
79
80
81
82
83\newconditional\tablehaspositions
84\newcount \noftabpositions
85\newtoks \posXCtoks
86
87\unexpanded\def\anch_tabulate_bpos{\bpos}
88\unexpanded\def\anch_tabulate_epos{\epos}
89
90\installcorenamespace{positiontables}
91
92\def\tbPOSprefix
93 {\??positiontables\number\noftabpositions:}
94
95\def\tablepos
96 {\normalexpanded{\global\posXCtoks\emptytoks\the\posXCtoks}}
97
98\let\tabulatepos\tablepos
99
100\unexpanded\def\tbXC {\dosingleempty\anch_tables_XC }
101\unexpanded\def\tbGSC{\dosingleempty\anch_tables_GSC}
102\unexpanded\def\tbGFC{\dosingleempty\anch_tables_GFC}
103\unexpanded\def\tbGTC{\dosingleempty\anch_tables_GTC}
104
105\def\anch_table_check_state
106 {\iftrialtypesetting
107 \global\settrue\tablehaspositions
108 \firstargumentfalse
109 \fi}
110
111\def\anch_tables_XC [#1]{\anch_table_check_state\iffirstargument\anch_tables_indeed_XC [#1]\else\expandafter\NC\fi}
112\def\anch_tables_GSC[#1]{\anch_table_check_state\iffirstargument\anch_tables_indeed_GSC[#1]\else\expandafter\NC\fi}
113\def\anch_tables_GFC[#1]{\anch_table_check_state\iffirstargument\anch_tables_indeed_GFC[#1]\else\expandafter\NC\fi}
114\def\anch_tables_GTC[#1]{\anch_table_check_state\iffirstargument\anch_tables_indeed_GTC[#1]\else\expandafter\NC\fi}
115
116\def\anch_tables_indeed_XC[#1]
117 {{\let\NC\relax\processcommalist[#1]\anch_tables_step_XC}}
118
119\def\anch_tables_step_XC#1
120 {\anch_tables_step_indeed_XC[#1]}
121
122\def\anch_tables_step_indeed_XC[#1#2]
123 {\if#1>\anch_tables_indeed_GFC [#2:#2]\else
124 \if#1\anch_tables_indeed_GFC [#2:#2]\else
125 \if#1<\anch_tables_indeed_GTC [#2:#2]\else
126 \if#1\anch_tables_indeed_GTC [#2:#2]\else
127 \if#1=\anch_tables_indeed_GSC [#2:#2]\else
128 \anch_tables_indeed_GSC[#1#2:#1#2]\fi\fi\fi\fi\fi}
129
130\def\anch_tables_indeed_GSC[#1]
131 {\processcommalist[#1]\anch_tables_step_GSC}
132
133\def\anch_tables_step_GSC#1
134 {\anch_tables_append_GSC[#1:#1]}
135
136\def\anch_tables_append_GSC[#1:#2:#3]
137
138 {\gtoksapp\posXCtoks{\anch_tables_process_GSC[#1:#2]}\NC}
139
140\def\anch_tables_process_GSC[#1:#2]
141 {\remappositionframed{#2}{\tbPOSprefix#1}
142 \anch_tabulate_bpos{\tbPOSprefix#1}
143 \doglobal\appendtoks\expandafter\anch_tabulate_epos\expandafter{\tbPOSprefix#1}\to\posXCtoks}
144
145
146\def\anch_tables_indeed_GFC[#1]
147 {\doglobal\appendtoks\anch_tables_delayed_GFC[#1]\to\posXCtoks\NC}
148
149
150\def\anch_tables_delayed_GFC[#1]
151 {\processcommalist[#1]\anch_tables_step_GFC}
152
153\def\anch_tables_step_GFC#1
154 {\anch_tables_process_GFC[#1:#1]}
155
156\def\anch_tables_process_GFC[#1:#2:#3]
157 {\remappositionframed{#2}{\tbPOSprefix#1}
158 \anch_tabulate_bpos{\tbPOSprefix#1}}
159
160\def\anch_tables_indeed_GTC[#1]
161 {\doglobal\appendtoks\anch_tables_delayed_GTC[#1]\to\posXCtoks\NC}
162
163
164\def\anch_tables_delayed_GTC[#1]
165 {\doglobal\appendtoks\anch_tables_process_GTC[#1]\to\posXCtoks}
166
167
168\def\anch_tables_process_GTC[#1]
169 {\processcommalist[#1]\anch_tables_step_GTC}
170
171\def\anch_tables_step_GTC#1
172 {\anch_tables_step_indeed_GTC[#1:#1]}
173
174\def\anch_tables_step_indeed_GTC[#1:#2]
175 {\anch_tabulate_epos{\tbPOSprefix#1}}
176
177
178
179
180\let\tabulatepos\tablepos
181
182\def\tabulatenormalpos
183 {\iftrialtypesetting
184
185 \else\ifconditional\tablehaspositions
186 \hss\tabulatepos\hss
187 \else
188
189 \fi\fi}
190
191\def\tabulateequalpos
192 {\iftrialtypesetting
193 \tabulateEQ
194 \else\ifconditional\tablehaspositions
195 \tabulateEQpos
196 \else
197 \tabulateEQ
198 \fi\fi}
199
200\def\tabulateEQpos
201 {\setbox\scratchbox\hbox{\tabulateEQ}
202 \hbox to \wd\scratchbox{\hss\kern\zeropoint\tabulatepos\hss}
203 \kern\wd\scratchbox
204 \box\scratchbox}
205
206\appendtoks
207 \global\advance\noftabpositions\plusone
208 \global\setfalse\tablehaspositions
209\to \everytabulate
210
211
212
213\let\anch_tabulate_flush_epos\relax
214
215\unexpanded\def\anch_tabulate_bpos_indeed
216 {\bpos}
217
218\unexpanded\def\anch_tabulate_epos_indeed#1
219 {\ifvoid\b_tabl_tabulate_current\c_tabl_tabulate_column
220 \epos{#1}
221 \glet\anch_tabulate_flush_epos\relax
222 \else
223 \gdef\anch_tabulate_flush_epos{\epos{#1}}
224 \fi}
225
226\def\flushtabulatesplitbox
227 {\box\b_tabl_tabulate
228 \iftrialtypesetting\else\ifconditional\tablehaspositions\anch_tabulate_flush_epos\fi\fi}
229
230\appendtoks
231 \let\anch_tabulate_bpos\anch_tabulate_bpos_indeed
232 \let\anch_tabulate_epos\anch_tabulate_epos_indeed
233 \glet\anch_tabulate_flush_epos\relax
234\to \everytabulate
235
236
237
238\appendtoks
239 \let\GSC\tbGSC
240 \let\GFC\tbGFC
241 \let\GTC\tbGTC
242 \let\XC \tbXC
243\to \everytabulate
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276\def\normalTABLEsimplebar {\unskip\!ttRightGlue\tablepos}
277\def\normalTABLEcomplexbar{\unskip\!ttRightGlue\omit\tablepos\!ttAlternateVrule}
278\def\normalTABLEquote {\unskip\!ttRightGlue\omit\tablepos}
279
280\appendtoks
281 \global\advance\noftabpositions\plusone
282 \global\setfalse\tablehaspositions
283\to \everytable
284
285
286
287\appendtoks
288 \let\GSC\tbGSC
289 \let\GFC\tbGFC
290 \let\GTC\tbGTC
291 \let\XC \tbXC
292\to \everytable
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369\unexpanded\def\remappositionframed#1#2
370 {\copyposition{b:#1}{b:#2}
371 \copyposition{e:#1}{e:#2}
372 \anch_positions_set_action{b:#2}{\dopositionaction{b:#1}}}
373
374\unexpanded\def\definepositionframed
375 {\dodoubleargument\anch_framed_define}
376
377\def\anch_framed_define[#1][#2]
378 {\anch_positions_set_action{b:#1}{\anch_framed_handle[#1][#2]}}
379
380\unexpanded\def\anch_framed_handle
381 {\bgroup
382 \anch_framed_indeed}
383
384\unexpanded\def\positionframed
385 {\bgroup
386 \dodoubleempty\anch_framed_indeed}
387
388\def\anch_framed_indeed[#1][#2]
389 {\setbox\scratchbox\hpack
390 {\scratchwidth \dimexpr\MPx{e:#1}\MPx{b:#1}\relax
391 \scratchdepth \dimexpr\MPy{b:#1}\MPy{e:#1}\MPd{e:#1}\relax
392 \scratchheight\dimexpr\scratchdepth\MPh{b:#1}\relax
393 \lower\scratchdepth\hpack
394 {\framed[\c!width=\scratchwidth,\c!height=\scratchheight,\c!offset=\v!overlay,#2]{}}}
395 \smashedbox\scratchbox
396 \egroup}
397
398\protect \endinput
399 |