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\newinteger\c_anch_tabs
22
23\protected\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\protected\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\protected\def\tabl_tabulate_hook_b_first{\clf_bposcolumnregistered{tabulate:\the\c_anch_tabs:\the\c_tabl_tabulate_column}}
50\protected\def\tabl_tabulate_hook_b_next {\clf_bposcolumn{tabulate:\the\c_anch_tabs:\the\c_tabl_tabulate_column}}
51\protected\def\tabl_tabulate_hook_e_first{\clf_eposcolumnregistered}
52\protected\def\tabl_tabulate_hook_e_next {\clf_eposcolumn}
53
54
55
56\appendtoks
57 \global\advanceby\c_anch_tabs\plusone
58\to \everytabulate
59
60
61
62\appendtoks
63 \c_anch_backgrounds_pos_no_shape\conditionaltrue
64\to \everytabulate
65
66
67
68
69
70
71
72
73
74
75
76\newconditional\tablehaspositions
77\newinteger \noftabpositions
78\newtoks \posXCtoks
79
80\protected\def\anch_tabulate_bpos{\bpos}
81\protected\def\anch_tabulate_epos{\epos}
82
83\installcorenamespace{positiontables}
84
85\permanent\def\tbPOSprefix{\??positiontables\number\noftabpositions:}
86
87\permanent\protected\def\tablepos
88 {\normalexpanded{\global\posXCtoks\emptytoks\the\posXCtoks}}
89
90\permanent\protected\def\tbXC {\anch_table_checked\anch_tables_indeed_XC }
91\permanent\protected\def\tbGSC{\anch_table_checked\anch_tables_indeed_GSC}
92\permanent\protected\def\tbGFC{\anch_table_checked\anch_tables_indeed_GFC}
93\permanent\protected\def\tbGTC{\anch_table_checked\anch_tables_indeed_GTC}
94
95\tolerant\def\anch_table_checked#1[#2]
96 {\iftrialtypesetting
97 \global\tablehaspositions\conditionaltrue
98 \expandafter\anch_tables_indeed_NC
99 \orelse\ifparameter#2\or
100 \expandafter#1
101 \else
102 \expandafter\anch_tables_indeed_NC
103 \fi[#2]}
104
105\def\anch_tables_indeed_NC[#1]
106 {\NC}
107
108\def\anch_tables_indeed_XC[#1]
109 {{\enforced\let\NC\relax\processcommalist[#1]\anch_tables_step_XC}}
110
111\def\anch_tables_step_XC#1
112 {\anch_tables_step_indeed_XC[#1]}
113
114\def\anch_tables_step_indeed_XC[#1#2]
115 {\if#1>\anch_tables_indeed_GFC[#2:#2]\orelse
116 \if#1\anch_tables_indeed_GFC[#2:#2]\orelse
117 \if#1<\anch_tables_indeed_GTC[#2:#2]\orelse
118 \if#1\anch_tables_indeed_GTC[#2:#2]\orelse
119 \if#1=\anch_tables_indeed_GSC[#2:#2]\orelse
120 \anch_tables_indeed_GSC[#1#2:#1#2]\fi}
121
122\def\anch_tables_indeed_GSC[#1]
123 {\processcommalist[#1]\anch_tables_step_GSC}
124
125\def\anch_tables_step_GSC#1
126 {\anch_tables_append_GSC[#1:#1]}
127
128\def\anch_tables_append_GSC[#1:#2:#3]
129
130 {\gtoksapp\posXCtoks{\anch_tables_process_GSC[#1:#2]}\NC}
131
132\def\anch_tables_process_GSC[#1:#2]
133 {\remappositionframed{#2}{\tbPOSprefix#1}
134 \anch_tabulate_bpos{\tbPOSprefix#1}
135
136 \xtoksapp\posXCtoks{\anch_tabulate_epos{\tbPOSprefix#1}}}
137
138\def\anch_tables_indeed_GFC[#1]
139
140 {\gtoksapp\posXCtoks{\anch_tables_delayed_GFC[#1]}\NC}
141
142\def\anch_tables_delayed_GFC[#1]
143 {\processcommalist[#1]\anch_tables_step_GFC}
144
145\def\anch_tables_step_GFC#1
146 {\anch_tables_process_GFC[#1:#1]}
147
148\def\anch_tables_process_GFC[#1:#2:#3]
149 {\remappositionframed{#2}{\tbPOSprefix#1}
150 \anch_tabulate_bpos{\tbPOSprefix#1}}
151
152\def\anch_tables_indeed_GTC[#1]
153
154 {\gtoksapp\posXCtoks{\anch_tables_delayed_GTC[#1]}\NC}
155
156\def\anch_tables_delayed_GTC[#1]
157
158 {\gtoksapp\posXCtoks{\anch_tables_process_GTC[#1]}\NC}
159
160\def\anch_tables_process_GTC[#1]
161 {\processcommalist[#1]\anch_tables_step_GTC}
162
163\def\anch_tables_step_GTC#1
164 {\anch_tables_step_indeed_GTC[#1:#1]}
165
166\def\anch_tables_step_indeed_GTC[#1:#2]
167 {\anch_tabulate_epos{\tbPOSprefix#1}}
168
169
170
171\aliased\let\tabulatepos\tablepos
172
173\permanent\protected\def\tabulatenormalpos
174 {\iftrialtypesetting
175
176 \orelse\ifconditional\tablehaspositions
177 \hss\tabulatepos\hss
178 \else
179
180 \fi}
181
182\permanent\protected\def\tabulateequalpos
183 {\iftrialtypesetting
184 \tabulateEQ
185 \orelse\ifconditional\tablehaspositions
186 \tabulateEQpos
187 \else
188 \tabulateEQ
189 \fi}
190
191\permanent\protected\def\tabulateEQpos
192 {\setbox\scratchbox\hbox{\tabulateEQ}
193 \hbox to \wd\scratchbox{\hss\kern\zeropoint\tabulatepos\hss}
194 \kern\wd\scratchbox
195 \box\scratchbox}
196
197\appendtoks
198 \global\advanceby\noftabpositions\plusone
199 \global\tablehaspositions\conditionalfalse
200\to \everytabulate
201
202
203
204\let\anch_tabulate_flush_epos\relax
205
206\protected\def\anch_tabulate_bpos_indeed
207 {\bpos}
208
209\protected\def\anch_tabulate_epos_indeed#1
210 {\ifvoid\b_tabl_tabulate_current\c_tabl_tabulate_column
211 \epos{#1}
212 \glet\anch_tabulate_flush_epos\relax
213 \else
214 \gdef\anch_tabulate_flush_epos{\epos{#1}}
215 \fi}
216
217\permanent\def\flushtabulatesplitbox
218 {\box\b_tabl_tabulate
219 \iftrialtypesetting\orelse\ifconditional\tablehaspositions\anch_tabulate_flush_epos\fi}
220
221\appendtoks
222 \let\anch_tabulate_bpos\anch_tabulate_bpos_indeed
223 \let\anch_tabulate_epos\anch_tabulate_epos_indeed
224 \glet\anch_tabulate_flush_epos\relax
225\to \everytabulate
226
227
228
229
230\mutable\lettonothing\GSC
231\mutable\lettonothing\GFC
232\mutable\lettonothing\GTC
233
234\appendtoks
235 \enforced\let\GSC\tbGSC
236 \enforced\let\GFC\tbGFC
237 \enforced\let\GTC\tbGTC
238 \enforced\let\XC \tbXC
239\to \everytabulate
240
241
242
243
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\permanent\def\normalTABLEsimplebar {\unskip\!ttRightGlue\tablepos}
273\permanent\def\normalTABLEcomplexbar{\unskip\!ttRightGlue\omit\tablepos\!ttAlternateVrule}
274\permanent\def\normalTABLEquote {\unskip\!ttRightGlue\omit\tablepos}
275
276\appendtoks
277 \global\advanceby\noftabpositions\plusone
278 \global\tablehaspositions\conditionalfalse
279\to \everytable
280
281
282
283\appendtoks
284 \enforced\let\GSC\tbGSC
285 \enforced\let\GFC\tbGFC
286 \enforced\let\GTC\tbGTC
287 \enforced\let\XC \tbXC
288\to \everytable
289
290
291
292
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\permanent\protected\def\remappositionframed#1#2
366 {\copyposition{b:#1}{b:#2}
367 \copyposition{e:#1}{e:#2}
368 \anch_positions_set_action{b:#2}{\dopositionaction{b:#1}}}
369
370\permanent\tolerant\protected\def\definepositionframed[#1]#*[#S#2]
371 {\anch_positions_set_action{b:#1}{\anch_framed_handle[#1][#2]}}
372
373\protected\def\anch_framed_handle
374 {\bgroup
375 \positionframed}
376
377\permanent\tolerant\protected\def\positionframed[#1]#*[#S#2]
378 {\setbox\scratchbox\hpack
379 {\scratchwidth {\MPx{e:#1}\MPx{b:#1}}
380 \scratchdepth {\MPy{b:#1}\MPy{e:#1}\MPd{e:#1}}
381 \scratchheight{\scratchdepth\MPh{b:#1}}
382 \lower\scratchdepth\hpack
383 {\framed[\c!width=\scratchwidth,\c!height=\scratchheight,\c!offset=\v!overlay,#2]{}}}
384 \smashedbox\scratchbox
385 \egroup}
386
387\protect \endinput
388 |