1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28\writestatus{loading}{ConTeXt Structure Macros Cross Referencing}
29
30\newif \iflocation
31\newinteger\locationcount
32\newinteger\locationorder
33\newbox \locationbox
34\newinteger\lastreferenceattribute
35\newinteger\lastdestinationattribute
36\newinteger\prefixcounter
37
38\registerctxluafile{strcrsc}{autosuffix}
39\registerctxluafile{strcref}{autosuffix}
40\registerctxluafile{noderef}{autosuffix}
41
42\unprotect
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\installcorenamespace{referencing}
70
71\installdirectcommandhandler \??referencing {referencing}
72
73\mutable\lettonothing\referenceprefix
74
75\mutable\lettonothing\currentdestinationattribute
76
77\mutable\lettonothing\currentreferenceattribute
78\mutable\lettonothing\currentreferencecoding
79\mutable\lettonothing\currentreferencecontent
80\mutable\lettonothing\currentreferencedata
81\mutable\lettonothing\currentreferenceexpansion
82\mutable\lettonothing\currentreferenceformatautocase
83\mutable\lettonothing\currentreferenceformatlabel
84\mutable\lettonothing\currentreferenceformatsetups
85\mutable\lettonothing\currentreferenceformattype
86\mutable\lettonothing\currentreferencekind
87\mutable\lettonothing\currentreferencelabels
88
89
90
91
92
93
94\mutable\lettonothing\currentreferenceuserdata
95
96\newif\ifreferencing \referencingtrue
97
98\appendtoks
99 \ifcstok{\referencingparameter\c!state}\v!start
100 \referencingtrue
101 \else
102 \referencingfalse
103 \fi
104\to \everysetupreferencing
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127\permanent\protected\def\showreferences{\enabletrackers[nodes.references.show,nodes.destinations.show]}
128
129
130
131\permanent\tolerant\protected\def\textreference [#labels]{\strc_references_set_named_reference\s!text{#labels}{}}
132\permanent\tolerant\protected\def\pagereference [#labels]{\strc_references_set_named_reference\s!page{#labels}{}{}}
133\permanent\tolerant\protected\def\reference [#labels]{\strc_references_set_named_reference\s!full{#labels}{}}
134\permanent\tolerant\protected\def\setreference [#labels]#spacer[#S#settings]{\strc_references_set_named_reference\s!user{#labels}{#settings}{}}
135
136\permanent\protected\def\dosetdirectpagereference#1{\strc_references_set_named_reference\s!page{#1}{}{}}
137
138\permanent\protected\def\usereferenceparameter#1
139 {\edef\m_strc_references_asked{#1\c!reference}
140 \ifempty\m_strc_references_asked\else
141 \dosetdirectpagereference\m_strc_references_asked
142 \fi}
143
144
145
146
147
148
149
150\def\strc_references_finish#prefix#reference#internal
151 {\normalexpanded{\clf_deferredenhancereference{#prefix}{#reference}}}
152
153\permanent\let\dofinishreference\strc_references_finish
154
155
156
157
158
159
160
161\setnewconstant\c_strc_references_bind_state\plusone
162
163\def\strc_references_inject_before
164 {}
165
166\def\strc_references_inject_after
167 {\ifcase\c_strc_references_bind_state
168
169 \or
170 \prewordbreak
171 \fi}
172
173\protected\def\strc_references_set_named_reference
174 {\ifreferencing
175 \expandafter\strc_references_set_named_reference_indeed
176 \else
177 \expandafter\gobblefourarguments
178 \fi}
179
180\newbox\b_strc_destination_nodes
181
182\protected\def\strc_references_flush_destination_nodes
183 {\ifvoid\b_strc_destination_nodes \else
184 \unhbox\b_strc_destination_nodes
185 \fi}
186
187\def\strc_references_placeholder
188 {\ifempty\dotaggedplaceholder\else
189 \c_attr_destination\lastdestinationattribute
190 \dotaggedplaceholder
191 \fi}
192
193\protected\def\strc_references_destination_point_yes
194 {\strc_references_inject_before
195 \dostarttagged\t!reference\empty
196 \dontleavehmode\hbox attr \destinationattribute\lastdestinationattribute\bgroup
197 \strc_references_flush_destination_nodes
198 \strc_references_placeholder
199 \egroup
200 \dostoptagged
201 \strc_references_inject_after}
202
203\protected\def\strc_references_destination_point_nop
204 {\strc_references_inject_before
205 \dostarttagged\t!reference\empty
206 \dontleavehmode\hbox \bgroup
207 \strc_references_flush_destination_nodes
208 \strc_references_placeholder
209 \egroup
210 \dostoptagged
211 \strc_references_inject_after}
212
213\protected\def\strc_references_start_destination_nodes
214 {\setbox\b_strc_destination_nodes\hbox\bgroup}
215
216\protected\def\strc_references_stop_destination_nodes
217 {\normalexpanded{\egroup\lastdestinationattribute\the\lastdestinationattribute\relax}}
218
219\protected\def\strc_references_set_named_reference_indeed#kind#labels#userdata#text
220 {\ifreferencing
221
222
223 \edef\currentreferencekind {#kind}
224 \edef\currentreferencelabels {#labels}
225 \edef\currentreferenceuserdata {#userdata}
226 \edef\currentreferenceexpansion{\referencingparameter\c!expansion}
227 \ifempty\currentreferencelabels
228 \lastdestinationattribute\attributeunsetvalue
229 \else
230 \ifx\currentreferenceexpansion\s!xml
231 \xmlstartraw
232 \xdef\currentreferencedata{#text}
233 \xmlstopraw
234 \glet\currentreferencecoding\s!xml
235 \else
236 \ifx\currentreferenceexpansion\v!yes
237 \xdef\currentreferencedata{#text}
238 \else
239 \xdef\currentreferencedata{\detokenize{#text}}
240 \fi
241 \glet\currentreferencecoding\s!tex
242 \fi
243
244 \setnextinternalreference
245 \strc_references_start_destination_nodes
246 \clf_setdestinationattribute
247 {
248 references {
249 internal \locationcount
250
251 view {\interactionparameter\c!focus}
252 \ifempty\referenceprefix\else
253 prefix {\referenceprefix}
254 \fi
255 reference {\currentreferencelabels}
256 }
257 metadata {
258 kind {\currentreferencekind}
259 \ifx\currentreferencekind\s!page\else
260 \ifx\currentreferencecoding\s!xml
261 xmlroot {\xmldocument}
262 \fi
263 catcodes \catcodetable
264 \fi
265 }
266 \ifempty\currentreferencedata\else
267 entries {
268 text {\currentreferencedata}
269 }
270 \fi
271 \ifempty\currentreferenceuserdata\else
272 userdata {\detokenize{#userdata}}
273 \fi
274 }
275 \relax
276 \strc_references_stop_destination_nodes
277 \fi
278 \else
279 \setbox\b_strc_destination_nodes\emptyhbox
280 \lastdestinationattribute\attributeunsetvalue
281 \fi
282
283 \xdef\currentdestinationattribute{\number\lastdestinationattribute}
284
285 \ifnum\lastdestinationattribute>\zerocount
286 \strc_references_destination_point_yes
287 \orelse\ifvoid\b_strc_destination_nodes\else
288 \strc_references_destination_point_nop
289 \fi}
290
291\def\strc_references_set_page_only_destination_attribute#labels
292 {\ifreferencing
293 \edef\currentreferencelabels{#labels}
294 \ifempty\currentreferencelabels
295 \setbox\b_strc_destination_nodes\emptyhbox
296 \lastdestinationattribute\attributeunsetvalue
297 \else
298 \strc_references_start_destination_nodes
299 \setnextinternalreference
300 \clf_setdestinationattribute
301 {
302 references {
303 internal \locationcount
304
305 view {\interactionparameter\c!focus}
306 \ifempty\referenceprefix\else
307 prefix {\referenceprefix}
308 \fi
309 reference {\currentreferencelabels}
310 }
311 metadata {
312 kind {page}
313 }
314 }
315 \relax
316 \strc_references_stop_destination_nodes
317 \fi
318 \else
319 \setbox\b_strc_destination_nodes\emptyhbox
320 \lastdestinationattribute\attributeunsetvalue
321 \fi}
322
323\protected\def\strc_references_direct_full_user#user#labels#text
324 {\ifreferencing
325 \strc_references_start_destination_nodes
326 \setnextinternalreference
327 \edef\m_strc_references_user{#user}
328 \edef\m_strc_references_text{#text}
329 \clf_setdestinationattribute
330 {
331 references {
332 internal \locationcount
333
334 view {\interactionparameter\c!focus}
335 \ifempty\referenceprefix\else
336 prefix {\referenceprefix}
337 \fi
338 reference {#labels}
339 }
340 metadata {
341 kind {\s!full}
342 }
343 \ifempty\m_strc_references_text \else
344 entries {
345 text {\m_strc_references_text}
346 }
347 \fi
348 \ifempty\m_strc_references_user \else
349 userdata {\m_strc_references_user}
350 \fi
351 }
352 \relax
353 \strc_references_stop_destination_nodes
354 \else
355 \setbox\b_strc_destination_nodes\emptyhbox
356 \lastdestinationattribute\attributeunsetvalue
357 \fi
358
359 \xdef\currentdestinationattribute{\number\lastdestinationattribute}
360
361 \ifnum\lastdestinationattribute>\zerocount
362 \strc_references_destination_point_yes
363 \orelse\ifvoid\b_strc_destination_nodes\else
364 \strc_references_destination_point_nop
365 \fi}
366
367\protected\def\strc_references_direct_full
368 {\strc_references_direct_full_user\empty}
369
370\permanent\let\dodirectfullreference\strc_references_direct_full
371
372\def\strc_references_set_page_only_destination_box_attribute#cs#labels
373 {\strc_references_set_page_only_destination_attribute{#labels}
374 \ifnum\lastdestinationattribute>\zerocount
375 \edef#cs{attr \destinationattribute\number\lastdestinationattribute}
376 \else
377 \lettonothing#cs
378 \fi}
379
380
381
382\permanent\protected\def\boxreference[#1]
383 {\begingroup
384 \dowithnextbox
385 {\strc_references_set_page_only_destination_attribute{#1}
386 \hpack
387 \ifnum\lastdestinationattribute=\attributeunsetvalue\else attr \destinationattribute \lastdestinationattribute \fi
388 {\box\b_strc_destination_nodes\box\nextbox}
389 \endgroup}}
390
391\permanent\protected\def\hboxreference[#1]{\boxreference[#1]\hbox}
392\permanent\protected\def\vboxreference[#1]{\boxreference[#1]\vbox}
393
394\mutable\def\defaultreferencepage#text{[[[#text]]]}
395\mutable\def\defaultreferencetext#text{[[[#text]]]}
396
397
398
399\def\strc_references_set_simple_reference#label
400 {\iflocation
401 \strc_references_start_destination_nodes
402 \setnextinternalreference
403 \clf_setdestinationattribute
404 {
405 references {
406 view {\interactionparameter\c!focus}
407 \ifempty\referenceprefix\else
408 prefix {\referenceprefix}
409 \fi
410 reference {#label}
411 internal \locationcount
412 }
413 metadata {
414 kind {\s!page}
415 }
416 }
417 \relax
418 \strc_references_stop_destination_nodes
419 \xdef\currentdestinationattribute{\number\lastdestinationattribute}
420 \else
421 \setbox\b_strc_destination_nodes\emptyhbox
422 \xdef\currentdestinationattribute{\number\attributeunsetvalue}
423 \fi}
424
425\def\strc_references_set_simple_internal_reference#label
426 {\iflocation
427 \strc_references_start_destination_nodes
428 \setnextinternalreference
429 \clf_setdestinationattribute
430 {
431 references {
432 view {\interactionparameter\c!focus}
433 reference {#label}
434 internal \locationcount
435 }
436 metadata {
437 kind {\s!page}
438 }
439 }
440 \relax
441 \strc_references_stop_destination_nodes
442 \xdef\currentdestinationattribute{\number\lastdestinationattribute}
443 \else
444 \setbox\b_strc_destination_nodes\emptyhbox
445 \xdef\currentdestinationattribute{\number\attributeunsetvalue}
446 \fi}
447
448\def\strc_references_get_simple_reference#label
449 {\iflocation
450 \clf_injectreference
451 {\referenceprefix}
452 {#label}
453 {
454 height \strutht
455 depth \strutdp
456 \extrareferencearguments
457 }
458 \relax
459 \xdef\currentreferenceattribute{\number\lastreferenceattribute}
460 \else
461 \xdef\currentreferenceattribute{\number\attributeunsetvalue}
462 \fi}
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484\permanent\tolerant\protected\def\contentreference[#1]#*[#S#2]
485 {\ifarguments
486 \expandafter\gobbletwoarguments
487 \or
488 \expandafter\strc_references_content_pickup_nop
489 \else
490 \expandafter\strc_references_content_pickup_yes
491 \fi{#1}{#2}}
492
493\def\strc_references_content_pickup_yes#1#2
494 {\hbox\bgroup\dowithnextbox{\strc_references_content_yes_finish{#1}{#2}}\hbox}
495
496\def\strc_references_content_pickup_nop#1#2
497 {\hbox\bgroup\dowithnextbox{\strc_references_content_nop_finish{#1}{#2}}\hbox}
498
499\def\strc_references_content_yes_finish#1#2
500 {\scratchwidth \wd\nextbox
501 \scratchheight\ht\nextbox
502 \scratchdepth \dp\nextbox
503 \setbox\nextbox\hpack
504 {\framed[\c!frame=\v!off,#2]{\box\nextbox}}
505 \strc_references_set_simple_reference{#1}
506 \setbox\nextbox\hpack attr \destinationattribute \currentdestinationattribute
507 {\strc_references_flush_destination_nodes
508 \box\nextbox}
509 \setbox\nextbox\hpack{\box\nextbox}
510 \wd\nextbox\scratchwidth
511 \ht\nextbox\scratchheight
512 \dp\nextbox\scratchdepth
513 \box\nextbox
514 \egroup}
515
516\def\strc_references_content_nop_finish#1#2
517 {\strc_references_set_simple_reference{#1}
518 \hpack attr \destinationattribute \currentdestinationattribute
519 {\strc_references_flush_destination_nodes
520 \box\nextbox}
521 \egroup}
522
523
524
525
526
527
528
529\newevery \everyreference \relax
530
531
532
533
534\appendtoks
535 \cleanupfeatures
536\to \everyreference
537
538
539
540
541
542
543
544\lettonothing\referenceprefix
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582\mutable\lettonothing\currentrealreference
583\mutable\lettonothing\currentpagereference
584\mutable\lettonothing\currenttextreference
585\mutable\lettonothing\currentsubtextreference
586\mutable\lettonothing\currentsubsubtextreference
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663\permanent\tolerant\protected\def\definereference[#name]#spacer[#S#specification]
664 {\clf_definereference{\referenceprefix}{#name}{\detokenize{#specification}}}
665
666\permanent\protected\def\resetreference[#name]
667 {\clf_resetreference{\referenceprefix}{#name}}
668
669\permanent\def\setpagereference#name#specification
670 {\clf_definereference{}{#name}{\v!page(\detokenize{#specification}}}
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687\newconditional\highlighthyperlinks \highlighthyperlinks\conditionaltrue
688
689
690
691
692
693
694
695
696\newconditional\gotonewwindow \gotonewwindow\conditionalfalse
697
698\permanent\def\doifelsereferencefound#label
699 {\clf_doifelsereference{\referenceprefix}{#label}{\extrareferencearguments}}
700
701\aliased\let\doifreferencefoundelse\doifelsereferencefound
702
703\permanent\def\doifelsereferencechecked#label
704 {\clf_doifelsereferencechecked{\referenceprefix}{#label}{\extrareferencearguments}}
705
706\aliased\let\doifcheckedreferencefoundelse\doifelsereferencechecked
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735\mutable\let\unknownreference\gobbleoneargument
736
737
738
739
740
741
742\mutable\def\dummyreference{{\tttf ??}}
743\mutable\def\emptyreference{{\tttf !!}}
744
745\installtextracker
746 {structures.referencing.show}
747 {\let\strc_references_dummy\strc_references_dummy_yes}
748 {\let\strc_references_dummy\strc_references_dummy_nop}
749
750\def\strc_references_dummy_nop
751 {\dummyreference}
752
753\def\strc_references_dummy_yes
754 {\dummyreference
755 \margindata
756 [\referencingparameter\c!labelalternative]
757 [\c!style=\referencingparameter\c!labelstyle,
758 \c!color=\referencingparameter\c!labelcolor]
759 {\askedreference}}
760
761\let\strc_references_dummy\strc_references_dummy_nop
762
763\setupreferencing
764 [\c!labelalternative=\v!inleft,
765 \c!labelcolor=darkred,
766 \c!labelstyle=\smallinfofont]
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800\ifdefined\buttonheight \else \newdimension\buttonheight \fi
801\ifdefined\buttonwidth \else \newdimension\buttonwidth \fi
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818\appendtoks
819 \locationfalse
820\to \everypreroll
821
822\permanent\def\nextinternalreference {\the\locationcount}
823\permanent\def\nextinternalorderreference{\the\locationorder}
824
825\permanent\def\setnextinternalreference
826 {\global\advanceby\locationcount\plusone}
827
828
829
830
831
832
833
834
835
836\permanent\def\thisissomeinternal#kind#name
837 {\begingroup
838 \clf_setinternalreference
839 reference {#kind:#name}
840 \relax
841 \hpack attr \destinationattribute\lastdestinationattribute{}
842 \endgroup}
843
844\installcorenamespace{savedinternalreference}
845
846\letcsname\??savedinternalreference\s!default\endcsname\!!zerocount
847
848\permanent\protected\def\storeinternalreference#1#2
849 {\xdefcsname\??savedinternalreference\currentstructurename\endcsname{\number#2}}
850
851\newconditional\preferpagereferences
852
853\permanent\def\gotosomeinternal#kind#name#target#text
854 {\ifconditional\preferpagereferences
855 \directgoto{#text}[page(#target)]
856 \else
857 \directgoto{#text}[#kind:#name]
858 \fi}
859
860\permanent\def\gotonextinternal#text#target
861 {\directgoto{#text}[internal(#target)]}
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886\newconditional\autocrossfilereferences
887
888\appendtoks
889 \ifcstok{\referencingparameter\c!autofile}\v!yes
890 \autocrossfilereferences\conditionaltrue
891 \else
892 \autocrossfilereferences\conditionalfalse
893 \fi
894\to \everysetupreferencing
895
896\appendtoks
897 \ifcstok{\referencingparameter\c!export}\v!yes
898 \clf_exportreferences
899 \fi
900\to \everygoodbye
901
902\permanent\protected\def\setupglobalreferenceprefix[#prefix]
903 {\xdef\referenceprefix{#prefix}}
904
905\permanent\protected\def\globalpushreferenceprefix#prefix
906 {\xdef\referenceprefix{\clf_pushreferenceprefix{#prefix}}}
907
908\permanent\protected\def\globalpopreferenceprefix
909 {\xdef\referenceprefix{\clf_popreferenceprefix}}
910
911\permanent\protected\def\pushreferenceprefix#prefix
912 {\edef\referenceprefix{\clf_pushreferenceprefix{#prefix}}}
913
914\permanent\protected\def\popreferenceprefix
915 {\edef\referenceprefix{\clf_popreferenceprefix}}
916
917\def\m_strc_references_prefix_yes{}
918\def\m_strc_references_prefix_nop{}
919
920\permanent\protected\def\setupreferenceprefix[#prefix]
921 {\edef\p_prefix{#prefix}
922 \ifempty\p_prefix
923 \lettonothing\referenceprefix
924 \orelse\ifx\p_prefix\m_strc_references_prefix_yes
925 \letreferencingparameter\c!prefix\s!unknown
926 \global\advanceby\prefixcounter\plusone
927 \edef\referenceprefix{\the\prefixcounter}
928 \orelse\ifx\p_prefix\m_strc_references_prefix_nop
929 \letreferencingparameter\c!prefix\s!unknown
930 \lettonothing\referenceprefix
931 \orelse\ifx\p_prefix\s!unknown
932
933 \else
934 \let\referenceprefix\p_prefix
935 \fi}
936
937\appendtoks
938 \setupreferenceprefix[\referencingparameter\c!prefix]
939\to \everysetupreferencing
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981\appendtoks
982
983 \ifdefined\in \aliased\let\normalmathin \in \permanent\protected\def\in {\mathortext\normalmathin \strc_references_in } \else \aliased\let\in \strc_references_in \fi
984 \ifdefined\over \aliased\let\normalmathover \over \permanent\protected\def\over {\mathortext\normalmathover \strc_references_about} \else \aliased\let\over \strc_references_about \fi
985
986
987
988
989 \aliased\let\at \strc_references_at
990 \aliased\let\about\strc_references_about
991 \aliased\let\from \strc_references_from
992\to \everydump
993
994
995
996\permanent \def\filterreference #key{\clf_filterreference{#key}}
997\permanent\protected\def\getreferenceentry#key{\clf_filterreference{#key}}
998
999\permanent\def\currentreferencenumber {\clf_filterreference{number}}
1000\permanent\def\currentreferencepage {\clf_filterreference{page}}
1001\permanent\def\currentreferencetitle {\clf_filterreference{title}}
1002\permanent\def\currentreferencetext {\clf_filterreference{text}}
1003
1004\permanent\def\currentreferencerealpage{\clf_filterreference{realpage}}
1005\aliased \let\currentreferenceorder \getinternalorderreference
1006
1007
1008
1009\permanent\tolerant\protected\def\getreference[#key]#spacer[#label]
1010 {\ifarguments\or
1011 \strc_references_dummy
1012 \else
1013 \doifelsereferencefound{#label}{\clf_filterreference{#key}}\strc_references_dummy
1014 \fi}
1015
1016\aliased\let\ref\getreference
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039\permanent\protected\def\strc_references_about[#label]
1040 {\dontleavehmode
1041 \begingroup
1042 \enforced\let\crlf\space
1043 \enforced\let\\\space
1044 \postponenotes
1045 \referencingparameter\c!left
1046 \doifelsereferencefound{#label}
1047 {\goto{\limitatetext\currentreferencetitle{\referencingparameter\c!width}\unknown}[#label]}
1048 {}
1049 \flushnotes
1050 \referencingparameter\c!right
1051 \endgroup}
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096\newinteger \nofreferencestates
1097\newconditional\pagestatespread
1098
1099\appendtoks
1100 \ifcstok{\referencingparameter\c!doublesided}\v!yes
1101 \pagestatespread\conditionaltrue
1102 \else
1103 \pagestatespread\conditionalfalse
1104 \fi
1105\to \everysetupreferencing
1106
1107\setupreferencing
1108 [\c!doublesided=\v!yes]
1109
1110\permanent\def\referencepagestate
1111 {\numexpr\clf_referencepagestate
1112 {rst::\number\nofreferencestates}
1113 \relax}
1114
1115\permanent\def\referencepagedetail
1116 {\numexpr\clf_referencepagedetail
1117 {rst::\number\nofreferencestates}
1118 true
1119 \ifconditional\pagestatespread false\ifdoublesided true\else false\fi\fi
1120 \relax}
1121
1122\permanent\def\referencerealpage {\clf_referencerealpage}
1123\permanent\def\referencecolumnnumber{\clf_referencecolumn}
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140\permanent\protected\def\tracedpagestate
1141 {{\blue\tttf(\ifcase\referencepagedetail unknown\or same\or previous\or next\or above\or below\else unknown\fi)}}
1142
1143\permanent\protected\def\markreferencepage
1144 {\dontleavehmode\begingroup
1145 \iftrialtypesetting
1146
1147 \else
1148
1149 \global\advanceby\nofreferencestates\plusone
1150 \xypos{rst::\number\nofreferencestates}
1151
1152 \fi
1153 \endgroup}
1154
1155\permanent\protected\def\doifcheckedpagestate#label
1156 {\doifelsereferencefound{#label}\strc_references_handle_page_state_yes\strc_references_handle_page_state_nop}
1157
1158\let\strc_references_handle_page_state_nop\sixthofsixarguments
1159
1160\def\strc_references_handle_page_state_yes
1161 {\markreferencepage
1162 \ifcase\referencepagedetail\relax
1163 \expandafter\sixthofsixarguments \or
1164 \expandafter\thirdofsixarguments \or
1165 \expandafter\firstofsixarguments \or
1166 \expandafter\fifthofsixarguments \or
1167 \expandafter\secondofsixarguments\or
1168 \expandafter\fourthofsixarguments\else
1169 \expandafter\sixthofsixarguments \fi}
1170
1171\permanent\protected\def\referencesymbol
1172 {\hpack\bgroup
1173 \strut
1174 \markreferencepage
1175 \high
1176 {\setupsymbolset[\interactionparameter\c!symbolset]
1177 \symbol[\ifcase\referencepagedetail\v!somewhere\or\v!nowhere\or\v!previous\or\v!next\or\v!previous\or\v!next\else\v!somewhere\fi]}
1178 \egroup}
1179
1180
1181
1182
1183\permanent\protected\def\somewhere#backward#foreward#dummy[#label]
1184 {\doifcheckedpagestate{#label}
1185 {\goto{#backward}[#label]}
1186 {\goto{#backward}[#label]}
1187 {\ignorespaces}
1188 {\goto{#foreward}[#label]}
1189 {\goto{#foreward}[#label]}
1190 {#label}}
1191
1192\permanent\protected\def\someplace#preceding#backward#current#foreward#following#dummy[#label]
1193 {\doifcheckedpagestate{#label}
1194 {\ifempty{#preceding}\goto{#preceding}[#label]\fi\ignorespaces}
1195 {\ifempty {#backward}\goto {#backward}[#label]\fi\ignorespaces}
1196 {\ifempty {#current}\goto {#current}[#label]\fi\ignorespaces}
1197 {\ifempty {#foreward}\goto {#foreward}[#label]\fi\ignorespaces}
1198 {\ifempty{#following}\goto{#following}[#label]\fi\ignorespaces}
1199 {#label}}
1200
1201\permanent\protected\def\atpage[#label]
1202 {\doifcheckedpagestate{#label}
1203 {\goto{\labeltext\v!precedingpage}[#label]}
1204 {\goto{\labeltext\v!hencefore}[#label]}
1205 {\ignorespaces}
1206 {\goto{\labeltext\v!hereafter}[#label]}
1207 {\goto{\labeltext\v!followingpage}[#label]}
1208 {\goto{\labeltexts\v!page\strc_references_dummy}[#label]}}
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231\permanent\def\symbolreference[#label]
1232 {\goto{\referencesymbol}[#label]}
1233
1234
1235
1236\newtoks\leftreferencetoks
1237\newtoks\rightreferencetoks
1238\newtoks\defaultleftreferencetoks
1239\newtoks\defaultrightreferencetoks
1240
1241\permanent\lettonothing\rightofreferencecontent
1242\permanent\lettonothing\leftofreference
1243\permanent\lettonothing\rightofreference
1244
1245\permanent\protected\def\leftofreferencecontent
1246 {\removeunwantedspaces
1247 \nonbreakablespace
1248 \ignorespaces}
1249
1250\installcorenamespace{referencinginteraction}
1251
1252\def\strc_references_interaction_all
1253 {\ifempty\leftreferencetoks
1254 \leftofreference
1255 \else
1256 \expand\leftreferencetoks
1257 \leftofreferencecontent
1258 \leftofreference
1259 \onlynonbreakablespace\relax
1260 \fi
1261 \currentreferencecontent
1262 \rightofreference
1263 \ifempty\rightreferencetoks\else
1264 \rightofreferencecontent
1265 \expand\rightreferencetoks
1266 \fi}
1267
1268\letcsname\??referencinginteraction\v!all\endcsname\strc_references_interaction_all
1269
1270\defcsname\??referencinginteraction\v!label\endcsname
1271 {\leftofreference
1272 \expand\leftreferencetoks
1273 \expand\rightreferencetoks
1274 \rightofreference}
1275
1276\defcsname\??referencinginteraction\v!text\endcsname
1277 {\leftofreference
1278 \currentreferencecontent
1279 \rightofreference}
1280
1281\defcsname\??referencinginteraction\v!symbol\endcsname
1282 {\referencesymbol}
1283
1284\permanent\def\referencesequence
1285 {\ifcsname\??referencinginteraction\referencingparameter\c!interaction\endcsname
1286 \expandafter\lastnamedcs
1287 \else
1288 \expandafter\strc_references_interaction_all
1289 \fi}
1290
1291\newtoks\everyresetinatreference
1292
1293\appendtoks
1294 \enforced\glet\leftofreference \relax
1295 \enforced\glet\rightofreference\relax
1296\to \everyresetinatreference
1297
1298\def\strc_references_start_goto
1299 {\dontleavehmode
1300 \begingroup}
1301
1302\def\strc_references_stop_goto
1303 {\expand\everyresetinatreference
1304 \endgroup}
1305
1306
1307
1308\tolerant\def\strc_references_pickup_goto#=#=#:#*[#3]
1309 {\leftreferencetoks
1310 \ifparameter#1\or
1311 {#1}
1312 \else
1313 \defaultleftreferencetoks
1314 \enforced\lettonothing\leftofreferencecontent
1315 \fi
1316 \rightreferencetoks
1317 \ifparameter#2\or
1318 {#2}
1319 \else
1320 \defaultrightreferencetoks
1321 \enforced\lettonothing\rightofreferencecontent
1322 \fi
1323
1324 \doifelsereferencefound{#3}
1325 {\goto{\referencesequence}[#3]}
1326 {\let\currentreferencecontent\strc_references_dummy
1327 \goto{\referencesequence}[#3]}
1328 \strc_references_stop_goto}
1329
1330\permanent\protected\def\strc_references_in
1331 {\strc_references_start_goto
1332 \let\currentreferencecontent\currentreferencedefault
1333 \strc_references_pickup_goto}
1334
1335\permanent\protected\def\strc_references_at
1336 {\strc_references_start_goto
1337 \let\currentreferencecontent\currentreferencepage
1338 \strc_references_pickup_goto}
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382\installcorenamespace{referenceformat}
1383
1384\installcommandhandler \??referenceformat {referenceformat} \??referenceformat
1385
1386\appendtoks
1387 \frozen\instance\protected\edefcsname\currentreferenceformat\endcsname{\strc_references_apply_format{\currentreferenceformat}}
1388\to \everydefinereferenceformat
1389
1390\setupreferenceformat
1391 [\c!left=,
1392 \c!right=,
1393 \c!text=,
1394 \c!label=,
1395 \c!autocase=\v!no,
1396 \c!style=,
1397 \c!type=default,
1398 \c!setups=,
1399 \c!color=]
1400
1401\protected\def\strc_references_apply_format#name
1402 {\strc_references_start_goto
1403 \edef\currentreferenceformat{#name}
1404 \enforced\gdef\leftofreference {\referenceformatparameter\c!left }
1405 \enforced\gdef\rightofreference {\referenceformatparameter\c!right }
1406 \edef\currentreferenceformatlabel {\referenceformatparameter\c!label }
1407 \edef\currentreferenceformattype {\referenceformatparameter\c!type }
1408 \edef\currentreferenceformatsetups {\referenceformatparameter\c!setups }
1409 \edef\currentreferenceformatautocase{\referenceformatparameter\c!autocase}
1410 \usereferenceformatstyleandcolor\c!style\c!color
1411 \ifempty\currentstyleparameter \else
1412 \resetinteractionparameter\c!style
1413 \fi
1414 \ifempty\currentcolorparameter \else
1415 \resetinteractionparameter\c!contrastcolor
1416 \resetinteractionparameter\c!color
1417 \fi
1418 \ifx\currentreferenceformatlabel\wildcardsymbol
1419 \edef\currentreferenceformatlabel{\autoreferencelabeltext}
1420 \fi
1421 \ifx\currentreferenceformatautocase\v!yes
1422 \setcharactercleaning[1]
1423 \fi
1424 \ifempty\currentreferenceformatlabel
1425 \defaultleftreferencetoks {\referenceformatparameter\c!text}
1426 \defaultrightreferencetoks\emptytoks
1427 \else
1428 \defaultleftreferencetoks {\leftlabeltext \currentreferenceformatlabel}
1429 \defaultrightreferencetoks{\rightlabeltext\currentreferenceformatlabel}
1430 \fi
1431 \ifempty\currentreferenceformattype
1432 \def\currentreferenceformattype{default}
1433 \fi
1434
1435 \ifempty\currentreferenceformatsetups
1436 \def\currentreferencecontent{\filterreference\currentreferenceformattype}
1437 \else
1438 \def\currentreferencecontent{\directsetup\currentreferenceformatsetups}
1439 \fi
1440
1441 \enforced\lettonothing\leftofreferencecontent
1442 \enforced\lettonothing\rightofreferencecontent
1443 \strc_references_pickup_goto}
1444
1445\permanent\protected\def\autoreferencelabeltext
1446 {\clf_getcurrentreferencemetadata{name}}
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485\newconditional\uselocationstrut \uselocationstrut\conditionaltrue
1486
1487\permanent\def\extrareferencearguments
1488 {highlight \luaconditional\highlighthyperlinks\space
1489 newwindow \luaconditional\gotonewwindow\space
1490 layer {\currentviewerlayer}}
1491
1492\permanent\protected\def\directgoto
1493 {\ifconditional\uselocationstrut
1494 \expandafter\strc_references_direct_goto
1495 \else
1496 \expandafter\strc_references_direct_goto_htdp
1497 \fi}
1498
1499\permanent\protected\def\goto
1500 {\ifconditional\uselocationstrut
1501 \expandafter\strc_references_goto
1502 \else
1503 \expandafter\strc_references_goto_htdp
1504 \fi}
1505
1506\permanent\tolerant\protected\def\namedgoto[#1]#:#*#=#*[#3]
1507 {\dontleavehmode\begingroup
1508 \setinteraction[#1]
1509 \goto{#2}[#3]
1510 \endgroup}
1511
1512
1513
1514
1515\newinteger\lastsavedreferenceattribute
1516
1517\newbox\referencebox
1518
1519\permanent\def\revivesavedreferenceattribute
1520 {\c_attr_reference\lastsavedreferenceattribute}
1521
1522\def\strc_references_direct_goto#content[#label]
1523 {\dontleavehmode
1524 \begingroup
1525 \c_attr_reference\attributeunsetvalue
1526 \global\lastsavedreferenceattribute\attributeunsetvalue
1527 \iflocation
1528 \clf_injectreference
1529 {\referenceprefix}
1530 {#label}
1531 {
1532 height \strutht
1533 depth \strutdp
1534 \extrareferencearguments
1535 }
1536 \relax
1537 \setlocationattributes
1538 \setstrut
1539 \global\lastsavedreferenceattribute\lastreferenceattribute
1540 \c_attr_reference\lastreferenceattribute
1541 \dostarttagged\t!link\empty
1542 #content
1543 \dostoptagged
1544 \else
1545 #content
1546 \fi
1547 \endgroup}
1548
1549\def\strc_references_direct_goto_htdp#content[#label]
1550 {\dontleavehmode
1551 \begingroup
1552 \global\lastsavedreferenceattribute\attributeunsetvalue
1553 \c_attr_reference\attributeunsetvalue
1554 \iflocation
1555 \clf_injectreference
1556 {\referenceprefix}
1557 {#label}
1558 {
1559 height \dimexpr\interactionparameter\c!height\relax
1560 depth \dimexpr\interactionparameter\c!depth \relax
1561 \extrareferencearguments
1562 }
1563 \relax
1564 \setlocationattributes
1565 \c_attr_reference\lastreferenceattribute
1566 \global\lastsavedreferenceattribute\lastreferenceattribute
1567 \dostarttagged\t!link\empty
1568 #content
1569 \dostoptagged
1570 \else
1571 #content
1572 \fi
1573 \endgroup}
1574
1575\def\strc_references_goto#content#dummy[#label]
1576 {\dontleavehmode
1577 \begingroup
1578
1579 \global\lastsavedreferenceattribute\attributeunsetvalue
1580 \c_attr_reference\attributeunsetvalue
1581 \iflocation
1582 \clf_doifelsereference{\referenceprefix}{#label}{\extrareferencearguments}
1583 {\clf_injectcurrentreferencehtdp
1584 \strutht
1585 \strutdp
1586 \relax
1587 \setlocationattributes
1588 \setstrut
1589 \global\lastsavedreferenceattribute\lastreferenceattribute
1590 \c_attr_reference\lastreferenceattribute
1591 \dostarttagged\t!link\empty
1592 #content
1593 \dostoptagged}
1594 {#content}
1595 \else
1596 #content
1597 \fi
1598
1599 \endgroup}
1600
1601\def\strc_references_goto_internal#content#dummy[#internal]
1602 {\dontleavehmode
1603 \begingroup
1604 \global\lastsavedreferenceattribute\attributeunsetvalue
1605 \c_attr_reference\attributeunsetvalue
1606 \iflocation
1607 \setstrut
1608 \strc_references_get_simple_reference{#internal}
1609 \global\lastsavedreferenceattribute\currentreferenceattribute
1610 \c_attr_reference\currentreferenceattribute
1611 \setlocationattributes
1612 \dostarttagged\t!link\empty
1613 #content
1614 \dostoptagged
1615 \else
1616 #content
1617 \fi
1618 \endgroup}
1619
1620\permanent\protected\def\startgoto[#label]
1621 {\dontleavehmode
1622 \begingroup
1623 \iflocation
1624 \clf_doifelsereference{\referenceprefix}{#label}{\extrareferencearguments}
1625 {\expandafter\strc_references_start_goto_yes}
1626 {\expandafter\strc_references_start_goto_nop}
1627 \else
1628 \expandafter\strc_references_start_goto_nop
1629 \fi}
1630
1631\permanent\protected\lettonothing\stopgoto
1632
1633\permanent\protected\def\strc_references_start_goto_nop
1634 {\enforced\let\stopgoto\strc_references_stop_goto_nop}
1635
1636\permanent\protected\def\strc_references_stop_goto_nop
1637 {\endgroup}
1638
1639\protected\def\strc_references_start_goto_yes
1640 {\clf_injectcurrentreferencehtdp
1641 \strutht
1642 \strutdp
1643 \relax
1644 \setlocationattributes
1645 \setstrut
1646 \global\lastsavedreferenceattribute\lastreferenceattribute
1647 \c_attr_reference\lastreferenceattribute
1648 \dostarttagged\t!link\empty
1649 \let\stopgoto\strc_references_stop_goto_yes}
1650
1651\protected\def\strc_references_stop_goto_yes
1652 {\dostoptagged
1653 \endgroup}
1654
1655\def\strc_references_goto_htdp#content#dummy[#label]
1656 {\dontleavehmode
1657 \begingroup
1658 \global\lastsavedreferenceattribute\attributeunsetvalue
1659 \c_attr_reference\attributeunsetvalue
1660 \iflocation
1661 \clf_doifelsereference{\referenceprefix}{#label}{\extrareferencearguments}
1662 {\clf_injectcurrentreferencehtdp
1663 \dimexpr\interactionparameter\c!height\relax
1664 \dimexpr\interactionparameter\c!depth \relax
1665 \relax
1666 \setlocationattributes
1667 \global\lastsavedreferenceattribute\lastreferenceattribute
1668 \c_attr_reference\lastreferenceattribute
1669 \dostarttagged\t!link\empty
1670 #content
1671 \dostoptagged}
1672 {#content}
1673 \else
1674 #content
1675 \fi
1676 \endgroup}
1677
1678\permanent\protected\def\directgotobox#content[#label]
1679 {\dontleavehmode
1680 \begingroup
1681 \global\lastsavedreferenceattribute\attributeunsetvalue
1682 \c_attr_reference\attributeunsetvalue
1683 \iflocation
1684 \clf_injectreference
1685 {\referenceprefix}
1686 {#label}
1687 {\extrareferencearguments}
1688 \relax
1689 \setlocationattributes
1690 \global\lastsavedreferenceattribute\lastreferenceattribute
1691 \dostarttagged\t!link\empty
1692 \hbox attr \referenceattribute \lastreferenceattribute {#content}
1693 \dostoptagged
1694 \else
1695 #content
1696 \fi
1697 \endgroup}
1698
1699\permanent\protected\def\directgotospecbox#resolver#content[#label]
1700 {\dontleavehmode
1701 \begingroup
1702 \global\lastsavedreferenceattribute\attributeunsetvalue
1703 \c_attr_reference\attributeunsetvalue
1704 \iflocation
1705 \clf_injectreference
1706 {\referenceprefix}
1707 {#label}
1708 {\extrareferencearguments}
1709 \relax
1710 \setlocationcolorspec{#resolver}
1711 \global\lastsavedreferenceattribute\lastreferenceattribute
1712 \dostarttagged\t!link\empty
1713 \hbox attr \referenceattribute \lastreferenceattribute {#content}
1714 \dostoptagged
1715 \else
1716 #content
1717 \fi
1718 \endgroup}
1719
1720\permanent\protected\def\directgotodumbbox#content[#label]
1721 {\dontleavehmode
1722 \begingroup
1723 \global\lastsavedreferenceattribute\attributeunsetvalue
1724 \c_attr_reference\attributeunsetvalue
1725 \iflocation
1726 \clf_injectreference
1727 {\referenceprefix}
1728 {#label}
1729 {\extrareferencearguments}
1730 \relax
1731 \global\lastsavedreferenceattribute\lastreferenceattribute
1732 \dostarttagged\t!link\empty
1733 \hbox attr \referenceattribute \lastreferenceattribute {#content}
1734 \dostoptagged
1735 \else
1736 #content
1737 \fi
1738 \endgroup}
1739
1740\permanent\protected\def\gotobox#content[#label]
1741 {\dontleavehmode
1742 \begingroup
1743 \global\lastsavedreferenceattribute\attributeunsetvalue
1744 \c_attr_reference\attributeunsetvalue
1745 \iflocation
1746 \clf_doifelsereference{\referenceprefix}{#label}{\extrareferencearguments}
1747 {\clf_injectcurrentreference
1748 \setlocationattributes
1749 \global\lastsavedreferenceattribute\lastreferenceattribute
1750 \dostarttagged\t!link\empty
1751 \hbox attr \referenceattribute \lastreferenceattribute {#content}
1752 \dostoptagged}
1753 {#content}
1754 \else
1755 #content
1756 \fi
1757 \endgroup}
1758
1759\permanent\protected\def\gotowdhtbox#width#height[#label]
1760 {\dontleavehmode
1761 \begingroup
1762 \setbox\scratchbox\emptyhbox
1763 \wd\scratchbox#width
1764 \ht\scratchbox#height
1765 \global\lastsavedreferenceattribute\attributeunsetvalue
1766 \c_attr_reference\attributeunsetvalue
1767 \clf_doifelsereference{\referenceprefix}{#label}{\extrareferencearguments}
1768 {\clf_injectcurrentreference
1769 \global\lastsavedreferenceattribute\lastreferenceattribute
1770 \hpack attr \referenceattribute \lastreferenceattribute {\box\scratchbox}}
1771 {\box\scratchbox}
1772 \endgroup}
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
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820\permanent\tolerant\protected\def\useurl[#label]#spacer[#url]#spacer[#file]#spacer[#description]
1821 {\clf_useurl{#label}{\detokenize{#url}}{\detokenize{#file}}{\detokenize{#description}}}
1822
1823\permanent\tolerant\protected\def\usefile[#label]#spacer[#file]#spacer[#description]
1824 {\clf_usefile{#label}{\detokenize{#file}}{\detokenize{#description}}}
1825
1826\aliased\let\useURL \useurl
1827\aliased\let\useexternaldocument\usefile
1828
1829\permanent\def\doifelseurldefined #label{\clf_doifelseurldefined {#label}}
1830\permanent\def\doifelsefiledefined#label{\clf_doifelsefiledefined{#label}}
1831
1832\aliased\let\doifurldefinedelse \doifelseurldefined
1833\aliased\let\doiffiledefinedelse\doifelsefiledefined
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851\installcorenamespace{url}
1852
1853\installdirectcommandhandler \??url {url}
1854
1855\setupurl
1856 [\c!style=\v!type,
1857 \c!color=]
1858
1859\permanent\protected\def\url[#label]
1860 {\dontleavehmode
1861 \begingroup
1862 \useurlstyleandcolor\c!style\c!color
1863 \hyphenatedurl{\clf_geturl{#label}}
1864 \endgroup}
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888\permanent\tolerant\protected\def\strc_references_from[#label]
1889 {\dontleavehmode
1890 \goto{\clf_from{#label}}[fileorurl(#label)]}
1891
1892\permanent\def\dofromurldescription#content
1893 {#content}
1894
1895\permanent\def\dofromurlliteral#content
1896 {\useurlstyleandcolor\c!style\c!color
1897 \hyphenatedurl{#content}}
1898
1899\aliased\let\dofromfiledescription\dofromurldescription
1900\aliased\let\dofromfileliteral \dofromurlliteral
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926\installcorenamespace{programs}
1927
1928\installdirectcommandhandler \??programs {programs}
1929
1930\permanent\tolerant\protected\def\defineprogram[#name]#spacer[#program]#spacer[#description]
1931 {\clf_defineprogram{#name}{#program}{#description}}
1932
1933\permanent\protected\def\program[#name]
1934 {\dontleavehmode
1935 \begingroup
1936 \useprogramsstyleandcolor\c!style\c!color
1937 \clf_getprogram{#name}
1938 \endgroup}
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971\permanent\tolerant\protected\def\definepage[#name]#spacer[#target]
1972 {\definereference[#name][page(#target)]}
1973
1974\permanent\protected\def\gotopage#text[#target]
1975 {\goto{#text}[\v!page(#target)]}
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998\permanent\tolerant\protected\def\coupledocument[#name]#spacer[#file]#spacer[#sections]#spacer[#description]
1999 {}
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013\permanent\protected\def\dotextprefix#text
2014 {\begingroup
2015 \setbox\scratchbox\hbox{#text}
2016 \ifdim\wd\scratchbox>\zeropoint
2017 \unhbox\scratchbox
2018 \edef\p_separator{\referencingparameter\c!separator}
2019 \ifempty\p_separator \else
2020 \removeunwantedspaces
2021 \p_separator
2022 \fi
2023 \else
2024 \unhbox\scratchbox
2025 \fi
2026 \endgroup}
2027
2028
2029
2030
2031\setupreferencing
2032 [\c!state=\v!start,
2033 \c!autofile=\v!no,
2034 \v!part\c!number=\v!yes,
2035 \v!chapter\c!number=\v!no,
2036 \c!interaction=\v!all,
2037 \c!convertfile=\v!no,
2038
2039 \c!prefix=,
2040 \c!width=.75\makeupwidth,
2041 \c!left=\quotation\bgroup,
2042 \c!right=\egroup,
2043 \c!global=\v!no,
2044 \c!expansion=\v!no,
2045 \c!separator=\nonbreakablespace,
2046 \c!export=\v!no]
2047
2048\setupprograms
2049 [\c!directory=,
2050 \c!style=\v!type,
2051 \c!color=]
2052
2053\definereference [\v!CloseDocument ] [action(close)]
2054\definereference [\v!ExitViewer ] [action(exit)]
2055\definereference [\v!FirstPage ] [action(first)]
2056\definereference [\v!LastPage ] [action(last)]
2057\definereference [\v!NextJump ] [action(forward)]
2058\definereference [\v!NextPage ] [action(next)]
2059\definereference [\v!PauseRendering ] [action(pauserendering)]
2060\definereference [\v!PreviousJump ] [action(backward)]
2061\definereference [\v!PreviousPage ] [action(previous)]
2062\definereference [\v!PrintDocument ] [action(print)]
2063\definereference [\v!SaveForm ] [action(exportform)]
2064\definereference [\v!LoadForm ] [action(importform)]
2065\definereference [\v!ResetForm ] [action(resetform)]
2066\definereference [\v!ResumeRendering ] [action(resumerendering)]
2067\definereference [\v!SaveDocument ] [action(save)]
2068\definereference [\v!SaveNamedDocument] [action(savenamed)]
2069\definereference [\v!OpenNamedDocument] [action(opennamed)]
2070\definereference [\v!SearchDocument ] [action(search)]
2071\definereference [\v!SearchAgain ] [action(searchagain)]
2072\definereference [\v!StartRendering ] [action(startrendering)]
2073\definereference [\v!StopRendering ] [action(stoprendering)]
2074\definereference [\v!SubmitForm ] [action(submitform)]
2075\definereference [\v!ToggleViewer ] [action(toggle)]
2076\definereference [\v!ViewerHelp ] [action(help)]
2077\definereference [\v!HideField ] [action(hide)]
2078\definereference [\v!ShowField ] [action(show)]
2079\definereference [\v!GotoPage ] [action(gotopage)]
2080\definereference [\v!Query ] [action(query)]
2081\definereference [\v!QueryAgain ] [action(queryagain)]
2082\definereference [\v!FitWidth ] [action(fitwidth)]
2083\definereference [\v!FitHeight ] [action(fitheight)]
2084\definereference [\v!ShowThumbs ] [action(thumbnails)]
2085\definereference [\v!ShowBookmarks ] [action(bookmarks)]
2086
2087\definereference [\v!HideLayer ] [action(hidelayer)]
2088\definereference [\v!VideLayer ] [action(videlayer)]
2089\definereference [\v!ToggleLayer ] [action(togglelayer)]
2090
2091\definereference [\v!firstpage] [page(firstpage)]
2092\definereference [\v!previouspage] [page(previouspage)]
2093\definereference [\v!nextpage] [page(nextpage)]
2094\definereference [\v!lastpage] [page(lastpage)]
2095\definereference [\v!forward] [page(forward)]
2096\definereference [\v!backward] [page(backward)]
2097\definereference [\v!firstsubpage] [page(firstsubpage)]
2098\definereference [\v!previoussubpage] [page(previoussubpage)]
2099\definereference [\v!nextsubpage] [page(nextsubpage)]
2100\definereference [\v!lastsubpage] [page(lastsubpage)]
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
2137\installcorenamespace{referencingprefix}
2138
2139\permanent\def\getreferencestructureprefix#kind#name#category
2140 {{
2141 prefix {\referencestructureprefixparameter{#kind}{#name}{#category}\c!prefix}
2142 separatorset {\referencestructureprefixparameter{#kind}{#name}{#category}\c!prefixseparatorset}
2143 conversion {\referencestructureprefixparameter{#kind}{#name}{#category}\c!prefixconversion}
2144 conversionset {\referencestructureprefixparameter{#kind}{#name}{#category}\c!prefixconversionset}
2145 starter {\referencestructureprefixparameter{#kind}{#name}{#category}\c!prefixstarter}
2146 stopper {\referencestructureprefixparameter{#kind}{#name}{#category}\c!prefixstopper}
2147 set {\referencestructureprefixparameter{#kind}{#name}{#category}\c!prefixset}
2148 segments {\referencestructureprefixparameter{#kind}{#name}{#category}\c!prefixsegments}
2149 connector {\referencestructureprefixparameter{#kind}{#name}{#category}\c!prefixconnector}
2150 }
2151 {
2152 separatorset {\referencestructureprefixparameter{#kind}{#name}{#category}\c!numberseparatorset}
2153 conversion {\referencestructureprefixparameter{#kind}{#name}{#category}\c!numberconversion}
2154 conversionset {\referencestructureprefixparameter{#kind}{#name}{#category}\c!numberconversionset}
2155 starter {\referencestructureprefixparameter{#kind}{#name}{#category}\c!numberstarter}
2156 stopper {\referencestructureprefixparameter{#kind}{#name}{#category}\c!numberstopper}
2157 segments {\referencestructureprefixparameter{#kind}{#name}{#category}\c!numbersegments}
2158 }}
2159
2160\permanent\tolerant\protected\def\setupreferencestructureprefix[#kind]#spacer[#category]#spacer[#S#settings]
2161 {\ifarguments\or\or
2162 \getparameters[\??referencingprefix:#kind][#category]
2163 \else
2164 \getparameters[\??referencingprefix#kind:#category][#settings]
2165 \fi}
2166
2167\permanent\def\referencestructureprefixparameter#kind#name#category#parameter
2168 {\ifcsname\??referencingprefix#name:#category#parameter\endcsname
2169 \lastnamedcs
2170 \orelse\ifcsname\??referencingprefix#kind:#category#parameter\endcsname
2171 \lastnamedcs
2172 \orelse\ifcsname\??referencingprefix:#category#parameter\endcsname
2173 \lastnamedcs
2174 \fi}
2175
2176\permanent\def\currentreferencedefault
2177 {\normalexpanded{\noexpand\clf_filterdefaultreference
2178 {\s!default}
2179 \noexpand\getreferencestructureprefix\clf_getcurrentprefixspec{\s!default}
2180 \relax}}
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226\protect \endinput
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247 |