1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22\writestatus{loading}{ConTeXt Typesetting Macros Margindata}
23
24\unprotect
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39\registerctxluafile{typomar}{}
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\installcorenamespace{margindata}
107\installcorenamespace{marginframed}
108
109\installcommandhandler \??margindata {margindata} \??margindata
110\installframedcommandhandler \??marginframed {marginframed} \??marginframed
111
112\setupmargindata
113 [\c!location=\v!left,
114
115
116 \c!style=\v!bold,
117 \c!color=,
118
119
120 \c!threshold=.25\exheight,
121 \c!margin=\v!normal,
122 \c!scope=\v!global,
123 \c!width=,
124
125
126
127 \c!line=0,
128 \c!anchor=\v!text,
129 \c!bottomspace=\strutdepth,
130 \c!dy=\zeropoint,
131 \c!distance=\zeropoint,
132 \c!hoffset=\zeropoint,
133 \c!voffset=\zeropoint]
134
135\setupmarginframed
136 [\c!strut=\v!yes,
137 \c!offset=\v!overlay,
138 \c!fr!analyze=\v!yes,
139 \c!frame=\v!off,
140 \c!width=\margindataparameter\c!width,
141 \c!align=\margindataparameter\c!align]
142
143\appendtoks
144 \setuevalue\currentmargindata{\margindata[\currentmargindata]}
145\to \everydefinemargindata
146
147\newconditional\inhibitmargindata
148\newtoks \everymargindatacontent
149
150\appendtoks
151 \settrue\inhibitmargindata
152\to \everyforgetall
153
154\appendtoks
155 \forgetall
156 \tf
157 \resetallattributes
158 \pickupattributes
159\to \everymargindatacontent
160
161
162
163
164\newcount\nofmargintexts
165
166\definepagestate[\s!margintext]
167
168\unexpanded\def\typo_margins_data_synchronize
169 {\doforcedtrackpagestate\s!margintext\nofmargintexts
170 \docheckpagestate\s!margintext\nofmargintexts
171
172 \realpageno\realpagestateno
173 \swapmargins}
174
175\unexpanded\def\margindata
176 {\iftrialtypesetting
177 \expandafter\typo_margins_data_nop
178 \else
179 \expandafter\typo_margins_data_yes
180 \fi}
181
182\def\typo_margins_data_nop[#name]
183 {\dodoubleempty\typo_margins_data_nop_indeed}
184
185\def\typo_margins_data_yes[#name]
186 {\setfalse\inhibitmargindata
187 \begingroup
188
189 \def\currentmargindata{#name}
190 \let\currentmarginframed\currentmargindata
191 \dodoubleempty\typo_margins_data_yes_indeed}
192
193\unexpanded\def\typo_margins_data_nop_indeed[#dataparameters][#textparameters]#content
194 {}
195
196
197
198
199
200\let\margindatahbox\naturalhbox
201
202\newcount\c_typo_margins_n
203
204\ifdefined\dotagmarginanchor \else \let\dotagmarginanchor\gobbleoneargument \fi
205\ifdefined\dotagmargintext \else \let\dotagmargintext \gobbleoneargument \fi
206
207\unexpanded\def\typo_margins_data_yes_indeed[#dataparameters][#textparameters]#content
208 {\iffirstargument
209 \setupcurrentmargindata[#dataparameters]
210 \fi
211 \doifelsenothing{#content}\donefalse\donetrue
212 \global\advance\c_typo_margins_n\plusone
213 \ifdone
214 \edef\currentmarginreference{\margindataparameter\c!reference}
215 \ifx\currentmarginreference\empty \else
216 \strc_references_set_page_only_destination_box_attribute\currentmarginreference\currentmarginreference
217 \fi
218 \edef\currentmargindatastrut{\margindataparameter\c!strut}
219 \dostarttaggedchained\t!margintext\currentmargindata\??margindata
220 \dotagmargintext\c_typo_margins_n
221 \ifcsname\currentmarginframedhash\s!parent\endcsname
222 \setbox\nextbox\margindatahbox \currentmarginreference \bgroup
223 \the\everymargindatacontent
224 \usemargindatastyleandcolor\c!style\c!color
225 \setupcurrentmarginframed[\c!location=\v!normal,#textparameters]
226 \typo_margins_data_synchronize
227 \inheritedmarginframedframed\bgroup
228 \ifx\currentmargindatastrut\empty \else
229 \synchronizestrut\currentmargindatastrut
230 \fi
231 \begstrut
232 \strc_references_flush_destination_nodes
233 \margindataparameter\c!command{#content}
234 \endstrut
235 \egroup
236 \egroup
237 \edef\currentmarginfirstheight{\number\dimexpr\framedfirstheight}
238 \else
239 \edef\currentmargindatawidth{\margindataparameter\c!width}
240 \ifx\currentmargindatawidth\empty
241 \setbox\nextbox\margindatahbox \currentmarginreference \bgroup
242 \typo_margins_data_synchronize
243 \the\everymargindatacontent
244 \usemargindatastyleandcolor\c!style\c!color
245 \ifx\currentmargindatastrut\empty \else
246 \synchronizestrut\currentmargindatastrut
247 \fi
248 \begstrut
249 \strc_references_flush_destination_nodes
250 \margindataparameter\c!command{#content}
251 \endstrut
252 \egroup
253 \let\currentmarginfirstheight\empty
254 \else
255 \setbox\nextbox\margindatahbox \currentmarginreference \bgroup
256 \typo_margins_data_synchronize
257 \dosetraggedcommand{\margindataparameter\c!align}
258 \vtop \bgroup
259 \the\everymargindatacontent
260 \usemargindatastyleandcolor\c!style\c!color
261 \hsize\currentmargindatawidth
262 \raggedcommand
263 \ifx\currentmargindatastrut\empty \else
264 \synchronizestrut\currentmargindatastrut
265 \fi
266 \begstrut
267 \strc_references_flush_destination_nodes
268 \margindataparameter\c!command{#content}
269 \endstrut
270 \egroup
271 \egroup
272 \edef\currentmarginfirstheight{true}
273 \fi
274 \fi
275 \dostoptagged
276 \fi
277 \ifdone
278 \edef\p_anchor{\margindataparameter\c!anchor}
279 \anch_positions_initialize
280 \dostarttagged\t!marginanchor\empty
281 \dotagmarginanchor\c_typo_margins_n
282 \clf_savemargindata
283 location {\margindataparameter\c!location}
284 method {\margindataparameter\c!method}
285 category {\margindataparameter\c!category}
286 name {\margindataparameter\c!name}
287 scope {\margindataparameter\c!scope}
288 option {\margindataparameter\c!option}
289 number \nextbox
290 margin {\margindataparameter\c!margin}
291 distance \dimexpr\margindataparameter\c!distance\relax
292 hoffset \dimexpr\margindataparameter\c!hoffset\relax
293 voffset \dimexpr\margindataparameter\c!voffset\relax
294 dy \dimexpr\margindataparameter\c!dy\relax
295 bottomspace \dimexpr\margindataparameter\c!bottomspace\relax
296 \ifx\currentmarginfirstheight\empty \else
297 baseline {\currentmarginfirstheight}
298 \fi
299 threshold \dimexpr\margindataparameter\c!threshold\relax
300 \ifhmode
301 inline true
302 \fi
303 anchor {\p_anchor\ifx\p_anchor\v!region:0\fi}
304
305
306
307
308
309
310
311
312
313 align {\margindataparameter\c!align}
314 line \numexpr\margindataparameter\c!line\relax
315 stackname {\margindataparameter\c!stackname}
316 stack {\margindataparameter\c!stack}
317 index \c_typo_margins_n
318 \relax
319 \dostoptagged
320 \else
321 \clf_savemargindata
322 location {\margindataparameter\c!location}
323 method {\margindataparameter\c!method}
324 category {\margindataparameter\c!category}
325 name {\margindataparameter\c!name}
326 scope {\margindataparameter\c!scope}
327 number \nextbox
328 \relax
329 \fi
330 \endgroup}
331
332
333
334\unexpanded\def\spaceorpar
335 {\endgraf\ifhmode\space\fi}
336
337\appendtoks
338 \enforced\let\\\spaceorpar
339\to \everymargindatacontent
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358\setupmargindata [\v!left ] [\c!method=\v!first,\c!location=\v!left ,\c!margin=\v!margin,\c!align=\v!flushright,\s!parent=\??margindata]
359\setupmargindata [\v!right] [\c!method=\v!first,\c!location=\v!right,\c!margin=\v!margin,\c!align=\v!flushleft, \s!parent=\??margindata]
360\setupmargindata [\v!outer] [\c!method=\v!first,\c!location=\v!outer,\c!margin=\v!margin,\c!align=\v!inner, \s!parent=\??margindata]
361\setupmargindata [\v!inner] [\c!method=\v!first,\c!location=\v!inner,\c!margin=\v!margin,\c!align=\v!outer, \s!parent=\??margindata]
362
363
364
365\definemargindata [\v!inleftmargin] [\v!left ] [\c!margin=\v!margin,\c!width=\leftmarginwidth ,\c!style=,\c!color=]
366\definemargindata [\v!inrightmargin] [\v!right] [\c!margin=\v!margin,\c!width=\rightmarginwidth,\c!style=,\c!color=]
367\definemargindata [\v!inoutermargin] [\v!outer] [\c!margin=\v!margin,\c!width=\outermarginwidth,\c!style=,\c!color=]
368\definemargindata [\v!ininnermargin] [\v!inner] [\c!margin=\v!margin,\c!width=\innermarginwidth,\c!style=,\c!color=]
369
370\definemargindata [\v!inleftedge] [\v!left ] [\c!margin=\v!edge ,\c!width=\leftedgewidth ,\c!style=,\c!color=,\c!category=\v!edge]
371\definemargindata [\v!inrightedge] [\v!right] [\c!margin=\v!edge ,\c!width=\rightedgewidth ,\c!style=,\c!color=,\c!category=\v!edge]
372\definemargindata [\v!inouteredge] [\v!outer] [\c!margin=\v!edge ,\c!width=\outeredgewidth ,\c!style=,\c!color=,\c!category=\v!edge]
373\definemargindata [\v!ininneredge] [\v!inner] [\c!margin=\v!edge ,\c!width=\inneredgewidth ,\c!style=,\c!color=,\c!category=\v!edge]
374
375\definemargindata [\v!atleftmargin] [\v!left ] [\c!margin=\v!normal,\c!width=\leftmarginwidth ,\c!style=,\c!color=]
376\definemargindata [\v!atrightmargin] [\v!right] [\c!margin=\v!normal,\c!width=\rightmarginwidth,\c!style=,\c!color=]
377
378
379
380\definemargindata [\v!inleft] [\v!left ] [\c!margin=\v!margin,\c!width=\leftmarginwidth ,\c!align=\v!flushright]
381\definemargindata [\v!inright] [\v!right] [\c!margin=\v!margin,\c!width=\rightmarginwidth,\c!align=\v!flushleft]
382\definemargindata [\v!inouter] [\v!outer] [\c!margin=\v!margin,\c!width=\outermarginwidth,\c!align=\v!inner]
383\definemargindata [\v!ininner] [\v!inner] [\c!margin=\v!margin,\c!width=\innermarginwidth,\c!align=\v!outer]
384
385
386
387\definemargindata [\v!inmargin] [\v!left] [\c!margin=\v!margin,\c!width=\leftmarginwidth, \c!align=\v!flushright]
388\definemargindata [\v!inother] [\v!right] [\c!margin=\v!margin,\c!width=\rightmarginwidth,\c!align=\v!flushleft]
389
390\definemargindata [\v!margintext] [\v!left] [\c!margin=\v!margin,\c!width=\leftmarginwidth, \c!align=\v!flushright,\c!stack=\v!yes]
391
392\setupmarginframed [\v!left ] [\c!method=\v!first,\c!align=\v!flushright,\s!parent=\??marginframed]
393\setupmarginframed [\v!right] [\c!method=\v!first,\c!align=\v!flushleft, \s!parent=\??marginframed]
394\setupmarginframed [\v!outer] [\c!method=\v!first,\c!align=\v!inner, \s!parent=\??marginframed]
395\setupmarginframed [\v!inner] [\c!method=\v!first,\c!align=\v!outer, \s!parent=\??marginframed]
396
397\definemarginframed [\v!inleft] [\v!left ]
398\definemarginframed [\v!inright] [\v!right]
399\definemarginframed [\v!inouter] [\v!outer]
400\definemarginframed [\v!ininner] [\v!inner]
401\definemarginframed [\v!inmargin] [\v!inleft]
402\definemarginframed [\v!inother] [\v!inright]
403
404\let\marginword \margintext
405\let\margintitle \margintext
406\let\inothermargin\inother
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426\let\definemarginline\definemargindata
427
428\unexpanded\def\defineinmargin
429 {\doquadrupleempty\typo_inmargin_define}
430
431\def\typo_inmargin_define[#name][#location][#align][#settings]
432 {\definemargindata[#name][\c!location=#location,\c!align=#align,#settings]
433 \definemarginframed[#name][#location][\c!align=#align,#settings]}
434
435\let\setupinmargin\setupmargindata
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471\definemargindata
472 [\v!margintext:\v!section]
473 [\v!left]
474 [\c!margin=\v!margin,
475 \c!width=\leftmarginwidth,
476 \c!align=\v!flushright]
477
478\defineheadalternative
479 [\v!margintext]
480 [\c!alternative=\v!somewhere,
481 \c!margintext=\v!margintext:\v!section,
482 \c!renderingsetup=\??headrenderings:\v!margintext]
483
484\startsetups[\??headrenderings:\v!margintext]
485 \executeifdefined{\headalternativeparameter\c!margintext}\margintext {
486 \ifconditional\headshownumber
487 \headnumbercontent
488 \hskip\headnumberdistance
489 \fi
490 \headtextcontent
491 }
492\stopsetups
493
494\protect \endinput
495 |