1
2
3
4
5
6
7
8
9
10
11
12
13
14\writestatus{loading}{ConTeXt Structure Macros Note Handling}
15
16\registerctxluafile{strcnot}{autosuffix}
17
18\unprotect
19
20
21
22
23
24\ifdefined\dotagsetnotesymbol \else \aliased\let\dotagsetnotesymbol\relax \fi
25\ifdefined\dotagsetnotation \else \aliased\let\dotagsetnotation \relax \fi
26
27
28
29
30
31
32
33
34
35
36
37
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\installcorenamespace{notation}
76
77\installcommandhandler \??notation {notation} \??notation
78
79\installcounterassociation{notation}
80
81\aliased\let\setupnotations\setupnotation
82
83\definesymbol[\v!note:\v!previouspage][\llap{\low{\symbol[\v!previouspage]}}]
84\definesymbol[\v!note:\v!nextpage ][\llap{\low{\symbol[\v!nextpage ]}}]
85
86\setupnotations
87 [\c!alternative=\v!note,
88
89
90
91
92
93
94 \c!numbercommand=\high,
95
96
97 \c!width=\v!fit,
98 \c!titledistance=.5em,
99 \c!distance=.5em,
100
101
102
103
104 \c!margin=\v!no,
105 \c!before=,
106 \c!inbetween=,
107 \c!after=,
108 \c!indentnext=\v!yes,
109 \c!indenting=\v!never,
110 \c!titleleft=(,
111 \c!titleright=),
112
113 \c!closecommand=\wordright,
114 \c!display=\v!yes,
115
116 \c!titlecommand=,
117 \c!expansion=\v!no,
118
119
120 \c!way=\v!by\v!text,
121 \c!prefix=\v!no,
122 \c!prefixconnector=.,
123
124
125 \c!number=\v!yes,
126 \c!text=,
127 \c!start=0,
128 \c!state=\v!start,
129 \c!levels=3]
130
131
132
133
134
135
136\protected\def\strc_define_commands_notation#tag#level#parent
137 {\ifempty{#parent}
138 \normalexpanded{\defineconstruction[#tag][\s!handler=\v!notation,\c!level=#level]}
139 \edefcsname\??notation#tag:\s!parent\endcsname{\??notation}
140 \else
141 \normalexpanded{\defineconstruction[#tag][#parent][\s!handler=\v!notation,\c!level=#level]}
142 \edefcsname\??note #tag:\s!parent\endcsname{\??note#parent}
143 \edefcsname\??notation#tag:\s!parent\endcsname{\??notation#parent}
144 \fi
145 \instance\protected\edefcsname\e!next #tag\endcsname{\strc_notations_next{#tag}{\number#level}}
146 \instance\protected\edefcsname\c!reset#tag\endcsname{\strc_notations_reset{#tag}{\number#level}}
147 \instance\protected\edefcsname #tag\endcsname{\strc_notations_command[#tag]}
148 \instance\protected\edefcsname\e!start#tag\endcsname{\strc_notations_start[#tag]}
149 \instance\protected\edefcsname\e!stop #tag\endcsname{\strc_notations_stop}}
150
151\lettonothing\m_strc_notation_sub
152
153\appendtoks
154 \lettonothing\m_strc_notation_sub
155 \ifempty\currentnotationparent
156
157 \strc_define_commands_notation
158 {\m_strc_notation_sub\currentnotation}
159 \plusone
160 \empty
161 \edef\p_levels{\notationparameter\c!levels}
162 \dostepwiserecurse\plustwo\p_levels\plusone
163 {\strc_define_commands_notation
164 {\v!sub\m_strc_notation_sub\currentnotation}
165 \recurselevel
166 {\m_strc_notation_sub\currentnotation}
167 \edef\m_strc_notation_sub{\v!sub\m_strc_notation_sub}}
168 \definelist[\currentnotation]
169 \else
170
171 \edef\p_levels{\notationparameter\c!levels}
172 \dorecurse\p_levels
173 {\strc_define_commands_notation
174 {\m_strc_notation_sub\currentnotation}
175 \recurselevel
176 {\m_strc_notation_sub\currentnotationparent}
177 \edef\m_strc_notation_sub{\v!sub\m_strc_notation_sub}}
178 \definelist[\currentnotation][\currentnotationparent]
179 \fi
180 \edef\p_counter{\notationparameter\s!counter}
181 \ifempty\p_counter
182 \let\p_counter\currentnotation
183 \fi
184 \doifelsecounter\p_counter\donothing{\strc_notes_define_counter\p_counter}
185 \letnotationparameter\s!counter\p_counter
186
187\to \everydefinenotation
188
189\lettonothing\p_strc_constructions_title
190\lettonothing\p_strc_constructions_number
191
192\protected\defcsname\??constructioninitializer\v!notation\endcsname
193 {\let \currentnotation \currentconstruction
194 \enforced\let\constructionparameter \notationparameter
195 \enforced\let\constructionnamespace \??notation
196 \enforced\let\detokenizedconstructionparameter\detokenizednotationparameter
197 \enforced\let\letconstructionparameter \letnotationparameter
198 \enforced\let\useconstructionstyleandcolor \usenotationstyleandcolor
199 \enforced\let\setupcurrentconstruction \setupcurrentnotation
200 \edef\p_strc_constructions_number{\constructionparameter\c!number}
201 \ifx\p_strc_constructions_number\v!yes
202 \c_strc_constructions_number_state\conditionaltrue
203 \iftrialtypesetting
204 \strc_counters_save\currentconstructionnumber
205 \fi
206
207 \else
208 \c_strc_constructions_number_state\conditionalfalse
209 \fi
210 \edef\p_strc_constructions_title{\constructionparameter\c!title}
211 \ifx\p_strc_constructions_title\v!yes
212 \c_strc_constructions_title_state\conditionaltrue
213 \else
214 \c_strc_constructions_title_state\conditionalfalse
215 \fi}
216
217\protected\defcsname\??constructionfinalizer\v!notation\endcsname
218 {\ifconditional\c_strc_constructions_number_state
219 \iftrialtypesetting
220 \strc_counters_restore\currentconstructionnumber
221 \fi
222 \fi}
223
224
225
226
227
228
229
230
231
232
233\protected\def\strc_notations_next {\strc_constructions_next_indeed \namednotationparameter}
234\protected\def\strc_notations_reset{\strc_constructions_reset_indeed\namednotationparameter}
235
236
237\newconditional\c_strc_notations_anchored_next
238
239\def\strc_notations_finalize
240 {\ifconditional\c_strc_notations_anchored_next
241 \expandafter\strc_notations_finalize_next
242 \else
243 \expandafter\strc_notations_finalize_previous
244 \fi}
245
246\def\strc_notations_finalize_previous
247 {\normalexpanded{\endgroup\noteparameter\c!next}}
248
249\def\strc_notations_finalize_next
250 {\endgroup\ignorespaces}
251
252\tolerant\protected\def\strc_notations_command[#1]#*[#S#2]
253 {\begingroup
254 \cdef\currentnote{#1}
255 \strc_constructions_initialize{#1}
256 \strc_notes_synchronize
257 \edef\p_next{\noteparameter\c!anchor}
258 \ifx\p_next\v!next
259 \c_strc_notations_anchored_next\conditionaltrue
260 \else
261 \c_strc_notations_anchored_next\conditionalfalse
262 \fi
263 \ifnotesenabled
264 \strc_counters_increment_sub\currentconstructionnumber\currentconstructionlevel
265 \fi
266 \ifhastok={#2}
267 \expandafter\strc_notations_command_setups
268 \else
269 \expandafter\strc_notations_command_reference
270 \fi[#2]}
271
272\def\strc_notations_command_setups[#S#1]
273 {\strc_constructions_register[][\c!label={\descriptionparameter\c!text},\c!reference=,\c!title=,\c!bookmark=,\c!list=,\c!referencetext=,#1]
274 \strc_notations_wrapup}
275
276\tolerant\def\strc_notations_command_reference[#1]#*#=
277 {\strc_constructions_register[][\c!label={\descriptionparameter\c!text},\c!reference={#1},\c!title={#2},\c!bookmark=,\c!list=,\c!referencetext=]
278 \strc_notations_wrapup}
279
280\def\strc_notations_wrapup
281 {\csname\??constructionnotehandler\currentconstructionhandler\endcsname
282 \strc_constructions_finalize
283 \strc_notations_finalize}
284
285\tolerant\protected\def\strc_notations_start
286 {\strc_notations_start_indeed{\csname\e!stop\currentnotation\endcsname}}
287
288\tolerant\protected\defcsname\e!start\e!namednotation\endcsname
289 {\strc_notations_start_indeed{\csname\e!stop\e!namednotation\endcsname}}
290
291\ifdefined\startnamednotation
292
293\else
294 \tolerant\protected\def\startnamednotation
295 {\strc_notations_start_indeed\stopnamednotation}
296\fi
297
298\tolerant\protected\def\strc_notations_start_indeed#1#*[#2]#*[#S#3]
299 {\begingroup
300 \cdef\currentnote{#2}
301 \strc_constructions_initialize{#2}
302 \strc_notes_synchronize
303 \ifnotesenabled
304 \strc_counters_increment_sub\currentconstructionnumber\currentconstructionlevel
305 \fi
306 \ifhastok={#3}
307 \expandafter\strc_notations_start_setups
308 \else
309 \expandafter\strc_notations_start_reference
310 \fi#1[#3]}
311
312\let\strc_notations_pickup_yes\relax
313
314\protected\def\strc_notations_start_setups#1[#S#2]
315 {\normalexpanded{\def\noexpand\strc_notations_pickup_yes###1{\strc_notations_start_setups_indeed[#2]{##1}}}
316 \strc_notations_pickup_yes}
317
318\protected\def\strc_notations_start_setups_indeed[#S#1]#*#2
319 {\strc_constructions_register[][\c!label={\descriptionparameter\c!text},\c!reference=,\c!title={#2},\c!bookmark=,\c!list=,\c!referencetext=,#1]
320 \strc_notations_wrapup}
321
322\protected\def\strc_notations_start_reference#1[#S#2]
323 {\normalexpanded{\def\noexpand\strc_notations_pickup_yes###1{\strc_notations_start_reference_indeed[#2]{##1}}}
324 \strc_notations_pickup_yes}
325
326\protected\def\strc_notations_start_reference_indeed[#1]#*#2
327 {\strc_constructions_register[][\c!label={\descriptionparameter\c!text},\c!reference={#1},\c!title={#2},\c!bookmark=,\c!list=,\c!referencetext=]
328 \strc_notations_wrapup}
329
330\protected\def\strc_notations_stop
331 {}
332
333
334
335
336
337
338\protected\defcsname\??constructionnotehandler\v!notation\endcsname
339 {\csname\??constructionnotehandler\currentconstructionhandler:\constructionparameter\c!type\endcsname}
340
341\protected\defcsname\??constructionnotehandler\v!notation:\endcsname
342 {[\currentconstructionhandler:\currentconstruction]}
343
344
345
346\defineconstructionalternative
347 [\v!note]
348 [\c!renderingsetup=\??constructionrenderings:\v!note]
349
350\startsetups[\??constructionrenderings:\v!note]
351 \noindent
352 \leftboundary
353 \llap{\box\constructionheadbox\kern{\constructionparameter\c!distance}}
354 \useconstructionstyleandcolor\c!style\c!color
355 \ignorespaces
356\stopsetups
357
358
359
360\installcorenamespace{note}
361
362\installframedcommandhandler \??note {note} \??note
363
364\let\setupnotes\setupnote
365
366
367
368\setupnotes
369 [\c!location=\v!page,
370
371 \c!rule=\v!on,
372 \c!before=\blank,
373 \c!bodyfont=\v!small,
374 \c!anchor=,
375
376
377
378
379
380 \c!rulethickness=\linewidth,
381 \c!frame=\v!off,
382 \c!distance=.125em,
383
384 \c!columndistance=1em,
385
386 \c!align=,
387 \c!split=\v!tolerant,
388 \c!width=\makeupwidth,
389 \c!height=\textheight,
390 \c!command=,
391 \c!separator=,
392 \c!textcommand=\high,
393 \c!textstyle=\tx,
394
395 \c!interaction=\v!yes,
396
397
398 \c!prefixconnector=.,
399
400 \c!prefix=\v!no,
401
402 \c!paragraph=\v!no,
403 \c!inbetween=\hskip\emwidth,
404 \c!symbol=\mathematics{*},
405 \c!n=1]
406
407\setupnotes
408 [\c!expansion=\v!no,
409 \c!xmlsetup=,
410 \s!catcodes=]
411
412
413
414
415
416\permanent\def\currentnoteinsertion {\noteparameter\s!insert}
417\permanent\def\currentnoteinsertionnumber{\namedinsertionnumber{\noteparameter\s!insert}}
418
419\appendtoks
420 \ifempty\currentnoteparent
421 \doifelseinsertion\currentnote
422 \donothing
423 {\defineinsertion[\currentnote]
424 \xtoksapp\t_strc_notes{\noexpand\strc_notes_process_list{\currentnote}}}
425 \letnoteparameter\s!insert\currentnote
426 \definenotation[\currentnote][\c!type=\v!note]
427 \else
428 \setexpandednoteparameter\s!insert{\namednoteparameter\currentnoteparent\s!insert}
429 \definenotation[\currentnote][\currentnoteparent][\c!type=\v!note]
430 \fi
431 \clf_definenote
432 {\currentnote}
433 {insert}
434 \currentnoteinsertionnumber
435 \relax
436\to \everydefinenote
437
438
439
440\def\strc_notes_define_counter#tag
441 {\definecounter[#tag]
442 \registerenumerationcounter{#tag}}
443
444\appendtoks
445 \synchronizenotationcounters
446\to \everysetupnotation
447
448\appendtoks
449 \synchronizenotationcounters
450\to \everydefinenotation
451
452
453
454
455\letcsname\??constructionstarthandler \v!notation\expandafter\endcsname\csname\??constructionstarthandler \v!construction\endcsname
456\letcsname\??constructionstophandler \v!notation\expandafter\endcsname\csname\??constructionstophandler \v!enumeration \endcsname
457\letcsname\??constructioncommandhandler\v!notation\expandafter\endcsname\csname\??constructioncommandhandler\v!enumeration \endcsname
458\letcsname\??constructiontexthandler \v!notation\expandafter\endcsname\csname\??constructiontexthandler \v!enumeration \endcsname
459
460\protected\defcsname\??constructionmainhandler\v!notation\endcsname#following
461 {\iftrialtypesetting \else
462 \begingroup
463 \currentconstructionsynchronize
464 \c_attr_destination\currentconstructionattribute\relax
465 \signalcharacter
466 \endgroup
467 \fi
468 \ifconditional\c_strc_notes_flushed\else
469 #following\relax
470 \fi}
471
472\newmarks\c_strc_notes_insert_mark
473
474\protected\defcsname\??constructionnotehandler\v!notation:\v!note\endcsname
475 {\ifnotesenabled
476
477
478
479 \let\currentnote\currentconstruction
480
481 \iftrialtypesetting
482 \strc_notes_inject_dummy
483 \else
484 \begingroup
485 \edef\currentnotenumber{\clf_storenote{\currentnote}\currentconstructionlistentry}
486 \processingnote\conditionaltrue
487 \ifconditional\c_strc_notes_skip
488 \glet\lastnotesymbol\strc_notes_inject_symbol_nop
489 \else
490 \iftypesettinglines
491 \ignorelines
492 \fi
493 \ifconditional\c_strc_notes_symbol
494 \strc_notes_inject_symbol_yes
495 \else
496 \unskip\unskip
497 \glet\lastnotesymbol\strc_notes_inject_symbol_yes
498 \fi
499 \fi
500 \ifconditional\postponingnotes
501 \global\postponednote\conditionaltrue
502 \orelse\ifconditional\inlocalnotes
503 \global\postponednote\conditionaltrue
504 \orelse\ifconditional\c_strc_notes_flushed
505 \handlenoteitself\currentnote\currentnotenumber
506 \orelse\ifconditional\c_strc_notes_delayed
507
508 \else
509 \handlenoteinsert\currentnote\currentnotenumber
510 \fi
511 \endgroup
512 \fi
513 \fi
514
515 \ifcstok{\noteparameter\c!range}\v!yes
516 \normalexpanded{\marks\c_strc_notes_insert_mark{\the\c_strc_notes_n}}
517 \fi
518
519 \ifconditional\c_strc_notes_skip
520 \global\c_strc_notes_skip\conditionalfalse
521 \else
522 \boundary\noteboundary
523 \fi}
524
525
526
527\permanent\protected\def\flushnoterange[#1]
528 {\begingroup
529 \cdef\currentnote{#1}
530
531
532
533
534
535 \clf_flushnoterange
536 {\currentnoteinsertionnumber}
537 \c_strc_notes_insert_mark
538 \relax
539 \endgroup}
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563\installcorenamespace{noteinteractioninline}
564\installcorenamespace{noteinteractiondisplay}
565
566\newconstant\a_strc_notes_symbol_reference
567\newconstant\a_strc_notes_number_reference
568\newconstant\a_strc_notes_text_reference
569\newconstant\a_strc_notes_text_destination
570
571\lettonothing\strc_notes_get_reference_attribute_symbol
572\lettonothing\strc_notes_get_destination_attribute_symbol
573
574\def\strc_notes_interaction_check_inline
575 {\edef\p_interaction{\noteparameter\c!interaction}
576 \csname\??noteinteractioninline
577 \ifcsname\??noteinteractioninline\p_interaction\endcsname\p_interaction\else\v!no\fi
578 \endcsname}
579
580\def\strc_notes_interaction_check_display
581 {\edef\p_interaction{\noteparameter\c!interaction}
582 \csname\??noteinteractiondisplay
583 \ifcsname\??noteinteractiondisplay\p_interaction\endcsname\p_interaction\else\v!no\fi
584 \endcsname}
585
586\mutable\let\currentnotenumber\!!zerocount
587
588\lettonothing\strc_notes_get_reference_attribute_symbol
589\lettonothing\strc_notes_get_destination_attribute_symbol
590
591\let\strc_notes_set_reference_attribute_number\donothing
592\let\strc_notes_set_reference_attribute_text \donothing
593\let\strc_notes_set_destination_attribute_text\donothing
594
595\let\strc_notes_set_style_color_inline \relax
596\let\strc_notes_set_style_color_display\relax
597
598
599
600\let\m_strc_notes_internal\relax
601
602\def\strc_notes_prepare_inline_references_nop
603 {\lettonothing\strc_notes_get_reference_attribute_symbol
604 \lettonothing\strc_notes_get_destination_attribute_symbol
605 \let\strc_notes_set_style_color_inline\strc_notes_set_style_color_inline_nop}
606
607\def\strc_notes_prepare_inline_references_yes
608 {\edef\m_strc_notes_internal{\clf_noteinternal{\currentnote}\currentnotenumber}
609 \strc_references_set_simple_reference{*\m_strc_notes_internal}
610 \strc_references_get_simple_reference{internal(\m_strc_notes_internal)}
611 \edef\strc_notes_get_destination_attribute_symbol{attr\destinationattribute\currentdestinationattribute}
612 \edef\strc_notes_get_reference_attribute_symbol{attr\referenceattribute\currentreferenceattribute}
613 \let\strc_notes_set_style_color_inline\strc_notes_set_style_color_inline_yes}
614
615\letcsname\??noteinteractioninline\v!no \endcsname\strc_notes_prepare_inline_references_nop
616\letcsname\??noteinteractioninline\v!all \endcsname\strc_notes_prepare_inline_references_yes
617\letcsname\??noteinteractioninline\v!number\endcsname\strc_notes_prepare_inline_references_yes
618\letcsname\??noteinteractioninline\v!text \endcsname\strc_notes_prepare_inline_references_yes
619\letcsname\??noteinteractioninline\v!yes \endcsname\strc_notes_prepare_inline_references_yes
620
621
622
623
624
625\def\strc_notes_prepare_display_references_nop
626 {\let\strc_notes_set_reference_attribute_number\donothing
627 \let\strc_notes_set_reference_attribute_text\donothing
628 \let\strc_notes_set_destination_attribute_text\donothing
629 \let\strc_notes_set_style_color_display\strc_notes_set_style_color_display_nop}
630
631\def\strc_notes_prepare_display_references_yes_number
632 {\edef\m_strc_notes_internal{\clf_noteinternal{\currentnote}\currentnotenumber}
633 \ifcase\m_strc_notes_internal\relax
634 \strc_notes_prepare_display_references_nop
635 \else
636 \let\strc_notes_set_reference_attribute_text\donothing
637 \strc_references_get_simple_reference{*\m_strc_notes_internal}
638 \edef\strc_notes_set_reference_attribute_number{\c_attr_reference\currentreferenceattribute}
639 \let\strc_notes_set_style_color_display\strc_notes_set_style_color_display_yes
640 \fi}
641
642\def\strc_notes_prepare_display_references_yes_text
643 {\edef\m_strc_notes_internal{\clf_noteinternal{\currentnote}\currentnotenumber}
644 \ifcase\m_strc_notes_internal\relax
645 \strc_notes_prepare_display_references_nop
646 \else
647 \strc_references_get_simple_reference{*\m_strc_notes_internal}
648 \edef\strc_notes_set_reference_attribute_text{\c_attr_reference\currentreferenceattribute}
649 \let\strc_notes_set_reference_attribute_number\donothing
650 \let\strc_notes_set_style_color_display\strc_notes_set_style_color_display_yes
651 \fi}
652
653\def\strc_notes_prepare_display_references_yes_all
654 {\edef\m_strc_notes_internal{\clf_noteinternal{\currentnote}\currentnotenumber}
655 \ifcase\m_strc_notes_internal\relax
656 \strc_notes_prepare_display_references_nop
657 \else
658 \strc_references_get_simple_reference{*\m_strc_notes_internal}
659 \edef\strc_notes_set_reference_attribute_text{\c_attr_reference\currentreferenceattribute}
660 \strc_references_get_simple_reference{*\m_strc_notes_internal}
661 \edef\strc_notes_set_reference_attribute_number{\c_attr_reference\currentreferenceattribute}
662 \let\strc_notes_set_style_color_display\strc_notes_set_style_color_display_yes
663 \fi}
664
665\letcsname\??noteinteractiondisplay\v!no \endcsname\strc_notes_prepare_display_references_nop
666\letcsname\??noteinteractiondisplay\v!all \endcsname\strc_notes_prepare_display_references_yes_all
667\letcsname\??noteinteractiondisplay\v!number\endcsname\strc_notes_prepare_display_references_yes_number
668\letcsname\??noteinteractiondisplay\v!text \endcsname\strc_notes_prepare_display_references_yes_text
669\letcsname\??noteinteractiondisplay\v!yes \endcsname\strc_notes_prepare_display_references_yes_number
670
671\mutable\let\strc_notes_set_style_color_inline_nop \usenotestyleandcolor
672\mutable\let\strc_notes_set_style_color_display_nop\usenotationstyleandcolor
673
674\protected\def\strc_notes_set_style_color_inline_yes#style#color
675 {\usenotestyleandcolor#style#color
676 \iflocation\strc_notes_set_style_color_special\fi}
677
678\protected\def\strc_notes_set_style_color_display_yes#style#color
679 {\usenotationstyleandcolor#style#color
680 \iflocation\strc_notes_set_style_color_special\fi}
681
682\def\strc_notes_set_style_color_special
683 {\iftrialtypesetting
684
685 \orelse\ifempty\currentcolorparameter
686 \scratchcounter\clf_notedeltapage{\currentnote}\currentnotenumber\relax
687 \setlocationcolorspecified\scratchcounter
688 \fi}
689
690\defcsname\??constructiontexthandler\v!notation\endcsname
691 {\begingroup
692
693
694
695
696
697 \strc_notes_set_reference_attribute_number
698 \dotagsetnotation
699 \strc_notes_set_style_color_display\c!headstyle\c!headcolor
700 \strc_enumerations_text
701 \endgroup}
702
703
704
705\protected\def\strc_notes_inject_pointer
706 {\ifcase\clf_notedeltapage{\currentnote}\currentnotenumber\relax\relax
707
708 \or
709
710 \or
711 \noteparameter\c!symbolcommand{\symbol[\v!note:\v!nextpage]}
712 \or
713 \noteparameter\c!symbolcommand{\symbol[\v!note:\v!previouspage]}
714 \fi}
715
716\protected\def\strc_notes_inject_symbol_yes
717 {\strc_notes_inject_symbol_indeed\conditionaltrue}
718
719\protected\def\strc_notes_inject_symbol_nop
720 {\strc_notes_inject_symbol_indeed\conditionalfalse}
721
722\definemargindata
723 [strcnotesdestinationmargin]
724 [\v!left]
725 [\c!margin=\zeropoint,
726 \c!width=\zeropoint,
727 \c!style=,
728 \c!color=]
729
730\protected\def\strc_notes_inject_symbol_indeed#synchronize
731 {\ifconditional\c_strc_notations_anchored_next\else
732 \removeunwantedspaces
733 \doifelseitalic\/\donothing
734 \fi
735 \ifnum\lastboundary=\noteboundary
736 \unboundary
737
738 \strc_notes_inject_separator
739 \fi
740 \nobreak
741 \begingroup
742 \strc_notes_interaction_check_inline\strc_notes_set_style_color_inline\c!textstyle\c!textcolor
743 \hbox \strc_notes_get_reference_attribute_symbol \strc_notes_get_destination_attribute_symbol \bgroup
744
745 \strc_references_flush_destination_nodes
746 \dostarttagged\t!descriptionsymbol\currentnote
747 \dotagsetnotesymbol
748 \noteparameter\c!textcommand{\clf_noteprefixednumber{\currentnote}\currentnotenumber\relax}
749
750 \ifcstok{\noteparameter\c!indicator}\v!yes
751 \strc_notes_inject_pointer
752 \fi
753 \dostoptagged
754 \egroup
755 \endgroup
756 \glettonothing\lastnotesymbol}
757
758\protected\def\strc_notes_inject_dummy
759 {\removeunwantedspaces
760 \doifelseitalic\/\donothing
761 \ifnum\lastboundary=\noteboundary
762 \unboundary
763
764 \strc_notes_inject_separator
765 \fi
766 \nobreak
767 \hpack to .5\emwidth{}
768 \glettonothing\lastnotesymbol}
769
770\protected\def\strc_notes_inject_separator
771 {\edef\p_textseparator{\noteparameter\c!textseparator}
772 \ifempty\p_textseparator
773 \kern{\noteparameter\c!distance}
774 \else
775
776 \nobreak
777 \hbox\bgroup
778 \usenotestyleandcolor\c!textstyle\c!textcolor
779 \noteparameter\c!textcommand{\p_textseparator}
780 \kern{\noteparameter\c!distance}
781 \egroup
782 \nobreak
783 \fi}
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846\newif\ifnotesenabled \notesenabledtrue
847
848
849
850
851\appendtoks \notesenabledfalse \to \everybeforepagebody
852\appendtoks \notesenabledfalse \to \everystructurelist
853\appendtoks \notesenabledfalse \to \everysimplifycommands
854\appendtoks \notesenabledfalse \to \everypreroll
855
856
857
858
859
860
861
862
863
864
865
866\newtoks\t_strc_notes
867
868\let\strc_notes_process_list\gobbleoneargument
869
870\protected\def\strc_notes_process#action
871 {\def\strc_notes_process_list##1{\cdef\currentnote{##1}\let\currentdescription\currentnote#action}
872 \expand\t_strc_notes}
873
874\newtoks\everychecknote
875\newtoks\everysynchronizenote
876
877\appendtoks
878 \ifempty\currentnote \else
879 \setupnotations[\currentnote][]
880 \fi
881\to \everysynchronizenote
882
883\def\strc_notes_synchronize
884 {\expand\everysynchronizenote}
885
886\appendtoks
887 \strc_notes_process\strc_notes_synchronize
888\to \everysetupnoteroot
889
890\appendtoks
891 \expand\everysynchronizenote
892\to \everydefinenote
893
894
895
896
897
898
899
900\installcorenamespace{notecommand}
901\installcorenamespace{notealign}
902\installcorenamespace{notepenalty}
903\installcorenamespace{noterule}
904
905\permanent\protected\def\currentnoterulecommand{\begincsname\??notecommand\currentnote\endcsname}
906\permanent\protected\def\currentnoterulealign {\begincsname\??notealign \currentnote\endcsname}
907
908\permanent\protected\def\currentnoterulecommandcommand{\noteparameter\c!rulecommand}
909\permanent\protected\def\currentnoterulecommandnormal {\normalnoterule}
910
911\permanent\protected\def\letcurrentnoterulecommand{\enforced\letcsname\??notecommand\currentnote\endcsname}
912\permanent\protected\def\letcurrentnoterulealign {\enforced\letcsname\??notealign \currentnote\endcsname}
913
914\appendtoks
915 \enforced\letcsname\??notecommand\currentnote\endcsname\currentnoterulecommandnormal
916 \enforced\letcsname\??notealign \currentnote\endcsname\lefttoright
917\to \everysynchronizenote
918
919\def\strc_notes_set_rule
920 {\letcurrentnoterulecommand\relax
921 \letcurrentnoterulealign \relax
922 \processcommacommand[\noteparameter\c!rule]\strc_notes_set_rule_step}
923
924\def\strc_notes_set_rule_step#alternative
925 {\begincsname\??noterule#alternative\endcsname}
926
927\def\strc_notes_set_rule_autodir
928 {\doifelserighttoleftinbox\currentnoteinsertionnumber\righttoleft\lefttoright}
929
930\defcsname\??noterule \v!command\endcsname{\letcurrentnoterulecommand\currentnoterulecommandcommand}
931\defcsname\??noterule \v!on\endcsname{\letcurrentnoterulecommand\currentnoterulecommandnormal}
932\defcsname\??noterule \v!normal\endcsname{\letcurrentnoterulecommand\currentnoterulecommandnormal}
933\defcsname\??noterule \v!left\endcsname{\letcurrentnoterulecommand\currentnoterulecommandnormal
934 \letcurrentnoterulealign \lefttoright}
935\defcsname\??noterule \v!right\endcsname{\letcurrentnoterulecommand\currentnoterulecommandnormal
936 \letcurrentnoterulealign \righttoleft}
937\defcsname\??noterule\v!paragraph\endcsname{\letcurrentnoterulecommand\currentnoterulecommandnormal
938 \letcurrentnoterulealign \strc_notes_set_rule_autodir}
939\defcsname\??noterule \v!off\endcsname{\letcurrentnoterulecommand\relax}
940
941\appendtoks
942 \strc_notes_set_rule
943\to \everysynchronizenote
944
945\permanent\def\currentnotepenalty
946 {\ifcsname\??notepenalty\noteparameter\c!split\endcsname
947 \lastnamedcs
948 \else
949 \numexpr\noteparameter\c!split\relax
950 \fi}
951
952\setnewconstant\notepenaltytolerant \zerocount
953\setnewconstant\notepenaltystrict 9999
954\setnewconstant\notepenaltyverystrict\maxdimen
955
956\letcsname\??notepenalty\v!tolerant \endcsname\notepenaltytolerant
957\letcsname\??notepenalty\v!strict \endcsname\notepenaltystrict
958\letcsname\??notepenalty\v!verystrict\endcsname\notepenaltyverystrict
959\letcsname\??notepenalty \endcsname\notepenaltytolerant
960
961
962
963
964
965\newif\ifnotelimit \notelimittrue
966
967\def\strc_notes_set_factor
968 {\edef\p_factor{\noteparameter\c!factor}
969 \ifempty\p_factor \else
970 \ifnum\p_factor<\zerocount \else
971
972 \insertmultiplier\currentnoteinsertionnumber\p_factor
973 \fi
974 \fi}
975
976\appendtoks
977 \strc_notes_set_factor
978\to \everysynchronizenote
979
980
981
982\installcorenamespace{notelocationvariant}
983\installcorenamespace{notepositionvariant}
984\installcorenamespace{notedelayedvariant}
985\installcorenamespace{notelocation}
986
987\newconditional\c_strc_notes_delayed
988\newconditional\c_strc_notes_flushed
989
990\protected\def\strc_notes_set_delayed_yes{\c_strc_notes_delayed\conditionaltrue\c_strc_notes_flushed\conditionalfalse}
991\protected\def\strc_notes_set_delayed_nop{\c_strc_notes_delayed\conditionalfalse\c_strc_notes_flushed\conditionalfalse}
992\protected\def\strc_notes_set_delayed_lst{\c_strc_notes_delayed\conditionaltrue\c_strc_notes_flushed\conditionaltrue}
993
994\defcsname\??notelocation\v!page\endcsname
995 {\letcsname\??notedelayedvariant \currentnote\endcsname\strc_notes_set_delayed_nop
996 \letcsname\??notelocationvariant\currentnote\endcsname\strc_notes_set_location_page}
997
998\defcsname\??notelocation\v!columns\endcsname
999 {\letcsname\??notedelayedvariant \currentnote\endcsname\strc_notes_set_delayed_nop
1000 \letcsname\??notelocationvariant\currentnote\endcsname\strc_notes_set_location_columns}
1001
1002\defcsname\??notelocation\v!lastcolumn\endcsname
1003 {\letcsname\??notedelayedvariant \currentnote\endcsname\strc_notes_set_delayed_nop
1004 \letcsname\??notelocationvariant\currentnote\endcsname\strc_notes_set_location_lastcolumn}
1005
1006\defcsname\??notelocation\v!firstcolumn\endcsname
1007 {\letcsname\??notedelayedvariant \currentnote\endcsname\strc_notes_set_delayed_nop
1008 \letcsname\??notelocationvariant\currentnote\endcsname\strc_notes_set_location_firstcolumn}
1009
1010\defcsname\??notelocation\v!none\endcsname
1011 {\letcsname\??notedelayedvariant \currentnote\endcsname\strc_notes_set_delayed_yes
1012 \letcsname\??notelocationvariant\currentnote\endcsname\strc_notes_set_location_none}
1013
1014\defcsname\??notelocation\v!list\endcsname
1015 {\letcsname\??notedelayedvariant \currentnote\endcsname\strc_notes_set_delayed_lst
1016 \letcsname\??notelocationvariant\currentnote\endcsname\strc_notes_set_location_none}
1017
1018\defcsname\??notelocation\v!text\endcsname
1019 {\letcsname\??notedelayedvariant \currentnote\endcsname\strc_notes_set_delayed_yes
1020 \letcsname\??notelocationvariant\currentnote\endcsname\strc_notes_set_location_text}
1021
1022\defcsname\??notelocation\v!high\endcsname
1023 {\letcsname\??notepositionvariant\currentnote\endcsname\strc_notes_set_position_high}
1024
1025\defcsname\??notelocation\v!bottom\endcsname
1026 {\letcsname\??notepositionvariant\currentnote\endcsname\strc_notes_set_position_bottom}
1027
1028\defcsname\??notedelayedvariant \??notedelayedvariant \endcsname{\strc_notes_set_delayed_nop }
1029\defcsname\??notepositionvariant\??notepositionvariant\endcsname{\strc_notes_set_position_bottom}
1030\defcsname\??notelocationvariant\??notelocationvariant\endcsname{\strc_notes_set_location_page }
1031
1032\protected\def\strc_notes_set_delayed
1033 {\csname\??notedelayedvariant
1034 \ifcsname\??notedelayedvariant\currentnote\endcsname
1035 \currentnote
1036 \else
1037 \??notedelayedvariant
1038 \fi
1039 \endcsname}
1040
1041\protected\def\strc_notes_set_position
1042 {\csname\??notepositionvariant
1043 \ifcsname\??notepositionvariant\currentnote\endcsname
1044 \currentnote
1045 \else
1046 \??notepositionvariant
1047 \fi
1048 \endcsname}
1049
1050\protected\def\strc_notes_set_location
1051 {\csname\??notelocationvariant
1052 \ifcsname\??notelocationvariant\currentnote\endcsname
1053 \currentnote
1054 \else
1055 \??notelocationvariant
1056 \fi
1057 \endcsname}
1058
1059\protected\def\strc_notes_set_variants
1060 {\normalexpanded{\rawprocesscommalist[\noteparameter\c!location]\strc_notes_set_location_step}}
1061
1062\protected\def\strc_notes_set_location_step#alternative
1063 {\begincsname\??notelocation#alternative\endcsname}
1064
1065\appendtoks
1066 \strc_notes_set_variants
1067 \strc_notes_set_delayed
1068\to \everysynchronizenote
1069
1070\newgluespec \s_strc_notes_distance
1071\newinteger \c_strc_notes_columns
1072\newgluespec \s_strc_notes_before
1073\newgluespec \s_strc_notes_inbetween
1074\newconditional\c_strc_notes_first_flushed
1075
1076
1077
1078\appendtoks
1079 \edef\p_spacebefore{\rootnoteparameter\c!spacebefore}
1080 \ifempty\p_spacebefore
1081 \global\s_strc_notes_before\zeropoint
1082 \else
1083 \setbox\scratchbox\vbox{\blank[\p_spacebefore]\global\s_strc_notes_before\lastskip}
1084 \fi
1085 \edef\p_spaceinbetween{\noteparameter\c!spaceinbetween}
1086 \ifempty\p_spaceinbetween
1087 \global\s_strc_notes_inbetween\zeropoint
1088 \else
1089 \setbox\scratchbox\vbox{\blank[\p_spaceinbetween]\global\s_strc_notes_inbetween\lastskip}
1090 \fi
1091\to \everysynchronizenote
1092
1093\def\strc_notes_set_distance
1094 {\begingroup
1095 \restoreglobalbodyfont
1096 \setbox\scratchbox\vbox
1097 {\forgetall
1098 \dontcomplain
1099 \noteparameter\c!before
1100 \ifvmode
1101 \nointerlineskip
1102 \fi
1103 \placenoterule
1104
1105 \strut
1106 \noteparameter\c!after}
1107
1108 \scratchdimen{\htdp\scratchbox\lineheight}
1109 \ifconditional\c_page_mvl_active
1110
1111 \orelse\ifgridsnapping
1112 \getnoflines\scratchdimen
1113 \scratchdimen\noflines\lineheight
1114 \fi
1115
1116
1117 \normalexpanded{
1118 \endgroup
1119 \s_strc_notes_distance\the\scratchdimen\relax
1120
1121 \ifconditional\c_page_mvl_split_inserts
1122 \insertlineheight\currentnoteinsertionnumber\relaxedspace\the\strutht\relax
1123 \insertlinedepth \currentnoteinsertionnumber\relaxedspace\the\strutdp\relax
1124 \fi}}
1125
1126\def\strc_notes_set_columns
1127 {\c_strc_notes_columns\noteparameter\c!n\relax
1128 \ifcase\c_strc_notes_columns
1129 \c_strc_notes_columns\plusone
1130 \fi}
1131
1132\def\strc_notes_set_location_page
1133 {\c_strc_notes_delayed\conditionalfalse
1134 \strc_notes_set_distance
1135 \strc_notes_set_columns
1136 \page_inserts_set_location\currentnoteinsertion\v!page
1137 \insertmultiplier\currentnoteinsertionnumber{(\plusthousand\c_strc_notes_columns)*\nofmulticolumns}
1138 \insertlimit \currentnoteinsertionnumber\ifnotelimit{(\noteparameter\c!height)*\c_strc_notes_columns}\else\maxdimen\fi
1139 \insertdistance \currentnoteinsertionnumber\s_strc_notes_distance}
1140
1141\def\strc_notes_set_location_columns
1142 {\c_strc_notes_delayed\conditionalfalse
1143 \strc_notes_set_distance
1144 \strc_notes_set_columns
1145
1146 \ifnum\nofcolumns=\zerocount
1147 \c_strc_notes_columns\plusone
1148 \fi
1149 \page_inserts_set_location \currentnoteinsertion\v!columns
1150 \insertmultiplier\currentnoteinsertionnumber{\plusthousand\c_strc_notes_columns}
1151 \insertlimit \currentnoteinsertionnumber\ifnotelimit{(\noteparameter\c!height)*\c_strc_notes_columns}\else\maxdimen\fi
1152 \insertdistance \currentnoteinsertionnumber\s_strc_notes_distance}
1153
1154\def\strc_notes_set_location_somecolumn#whatcolumn
1155 {\c_strc_notes_delayed\conditionalfalse
1156 \strc_notes_set_distance
1157 \strc_notes_set_columns
1158 \page_inserts_set_location \currentnoteinsertion#whatcolumn
1159 \insertmultiplier\currentnoteinsertionnumber\plusthousand
1160 \insertlimit \currentnoteinsertionnumber\ifnotelimit{\noteparameter\c!height}\else\maxdimen\fi
1161 \insertdistance \currentnoteinsertionnumber\s_strc_notes_distance}
1162
1163\def\strc_notes_set_location_firstcolumn{\strc_notes_set_location_somecolumn\v!firstcolumn}
1164\def\strc_notes_set_location_lastcolumn {\strc_notes_set_location_somecolumn\v!lastcolumn }
1165
1166\def\strc_notes_set_location_text
1167 {\c_strc_notes_delayed\conditionaltrue
1168 \clf_setnotestate{\currentnote}{store}
1169 \page_inserts_set_location \currentnoteinsertion\v!text
1170 \insertmultiplier\currentnoteinsertionnumber\zerocount
1171 \insertlimit \currentnoteinsertionnumber\maxdimen
1172 \insertdistance \currentnoteinsertionnumber\zeropoint}
1173
1174\let\strc_notes_set_location_none\strc_notes_set_location_text
1175
1176\def\strc_notes_set_properties
1177 {\strc_notes_set_columns
1178 \strc_notes_set_distance
1179 \strc_notes_set_location
1180 \strc_notes_set_delayed
1181 \strc_notes_set_factor}
1182
1183\let\strc_notes_set_position_high\relax
1184
1185\def\strc_notes_set_position_bottom
1186 {\c_notes_bottom_present\conditionaltrue}
1187
1188\appendtoks
1189 \strc_notes_set_properties
1190\to \everysynchronizenote
1191
1192
1193
1194\newconditional\c_notes_bottom_present
1195
1196
1197
1198
1199
1200
1201\def\strc_notes_check_if_bottom_present_indeed
1202 {\ifzeropt\insertheight\currentnoteinsertionnumber\else
1203 \strc_notes_set_position
1204 \fi}
1205
1206\def\strc_notes_check_if_bottom_present_step
1207 {\ifconditional\c_notes_bottom_present\else\strc_notes_check_if_bottom_present_indeed\fi}
1208
1209\def\strc_notes_check_if_bottom_present
1210 {\c_notes_bottom_present\conditionalfalse
1211 \strc_notes_process\strc_notes_check_if_bottom_present_step}
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226\permanent\protected\def\placenoterule
1227 {\begingroup
1228 \currentnoterulealign
1229 \currentnoterulecommand
1230 \par
1231 \endgroup}
1232
1233\permanent\protected\def\normalnoterule
1234 {\ifvmode
1235
1236 \dontleavehmode \blackrule
1237 [\c!color=\noteparameter\c!rulecolor,
1238 \c!width=.2\hsize,
1239 \c!height=\noteparameter\c!rulethickness,
1240 \c!depth=\zeropoint]
1241 \endgraf
1242 \kern\strutdepth
1243 \fi}
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297\newconditional\c_strc_notes_symbol \c_strc_notes_symbol\conditionaltrue
1298\newconditional\c_strc_notes_skip
1299
1300\newcount\c_strc_notes_n
1301
1302\permanent\protected\def\setnote [#tag]{\csname#tag\endcsname}
1303\permanent\protected\def\setnotetext[#tag]{\global\c_strc_notes_skip\conditionaltrue\csname#tag\endcsname}
1304
1305\permanent\protected\def\handlenoteinsert#tag#id
1306 {\begingroup
1307 \cdef\currentnote{#tag}
1308 \strc_constructions_initialize{#tag}
1309 \strc_notes_synchronize
1310 \global\advanceby\c_strc_notes_n\plusone
1311 \expand\everybeforenoteinsert
1312
1313 \insert
1314 \s!index \currentnoteinsertionnumber
1315 \s!data \c_strc_notes_n
1316 \bgroup
1317 \expand\everyinsidenoteinsert\relax
1318 \usesetupsparameter\noteparameter
1319 \useinterlinespaceparameter\noteparameter
1320 \ifcstok{\noteparameter\c!paragraph}\v!yes
1321 \nointerlineskip
1322 \startvboxtohboxseparator
1323 \noteparameter\c!inbetween
1324 \stopvboxtohboxseparator
1325 \startvboxtohbox
1326 \handlenoteitself{#tag}{#id}
1327 \stopvboxtohbox
1328 \else
1329 \handlenoteitself{#tag}{#id}
1330 \fi
1331 \egroup
1332 \expand\everyafternoteinsert
1333 \endgroup}
1334
1335\permanent\protected\def\betweennoteitself#tag
1336 {\cdef\currentnote{#tag}
1337 \ifcstok{\noteparameter\c!paragraph}\v!yes
1338 \noteparameter\c!inbetween
1339 \fi}
1340
1341\permanent\protected\def\handlenoteitself#tag#id
1342 {\edef\currentnotenumber{#id}
1343 \cdef\currentnote{#tag}
1344 \strc_constructions_initialize{#tag}
1345 \strc_notes_synchronize
1346 \edef\currentconstructionlistentry{\clf_notelistindex{\currentnote}#id}
1347
1348
1349
1350 \reinstatecachedconstructionnumberentry\currentconstructionlistentry
1351
1352 \dontcomplain
1353
1354 \strc_notes_interaction_check_display
1355 \strc_notes_set_reference_attribute_text
1356 \strc_constructions_stored_start
1357 \begstrut
1358 \strc_references_flush_destination_nodes
1359 \strc_notes_set_destination_attribute_text
1360 \ifconditional\c_strc_notes_flushed\else
1361 \strc_notes_inject_text\relax
1362 \fi
1363 \ifvmode\obeydepth\else\endstrut\fi
1364 \strc_constructions_stored_stop
1365
1366 }
1367
1368\protected\def\strc_notes_inject_text
1369 {\clf_savedlisttitle{\currentconstructionmain}\currentconstructionlistentry\relax}
1370
1371\installstructurelistprocessor{construction}{\usestructurelistprocessor{section}}
1372
1373\newboundary\noteboundary
1374
1375\newconditional\processingnote
1376\newconditional\postponednote
1377
1378\newtoks\everybeforenoteinsert
1379\newtoks\everyinsidenoteinsert
1380\newtoks\everyafternoteinsert
1381
1382\permanent\protected\def\doifelseinnote
1383 {\ifconditional\processingnote
1384 \expandafter\firstoftwoarguments
1385 \else
1386 \expandafter\secondoftwoarguments
1387 \fi}
1388
1389\appendtoks
1390 \enforced\lettonothing\flushnotes
1391 \enforced\lettonothing\postponenotes
1392 \forgetall
1393 \resetallattributes
1394 \inheritmaintextcolor
1395\to \everybeforenoteinsert
1396
1397\def\strc_notes_set_penalties
1398 {
1399 \floatingpenalty \currentnotepenalty
1400 \insertpenalty\currentnoteinsertionnumber\currentnotepenalty
1401
1402 \interlinepenalty\plushundred
1403
1404 \ifnum\noteparameter\c!n>\plusone
1405 \penalty\zerocount
1406 \fi}
1407
1408\appendtoks
1409 \strc_notes_set_penalties
1410 \forgetall
1411 \strc_notes_set_bodyfont
1412 \redoconvertfont
1413 \splittopskip\strutht
1414 \splitmaxdepth\strutdp
1415\insertmaxdepth \currentnoteinsertionnumber\strutdp
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425 \pickupattributes
1426\to \everyinsidenoteinsert
1427
1428
1429
1430\appendtoks \strc_itemgroups_push \to \everybeforenoteinsert
1431\appendtoks \strc_itemgroups_pop \to \everyafternoteinsert
1432
1433
1434
1435
1436
1437
1438
1439\setupnotes
1440 [\c!width=\v!auto]
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461\permanent\protected\def\setnotehsize
1462 {\edef\p_width{\noteparameter\c!width}
1463 \ifx\p_width\v!auto
1464
1465 \let\p_width\makeupwidth
1466 \setnoteparameter\c!width{\makeupwidth}
1467 \fi
1468 \hsize{\p_width}}
1469
1470\appendtoks
1471
1472 \setnotehsize
1473 \setsimplecolumnshsize[\c!distance=\noteparameter\c!columndistance,\c!n=\noteparameter\c!n,\c!width=\noteparameter\c!width]
1474\to \everyinsidenoteinsert
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484\newconditional\c_strc_notes_first_placed
1485
1486\permanent\protected\def\placenoteinserts
1487 {\c_strc_notes_first_placed\conditionalfalse
1488 \strc_notes_process\strc_notes_place_inserts}
1489
1490\def\strc_notes_place_inserts
1491 {\strc_notes_set_delayed
1492 \ifconditional\c_strc_notes_delayed \else
1493
1494 \ifcase\insertheight\currentnoteinsertionnumber\else
1495 \strc_notes_place_inserts_indeed
1496 \c_strc_notes_first_placed\conditionaltrue
1497 \fi
1498 \fi}
1499
1500\newbox\b_strc_notes_inserts
1501
1502\def\strc_notes_place_inserts_indeed_before
1503 {\endgraf
1504 \ifvmode
1505 \whitespace
1506 \ifconditional\c_strc_notes_first_placed
1507 \edef\p_spaceinbetween{\noteparameter\c!spaceinbetween}
1508 \ifempty\p_spaceinbetween\else
1509 \blank[\p_spaceinbetween]
1510 \fi
1511 \else
1512 \edef\p_spacebefore{\rootnoteparameter\c!spacebefore}
1513 \ifempty\p_spacebefore\else
1514 \blank[\p_spacebefore]
1515 \fi
1516 \fi
1517 \noteparameter\c!before
1518 \nointerlineskip
1519 \fi
1520 \placenoterule}
1521
1522\def\strc_notes_place_inserts_indeed_after
1523 {\endgraf
1524 \ifvmode
1525 \noteparameter\c!after
1526 \fi}
1527
1528\def\strc_notes_place_inserts_indeed
1529 {\relax
1530
1531 \ifcase\insertheight\currentnoteinsertionnumber\else
1532
1533 \strc_notes_place_inserts_indeed_before
1534 \bgroup
1535 \strc_notes_set_bodyfont
1536 \setbox\b_strc_notes_inserts\hbox
1537 {\strc_notes_flush_inserts}
1538 \page_postprocessors_linenumbers_deepbox\b_strc_notes_inserts
1539 \setbox\b_strc_notes_inserts\hbox
1540 {\setupcurrentnote
1541 [\c!location=,
1542 \c!width=\v!fit,
1543 \c!height=\v!fit,
1544 \c!strut=\v!no,
1545 \c!offset=\v!overlay]
1546 \inheritednoteframed
1547 {\ifzeropt\dp\b_strc_notes_inserts
1548 \hpack{\lower\strutdp\box\b_strc_notes_inserts}
1549 \else
1550 \box\b_strc_notes_inserts
1551 \fi}}
1552 \setbox\b_strc_notes_inserts\hpack{\lower\strutdepth\box\b_strc_notes_inserts}
1553 \dp\b_strc_notes_inserts\strutdepth
1554 \ifvmode
1555 \nointerlineskip
1556 \fi
1557 \box\b_strc_notes_inserts
1558 \egroup
1559 \strc_notes_place_inserts_indeed_after
1560 \fi}
1561
1562\def\strc_notes_place_inserts_very_indeed#1
1563 {\strc_notes_place_inserts_indeed_before
1564 \bgroup
1565 \strc_notes_set_bodyfont
1566 #1
1567 \page_postprocessors_linenumbers_deepbox\b_strc_notes_inserts
1568 \scratchheight\ht\b_strc_notes_inserts
1569 \scratchdepth \dp\b_strc_notes_inserts
1570 \setbox\b_strc_notes_inserts\hbox
1571 {\setupcurrentnote
1572 [\c!location=,
1573 \c!width=\v!fit,
1574 \c!height=\v!fit,
1575 \c!strut=\v!no,
1576 \c!offset=\v!overlay]
1577 \inheritednoteframed
1578 {\box\b_strc_notes_inserts}}
1579 \ht\b_strc_notes_inserts\scratchheight
1580
1581 \dp\b_strc_notes_inserts\strutdepth
1582 \ifvmode
1583 \nointerlineskip
1584 \fi
1585 \box\b_strc_notes_inserts
1586 \egroup
1587 \strc_notes_place_inserts_indeed_after}
1588
1589\def\strc_notes_flush_inserts
1590 {\ifcase\noteparameter\c!n\relax
1591
1592 \or
1593 \strc_notes_flush_inserts_normal
1594 \else
1595 \strc_notes_flush_inserts_columns
1596 \fi}
1597
1598\def\strc_notes_flush_inserts_normal
1599 {\strc_notes_flush_global
1600 \obeydepth}
1601
1602\def\strc_notes_flush_inserts_columns
1603 {\begingroup
1604 \setnotehsize
1605 \startsimplecolumns[\c!distance=\noteparameter\c!columndistance,\c!n=\noteparameter\c!n,\c!width=\noteparameter\c!width]
1606 \strc_notes_flush_global
1607 \stopsimplecolumns
1608 \endgroup}
1609
1610
1611
1612\def\strc_notes_flush_global
1613 {\begingroup
1614 \useinterlinespaceparameter\noteparameter
1615 \ifcstok{\noteparameter\c!paragraph}\v!yes
1616 \leftorrightvbox
1617 {\starthboxestohbox
1618 \iftrialtypesetting
1619 \insertuncopy
1620 \else
1621 \insertunbox
1622 \fi
1623 \currentnoteinsertionnumber
1624 \stophboxestohbox}
1625 \else
1626 \iftrialtypesetting
1627 \ifvmode\insertuncopy\else\insertcopy\fi
1628 \else
1629 \ifvmode\insertunbox \else\insertbox \fi
1630 \fi
1631 \currentnoteinsertionnumber
1632 \fi
1633 \endgroup}
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659\newconditional\postponingnotes
1660
1661
1662
1663\permanent\protected\def\postponenotes
1664 {\ifcase\insertionmigrationmode
1665 \ifconditional\postponingnotes\else
1666 \global\postponingnotes\conditionaltrue
1667 \enforced\glet\flushnotes\doflushnotes
1668 \clf_postponenotes
1669 \fi
1670 \fi}
1671
1672\permanent\lettonothing\flushnotes
1673
1674
1675
1676\permanent\protected\def\startpostponingnotes
1677 {\ifconditional\postponingnotes\else
1678 \global\postponingnotes\conditionaltrue
1679
1680 \clf_postponenotes
1681 \fi}
1682
1683\permanent\protected\def\stoppostponingnotes
1684 {\doflushnotes}
1685
1686\permanent\protected\def\doflushnotes
1687 {\ifconditional\postponingnotes
1688 \begingroup
1689 \enforced\lettonothing\flushnotes
1690 \enforced\lettonothing\postponenotes
1691 \ifconditional\postponednote
1692 \ifhmode
1693
1694 \signalcharacter
1695 \fi
1696 \fi
1697 \clf_flushpostponednotes
1698 \global\postponednote\conditionalfalse
1699 \global\postponingnotes\conditionalfalse
1700 \enforced\glettonothing\flushnotes
1701 \endgroup
1702 \fi}
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715\newtoks\everyplacelocalnotes
1716
1717\appendtoks
1718 \enforced\lettonothing\flushnotes
1719 \enforced\lettonothing\postponenotes
1720\to \everyplacelocalnotes
1721
1722\newconditional\inlocalnotes
1723
1724\mutable\lettonothing\localnoteslist
1725
1726\permanent\tolerant\protected\def\startlocalnotes[#list]
1727 {\inlocalnotes\conditionaltrue
1728 \def\localnoteslist{#list}
1729 \processcommacommand[\localnoteslist]\strc_notes_local_start_step}
1730
1731\permanent\protected\def\stoplocalnotes
1732 {\processcommacommand[\localnoteslist]\strc_notes_local_stop_step
1733 \inlocalnotes\conditionalfalse}
1734
1735\lettonothing\p_strc_notes_continue
1736
1737\def\strc_notes_local_start_step#tag
1738 {\p_strc_notes_continue{\noteparameter\c!continue}
1739 \ifx\p_strc_notes_continue\v!yes \else
1740 \strc_counters_save{#tag}
1741 \strc_counters_reset{#tag}
1742 \fi
1743 \clf_savenote{#tag}{store}}
1744
1745\def\strc_notes_local_stop_step#tag
1746 {\p_strc_notes_continue{\noteparameter\c!continue}
1747 \ifx\p_strc_notes_continue\v!yes \else
1748 \strc_counters_restore{#tag}
1749 \fi
1750 \clf_restorenote{#tag}}
1751
1752\permanent\tolerant\protected\def\placelocalnotes[#tag]#spacer[#S#settings]
1753 {\iftok{\clf_getnotestate{#tag}}{store}
1754 \strc_notes_local_place_indeed{#settings}{#tag}
1755 \fi}
1756
1757\def\strc_notes_local_place_indeed#settings#tag
1758 {\begingroup
1759 \cdef\currentnote{#tag}
1760 \expand\everyplacelocalnotes
1761
1762 \setupcurrentnote[#settings]
1763 \strc_notes_place_local_alternative
1764 \strc_notes_set_properties
1765 \endgroup
1766 }
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802\permanent\protected\def\placebottomnotes
1803 {\strc_notes_process\strc_notes_place_inserts}
1804
1805\permanent\tolerant\protected\def\placenotes[#list]#spacer[#S#settings]
1806 {\processcommalist[#list]{\strc_notes_place_indeed{#settings}}}
1807
1808\def\strc_notes_place_indeed#settings#tag
1809 {\cdef\currentnote{#tag}
1810 \iftok{\clf_getnotestate{#tag}}{store}
1811 \expandafter\strc_notes_local_place_indeed
1812 \else
1813 \expandafter\strc_notes_global_place_indeed
1814 \fi
1815 {#settings}{#tag}}
1816
1817\def\strc_notes_global_place_indeed#settings#tag
1818 {\begingroup
1819 \setupnote[#tag][#settings]
1820 \strc_notes_place_inserts
1821 \endgroup
1822 \expand\everysetupnote}
1823
1824
1825
1826\installcorenamespace{notealternative}
1827
1828\permanent\protected\def\installnotealternative#alternative#command
1829 {\defcsname\??notealternative#alternative\endcsname{#command}}
1830
1831\permanent\protected\def\doifnotescollected#tag
1832 {\clf_doifnotecontent{#tag}}
1833
1834\def\strc_notes_place_local_alternative
1835 {\doifnotescollected\currentnote
1836 {\endgraf
1837 \ifvmode
1838 \whitespace
1839 \noteparameter\c!before
1840 \fi
1841 \begingroup
1842 \strc_notes_set_bodyfont
1843 \begincsname\??notealternative\noteparameter\c!alternative\endcsname
1844 \endgroup
1845 \ifvmode
1846 \noteparameter\c!after
1847 \fi}}
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857\permanent\def\flushlocalnotes#tag{\clf_flushnotes{#tag}{store}{\noteparameter\c!criterium}}
1858
1859\installnotealternative \v!none
1860 {\flushlocalnotes\currentnote}
1861
1862\installnotealternative \empty
1863 {\flushlocalnotes\currentnote}
1864
1865\installnotealternative \v!grid
1866 {\begingroup
1867 \setupcurrentnote[\c!location=]
1868 \snaptogrid\hbox
1869 {\inheritednoteframed
1870 {\flushlocalnotes\currentnote}}
1871 \endgroup}
1872
1873\installnotealternative \v!fixed
1874 {\begingroup
1875 \setupcurrentnote[\c!location=]
1876 \inheritednoteframed
1877 {\flushlocalnotes\currentnote}
1878 \endgroup}
1879
1880\installnotealternative \v!columns
1881 {\begingroup
1882 \setupcurrentnote[\c!location=]
1883 \inheritednoteframed
1884 {\ifchkdimension\noteparameter\c!width\or\else\setexpandednoteparameter\c!width{\the\hsize}\fi
1885 \startsimplecolumns[\c!distance=\noteparameter\c!columndistance,\c!n=\noteparameter\c!n,\c!width=\noteparameter\c!width]
1886 \flushlocalnotes\currentnote
1887 \stopsimplecolumns}
1888 \endgroup}
1889
1890
1891
1892\newconstant\c_strc_notes_page_location
1893
1894\protected\def\strc_notes_check_locations
1895 {\edef\p_strc_notes_location{\rootnoteparameter\c!location}
1896 \c_strc_notes_page_location
1897 \ifx\p_strc_notes_location\v!firstcolumn\plusone \else
1898 \ifx\p_strc_notes_location\v!lastcolumn \plustwo \else
1899 \zerocount\fi\fi}
1900
1901\appendtoks
1902 \strc_notes_check_locations
1903\to \everysynchronizenote
1904
1905
1906
1907\newif\ifnotespresent
1908
1909\permanent\protected\def\checknotepresence
1910 {\notespresentfalse
1911 \strc_notes_process\strc_notes_check_presence}
1912
1913\def\strc_notes_check_presence
1914
1915 {\ifcase\insertheight\currentnoteinsertionnumber\else
1916 \notespresenttrue
1917 \fi}
1918
1919
1920
1921
1922
1923
1924
1925
1926 \permanent\protected\def\fakenotes
1927 {\ifhmode\endgraf\fi\ifvmode
1928 \calculatetotalclevernoteheight
1929 \ifdim\totalnoteheight>\zeropoint \kern\totalnoteheight \fi
1930 \fi}
1931
1932 \permanent\protected\def\fakepagenotes
1933 {\ifhmode\endgraf\fi\ifvmode
1934 \calculatetotalpagenoteheight
1935 \ifdim\totalnoteheight>\zeropoint \kern\totalnoteheight \fi
1936 \fi}
1937
1938
1939
1940 \newdimen\totalnoteheight
1941
1942 \permanent\protected\def\additionaltotalnoteheight#insert
1943 {\dimexpr
1944 \ifnum\insertheight#insert=\zeropoint
1945 \zeropoint
1946 \orelse\ifnum\insertmultiplier#insert=\zeropoint
1947 \zeropoint
1948 \else
1949 \insertheight #insert
1950 \insertdistance#insert
1951 \fi
1952 \relax}
1953
1954 \permanent\def\docalculatetotalnoteheight
1955 {\ifcase\c_strc_notes_page_location
1956 \advanceby\totalnoteheight\normalexpanded{\additionaltotalnoteheight\currentnoteinsertionnumber}
1957 \fi}
1958
1959 \permanent\def\docalculatetotalclevernoteheight
1960 {\ifcase\c_strc_notes_page_location \else
1961 \advanceby\totalnoteheight\normalexpanded{\additionaltotalnoteheight\currentnoteinsertionnumber}
1962 \fi}
1963
1964 \permanent\def\docalculatetotalpagenoteheight
1965 {\advanceby\totalnoteheight\normalexpanded{\additionaltotalnoteheight\currentnoteinsertionnumber}}
1966
1967 \permanent\def\calculatetotalnoteheight {\totalnoteheight\zeropoint\strc_notes_process\docalculatetotalnoteheight}
1968 \permanent\def\calculatetotalclevernoteheight{\totalnoteheight\zeropoint\strc_notes_process\docalculatetotalclevernoteheight}
1969 \permanent\def\calculatetotalpagenoteheight {\totalnoteheight\zeropoint\strc_notes_process\docalculatetotalpagenoteheight}
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996\def\strc_notes_set_bodyfont
1997 {\let\strc_notes_set_bodyfont\relax
1998 \restoreglobalbodyfont
1999 \usebodyfontparameter\noteparameter
2000 \usealignparameter\noteparameter}
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020\definenote [\v!footnote]
2021\definenote [\v!endnote ] [\c!location=\v!none]
2022\definenote [\v!mathnote] [\c!location=\v!none]
2023
2024
2025
2026\permanent\protected\def\setupfootnotedefinition{\setupnotation [\v!footnote]}
2027\permanent\protected\def\setupfootnotes {\setupnote [\v!footnote]}
2028\permanent \def\footnotetext {\setnotetext [\v!footnote]}
2029\permanent\protected\def\placefootnotes {\strc_notes_place_footnotes [\v!footnote]}
2030\permanent\protected\def\placelocalfootnotes {\strc_notes_place_local_footnotes[\v!footnote]}
2031\permanent\protected\def\startlocalfootnotes {\startlocalnotes [\v!footnote]}
2032\permanent\protected\def\stoplocalfootnotes {\stoplocalnotes }
2033
2034\tolerant\def\strc_notes_place_footnotes[#list]#spacer[#S#settings]
2035 {\ifarguments\or
2036 \placenotes[#list][\c!height=\textheight]
2037 \or
2038 \placenotes[#list][#settings,\c!height=\textheight]
2039 \fi}
2040
2041\tolerant\def\strc_notes_place_local_footnotes[#list]#spacer[#S#settings]
2042 {\ifarguments\or
2043 \placelocalnotes[#list][\c!height=\textheight]
2044 \or
2045 \placelocalnotes[#list][#settings,\c!height=\textheight]
2046 \fi}
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056\permanent\def\doifelsenoteonsamepage#tag{\clf_doifnoteonsamepageasprevious{#tag}}
2057
2058\aliased\let\doifnoteonsamepageelse\doifelsenoteonsamepage
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071\installcorenamespace{notesymbol}
2072
2073\mutable\lettonothing\lastnotesymbol
2074
2075\permanent\tolerant\protected\def\notesymbol[#tag]#keepspacer[#reference]
2076 {\ifnotesenabled
2077 \dontleavehmode
2078 \begingroup
2079 \cdef\currentnote{#tag}
2080 \usenotestyleandcolor\c!textstyle\c!textcolor
2081 \ifempty{#reference}
2082 \noteparameter\c!textcommand\lastnotesymbol
2083 \else
2084 \unskip
2085 \noteparameter\c!textcommand{\in[#reference]}
2086 \fi
2087 \endgroup
2088 \fi}
2089
2090\permanent\tolerant\protected\def\note[#tag]#keepspacer[#reference]
2091 {\ifempty{#reference}
2092 \notesymbol[\v!footnote][#tag]
2093 \else
2094 \notesymbol[#tag][#reference]
2095 \fi}
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136\appendtoks
2137 \setsystemmode\currentnote
2138\to \everysynchronizenote
2139
2140\protect \endinput
2141 |