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