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