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