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\protected\edefcsname\currentmargindata\endcsname{\margindata[\currentmargindata]}
140\to \everydefinemargindata
141
142\newconditional\inhibitmargindata
143\newtoks \everymargindatacontent
144
145\mutable\lettonothing\currentmargindatastrut
146\mutable\lettonothing\currentmargindatawidth
147\mutable\lettonothing\currentmarginfirstheight
148\mutable\lettonothing\currentmarginreference
149
150\appendtoks
151 \inhibitmargindata\conditionaltrue
152\to \everyforgetall
153
154\appendtoks
155 \forgetall
156 \tf
157 \resetallattributes
158 \pickupattributes
159\to \everymargindatacontent
160
161
162
163
164\newinteger\nofmargintexts
165\newinteger\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\v!margin}
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[#S#dataparameters]#spacer[#S#textparameters]#:#content
187 {}
188
189\permanent\tolerant\protected\def\typo_margins_data_yes[#name]#spacer[#S#dataparameters]#spacer[#S#textparameters]#:#content
190 {\inhibitmargindata\conditionalfalse
191 \begingroup
192
193 \def\currentmargindata{#name}
194 \let\currentmarginframed\currentmargindata
195 \ifparameter#dataparameters\or
196 \setupcurrentmargindata[#dataparameters]
197 \fi
198 \ifparameter#content\donefalse\or\donetrue\else\donefalse\fi
199 \global\advanceby\c_typo_margins_n\plusone
200 \ifdone
201 \edef\currentmarginreference{\margindataparameter\c!reference}
202 \ifempty\currentmarginreference \else
203 \strc_references_set_page_only_destination_box_attribute\currentmarginreference\currentmarginreference
204 \fi
205 \edef\currentmargindatastrut{\margindataparameter\c!strut}
206 \dostarttaggedchained\t!margintext\currentmargindata\currentmargindata\??margindata
207 \dotagmargintext\c_typo_margins_n
208 \ifcsname\currentmarginframedhash\s!parent\endcsname
209 \setbox\nextbox\naturalhbox \currentmarginreference \bgroup
210 \expand\everymargindatacontent
211 \usemargindatastyleandcolor\c!style\c!color
212 \setupcurrentmarginframed[\c!location=\v!normal,#textparameters]
213 \typo_margins_data_synchronize
214 \inheritedmarginframedframed\bgroup
215 \ifempty\currentmargindatastrut \else
216 \synchronizestrut\currentmargindatastrut
217 \fi
218 \begstrut
219 \strc_references_flush_destination_nodes
220 \margindataparameter\c!command{#content}
221 \endstrut
222 \egroup
223 \egroup
224 \edef\currentmarginfirstheight{\number\dimexpr\framedfirstheight}
225 \else
226 \edef\currentmargindatawidth{\margindataparameter\c!width}
227 \ifempty\currentmargindatawidth
228 \setbox\nextbox\naturalhbox \currentmarginreference \bgroup
229 \typo_margins_data_synchronize
230 \expand\everymargindatacontent
231 \usemargindatastyleandcolor\c!style\c!color
232 \ifempty\currentmargindatastrut \else
233 \synchronizestrut\currentmargindatastrut
234 \fi
235 \begstrut
236 \strc_references_flush_destination_nodes
237 \margindataparameter\c!command{#content}
238 \endstrut
239 \egroup
240 \lettonothing\currentmarginfirstheight
241 \else
242 \setbox\nextbox\naturalhbox \currentmarginreference \bgroup
243 \typo_margins_data_synchronize
244 \dosetraggedcommand{\margindataparameter\c!align}
245 \vtop \bgroup
246 \expand\everymargindatacontent
247 \usemargindatastyleandcolor\c!style\c!color
248 \hsize{\currentmargindatawidth}
249 \raggedcommand
250 \ifempty\currentmargindatastrut \else
251 \synchronizestrut\currentmargindatastrut
252 \fi
253 \begstrut
254 \strc_references_flush_destination_nodes
255 \margindataparameter\c!command{#content}
256 \endstrut
257 \egroup
258 \egroup
259 \edef\currentmarginfirstheight{true}
260 \fi
261 \fi
262 \dostoptagged
263 \fi
264 \ifdone
265 \edef\p_anchor{\margindataparameter\c!anchor}
266 \anch_positions_initialize
267 \dostarttaggednodetail\t!marginanchor
268 \dotagmarginanchor\c_typo_margins_n
269 \clf_savemargindata
270 location {\margindataparameter\c!location}
271 method {\margindataparameter\c!method}
272 category {\margindataparameter\c!category}
273 name {\margindataparameter\c!name}
274 scope {\margindataparameter\c!scope}
275 option {\margindataparameter\c!option}
276 number \nextbox
277 margin {\margindataparameter\c!margin}
278 distance {\margindataparameter\c!distance}
279 hoffset {\margindataparameter\c!hoffset}
280 voffset {\margindataparameter\c!voffset}
281 dy {\margindataparameter\c!dy}
282 bottomspace {\margindataparameter\c!bottomspace}
283 \ifempty\currentmarginfirstheight \else
284 baseline {\currentmarginfirstheight}
285 \fi
286 threshold {\margindataparameter\c!threshold}
287 \ifhmode
288 inline true
289 \fi
290 anchor {\p_anchor\ifx\p_anchor\v!region:0\fi}
291
292
293
294
295
296
297
298
299
300 align {\margindataparameter\c!align}
301 line {\margindataparameter\c!line}
302 stackname {\margindataparameter\c!stackname}
303 stack {\margindataparameter\c!stack}
304 index \c_typo_margins_n
305 \relax
306 \dostoptagged
307 \else
308 \clf_savemargindata
309 location {\margindataparameter\c!location}
310 method {\margindataparameter\c!method}
311 category {\margindataparameter\c!category}
312 name {\margindataparameter\c!name}
313 scope {\margindataparameter\c!scope}
314 number \nextbox
315 \relax
316 \fi
317 \endgroup}
318
319
320
321\appendtoks
322 \enforced\let\\\spaceorpar
323\to \everymargindatacontent
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342\setupmargindata [\v!left ] [\c!method=\v!first,\c!location=\v!left ,\c!margin=\v!margin,\c!align=\v!flushright,\s!parent=\??margindata]
343\setupmargindata [\v!right] [\c!method=\v!first,\c!location=\v!right,\c!margin=\v!margin,\c!align=\v!flushleft, \s!parent=\??margindata]
344\setupmargindata [\v!outer] [\c!method=\v!first,\c!location=\v!outer,\c!margin=\v!margin,\c!align=\v!inner, \s!parent=\??margindata]
345\setupmargindata [\v!inner] [\c!method=\v!first,\c!location=\v!inner,\c!margin=\v!margin,\c!align=\v!outer, \s!parent=\??margindata]
346
347
348
349\definemargindata [\v!inleftmargin] [\v!left ] [\c!margin=\v!margin,\c!width=\leftmarginwidth ,\c!style=,\c!color=]
350\definemargindata [\v!inrightmargin] [\v!right] [\c!margin=\v!margin,\c!width=\rightmarginwidth,\c!style=,\c!color=]
351\definemargindata [\v!inoutermargin] [\v!outer] [\c!margin=\v!margin,\c!width=\outermarginwidth,\c!style=,\c!color=]
352\definemargindata [\v!ininnermargin] [\v!inner] [\c!margin=\v!margin,\c!width=\innermarginwidth,\c!style=,\c!color=]
353
354\definemargindata [\v!inleftedge] [\v!left ] [\c!margin=\v!edge ,\c!width=\leftedgewidth ,\c!style=,\c!color=,\c!category=\v!edge]
355\definemargindata [\v!inrightedge] [\v!right] [\c!margin=\v!edge ,\c!width=\rightedgewidth ,\c!style=,\c!color=,\c!category=\v!edge]
356\definemargindata [\v!inouteredge] [\v!outer] [\c!margin=\v!edge ,\c!width=\outeredgewidth ,\c!style=,\c!color=,\c!category=\v!edge]
357\definemargindata [\v!ininneredge] [\v!inner] [\c!margin=\v!edge ,\c!width=\inneredgewidth ,\c!style=,\c!color=,\c!category=\v!edge]
358
359\definemargindata [\v!atleftmargin] [\v!left ] [\c!margin=\v!normal,\c!width=\leftmarginwidth ,\c!style=,\c!color=]
360\definemargindata [\v!atrightmargin] [\v!right] [\c!margin=\v!normal,\c!width=\rightmarginwidth,\c!style=,\c!color=]
361
362
363
364\definemargindata [\v!inleft] [\v!left ] [\c!margin=\v!margin,\c!width=\leftmarginwidth ,\c!align=\v!flushright]
365\definemargindata [\v!inright] [\v!right] [\c!margin=\v!margin,\c!width=\rightmarginwidth,\c!align=\v!flushleft]
366\definemargindata [\v!inouter] [\v!outer] [\c!margin=\v!margin,\c!width=\outermarginwidth,\c!align=\v!inner]
367\definemargindata [\v!ininner] [\v!inner] [\c!margin=\v!margin,\c!width=\innermarginwidth,\c!align=\v!outer]
368
369
370
371\definemargindata [\v!inmargin] [\v!left] [\c!margin=\v!margin,\c!width=\leftmarginwidth, \c!align=\v!flushright]
372\definemargindata [\v!inother] [\v!right] [\c!margin=\v!margin,\c!width=\rightmarginwidth,\c!align=\v!flushleft]
373
374\definemargindata [\v!margintext] [\v!left] [\c!margin=\v!margin,\c!width=\leftmarginwidth, \c!align=\v!flushright,\c!stack=\v!yes]
375
376\setupmarginframed [\v!left ] [\c!method=\v!first,\c!align=\v!flushright,\s!parent=\??marginframed]
377\setupmarginframed [\v!right] [\c!method=\v!first,\c!align=\v!flushleft, \s!parent=\??marginframed]
378\setupmarginframed [\v!outer] [\c!method=\v!first,\c!align=\v!inner, \s!parent=\??marginframed]
379\setupmarginframed [\v!inner] [\c!method=\v!first,\c!align=\v!outer, \s!parent=\??marginframed]
380
381\definemarginframed [\v!inleft] [\v!left ]
382\definemarginframed [\v!inright] [\v!right]
383\definemarginframed [\v!inouter] [\v!outer]
384\definemarginframed [\v!ininner] [\v!inner]
385\definemarginframed [\v!inmargin] [\v!inleft]
386\definemarginframed [\v!inother] [\v!inright]
387
388\aliased\let\marginword \margintext
389\aliased\let\margintitle \margintext
390\aliased\let\inothermargin\inother
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410\permanent\tolerant\protected\def\defineinmargin[#name]#spacer[#location]#spacer[#align]#spacer[#S#settings]
411 {\ifparameter#1\else
412 \definemargindata[#name][\c!location=#location,\c!align=#align,#settings]
413 \definemarginframed[#name][#location][\c!align=#align,#settings]
414 \fi}
415
416\aliased\let\definemarginline\definemargindata
417\aliased\let\setupinmargin \setupmargindata
418
419
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\definemargindata
454 [\v!margintext:\v!section]
455 [\v!left]
456 [\c!margin=\v!margin,
457 \c!width=\leftmarginwidth,
458 \c!align=\v!flushright]
459
460\defineheadalternative
461 [\v!margintext]
462 [\c!alternative=\v!somewhere,
463 \c!margintext=\v!margintext:\v!section,
464 \c!renderingsetup=\??headrenderings:\v!margintext]
465
466\startsetups[\??headrenderings:\v!margintext]
467 \executeifdefined{\headalternativeparameter\c!margintext}\margintext {
468 \ifconditional\headshownumber
469 \headnumbercontent
470 \hkern\headnumberdistance
471 \wordboundary
472 \fi
473 \headtextcontent
474 }
475\stopsetups
476
477\protect \endinput
478 |