strc-ref.mklx /size: 75 Kb    last modification: 2021-10-28 13:51
1
%D \module
2
%D [ file=strc-ref,
3
%D version=2008.10.20,
4
%D title=\CONTEXT\ Structure Macros,
5
%D subtitle=Cross Referencing,
6
%D author=Hans Hagen,
7
%D date=\currentdate,
8
%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
9
%C
10
%C This module is part of the \CONTEXT\ macro||package and is
11
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12
%C details.
13 14
% todo: (1) configure references, (2) rendering => with presets
15
%
16
% \defineconversionset[default][Character,number,Romannumerals,Character][number]
17
% \defineseparatorset [default][.,.,--][.]
18
% \setuphead[subsection][sectionstopper=),sectionsegments=4:4]
19
% \setupreferencestructureprefix[default][prefixsegments=2:4]
20
% \setupreferencestructureprefix[figure][default][prefixsegments=3:4]
21
% \chapter {One}
22
% \section {One}
23
% \subsection[sec:test]{Two}
24
% See \in[sec:test] and \in[fig:xx] and \in[fig:yy]
25
% \placefigure[here][fig:xx]{}{}
26
% \placefigure[here][fig:yy]{}{}
27 28
\writestatus
{
loading
}
{
ConTeXt
Structure
Macros
/
Cross
Referencing
}
29 30
\registerctxluafile
{
strc
-
rsc
}
{
}
31
\registerctxluafile
{
strc
-
ref
}
{
}
32
\registerctxluafile
{
node
-
ref
}
{
autosuffix
,
optimize
}
33 34
\unprotect
35 36
% todo : unknown/illegal reference no arg
37
% todo : +n pages check on 'samepage' (contrastcolor)
38
% todo : multiple text in reference
39 40
% Makes more sense to build action data first, especially now openaction etc are
41
% supported.
42
%
43
% \definespecial\doexecuteactionchain w h
44
% \definespecial\dosetgotolocation
45
% \definespecial\dosetexecuteJScode
46
% ...
47 48
%D This module deals with referencing. In \CONTEXT\ referencing is one of the core
49
%D features, although at a first glance probably nobody will notice. This is good,
50
%D because referencing should be as hidden as possible.
51
%D
52
%D Before we start implementing functionality we provide a way to set up this
53
%D mechanism.
54
%D
55
%D \showsetup{setupreferencing}
56
%D
57
%D In interactive documents verbose references don't always make sense (what is a
58
%D page number in an unnumbered document). By setting the \type{interaction}
59
%D variable, one can influences the way interactive references are set.
60 61
\installcorenamespace
{
referencing
}
62 63
\installdirectcommandhandler
\??referencing
{
referencing
}
% \??referencing
64 65
\mutable
\let
\referenceprefix
\empty
66 67
\mutable
\let
\currentdestinationattribute
\empty
68 69
\mutable
\let
\currentreferenceattribute
\empty
70
\mutable
\let
\currentreferencecoding
\empty
71
\mutable
\let
\currentreferencecontent
\empty
72
\mutable
\let
\currentreferencedata
\empty
73
\mutable
\let
\currentreferenceexpansion
\empty
74
\mutable
\let
\currentreferenceformatautocase
\empty
75
\mutable
\let
\currentreferenceformatlabel
\empty
76
\mutable
\let
\currentreferenceformatsetups
\empty
77
\mutable
\let
\currentreferenceformattype
\empty
78
\mutable
\let
\currentreferencekind
\empty
79
\mutable
\let
\currentreferencelabels
\empty
80
%mutable\let\currentreferencenumber \empty
81
\mutable
\let
\currentreferenceorder
\empty
82
%mutable\let\currentreferencepage \empty
83
%mutable\let\currentreferencerealpage \empty
84
%mutable\let\currentreferencetext \empty
85
%mutable\let\currentreferencetitle \empty
86
\mutable
\let
\currentreferenceuserdata
\empty
87 88 89
\newif
\ifreferencing
\referencingtrue
90 91
\appendtoks
92
\edef
\p_state
{
\referencingparameter
\c!state
}
%
93
\ifx
\p_state
\v!start
94
\referencingtrue
95
\else
96
\referencingfalse
97
\fi
98
\to
\everysetupreferencing
99 100
%D In paper documents, referencing comes down to cross referencing, but in
101
%D their interactive counterparts, is also involves navigation. Many features
102
%D implemented here are therefore closely related to navigation.
103
%D
104
%D Many \CONTEXT\ commands can optionally be fed with a reference. Such a
105
%D reference, when called upon, returns the number of a figure, table, chapter
106
%D etc, a piece of text, or a pagenumber.
107
%D
108
%D There are three ways of defining a reference:
109
%D
110
%D \starttyping
111
%D \pagereference[here]
112
%D \textreference[here]{some text}
113
%D \stoptyping
114
%D
115
%D the third alternative combines them in:
116
%D
117
%D \starttyping
118
%D \reference[here]{some text}
119
%D \stoptyping
120 121
\permanent
\protected
\def
\showreferences
{
\enabletrackers
[
nodes
.
references
.
show
,
nodes
.
destinations
.
show
]
}
122 123
%D These are implemented in a low level form as:
124 125
\permanent
\tolerant
\protected
\def
\textreference
[
#
labels
]
{
\strc_references_set_named_reference
\s!text
{
#
labels
}
{
}
}
126
\permanent
\tolerant
\protected
\def
\pagereference
[
#
labels
]
{
\strc_references_set_named_reference
\s!page
{
#
labels
}
{
}
{
}
}
127
\permanent
\tolerant
\protected
\def
\reference
[
#
labels
]
{
\strc_references_set_named_reference
\s!full
{
#
labels
}
{
}
}
128
\permanent
\tolerant
\protected
\def
\setreference
[
#
labels
]
#
spacer
[
#
settings
]
{
\strc_references_set_named_reference
\s!user
{
#
labels
}
{
#
settings
}
{
}
}
129 130
\permanent
\protected
\def
\dosetdirectpagereference
#
1
{
\strc_references_set_named_reference
\s!page
{
#
1
}
{
}
{
}
}
% low level, maybe use _
131 132
\permanent
\protected
\def
\usereferenceparameter
#
1
% faster local variant
133
{
\edef
\m_strc_references_asked
{
#
1
\c!reference
}
%
134
\ifempty
\m_strc_references_asked
\else
135
\dosetdirectpagereference
\m_strc_references_asked
136
\fi
}
137 138
%D Actually there is not much difference between a text and a full reference, but
139
%D it's the concept that counts. The low level implementation is:
140 141
\newcount
\lastreferenceattribute
142
\newcount
\lastdestinationattribute
143 144
\def
\strc_references_finish
#
prefix
#
reference
#
internal
% gets expanded anyway
145
{
\normalexpanded
{
\clf_deferredenhancereference
{
#
prefix
}
{
#
reference
}
}
}
146 147
\permanent
\let
\dofinishreference
\strc_references_finish
% used at lua end
148 149
%D This is somewhat tricky: we want to keep the reference with the following word but
150
%D that word should also hyphenate. We need to find a better way.
151 152
% 0 = nothing
153
% 1 = bind to following word
154 155
\setnewconstant
\c_strc_references_bind_state
\plusone
156 157
\def
\strc_references_inject_before
158
{
}
159 160
\def
\strc_references_inject_after
161
{
\ifcase
\c_strc_references_bind_state
162
% nothing
163
\or
164
\prewordbreak
% to be tested: \removeunwantedspaces\permithyphenation
165
\fi
}
166 167 168
\protected
\def
\strc_references_set_named_reference
169
{
\ifreferencing
170
\expandafter
\strc_references_set_named_reference_indeed
171
\else
172
\expandafter
\gobblefourarguments
173
\fi
}
174 175
\newbox
\b_strc_destination_nodes
176 177
\protected
\def
\strc_references_flush_destination_nodes
178
{
\ifvoid
\b_strc_destination_nodes
\else
179
\unhbox
\b_strc_destination_nodes
180
\fi
}
181 182
\def
\strc_references_placeholder
183
{
\ifempty
\dotaggedplaceholder
\else
184
\c_attr_destination
\lastdestinationattribute
185
\dotaggedplaceholder
186
\fi
}
187 188
\protected
\def
\strc_references_destination_point_yes
189
{
\strc_references_inject_before
% new
190
\dostarttagged
\t!reference
\empty
191
\dontleavehmode
\hbox
attr
\destinationattribute
\lastdestinationattribute
\bgroup
% \hpack
192
\strc_references_flush_destination_nodes
193
\strc_references_placeholder
194
\egroup
195
\dostoptagged
196
\strc_references_inject_after
}
197 198
\protected
\def
\strc_references_destination_point_nop
199
{
\strc_references_inject_before
% new
200
\dostarttagged
\t!reference
\empty
201
\dontleavehmode
\hbox
\bgroup
% \hpack
202
\strc_references_flush_destination_nodes
203
\strc_references_placeholder
204
\egroup
205
\dostoptagged
206
\strc_references_inject_after
}
207 208
\protected
\def
\strc_references_start_destination_nodes
% messy but we need the delay
209
{
\setbox
\b_strc_destination_nodes
\hbox
\bgroup
}
% also sets lastdestinationattribute
210 211
\protected
\def
\strc_references_stop_destination_nodes
212
{
\normalexpanded
{
\egroup
\lastdestinationattribute
\the
\lastdestinationattribute
\relax
}
}
213 214
\protected
\def
\strc_references_set_named_reference_indeed
#
kind
#
labels
#
userdata
#
text
% labels userdata text -> todo: userdata
215
{
\ifreferencing
216
% we could have a more efficient one for page references but for the moment
217
% we don't care too much
218
\edef
\currentreferencekind
{
#
kind
}
%
219
\edef
\currentreferencelabels
{
#
labels
}
%
220
\edef
\currentreferenceuserdata
{
#
userdata
}
%
221
\edef
\currentreferenceexpansion
{
\referencingparameter
\c!expansion
}
% {\referenceparameter\c!expansion}
222
\ifempty
\currentreferencelabels
223
\lastdestinationattribute
\attributeunsetvalue
224
\else
225
\ifx
\currentreferenceexpansion
\s!xml
226
\xmlstartraw
227
\xdef
\currentreferencedata
{
#
text
}
% data, no text else conflict
228
\xmlstopraw
229
\glet
\currentreferencecoding
\s!xml
230
\else
231
\ifx
\currentreferenceexpansion
\v!yes
232
\xdef
\currentreferencedata
{
#
text
}
%
233
\else
234
\xdef
\currentreferencedata
{
\detokenize
{
#
text
}
}
%
235
\fi
236
\glet
\currentreferencecoding
\s!tex
237
\fi
238
% beware, the structures.references.set writes a
239
\setnextinternalreference
240
\strc_references_start_destination_nodes
241
\clf_setdestinationattribute
242
{
%
243
references
{
%
244
internal
\locationcount
245
% block {\currentsectionblock}%
246
view
{
\interactionparameter
\c!focus
}
%
247
\ifempty
\referenceprefix
\else
248
prefix
{
\referenceprefix
}
%
249
\fi
250
reference
{
\currentreferencelabels
}
%
251
}
%
252
metadata
{
%
253
kind
{
\currentreferencekind
}
%
254
\ifx
\currentreferencekind
\s!page
\else
255
\ifx
\currentreferencecoding
\s!xml
256
xmlroot
{
\xmldocument
}
%
257
\fi
258
catcodes
\catcodetable
259
\fi
260
}
%
261
\ifempty
\currentreferencedata
\else
262
entries
{
%
263
text
{
\currentreferencedata
}
%
264
}
%
265
\fi
266
\ifempty
\currentreferenceuserdata
\else
267
userdata
{
\detokenize
{
#
userdata
}
}
%
268
\fi
269
}
%
270
\relax
271
\strc_references_stop_destination_nodes
272
\fi
273
\else
274
\setbox
\b_strc_destination_nodes
\emptyhbox
275
\lastdestinationattribute
\attributeunsetvalue
276
\fi
277
% will become obsolete:
278
\xdef
\currentdestinationattribute
{
\number
\lastdestinationattribute
}
%
279
% will become an option:
280
\ifnum
\lastdestinationattribute
>
\zerocount
281
\strc_references_destination_point_yes
282
\orelse
\ifvoid
\b_strc_destination_nodes
\else
283
\strc_references_destination_point_nop
284
\fi
}
285 286
\def
\strc_references_set_page_only_destination_attribute
#
labels
% could in fact be fully expandable
287
{
\ifreferencing
288
\edef
\currentreferencelabels
{
#
labels
}
%
289
\ifempty
\currentreferencelabels
290
\setbox
\b_strc_destination_nodes
\emptyhbox
291
\lastdestinationattribute
\attributeunsetvalue
292
\else
293
\strc_references_start_destination_nodes
294
\setnextinternalreference
295
\clf_setdestinationattribute
296
{
%
297
references
{
%
298
internal
\locationcount
299
% block {\currentsectionblock}%
300
view
{
\interactionparameter
\c!focus
}
%
301
\ifempty
\referenceprefix
\else
302
prefix
{
\referenceprefix
}
%
303
\fi
304
reference
{
\currentreferencelabels
}
%
305
}
%
306
metadata
{
%
307
kind
{
page
}
%
308
}
%
309
}
%
310
\relax
311
\strc_references_stop_destination_nodes
312
\fi
313
\else
314
\setbox
\b_strc_destination_nodes
\emptyhbox
315
\lastdestinationattribute
\attributeunsetvalue
316
\fi
}
317 318
\protected
\def
\strc_references_direct_full_user
#
user
#
labels
#
text
%
319
{
\ifreferencing
320
\strc_references_start_destination_nodes
321
\setnextinternalreference
322
\edef
\m_strc_references_user
{
#
user
}
%
323
\edef
\m_strc_references_text
{
#
text
}
%
324
\clf_setdestinationattribute
325
{
%
326
references
{
%
327
internal
\locationcount
328
% block {\currentsectionblock}%
329
view
{
\interactionparameter
\c!focus
}
%
330
\ifempty
\referenceprefix
\else
331
prefix
{
\referenceprefix
}
%
332
\fi
333
reference
{
#
labels
}
%
334
}
%
335
metadata
{
%
336
kind
{
\s!full
}
%
337
}
%
338
\ifempty
\m_strc_references_text
\else
339
entries
{
%
340
text
{
\m_strc_references_text
}
%
341
}
%
342
\fi
343
\ifempty
\m_strc_references_user
\else
344
userdata
{
\m_strc_references_user
}
% \detokenize\expandafter{\normalexpanded{...}}
345
\fi
346
}
%
347
\relax
348
\strc_references_stop_destination_nodes
349
\else
350
\setbox
\b_strc_destination_nodes
\emptyhbox
351
\lastdestinationattribute
\attributeunsetvalue
352
\fi
353
% will become obsolete:
354
\xdef
\currentdestinationattribute
{
\number
\lastdestinationattribute
}
%
355
% will become an option:
356
\ifnum
\lastdestinationattribute
>
\zerocount
357
\strc_references_destination_point_yes
358
\orelse
\ifvoid
\b_strc_destination_nodes
\else
359
\strc_references_destination_point_nop
360
\fi
}
361 362
\protected
\def
\strc_references_direct_full
363
{
\strc_references_direct_full_user
\empty
}
364 365
\permanent
\let
\dodirectfullreference
\strc_references_direct_full
% for at lua end (no longer)
366 367
\def
\strc_references_set_page_only_destination_box_attribute
#
cs
#
labels
%
368
{
\strc_references_set_page_only_destination_attribute
{
#
labels
}
%
369
\ifnum
\lastdestinationattribute
>
\zerocount
370
\edef
#
cs
{
attr
\destinationattribute
\number
\lastdestinationattribute
}
%
371
\else
372
\let
#
cs
\empty
373
\fi
}
374 375
%D It's about time to clean up references .. stable enough now.
376 377
\permanent
\protected
\def
\boxreference
[
#
1
]
%
378
{
\begingroup
379
\dowithnextbox
380
{
\strc_references_set_page_only_destination_attribute
{
#
1
}
%
381
\hpack
% \hbox
382
\ifnum
\lastdestinationattribute
=
\attributeunsetvalue
\else
attr
\destinationattribute
\lastdestinationattribute
\fi
383
{
\box
\b_strc_destination_nodes
\box
\nextbox
}
%
384
\endgroup
}
}
385 386
\permanent
\protected
\def
\hboxreference
[
#
1
]
{
\boxreference
[
#
1
]
\hbox
}
387
\permanent
\protected
\def
\vboxreference
[
#
1
]
{
\boxreference
[
#
1
]
\vbox
}
388 389
\mutable
\def
\defaultreferencepage
#
text
{
[
[
[
#
text
]
]
]
}
390
\mutable
\def
\defaultreferencetext
#
text
{
[
[
[
#
text
]
]
]
}
391 392
%D For internal usage:
393 394
\def
\strc_references_set_simple_reference
#
label
%
395
{
\iflocation
396
\strc_references_start_destination_nodes
397
\setnextinternalreference
398
\clf_setdestinationattribute
399
{
%
400
references
{
%
401
view
{
\interactionparameter
\c!focus
}
%
402
\ifempty
\referenceprefix
\else
403
prefix
{
\referenceprefix
}
%
404
\fi
405
reference
{
#
label
}
%
406
internal
\locationcount
407
}
%
408
metadata
{
%
409
kind
{
\s!page
}
%
410
}
%
411
}
%
412
\relax
413
\strc_references_stop_destination_nodes
414
\xdef
\currentdestinationattribute
{
\number
\lastdestinationattribute
}
%
415
\else
416
\setbox
\b_strc_destination_nodes
\emptyhbox
417
\xdef
\currentdestinationattribute
{
\number
\attributeunsetvalue
}
%
418
\fi
}
419 420
\def
\strc_references_set_simple_internal_reference
#
label
% no prefix
421
{
\iflocation
422
\strc_references_start_destination_nodes
423
\setnextinternalreference
424
\clf_setdestinationattribute
425
{
%
426
references
{
%
427
view
{
\interactionparameter
\c!focus
}
%
428
reference
{
#
label
}
%
429
internal
\locationcount
430
}
%
431
metadata
{
%
432
kind
{
\s!page
}
%
433
}
%
434
}
%
435
\relax
436
\strc_references_stop_destination_nodes
437
\xdef
\currentdestinationattribute
{
\number
\lastdestinationattribute
}
%
438
\else
439
\setbox
\b_strc_destination_nodes
\emptyhbox
440
\xdef
\currentdestinationattribute
{
\number
\attributeunsetvalue
}
%
441
\fi
}
442 443
\def
\strc_references_get_simple_reference
#
label
%
444
{
\iflocation
445
\clf_injectreference
446
{
\referenceprefix
}
%
447
{
#
label
}
%
448
{
%
449
height
\ht
\strutbox
450
depth
\dp
\strutbox
451
\extrareferencearguments
452
}
%
453
\relax
454
\xdef
\currentreferenceattribute
{
\number
\lastreferenceattribute
}
%
455
\else
456
\xdef
\currentreferenceattribute
{
\number
\attributeunsetvalue
}
%
457
\fi
}
458 459
%D \macros
460
%D {contentreference}
461
%D
462
%D \starttyping
463
%D \setupinteraction
464
%D [state=start,
465
%D focus=standard]
466
%D
467
%D \setupheader
468
%D [state=stop]
469
%D
470
%D See page \goto{page 2}[page2] \page
471
%D
472
%D \contentreference
473
%D [page2]
474
%D [offset=1cm,toffset=2cm,frame=on]
475
%D {\externalfigure[cow.pdf][factor=fit]}
476
%D
477
%D \stoptyping
478 479
\permanent
\tolerant
\protected
\def
\contentreference
[
#
1
]
#
*
[
#
2
]
%
480
{
\ifarguments
481
\expandafter
\gobbletwoarguments
482
\or
483
\expandafter
\strc_references_content_pickup_nop
484
\else
485
\expandafter
\strc_references_content_pickup_yes
486
\fi
{
#
1
}
{
#
2
}
}
487 488
\def
\strc_references_content_pickup_yes
#
1
#
2
%
489
{
\hbox
\bgroup
\dowithnextbox
{
\strc_references_content_yes_finish
{
#
1
}
{
#
2
}
}
\hbox
}
490 491
\def
\strc_references_content_pickup_nop
#
1
#
2
%
492
{
\hbox
\bgroup
\dowithnextbox
{
\strc_references_content_nop_finish
{
#
1
}
{
#
2
}
}
\hbox
}
493 494
\def
\strc_references_content_yes_finish
#
1
#
2
%
495
{
\scratchwidth
\wd
\nextbox
496
\scratchheight
\ht
\nextbox
497
\scratchdepth
\dp
\nextbox
498
\setbox
\nextbox
\hpack
499
{
\framed
[
\c!frame
=
\v!off
,
#
2
]
{
\box
\nextbox
}
}
%
500
\strc_references_set_simple_reference
{
#
1
}
%
501
\setbox
\nextbox
\hpack
attr
\destinationattribute
\currentdestinationattribute
% \hpack ?
502
{
\strc_references_flush_destination_nodes
503
\box
\nextbox
}
%
504
\setbox
\nextbox
\hpack
{
\box
\nextbox
}
%
505
\wd
\nextbox
\scratchwidth
506
\ht
\nextbox
\scratchheight
507
\dp
\nextbox
\scratchdepth
508
\box
\nextbox
509
\egroup
}
510 511
\def
\strc_references_content_nop_finish
#
1
#
2
%
512
{
\strc_references_set_simple_reference
{
#
1
}
%
513
\hpack
attr
\destinationattribute
\currentdestinationattribute
% \hpack ?
514
{
\strc_references_flush_destination_nodes
515
\box
\nextbox
}
%
516
\egroup
}
517 518
%D \macros
519
%D {everyreference}
520
%D
521
%D For rather tricky purposes, one can assign sanitizing macros to \type
522
%D {\everyreference} (no longer that relevant).
523 524
\newevery
\everyreference
\relax
525 526
%D This is really needed, since for instance Polish has a different alphabet and
527
%D needs accented entries in registers.
528 529
\appendtoks
530
\cleanupfeatures
531
\to
\everyreference
532 533
%D We did not yet discuss prefixing. Especially in interactive documents, it's not
534
%D always easy to keep track of duplicate references. The prefix mechanism, which we
535
%D will describe later on, solves this problem. By (automatically) adding a prefix
536
%D one keeps references local, but the global ones in view. To enable this feature,
537
%D we explictly split the prefix from the reference.
538 539
\let
\referenceprefix
\empty
540 541
%D For a long time the only way to access an external file was to use the file
542
%D prefix (\type {somefile::}. However, when you split up a document, redefining the
543
%D references may be such a pain, that another approach is feasible. By setting the
544
%D \type {autofile} variable to \type {yes} or \type {page}, you can access the
545
%D reference directly.
546
%D
547
%D \starttabulate[||||]
548
%D \NC filename::tag \NC page(filename::pnum) \NC tag \NC\NR
549
%D \NC $\star$ \NC \NC \NC\NR
550
%D \NC $\star$ \NC $\star$ \NC $\star$ \NC\NR
551
%D \NC \NC $\star$ \NC \NC\NR
552
%D \stoptabulate
553 554
\permanent
\protected
\def
\usereferences
[
#
filename
]
{
}
% obsolete
555 556
%D As mentioned we will also use the cross reference mechanism for navigational
557
%D purposes. The main reason for this is that we want to treat both categories
558
%D alike:
559
%D
560
%D \starttyping
561
%D \goto{go back}[PreviousJump]
562
%D \goto{colofon}[colofon page]
563
%D \stoptyping
564
%D
565
%D Here \type{PreviousJump} is handled by the viewer, while the
566
%D \type{colofon page} reference is, apart from hyperlinking, a
567
%D rather normal reference.
568
%D
569
%D We already saw that cross refences are written to and read from a file. The pure
570
%D navigational ones don't need to be written to file, but both for fast processing
571
%D and transparant integration, they are saved internally as a sort of reference. We
572
%D can easily distinguish such system references from real cross reference ones by
573
%D their tag.
574
%D
575
%D We also use the odd/even characteristic to determine the page state.
576 577
\mutable
\let
\currentrealreference
\empty
578
\mutable
\let
\currentpagereference
\empty
579
\mutable
\let
\currenttextreference
\empty
580
\mutable
\let
\currentsubtextreference
\empty
581
\mutable
\let
\currentsubsubtextreference
\empty
582 583
\newcount
\referencehastexstate
% set in backend
584 585
% referencepagestate:
586
%
587
% 0 = no page ref, 1=same page, 2=before, 3=after
588 589
%D Cross references appear as numbers (figure~1.1, chapter~2) or pagenumbers
590
%D (page~2, page 3--2), and are called with \type {\in} and \type {\at}. In
591
%D interactive documents we also have \type {\goto}, \type {\button} and alike.
592
%D These are more versatile and look like:
593
%D
594
%D \starttyping
595
%D \goto[reference]
596
%D \goto[outer reference::]
597
%D \goto[outer reference::inner reference]
598
%D \goto[operation(argument)]
599
%D \goto[operation(action{argument,argument})]
600
%D \goto[action]
601
%D \goto[action{argument}]
602
%D \stoptyping
603
%D
604
%D The first one is a normal reference, the second and third are references to a
605
%D file or \URL. The brace delimited references for instance refer to a \JAVASCRIPT.
606
%D The last example shows that we can pass arguments to the actions.
607
%D
608
%D Now we've come to the testing step. As we can see below, this macro does bit more
609
%D than testing: it also resolves the reference. This means that whenever we test
610
%D for the existance of a reference at an outer level, we have all the relevant
611
%D properties of that reference avaliable inside the true branche~(\type {#2}).
612
%D
613
%D The prefix has to do with localizing references. When a prefix is set, looking
614
%D for a reference comes to looking for the prefixed one, and when not found,
615
%D looking for the non prefixed one. Consider for instance the prefix set to \type
616
%D {sidetrack}.
617
%D
618
%D \starttyping
619
%D \pagereference[important]
620
%D \pagereference[unimportant]
621
%D \setupreferencing[prefix=sidetrack]
622
%D \pagereference[important]
623
%D \stoptyping
624
%D
625
%D results in saving (writing) the references
626
%D
627
%D \starttyping
628
%D ...{}{important}
629
%D ...{}{unimportant}
630
%D ...{sidetrack}{important}...
631
%D \stoptyping
632
%D
633
%D Now when we call for \type{unimportant}, we will indeed get the pagenumber
634
%D associated to this reference. But when we call for \type{important}, while the
635
%D prefix is still set, we will get the pagenumber bound to the prefixed one.
636
%D
637
%D {\em Some day, when processing time and memory are no longer
638
%D performance factors, we will introduce multi||level
639
%D prefixes.}
640
%D
641
%D Before we start analyzing, I introduce a general definition macro. Consider:
642
%D
643
%D \starttyping
644
%D \goto{do}[JS(My_Script{"test",123}),titlepage]
645
%D \stoptyping
646
%D
647
%D This can also be achieved by:
648
%D
649
%D \starttyping
650
%D \definereference[startup][JS(My_Script{"test",123}),titlepage]
651
%D \goto{do}[startup]
652
%D \stoptyping
653
%D
654
%D Now is this is a handy feature or not?
655
%D
656
%D \showsetup{definereference}
657
%D
658
%D We can trace references by setting the next switch to true.
659 660
\permanent
\tolerant
\protected
\def
\definereference
[
#
name
]
#
spacer
[
#
specification
]
%
661
{
\clf_definereference
{
\referenceprefix
}
{
#
name
}
{
\detokenize
{
#
specification
}
}
}
662 663
\permanent
\protected
\def
\resetreference
[
#
name
]
%
664
{
\clf_resetreference
{
\referenceprefix
}
{
#
name
}
}
665 666
\permanent
\def
\setpagereference
#
name
#
specification
% hm,. low level ?
667
{
\clf_definereference
{
}
{
#
name
}
{
\v!page
(
\detokenize
{
#
specification
}
}
}
% is detokenize needed here?
668 669
%D Chained references are defined as:
670
%D
671
%D \starttyping
672
%D \goto{somewhere}[JS(somescript),nextpage,JS(anotherscript)]
673
%D \stoptyping
674
%D
675
%D Actually supporting chains is up to the special driver. Here we only provide the
676
%D hooks.
677 678
%D \macros
679
%D {highlighthyperlinks}
680
%D
681
%D The next switch can be used to make user hyperlinks are not highlighted when
682
%D clicked on.
683 684
\newconditional
\highlighthyperlinks
\settrue
\highlighthyperlinks
685 686
%D \macros
687
%D {gotonewwindow}
688
%D
689
%D To make the {\em goto previous jump} feature more convenient when using more than
690
%D one file, it makes sense to force the viewer to open a new window for each file
691
%D opened.
692 693
\newconditional
\gotonewwindow
\setfalse
\gotonewwindow
694 695
\permanent
\def
\expandtexincurrentreference
% will happen in lua some time
696
{
\ifcase
\referencehastexstate
\else
\clf_expandcurrentreference
\fi
}
697 698
\permanent
\def
\expandreferenceoperation
#
tag
#
content
{
\clf_setreferenceoperation
#
tag
{
#
content
}
}
699
\permanent
\def
\expandreferencearguments
#
tag
#
content
{
\clf_setreferencearguments
#
tag
{
#
content
}
}
700 701
\permanent
\def
\doifelsereferencefound
#
label
#
yes
#
nop
%
702
{
\clf_doifelsereference
{
\referenceprefix
}
{
#
label
}
{
\extrareferencearguments
}
%
703
{
\expandtexincurrentreference
704
#
yes
}
%
705
{
#
nop
}
}
706 707
\aliased
\let
\doifreferencefoundelse
\doifelsereferencefound
708 709
%D The tester only splits the reference in components but does not look into them.
710
%D The following macro does a preroll and determines for instance the current real
711
%D reference pagenumber. The \type {\currentrealreference} macro does the same so
712
%D unless one wants to use the pagestate the next macro seldom needs to be called.
713
%D
714
%D The inner case is simple. Only two cases have to be taken
715
%D care of:
716
%D
717
%D \starttyping
718
%D \goto{some text}[reference]
719
%D \goto{some text}[prefix:reference]
720
%D \stoptyping
721
%D
722
%D References to other files however are treated strict or tolerant, depending on
723
%D their loading and availability:
724
%D
725
%D \starttyping
726
%D \useexternaldocument[somefile][filename][a nice description]
727
%D
728
%D \goto{checked reference}[somefile::reference]
729
%D \goto{unchecked reference}[somefile::]
730
%D \goto{unchecked reference}[anotherfile::reference]
731
%D \stoptyping
732
%D
733
%D An unknown reference is reported on the screen, in the log file and, when
734
%D enabled, in the left margin of the text.
735 736
\mutable
\let
\unknownreference
\gobbleoneargument
737 738
%D When a reference is not found, we typeset a placeholder (two glyphs are often
739
%D enough to represent the reference text).
740 741
% \askedreference defined in lua
742 743
\mutable
\def
\dummyreference
{
{
\tttf
?
?
}
}
744
\mutable
\def
\emptyreference
{
{
\tttf
!
!
}
}
745 746
\installtextracker
747
{
structures
.
referencing
.
show
}
748
{
\let
\strc_references_dummy
\strc_references_dummy_yes
}
749
{
\let
\strc_references_dummy
\strc_references_dummy_nop
}
750 751
\def
\strc_references_dummy_nop
752
{
\dummyreference
}
753 754
\def
\strc_references_dummy_yes
755
{
\dummyreference
756
\margindata
757
[
\referencingparameter
\c!labelalternative
]
% alternative?
758
[
\c!style
=
\referencingparameter
\c!labelstyle
,
759
\c!color
=
\referencingparameter
\c!labelcolor
]
760
{
\askedreference
}
}
761 762
\let
\strc_references_dummy
\strc_references_dummy_nop
763 764
\setupreferencing
765
[
\c!labelalternative
=
\v!inleft
,
766
\c!labelcolor
=
darkred
,
767
\c!labelstyle
=
\smallinfofont
]
768 769
%D To prevent repetitive messages concerning a reference being defined, we set such
770
%D an unknown reference to an empty one after the first encounter.
771
%D
772
%D Apart from cross references supplied by the user, \CONTEXT\ generates cross
773
%D references itself. Most of them are not saved as a reference, but stored with
774
%D their source, for instance a list or an index entry. Such automatically
775
%D generated, for the user invisible, references are called {\em internal
776
%D references}. The user supplied ones are labeled as {\em external references}.
777
%D
778
%D A second important characteristic is that when we want to support different
779
%D backends (viewers), we need to support named destinations as well as page
780
%D numbers. I invite readers to take a glance at the special driver modules to
781
%D understand the fine points of this. As a result we will deal with {\em locations}
782
%D as well as {\em real page numbers}. We explictly call this pagenumber a real one,
783
%D because it is independant of the page numbering scheme used in the document.
784
%D
785
%D One of the reasons for \CONTEXT\ being the first \TEX\ base macropackage to
786
%D support sophisticated interactive \PDF\ files, lays in the mere fact that real
787
%D page numbers are available in most two pass data, like references, list data and
788
%D index entries.
789
%D
790
%D We will speak of \type {thisis...} when we are marking a location, and
791
%D \type {goto...} when we point to such a location. The latter one can be seen as a
792
%D hyperlink to the former one. In the next macros one we use constructs like:
793
%D
794
%D \starttyping
795
%D \dostart...
796
%D \dostop...
797
%D \stoptyping
798
%D
799
%D The flag \type {\iflocation} signals if we're in interactive mode.
800 801
\ifdefined
\buttonheight
\else
\newdimen
\buttonheight
\fi
802
\ifdefined
\buttonwidth
\else
\newdimen
\buttonwidth
\fi
803 804
%D Internal references can best be set using the next few macros. Setting such
805
%D references to unique values is completely up to the macros that call them.
806
%D
807
%D \starttyping
808
%D \thisissomeinternal{tag}{identifier}
809
%D \gotosomeinternal {tag}{identifier}{pagenumber}{text}
810
%D \stoptyping
811
%D
812
%D We could do this in \LUA\ \unknown
813 814
\newif
\iflocation
815
\newcount
\locationcount
816
\newcount
\locationorder
817
\newbox
\locationbox
818 819
\appendtoks
820
\locationfalse
821
\to
\everypreroll
822 823
\permanent
\def
\nextinternalreference
{
\the
\locationcount
}
824
\permanent
\def
\nextinternalorderreference
{
\the
\locationorder
}
825 826
\permanent
\def
\setnextinternalreference
827
{
\global
\advance
\locationcount
\plusone
}
828 829
\permanent
\def
\setnextinternalreferences
#
kind
#
name
% plural
830
{
\clf_setnextinternalreference
{
#
kind
}
{
#
name
}
}
831 832
\permanent
\def
\getinternalorderreference
#
kind
#
name
%
833
{
\clf_currentreferenceorder
{
#
kind
}
{
#
name
}
}
834 835
\permanent
\def
\thisissomeinternal
#
kind
#
name
% only for old time sake, will go away
836
{
\begingroup
837
\clf_setinternalreference
838
reference
{
#
kind
:
#
name
}
% no view
839
\relax
840
\hpack
attr
\destinationattribute
\lastdestinationattribute
{
}
%
841
\endgroup
}
842 843
\installcorenamespace
{
savedinternalreference
}
844 845
\letcsname
\??savedinternalreference
\s!default
\endcsname
\!!zerocount
846 847
\permanent
\protected
\def
\storeinternalreference
#
1
#
2
%
848
{
\xdefcsname
\??savedinternalreference
\currentstructurename
\endcsname
{
\number
#
2
}
}
849 850
\newconditional
\preferpagereferences
851 852
\permanent
\def
\gotosomeinternal
#
kind
#
name
#
target
#
text
%
853
{
\ifconditional
\preferpagereferences
854
\directgoto
{
#
text
}
[
page
(
#
target
)
]
%
855
\else
856
\directgoto
{
#
text
}
[
#
kind
:
#
name
]
%
857
\fi
}
858 859
\permanent
\def
\gotonextinternal
#
text
#
target
%
860
{
\directgoto
{
#
text
}
[
internal
(
#
target
)
]
}
861 862
%D In this module we define three system references: one for handling navigational,
863
%D viewer specific, commands, another for jumping to special pages, like the first
864
%D or last one, and a third reference for linking tree like lists, like tables of
865
%D contents. The latter two adapt themselves to the current state.
866
%D
867
%D An example of an action is:
868
%D
869
%D \starttyping
870
%D \goto{some action}[PreviousJump]
871
%D \stoptyping
872
%D
873
%D as well as:
874
%D
875
%D \starttyping
876
%D \goto{some text}[\v!action(PreviousJump]
877
%D \stoptyping
878
%D
879
%D One can also activate an automatic prefix mechanism. By setting the
880
%D \type {\prefix} variable to \type {+}, the prefix is incremented, when set to
881
%D \type {-} or empty, the prefix is reset. Other values become the prefix.
882 883
\newcount
\prefixcounter
884 885
\newconditional
\autocrossfilereferences
886 887
\appendtoks
888
\edef
\p_autofile
{
\referencingparameter
\c!autofile
}
%
889
\ifx
\p_autofile
\v!yes
890
\settrue
\autocrossfilereferences
891
\else
892
\setfalse
\autocrossfilereferences
893
\fi
894
\to
\everysetupreferencing
895 896
\appendtoks
897
\edef
\p_export
{
\referencingparameter
\c!export
}
%
898
\ifx
\p_export
\v!yes
899
\clf_exportreferences
900
\fi
901
\to
\everygoodbye
902 903
\permanent
\protected
\def
\setupglobalreferenceprefix
[
#
prefix
]
%
904
{
\xdef
\referenceprefix
{
#
prefix
}
}
905 906
\permanent
\protected
\def
\globalpushreferenceprefix
#
prefix
%
907
{
\xdef
\referenceprefix
{
\clf_pushreferenceprefix
{
#
prefix
}
}
}
908 909
\permanent
\protected
\def
\globalpopreferenceprefix
910
{
\xdef
\referenceprefix
{
\clf_popreferenceprefix
}
}
911 912
\permanent
\protected
\def
\pushreferenceprefix
#
prefix
%
913
{
\edef
\referenceprefix
{
\clf_pushreferenceprefix
{
#
prefix
}
}
}
914 915
\permanent
\protected
\def
\popreferenceprefix
916
{
\edef
\referenceprefix
{
\clf_popreferenceprefix
}
}
917 918
\def
\m_strc_references_prefix_yes
{
+
}
919
\def
\m_strc_references_prefix_nop
{
-
}
920 921
\permanent
\protected
\def
\setupreferenceprefix
[
#
prefix
]
%
922
{
\edef
\p_prefix
{
#
prefix
}
%
923
\ifempty
\p_prefix
924
\let
\referenceprefix
\empty
925
\orelse
\ifx
\p_prefix
\m_strc_references_prefix_yes
926
\letreferencingparameter
\c!prefix
\s!unknown
927
\global
\advance
\prefixcounter
\plusone
928
\edef
\referenceprefix
{
\the
\prefixcounter
}
%
929
\orelse
\ifx
\p_prefix
\m_strc_references_prefix_nop
930
\letreferencingparameter
\c!prefix
\s!unknown
931
\let
\referenceprefix
\empty
932
\orelse
\ifx
\p_prefix
\s!unknown
933
% forget about it
934
\else
935
\let
\referenceprefix
\p_prefix
936
\fi
}
937 938
\appendtoks
939
\setupreferenceprefix
[
\referencingparameter
\c!prefix
]
940
\to
\everysetupreferencing
941 942
%D We can typeset a reference using \type {\in}, \type {\at} and \type {\about} and
943
%D goto specific locations using \type {\goto}. The last one does not make that much
944
%D sense in a paper document. To complicate things, \PLAIN\ \TEX\ also implements an
945
%D \type {\in} but fortunately that one only makes sense in math mode.
946
%D
947
%D Typesetting the reference is a bit more complicated than one would at first sight
948
%D expect. This is due to the fact that we distinguish three (five) alternative
949
%D calls:
950
%D
951
%D \placefigure
952
%D [here][three calls]
953
%D {Three alternatives reference calls.}
954
%D {\startcombination[1*3]
955
%D {\framed{\type{ \in }}} {a}
956
%D {\framed{\type{ \at }}} {b}
957
%D {\framed{\type{\goto}}} {c}
958
%D \stopcombination}
959
%D
960
%D \startbuffer
961
%D \in figure[fig:three calls]
962
%D \in{figure}[fig:three calls]
963
%D \in figure a[fig:three calls]
964
%D \in{figure}{a}[fig:three calls]
965
%D figure~\in[fig:three calls]
966
%D \stopbuffer
967
%D
968
%D \typebuffer
969
%D
970
%D This turns up as:
971
%D
972
%D \startlines
973
%D \getbuffer
974
%D \stoplines
975
%D
976
%D The dual \type {{}} results in a split reference. In a document meant for paper,
977
%D one is tempted to use the last (most straightforward) alternative. When a
978
%D document is also meant voor electronic distribution, the former alternatives have
979
%D preference, because everything between the \type {\in} and~\type {[} becomes
980
%D active (and when asked for, typeset in a different color and typeface).
981 982
\appendtoks
983
% likely math
984
\ifdefined
\in
\aliased
\let
\normalmathin
\in
\permanent
\protected
\def
\in
{
\mathortext
\normalmathin
\strc_references_in
}
\else
\aliased
\let
\in
\strc_references_in
\fi
985
\ifdefined
\over
\aliased
\let
\normalmathover
\over
\permanent
\protected
\def
\over
{
\mathortext
\normalmathover
\strc_references_about
}
\else
\aliased
\let
\over
\strc_references_about
\fi
986
%
987
% \ifdefined\at \aliased\let\normalmathat \at \permanent\protected\def\at {\mathortext\normalmathat \strc_references_at } \else \aliased\let\at \strc_references_at \fi
988
% \ifdefined\about \aliased\let\normalmathabout\about \permanent\protected\def\about{\mathortext\normalmathabout\strc_references_about} \else \aliased\let\about\strc_references_about \fi
989
% \ifdefined\from \aliased\let\normalmathfrom \from \permanent\protected\def\from {\mathortext\normalmathfrom \strc_references_from } \else \aliased\let\from \strc_references_from \fi
990
\aliased
\let
\at
\strc_references_at
991
\aliased
\let
\about
\strc_references_about
992
\aliased
\let
\from
\strc_references_from
993
\to
\everydump
994 995
\permanent
\def
\filterreference
#
key
{
\clf_filterreference
{
#
key
}
}
% no checking, expandable
996
\permanent
\protected
\def
\getreferenceentry
#
key
{
\clf_filterreference
{
#
key
}
}
% no checking, not expandable
997 998
\permanent
\def
\currentreferencenumber
{
\clf_filterreference
{
number
}
}
999
\permanent
\def
\currentreferencepage
{
\clf_filterreference
{
page
}
}
1000
\permanent
\def
\currentreferencetitle
{
\clf_filterreference
{
title
}
}
1001
\permanent
\def
\currentreferencetext
{
\clf_filterreference
{
text
}
}
1002
%permanent\def\currentreferencedefault {\clf_filterreference{default}}
1003
\permanent
\def
\currentreferencerealpage
{
\clf_filterreference
{
realpage
}
}
1004 1005
%D The most straightforward way of retrieving references is using \type {\ref}.
1006 1007
\permanent
\tolerant
\protected
\def
\getreference
[
#
key
]
#
spacer
[
#
label
]
% #key = number page title text default realpage ...
1008
{
\ifarguments
\or
1009
\strc_references_dummy
1010
\else
1011
\doifelsereferencefound
{
#
label
}
{
\clf_filterreference
{
#
key
}
}
\strc_references_dummy
1012
\fi
}
1013 1014
\aliased
\let
\ref
\getreference
1015 1016
%D Special cases:
1017 1018
\permanent
\protected
\def
\strc_references_about
[
#
label
]
%
1019
{
\dontleavehmode
1020
\begingroup
1021
\enforced
\let
\crlf
\space
1022
\enforced
\let
\\
\space
1023
\postponenotes
% might go
1024
\referencingparameter
\c!left
1025
\doifelsereferencefound
{
#
label
}
1026
{
\goto
{
\limitatetext
\currentreferencetitle
{
\referencingparameter
\c!width
}
\unknown
}
[
#
label
]
}
% not so efficient (dup lookup)
1027
{
}
% todo
1028
\flushnotes
% might go
1029
\referencingparameter
\c!right
1030
\endgroup
}
1031 1032
%D The previously discussed setup macro lets us specify the representation of
1033
%D references. A symbol reference does not show the specific data, like the number
1034
%D of a figure, but shows one of: \hbox {$^\goforwardcharacter$
1035
%D $^\gobackwardcharacter$ $^\gonowherecharacter$}, depending on the direction to
1036
%D go.
1037
%D
1038
%D \starttyping
1039
%D ... \somewhere{backward text}{forward text}[someref] ...
1040
%D ... \atpage[someref] ...
1041
%D \stoptyping
1042 1043
% standard detail
1044
%
1045
% 0 = unknown unknown
1046
% 1 = same on same page
1047
% 2 = before preceding page
1048
% 3 = after following page
1049
%
1050
% 4 = above above on same page
1051
% 5 = below below on same page
1052 1053
% todo: optimize for use in pagebody
1054
% todo: maybe make it optional
1055 1056
% \setuppagenumbering[alternative=doublesided]
1057
% \setupreferencing [doublesided=no] % yes is default
1058
%
1059
% \somewhere{backward}{foreward}[label]
1060
% \someplace{preceding}{backward}{current}{foreward}{following}[label]
1061
% \atpage[#label]
1062
% \doifcheckedpagestate{label}{preceding}{backward}{current}{foreward}{following}{otherwise}
1063
%
1064
% \dorecurse {20} {
1065
% \placefigure[here][fig:#1]{}{\externalfigure[dummy]}
1066
% \dorecurse {20} {
1067
% ##1: \atpage[fig:##1] /
1068
% \doifcheckedpagestate
1069
% {fig:##1}
1070
% {preceding}{backward}{current}{foreward}{following}
1071
% {otherwise}
1072
% }
1073
% }
1074 1075
\newcount
\nofreferencestates
1076
\newconditional
\pagestatespread
1077 1078
\appendtoks
1079
\doifelse
{
\referencingparameter
\c!doublesided
}
\v!yes
\settrue
\setfalse
\pagestatespread
1080
\to
\everysetupreferencing
1081 1082
\setupreferencing
1083
[
\c!doublesided
=
\v!yes
]
1084 1085
\permanent
\def
\referencepagestate
1086
{
\numexpr
\clf_referencepagestate
1087
{
rst
:
:
\number
\nofreferencestates
}
%
1088
\relax
}
1089 1090
\permanent
\def
\referencepagedetail
1091
{
\numexpr
\clf_referencepagedetail
1092
{
rst
:
:
\number
\nofreferencestates
}
%
1093
true
%
1094
\ifconditional
\pagestatespread
false
\ifdoublesided
true
\else
false
\fi
\fi
1095
\relax
}
1096 1097
\permanent
\def
\referencerealpage
{
\clf_referencerealpage
}
% todo: no need for wrapping
1098
\permanent
\def
\referencecolumnnumber
{
\clf_referencecolumn
}
% todo: no need for wrapping
1099 1100
% So we need : instead of \ but that's only lmtx:
1101
%
1102
% \def\referencecolumnnumber
1103
% {\numexpr\dimexpr\clf_referenceposx-\cutspace\relax:\dimexpr\makeupwidth/\nofcolumns\relax+\plusone\relax}
1104
%
1105
% Tacos patch of the older one, kept here as illustration
1106
%
1107
% \def\referencecolumnnumber
1108
% {\numexpr
1109
% \dimexpr\clf_referenceposx-\cutspace-\makeupwidth/(2*\nofcolumns)\relax
1110
% /\dimexpr \makeupwidth/ \nofcolumns \relax
1111
% +\plusone
1112
% \relax}
1113 1114 1115
\permanent
\protected
\def
\tracedpagestate
1116
{
{
\blue
\tttf
(
\ifcase
\referencepagedetail
unknown
\or
same
\or
previous
\or
next
\or
above
\or
below
\else
unknown
\fi
)
}
}
1117 1118
\permanent
\protected
\def
\markreferencepage
1119
{
\dontleavehmode
\begingroup
1120
\iftrialtypesetting
1121
% issue warning that not stable
1122
\else
1123
% needs checking ... but probably never in trialmode
1124
\global
\advance
\nofreferencestates
\plusone
1125
\xypos
{
rst
:
:
\number
\nofreferencestates
}
%
1126
% \tracedpagestate
1127
\fi
1128
\endgroup
}
1129 1130
\permanent
\protected
\def
\doifcheckedpagestate
#
label
% #preceding#backward#current#foreward#following#otherwise%
1131
{
\doifelsereferencefound
{
#
label
}
\strc_references_handle_page_state_yes
\strc_references_handle_page_state_nop
}
1132 1133
\let
\strc_references_handle_page_state_nop
\sixthofsixarguments
1134 1135
\def
\strc_references_handle_page_state_yes
1136
{
\markreferencepage
1137
\ifcase
\referencepagedetail
1138
\expandafter
\sixthofsixarguments
\or
1139
\expandafter
\thirdofsixarguments
\or
1140
\expandafter
\firstofsixarguments
\or
1141
\expandafter
\fifthofsixarguments
\or
1142
\expandafter
\secondofsixarguments
\or
1143
\expandafter
\fourthofsixarguments
\else
1144
\expandafter
\sixthofsixarguments
\fi
}
1145 1146
\permanent
\protected
\def
\referencesymbol
1147
{
\hpack
\bgroup
1148
\strut
1149
\markreferencepage
1150
\high
1151
{
\setupsymbolset
[
\interactionparameter
\c!symbolset
]
%
1152
\symbol
[
\ifcase
\referencepagedetail
\v!somewhere
\or
\v!nowhere
\or
\v!previous
\or
\v!next
\or
\v!previous
\or
\v!next
\else
\v!somewhere
\fi
]
}
%
1153
\egroup
}
1154 1155
%D Hereafter the \type {\ignorespaces} binds the state node to next character (more likely
1156
%D than a preceding one) and one can always add an explicit space.
1157 1158
\permanent
\protected
\def
\somewhere
#
backward
#
foreward
#
dummy
[
#
label
]
% #dummy gobbles space around #foreward
1159
{
\doifcheckedpagestate
{
#
label
}
%
1160
{
\goto
{
#
backward
}
[
#
label
]
}
%
1161
{
\goto
{
#
backward
}
[
#
label
]
}
%
1162
{
\ignorespaces
}
%
1163
{
\goto
{
#
foreward
}
[
#
label
]
}
%
1164
{
\goto
{
#
foreward
}
[
#
label
]
}
%
1165
{
#
label
}
}
%
1166 1167
\permanent
\protected
\def
\someplace
#
preceding
#
backward
#
current
#
foreward
#
following
#
dummy
[
#
label
]
% #dummy gobbles space around #foreward
1168
{
\doifcheckedpagestate
{
#
label
}
%
1169
{
\doifelsenothing
{
#
preceding
}
{
\goto
{
#
preceding
}
[
#
label
]
}
\ignorespaces
}
%
1170
{
\doifelsenothing
{
#
backward
}
{
\goto
{
#
backward
}
[
#
label
]
}
\ignorespaces
}
%
1171
{
\doifelsenothing
{
#
current
}
{
\goto
{
#
current
}
[
#
label
]
}
\ignorespaces
}
%
1172
{
\doifelsenothing
{
#
foreward
}
{
\goto
{
#
foreward
}
[
#
label
]
}
\ignorespaces
}
%
1173
{
\doifelsenothing
{
#
following
}
{
\goto
{
#
following
}
[
#
label
]
}
\ignorespaces
}
%
1174
{
#
label
}
}
1175 1176
\permanent
\protected
\def
\atpage
[
#
label
]
% todo
1177
{
\doifcheckedpagestate
{
#
label
}
%
1178
{
\goto
{
\labeltext
\v!precedingpage
}
[
#
label
]
}
%
1179
{
\goto
{
\labeltext
\v!hencefore
}
[
#
label
]
}
%
1180
{
\ignorespaces
}
%
1181
{
\goto
{
\labeltext
\v!hereafter
}
[
#
label
]
}
%
1182
{
\goto
{
\labeltext
\v!followingpage
}
[
#
label
]
}
%
1183
{
\goto
{
\labeltexts
\v!page
\strc_references_dummy
}
[
#
label
]
}
}
1184 1185
% Someone requested this but in retrospect didn't need it so we keep it as example.
1186
% Beware: a node is injected which is why we add ignorespaces!
1187
%
1188
% \protected\def\strc_references_conditional#action#text[#condition]#dummy[#label]%
1189
% {\doifcheckedpagestate{#label}%
1190
% {\doifelse{#condition}\v!precedingpage{#action{#text}[#label]}\ignorespaces}%
1191
% {\doifelse{#condition}\v!hencefore {#action{#text}[#label]}\ignorespaces}%
1192
% {\doifelse{#condition}\v!current {#action{#text}[#label]}\ignorespaces}%
1193
% {\doifelse{#condition}\v!hereafter {#action{#text}[#label]}\ignorespaces}%
1194
% {\doifelse{#condition}\v!followingpage{#action{#text}[#label]}\ignorespaces}%
1195
% {#label}}
1196
%
1197
% \protected\def\conditionalat {\strc_references_conditional\at}
1198
% \protected\def\conditionalin {\strc_references_conditional\in}
1199
% \protected\def\conditionalabout{\strc_references_conditional\about}
1200 1201
%D The other alternatives just conform their names: only the label, only the text, or the
1202
%D label and the text.
1203 1204
% \dounknownreference -> \dummyreference
1205 1206
\permanent
\def
\symbolreference
[
#
label
]
% for old times sake
1207
{
\goto
{
\referencesymbol
}
[
#
label
]
}
1208 1209
% \referencecontentmode 0=all 1=label 2=text 3=symbol
1210 1211
\newtoks
\leftreferencetoks
1212
\newtoks
\rightreferencetoks
1213
\newtoks
\defaultleftreferencetoks
1214
\newtoks
\defaultrightreferencetoks
1215 1216
\permanent
\let
\rightofreferencecontent
\empty
1217
\permanent
\let
\leftofreference
\empty
1218
\permanent
\let
\rightofreference
\empty
1219 1220
\permanent
\protected
\def
\leftofreferencecontent
1221
{
\removeunwantedspaces
1222
\nonbreakablespace
1223
\ignorespaces
}
1224 1225
\installcorenamespace
{
referencinginteraction
}
1226 1227
\def
\strc_references_interaction_all
1228
{
\the
\leftreferencetoks
1229
\doifelsesometoks
\leftreferencetoks
\leftofreferencecontent
\donothing
1230
\leftofreference
1231
\doifelsesometoks
\leftreferencetoks
\onlynonbreakablespace
\relax
% new, replace space by nonbreakable if present
1232
\currentreferencecontent
1233
\rightofreference
1234
\doifelsesometoks
\rightreferencetoks
\rightofreferencecontent
\donothing
1235
\the
\rightreferencetoks
}
1236 1237
\letcsname
\??referencinginteraction
\v!all
\endcsname
\strc_references_interaction_all
1238 1239
\defcsname
\??referencinginteraction
\v!label
\endcsname
1240
{
\leftofreference
1241
\the
\leftreferencetoks
1242
\the
\rightreferencetoks
1243
\rightofreference
}
1244 1245
\defcsname
\??referencinginteraction
\v!text
\endcsname
1246
{
\leftofreference
1247
\currentreferencecontent
1248
\rightofreference
}
1249 1250
\defcsname
\??referencinginteraction
\v!symbol
\endcsname
1251
{
\referencesymbol
}
1252 1253
\permanent
\def
\referencesequence
1254
{
\ifcsname
\??referencinginteraction
\referencingparameter
\c!interaction
\endcsname
1255
\expandafter
\lastnamedcs
1256
\else
1257
\expandafter
\strc_references_interaction_all
1258
\fi
}
1259 1260
\newtoks
\everyresetinatreference
1261 1262
\appendtoks
1263
\enforced
\glet
\leftofreference
\relax
1264
\enforced
\glet
\rightofreference
\relax
1265
\to
\everyresetinatreference
1266 1267
\def
\strc_references_start_goto
1268
{
\dontleavehmode
1269
\begingroup
}
1270 1271
\def
\strc_references_stop_goto
1272
{
\the
\everyresetinatreference
1273
\endgroup
}
1274 1275
% NEEDS TESTING:
1276 1277
\tolerant
\def
\strc_references_pickup_goto
#
=
#
=
#
:
#
*
[
#
3
]
%
1278
{
\leftreferencetoks
1279
\ifparameter
#
1
\or
1280
{
#
1
}
%
1281
\else
1282
\defaultleftreferencetoks
1283
\enforced
\let
\leftofreferencecontent
\empty
1284
\fi
1285
\rightreferencetoks
1286
\ifparameter
#
2
\or
1287
{
#
2
}
%
1288
\else
1289
\defaultrightreferencetoks
1290
\enforced
\let
\rightofreferencecontent
\empty
1291
\fi
1292
% inefficient: double resolve
1293
\doifelsereferencefound
{
#
3
}
% we need to resolve the text
1294
{
\goto
{
\referencesequence
}
[
#
3
]
}
1295
{
\let
\currentreferencecontent
\strc_references_dummy
1296
\goto
{
\referencesequence
}
[
#
3
]
}
%
1297
\strc_references_stop_goto
}
1298 1299
\permanent
\protected
\def
\strc_references_in
1300
{
\strc_references_start_goto
1301
\let
\currentreferencecontent
\currentreferencedefault
1302
\strc_references_pickup_goto
}
1303 1304
\permanent
\protected
\def
\strc_references_at
1305
{
\strc_references_start_goto
1306
\let
\currentreferencecontent
\currentreferencepage
1307
\strc_references_pickup_goto
}
1308 1309
%D \macros
1310
%D {definereferenceformat}
1311
%D
1312
%D The next few macros were made for for David Arnold and Taco Hoekwater. They can
1313
%D be used for predefining reference texts, and thereby stimulate efficiency.
1314
%D
1315
%D \starttyping
1316
%D \definereferenceformat[informula] [left=(,right=),text=formula]
1317
%D \definereferenceformat[informulas] [left=(,right=),text=formulas]
1318
%D \definereferenceformat[andformula] [left=(,right=),text=and]
1319
%D \definereferenceformat[andformulas][left=(,right=),text=and]
1320
%D
1321
%D \informula [b] and \informula [for:c]
1322
%D the \informula {formulas}[b] \informula {and} [for:c]
1323
%D the \informulas {formulas}[b] \informula {and} [for:c]
1324
%D the \informulas [b] \informula {en} [for:c]
1325
%D the \informulas [b] \andformula [for:c]
1326
%D \stoptyping
1327
%D
1328
%D Instead of a text, one can specify a label, which should be defined with \type
1329
%D {\setuplabeltext}.
1330
%D
1331
%D Watch out: the second argument is somewhat special and mostly meant for a suffix
1332
%D to a number:
1333
%D
1334
%D \startbuffer
1335
%D \definereferenceformat [intesta] [left=(,right=),text=Whatever~]
1336
%D \definereferenceformat [intestb] [left=(,right=),label=figure]
1337
%D
1338
%D \placeformula[x]\startformula a \stopformula
1339
%D
1340
%D \starttabulate[|||||]
1341
%D \NC \in [x] \NC \in {left}[x] \NC \in {}{right}[x] \NC \in {left}{right}[x] \NC \NR
1342
%D \NC \intesta[x] \NC \intesta{left}[x] \NC \intesta{}{right}[x] \NC \intesta{left}{right}[x] \NC \NR
1343
%D \NC \intestb[x] \NC \intestb{left}[x] \NC \intestb{}{right}[x] \NC \intestb{left}{right}[x] \NC \NR
1344
%D \stoptabulate
1345
%D \stopbuffer
1346
%D
1347
%D \typebuffer \getbuffer
1348 1349
% to be done: interfaced
1350 1351
\installcorenamespace
{
referenceformat
}
1352 1353
\installcommandhandler
\??referenceformat
{
referenceformat
}
\??referenceformat
1354 1355
\appendtoks
1356
\setuevalue
\currentreferenceformat
{
\strc_references_apply_format
{
\currentreferenceformat
}
}
%
1357
\to
\everydefinereferenceformat
1358 1359
\setupreferenceformat
1360
[
\c!left
=
,
1361
\c!right
=
,
1362
\c!text
=
,
1363
\c!label
=
,
1364
\c!autocase
=
\v!no
,
1365
\c!style
=
,
1366
\c!type
=
default
,
% to be done: interfaced
1367
\c!setups
=
,
1368
\c!color
=
]
1369 1370
\protected
\def
\strc_references_apply_format
#
name
%
1371
{
\strc_references_start_goto
1372
\edef
\currentreferenceformat
{
#
name
}
%
1373
\enforced
\gdef
\leftofreference
{
\referenceformatparameter
\c!left
}
%
1374
\enforced
\gdef
\rightofreference
{
\referenceformatparameter
\c!right
}
%
1375
\edef
\currentreferenceformatlabel
{
\referenceformatparameter
\c!label
}
%
1376
\edef
\currentreferenceformattype
{
\referenceformatparameter
\c!type
}
%
1377
\edef
\currentreferenceformatsetups
{
\referenceformatparameter
\c!setups
}
%
1378
\edef
\currentreferenceformatautocase
{
\referenceformatparameter
\c!autocase
}
%
1379
\usereferenceformatstyleandcolor
\c!style
\c!color
1380
\ifempty
\currentstyleparameter
\else
1381
\resetinteractionparameter
\c!style
1382
\fi
1383
\ifempty
\currentcolorparameter
\else
1384
\resetinteractionparameter
\c!contrastcolor
1385
\resetinteractionparameter
\c!color
1386
\fi
1387
\ifx
\currentreferenceformatlabel
\wildcardsymbol
1388
\edef
\currentreferenceformatlabel
{
\autoreferencelabeltext
}
%
1389
\fi
1390
\ifx
\currentreferenceformatautocase
\v!yes
1391
\setcharactercleaning
[
1
]
%
1392
\fi
1393
\ifempty
\currentreferenceformatlabel
1394
\defaultleftreferencetoks
{
\referenceformatparameter
\c!text
}
%
1395
\defaultrightreferencetoks
\emptytoks
1396
\else
1397
\defaultleftreferencetoks
{
\leftlabeltext
\currentreferenceformatlabel
}
%
1398
\defaultrightreferencetoks
{
\rightlabeltext
\currentreferenceformatlabel
}
%
1399
\fi
1400
\ifempty
\currentreferenceformattype
1401
\def
\currentreferenceformattype
{
default
}
%
1402
\fi
1403
%
1404
\ifempty
\currentreferenceformatsetups
1405
\def
\currentreferencecontent
{
\filterreference
\currentreferenceformattype
}
%
1406
\else
1407
\def
\currentreferencecontent
{
\directsetup
\currentreferenceformatsetups
}
%
1408
\fi
1409
%
1410
\enforced
\let
\leftofreferencecontent
\empty
1411
\enforced
\let
\rightofreferencecontent
\empty
1412
\strc_references_pickup_goto
}
1413 1414
\permanent
\protected
\def
\autoreferencelabeltext
1415
{
\clf_getcurrentreferencemetadata
{
name
}
}
1416 1417
% \starttext
1418
% \definereferenceformat[inxx] [left=(,right=),text=txt]
1419
% \setupinteraction[state=start]
1420
% \chapter[one]{xx}
1421
% [\goto{state}[file(mk-last-state)]]
1422
% [\goto{state} [file(mk-last-state)]]
1423
% [\at{page} [one]]
1424
% [\at{page}[one]]
1425
% [\at{page}{okay}[one]]
1426
% [\inxx{a}{b}[one]]
1427
% \stoptext
1428 1429
% \startsetups referenceformat:numberplustext
1430
% \filterreference{number}, \filterreference{title}
1431
% \stopsetups
1432
%
1433
% \definereferenceformat[hellup][text=Hellup ,setups=referenceformat:numberplustext]
1434 1435
%D In interactive documents going to a specific location is not bound to cross
1436
%D references. The \type {\goto} commands can be used to let users access another
1437
%D part of the document. In this respect, interactive tables of contents and
1438
%D registers can be considered goto's. Because in fact a \type {\goto} is just a
1439
%D reference without reference specific data, the previous macros are implemented
1440
%D using the goto functionality.
1441
%D
1442
%D \showsetup{goto}
1443
%D
1444
%D One important characteristic is that the first argument of \type {\goto} (and
1445
%D therefore \type {\at} and \type {\in} is split at spaces. This means that,
1446
%D although hyphenation is prevented, long references can cross line endings.
1447 1448
% \starttext
1449
% \setupinteraction[state=start]
1450
% [\goto{state}[file(mk-last-state)]]
1451
% [\goto{state} [file(mk-last-state)]]
1452
% \stoptext
1453 1454
\newconditional
\uselocationstrut
\settrue
\uselocationstrut
1455 1456
\permanent
\def
\extrareferencearguments
1457
{
highlight
\luaconditional
\highlighthyperlinks
\space
1458
newwindow
\luaconditional
\gotonewwindow
\space
1459
layer
{
\currentviewerlayer
}
}
1460 1461
\permanent
\protected
\def
\directgoto
1462
{
\ifconditional
\uselocationstrut
1463
\expandafter
\strc_references_direct_goto
1464
\else
1465
\expandafter
\strc_references_direct_goto_htdp
1466
\fi
}
1467 1468
\permanent
\protected
\def
\goto
1469
{
\ifconditional
\uselocationstrut
1470
\expandafter
\strc_references_goto
1471
\else
1472
\expandafter
\strc_references_goto_htdp
1473
\fi
}
1474 1475
% The unbox trick is needed in order to permit \par inside a reference. Otherwise
1476
% the reference attribute migrates to the outer boxes.
1477 1478
\newcount
\lastsavedreferenceattribute
1479 1480
\newbox
\referencebox
1481 1482
\permanent
\def
\revivesavedreferenceattribute
% sometimes handy as no test etc needed
1483
{
\c_attr_reference
\lastsavedreferenceattribute
}
1484 1485
\def
\strc_references_direct_goto
#
content
[
#
label
]
% no test for valid references
1486
{
\dontleavehmode
1487
\begingroup
1488
\c_attr_reference
\attributeunsetvalue
1489
\global
\lastsavedreferenceattribute
\attributeunsetvalue
1490
\iflocation
1491
\clf_injectreference
1492
{
\referenceprefix
}
%
1493
{
#
label
}
%
1494
{
%
1495
height
\ht
\strutbox
1496
depth
\dp
\strutbox
1497
\extrareferencearguments
1498
}
%
1499
\relax
1500
\setlocationattributes
1501
\setstrut
% can be option
1502
\global
\lastsavedreferenceattribute
\lastreferenceattribute
1503
\c_attr_reference
\lastreferenceattribute
1504
\dostarttagged
\t!link
\empty
% not here
1505
#
content
%
1506
\dostoptagged
1507
\else
1508
#
content
%
1509
\fi
1510
\endgroup
}
1511 1512
\def
\strc_references_direct_goto_htdp
#
content
[
#
label
]
% no test for valid references
1513
{
\dontleavehmode
1514
\begingroup
1515
\global
\lastsavedreferenceattribute
\attributeunsetvalue
1516
\c_attr_reference
\attributeunsetvalue
1517
\iflocation
1518
\clf_injectreference
1519
{
\referenceprefix
}
%
1520
{
#
label
}
%
1521
{
%
1522
height
\dimexpr
\interactionparameter
\c!height
\relax
1523
depth
\dimexpr
\interactionparameter
\c!depth
\relax
1524
\extrareferencearguments
1525
}
%
1526
\relax
1527
\setlocationattributes
1528
\c_attr_reference
\lastreferenceattribute
1529
\global
\lastsavedreferenceattribute
\lastreferenceattribute
1530
\dostarttagged
\t!link
\empty
1531
#
content
%
1532
\dostoptagged
1533
\else
1534
#
content
%
1535
\fi
1536
\endgroup
}
1537 1538
\def
\strc_references_goto
#
content
#
dummy
[
#
label
]
% #dummy gobbles spaces
1539
{
\dontleavehmode
1540
\begingroup
1541
%\setbox\referencebox\hbox\bgroup % experiment, might change again to non \par support
1542
\global
\lastsavedreferenceattribute
\attributeunsetvalue
1543
\c_attr_reference
\attributeunsetvalue
1544
\iflocation
1545
\clf_doifelsereference
{
\referenceprefix
}
{
#
label
}
{
\extrareferencearguments
}
%
1546
{
\expandtexincurrentreference
1547
\clf_injectcurrentreferencehtdp
1548
\ht
\strutbox
1549
\dp
\strutbox
1550
\relax
1551
\setlocationattributes
1552
\setstrut
% can be option
1553
\global
\lastsavedreferenceattribute
\lastreferenceattribute
1554
\c_attr_reference
\lastreferenceattribute
1555
\dostarttagged
\t!link
\empty
1556
#
content
%
1557
\dostoptagged
}
%
1558
{
#
content
}
%
1559
\else
1560
#
content
%
1561
\fi
1562
%\egroup\unhbox\referencebox}
1563
\endgroup
}
1564 1565
\def
\strc_references_goto_internal
#
content
#
dummy
[
#
internal
]
% #dummy gobbles spaces
1566
{
\dontleavehmode
1567
\begingroup
1568
\global
\lastsavedreferenceattribute
\attributeunsetvalue
1569
\c_attr_reference
\attributeunsetvalue
1570
\iflocation
1571
\setstrut
% can be option
1572
\strc_references_get_simple_reference
{
#
internal
}
%
1573
\global
\lastsavedreferenceattribute
\currentreferenceattribute
1574
\c_attr_reference
\currentreferenceattribute
1575
\setlocationattributes
1576
\dostarttagged
\t!link
\empty
1577
#
content
%
1578
\dostoptagged
1579
\else
1580
#
content
%
1581
\fi
1582
\endgroup
}
1583 1584
\permanent
\protected
\def
\startgoto
[
#
label
]
%
1585
{
\dontleavehmode
1586
\begingroup
1587
\iflocation
1588
\clf_doifelsereference
{
\referenceprefix
}
{
#
label
}
{
\extrareferencearguments
}
%
1589
{
\expandafter
\strc_references_start_goto_yes
}
%
1590
{
\expandafter
\strc_references_start_goto_nop
}
%
1591
\else
1592
\expandafter
\strc_references_start_goto_nop
1593
\fi
}
1594 1595
\permanent
\protected
\lettonothing
\stopgoto
1596 1597
\permanent
\protected
\def
\strc_references_start_goto_nop
1598
{
\enforced
\let
\stopgoto
\strc_references_stop_goto_nop
}
1599 1600
\permanent
\protected
\def
\strc_references_stop_goto_nop
1601
{
\endgroup
}
1602 1603
\protected
\def
\strc_references_start_goto_yes
1604
{
\expandtexincurrentreference
1605
\clf_injectcurrentreferencehtdp
1606
\ht
\strutbox
1607
\dp
\strutbox
1608
\relax
1609
\setlocationattributes
1610
\setstrut
% can be option
1611
\global
\lastsavedreferenceattribute
\lastreferenceattribute
1612
\c_attr_reference
\lastreferenceattribute
1613
\dostarttagged
\t!link
\empty
1614
\let
\stopgoto
\strc_references_stop_goto_yes
}
1615 1616
\protected
\def
\strc_references_stop_goto_yes
1617
{
\dostoptagged
1618
\endgroup
}
1619 1620
\def
\strc_references_goto_htdp
#
content
#
dummy
[
#
label
]
% dummy gobbles spaces
1621
{
\dontleavehmode
1622
\begingroup
1623
\global
\lastsavedreferenceattribute
\attributeunsetvalue
1624
\c_attr_reference
\attributeunsetvalue
1625
\iflocation
1626
\clf_doifelsereference
{
\referenceprefix
}
{
#
label
}
{
\extrareferencearguments
}
%
1627
{
\expandtexincurrentreference
1628
\clf_injectcurrentreferencehtdp
1629
\dimexpr
\interactionparameter
\c!height
\relax
1630
\dimexpr
\interactionparameter
\c!depth
\relax
1631
\relax
1632
\setlocationattributes
1633
\global
\lastsavedreferenceattribute
\lastreferenceattribute
1634
\c_attr_reference
\lastreferenceattribute
1635
\dostarttagged
\t!link
\empty
1636
#
content
%
1637
\dostoptagged
}
%
1638
{
#
content
}
%
1639
\else
1640
#
content
%
1641
\fi
1642
\endgroup
}
1643 1644
\permanent
\protected
\def
\directgotobox
#
content
[
#
label
]
% no test for valid references
1645
{
\dontleavehmode
1646
\begingroup
1647
\global
\lastsavedreferenceattribute
\attributeunsetvalue
1648
\c_attr_reference
\attributeunsetvalue
1649
\iflocation
1650
\clf_injectreference
1651
{
\referenceprefix
}
%
1652
{
#
label
}
%
1653
{
\extrareferencearguments
}
%
1654
\relax
1655
\setlocationattributes
1656
\global
\lastsavedreferenceattribute
\lastreferenceattribute
1657
\dostarttagged
\t!link
\empty
1658
\hbox
attr
\referenceattribute
\lastreferenceattribute
{
#
content
}
%
1659
\dostoptagged
1660
\else
1661
#
content
%
1662
\fi
1663
\endgroup
}
1664 1665
\permanent
\protected
\def
\directgotospecbox
#
resolver
#
content
[
#
label
]
% no test for valid references
1666
{
\dontleavehmode
1667
\begingroup
1668
\global
\lastsavedreferenceattribute
\attributeunsetvalue
1669
\c_attr_reference
\attributeunsetvalue
1670
\iflocation
1671
\clf_injectreference
1672
{
\referenceprefix
}
%
1673
{
#
label
}
%
1674
{
\extrareferencearguments
}
%
1675
\relax
1676
\setlocationcolorspec
{
#
resolver
}
% no consequence for strut
1677
\global
\lastsavedreferenceattribute
\lastreferenceattribute
1678
\dostarttagged
\t!link
\empty
1679
\hbox
attr
\referenceattribute
\lastreferenceattribute
{
#
content
}
%
1680
\dostoptagged
1681
\else
1682
#
content
%
1683
\fi
1684
\endgroup
}
1685 1686
\permanent
\protected
\def
\directgotodumbbox
#
content
[
#
label
]
% no test for valid references
1687
{
\dontleavehmode
1688
\begingroup
1689
\global
\lastsavedreferenceattribute
\attributeunsetvalue
1690
\c_attr_reference
\attributeunsetvalue
1691
\iflocation
1692
\clf_injectreference
1693
{
\referenceprefix
}
%
1694
{
#
label
}
%
1695
{
\extrareferencearguments
}
%
1696
\relax
1697
\global
\lastsavedreferenceattribute
\lastreferenceattribute
1698
\dostarttagged
\t!link
\empty
1699
\hbox
attr
\referenceattribute
\lastreferenceattribute
{
#
content
}
%
1700
\dostoptagged
1701
\else
1702
#
content
%
1703
\fi
1704
\endgroup
}
1705 1706
\permanent
\protected
\def
\gotobox
#
content
[
#
label
]
%
1707
{
\dontleavehmode
1708
\begingroup
1709
\global
\lastsavedreferenceattribute
\attributeunsetvalue
1710
\c_attr_reference
\attributeunsetvalue
1711
\iflocation
1712
\clf_doifelsereference
{
\referenceprefix
}
{
#
label
}
{
\extrareferencearguments
}
%
1713
{
\expandtexincurrentreference
1714
\clf_injectcurrentreference
1715
\setlocationattributes
1716
\global
\lastsavedreferenceattribute
\lastreferenceattribute
1717
\dostarttagged
\t!link
\empty
1718
\hbox
attr
\referenceattribute
\lastreferenceattribute
{
#
content
}
%
1719
\dostoptagged
}
%
1720
{
#
content
}
%
1721
\else
1722
#
content
%
1723
\fi
1724
\endgroup
}
1725 1726
\permanent
\protected
\def
\gotowdhtbox
#
width
#
height
[
#
label
]
% fast variant for overlays
1727
{
\dontleavehmode
1728
\begingroup
1729
\setbox
\scratchbox
\emptyhbox
1730
\wd
\scratchbox
#
width
%
1731
\ht
\scratchbox
#
height
%
1732
\global
\lastsavedreferenceattribute
\attributeunsetvalue
1733
\c_attr_reference
\attributeunsetvalue
1734
\clf_doifelsereference
{
\referenceprefix
}
{
#
label
}
{
\extrareferencearguments
}
%
1735
{
\clf_injectcurrentreference
1736
\global
\lastsavedreferenceattribute
\lastreferenceattribute
1737
\hpack
attr
\referenceattribute
\lastreferenceattribute
{
\box
\scratchbox
}
}
1738
{
\box
\scratchbox
}
%
1739
\endgroup
}
1740 1741
%D An reference to another document can be specified as a file or as an \URL. Both
1742
%D are handled by the same mechanism and can be issued by saying something like:
1743
%D
1744
%D \starttyping
1745
%D \goto[dictionary::the letter a]
1746
%D \stoptyping
1747
%D
1748
%D One can imagine that many references to such a dictionary are made, so in most
1749
%D cases such a document reference in an indirect one.
1750
%D
1751
%D \showsetup{useexternaldocument}
1752
%D
1753
%D For example:
1754
%D
1755
%D \starttyping
1756
%D \useexternaldocument
1757
%D [dictionary][engldict]
1758
%D [The Famous English Dictionary]
1759
%D \stoptyping
1760
%D
1761
%D The next macro implements these relations, and also take care of loading the
1762
%D document specific references.
1763
%D
1764
%D The \URL\ alternative takes four arguments:
1765
%D
1766
%D \showsetup{useURL}
1767
%D
1768
%D like:
1769
%D
1770
%D \starttyping
1771
%D \useURL
1772
%D [dictionary][http://www.publisher.com/public][engldict]
1773
%D [The Famous English Dictionary]
1774
%D \stoptyping
1775
%D
1776
%D Several specifications are possible:
1777
%D
1778
%D \starttyping
1779
%D \useURL [id] [url] [file] [description]
1780
%D \useURL [id] [url] [file]
1781
%D \useURL [id] [url]
1782
%D \stoptyping
1783
%D
1784
%D This time we don't load the references when no file is specified. This is logical
1785
%D when one keeps in mind that a valid \URL\ can also be a mail address.
1786 1787
\permanent
\tolerant
\protected
\def
\useurl
[
#
label
]
#
spacer
[
#
url
]
#
spacer
[
#
file
]
#
spacer
[
#
description
]
%
1788
{
\clf_useurl
{
#
label
}
{
\detokenize
{
#
url
}
}
{
\detokenize
{
#
file
}
}
{
\detokenize
{
#
description
}
}
}
1789 1790
\permanent
\tolerant
\protected
\def
\usefile
[
#
label
]
#
spacer
[
#
file
]
#
spacer
[
#
description
]
%
1791
{
\clf_usefile
{
#
label
}
{
\detokenize
{
#
file
}
}
{
\detokenize
{
#
description
}
}
}
1792 1793
\aliased
\let
\useURL
\useurl
1794
\aliased
\let
\useexternaldocument
\usefile
1795 1796
\permanent
\def
\doifelseurldefined
#
label
{
\clf_doifelseurldefined
{
#
label
}
}
% todo: no wrap
1797
\permanent
\def
\doifelsefiledefined
#
label
{
\clf_doifelsefiledefined
{
#
label
}
}
% todo: no wrap
1798 1799
\aliased
\let
\doifurldefinedelse
\doifelseurldefined
1800
\aliased
\let
\doiffiledefinedelse
\doifelsefiledefined
1801 1802
%D \macros
1803
%D {url,setupurl}
1804
%D
1805
%D We also have: \type {\url} for directly calling the description. So we can say:
1806
%D
1807
%D \starttyping
1808
%D \useURL [one] [http://www.test.nl]
1809
%D \useURL [two] [http://www.test.nl] [] [Some Site]
1810
%D
1811
%D \url[one] or \from[two] or \goto{Whatever Site}[URL(two)]
1812
%D \stoptyping
1813
%D
1814
%D An \URL\ can be set up with
1815
%D
1816
%D \showsetup{setupurl}
1817 1818
\installcorenamespace
{
url
}
1819 1820
\installdirectcommandhandler
\??url
{
url
}
1821 1822
\setupurl
1823
[
\c!style
=
\v!type
,
1824
\c!color
=
]
1825 1826
\permanent
\protected
\def
\url
[
#
label
]
% move \hyphenatedurl to lua end (is already lua)
1827
{
\dontleavehmode
1828
\begingroup
1829
\useurlstyleandcolor
\c!style
\c!color
1830
\hyphenatedurl
{
\clf_geturl
{
#
label
}
}
%
1831
\endgroup
}
1832 1833
%D This macro is hooked into a support macro, and thereby \URL's break ok, according
1834
%D to the setting of a switch,
1835
%D
1836
%D \startbuffer
1837
%D \useURL
1838
%D [test]
1839
%D [sentence_sentence~sentence//sentence:sentence.sentence]
1840
%D \stopbuffer
1841
%D
1842
%D \typebuffer
1843
%D
1844
%D Such an \URL\ is, depending on the settings, hyphenated as:
1845
%D
1846
%D \getbuffer
1847 1848
%D When defining the external source of information, one can also specify a suitable
1849
%D name (the last argument). This name can be called upon with:
1850
%D
1851
%D \showsetup{from}
1852
%D
1853
%D We keep this for compatibility reasons, hence the hackery.
1854 1855
\permanent
\tolerant
\protected
\def
\strc_references_from
[
#
label
]
%
1856
{
\dontleavehmode
1857
\goto
{
\clf_from
{
#
label
}
}
[
fileorurl
(
#
label
)
]
}
1858 1859
\permanent
\def
\dofromurldescription
#
content
% called at the lua end
1860
{
#
content
}
1861 1862
\permanent
\def
\dofromurlliteral
#
content
% called at the lua end
1863
{
\useurlstyleandcolor
\c!style
\c!color
1864
\hyphenatedurl
{
#
content
}
}
1865 1866
\aliased
\let
\dofromfiledescription
\dofromurldescription
1867
\aliased
\let
\dofromfileliteral
\dofromurlliteral
% maybe some day setupfile that inherits from url
1868 1869
%D We also support:
1870
%D
1871
%D \starttyping
1872
%D \goto{some text}[file(identifier{location}]
1873
%D \stoptyping
1874
%D
1875
%D which is completely equivalent with
1876
%D
1877
%D \starttyping
1878
%D \goto{some text}[identifier::location]
1879
%D \stoptyping
1880 1881
%D A special case of references are those to programs. These, very system dependant
1882
%D references are implemented by abusing some of the previous macros.
1883
%D
1884
%D \showsetup{setupprograms}
1885
%D \showsetup{defineprogram}
1886
%D \showsetup{program} % changed functionality !
1887
%D
1888
%D The latter gives access to the description of the program,
1889
%D being the last argument to the definition command.
1890 1891
% also lua, like urls and files
1892 1893
\installcorenamespace
{
programs
}
1894 1895
\installdirectcommandhandler
\??programs
{
programs
}
1896 1897
\permanent
\tolerant
\protected
\def
\defineprogram
[
#
name
]
#
spacer
[
#
program
]
#
spacer
[
#
description
]
%
1898
{
\clf_defineprogram
{
#
name
}
{
#
program
}
{
#
description
}
}
1899 1900
\permanent
\protected
\def
\program
[
#
name
]
% incompatible, more consistent, hardy used anyway
1901
{
\dontleavehmode
1902
\begingroup
1903
\useprogramsstyleandcolor
\c!style
\c!color
1904
\clf_getprogram
{
#
name
}
%
1905
\endgroup
}
1906 1907
%D As we can see, we directly use the special reference mechanism, which means that
1908
%D
1909
%D \starttyping
1910
%D \goto{some text}[program(name{args})]
1911
%D \stoptyping
1912
%D
1913
%D is valid.
1914 1915
%D The next macro provides access to the actual pagenumbers. When documenting and
1916
%D sanitizing the original reference macros, I decided to keep the present meaning
1917
%D as well as to make this meaning available as a special reference method. So now
1918
%D one can use:
1919
%D
1920
%D \starttyping
1921
%D \gotopage{some text}[location]
1922
%D \gotopage{some text}[number]
1923
%D \gotopage{some text}[file::number]
1924
%D \stoptyping
1925
%D
1926
%D as well as:
1927
%D
1928
%D \starttyping
1929
%D \goto{some text}[page(location)]
1930
%D \goto{some text}[page(number)]
1931
%D \goto{some text}[file::page(number)]
1932
%D \stoptyping
1933
%D
1934
%D Here location is a keyword like \type{nextpage}.
1935
%D
1936
%D \showsetup{gotopage}
1937 1938
\permanent
\tolerant
\protected
\def
\definepage
[
#
name
]
#
spacer
[
#
target
]
%
1939
{
\definereference
[
#
name
]
[
page
(
#
target
)
]
}
1940 1941
\permanent
\protected
\def
\gotopage
#
text
[
#
target
]
%
1942
{
\goto
{
#
text
}
[
\v!page
(
#
target
)
]
}
1943 1944
%D The previous definitions are somewhat obsolete so we don't use it here.
1945 1946
%D We can cross link documents by using:
1947
%D
1948
%D \showsetup{coupledocument}
1949
%D
1950
%D like:
1951
%D
1952
%D \starttyping
1953
%D \coupledocument[print][somefile][chapter,section]
1954
%D \stoptyping
1955
%D
1956
%D After which when applicable, we have available the references:
1957
%D
1958
%D \starttyping
1959
%D \goto{print version}[print::chapter]
1960
%D \stoptyping
1961
%D
1962
%D and alike. The title placement definition macros have a key \type {file}, which
1963
%D is interpreted as the file to jump to, that is, when one clicks on the title.
1964 1965
\permanent
\tolerant
\protected
\def
\coupledocument
[
#
name
]
#
spacer
[
#
file
]
#
spacer
[
#
sections
]
#
spacer
[
#
description
]
%
1966
{
}
% this will be done differently (when it's needed)
1967 1968
%D \macros
1969
%D {dotextprefix}
1970
%D
1971
%D In previous macros we used \type {\dotextprefix} to generate a space between
1972
%D a label and a number.
1973
%D
1974
%D \starttyping
1975
%D \dotextprefix{text}
1976
%D \stoptyping
1977
%D
1978
%D Only when \type {text} is not empty, a space is inserted.
1979 1980
\permanent
\protected
\def
\dotextprefix
#
text
%
1981
{
\begingroup
1982
\setbox
\scratchbox
\hbox
{
#
text
}
% to be solved some day
1983
\ifdim
\wd
\scratchbox
>
\zeropoint
1984
\unhbox
\scratchbox
1985
\edef
\p_separator
{
\referencingparameter
\c!separator
}
%
1986
\ifempty
\p_separator
\else
1987
\removeunwantedspaces
% remove is new
1988
\p_separator
1989
\fi
1990
\else
1991
\unhbox
\scratchbox
1992
\fi
1993
\endgroup
}
1994 1995
%D In the next settings we see some variables that were not used here and that
1996
%D concern the way the pagenumbers refered to are typeset.
1997 1998
\setupreferencing
1999
[
\c!state
=
\v!start
,
2000
\c!autofile
=
\v!no
,
2001
\v!part
\c!number
=
\v!yes
,
2002
\v!chapter
\c!number
=
\v!no
,
2003
\c!interaction
=
\v!all
,
2004
\c!convertfile
=
\v!no
,
2005
%\c!strut=\v!no, % some day an option
2006
\c!prefix
=
,
2007
\c!width
=
.
7
5
\makeupwidth
,
2008
\c!left
=
\quotation
\bgroup
,
2009
\c!right
=
\egroup
,
2010
\c!global
=
\v!no
,
2011
\c!expansion
=
\v!no
,
2012
\c!separator
=
\nonbreakablespace
,
2013
\c!export
=
\v!no
]
2014 2015
\setupprograms
2016
[
\c!directory
=
,
2017
\c!style
=
\v!type
,
2018
\c!color
=
]
2019 2020
\definereference
[
\v!CloseDocument
]
[
action
(
close
)
]
2021
\definereference
[
\v!ExitViewer
]
[
action
(
exit
)
]
2022
\definereference
[
\v!FirstPage
]
[
action
(
first
)
]
2023
\definereference
[
\v!LastPage
]
[
action
(
last
)
]
2024
\definereference
[
\v!NextJump
]
[
action
(
forward
)
]
2025
\definereference
[
\v!NextPage
]
[
action
(
next
)
]
2026
\definereference
[
\v!PauseRendering
]
[
action
(
pauserendering
)
]
2027
\definereference
[
\v!PreviousJump
]
[
action
(
backward
)
]
2028
\definereference
[
\v!PreviousPage
]
[
action
(
previous
)
]
2029
\definereference
[
\v!PrintDocument
]
[
action
(
print
)
]
2030
\definereference
[
\v!SaveForm
]
[
action
(
exportform
)
]
2031
\definereference
[
\v!LoadForm
]
[
action
(
importform
)
]
2032
\definereference
[
\v!ResetForm
]
[
action
(
resetform
)
]
2033
\definereference
[
\v!ResumeRendering
]
[
action
(
resumerendering
)
]
2034
\definereference
[
\v!SaveDocument
]
[
action
(
save
)
]
2035
\definereference
[
\v!SaveNamedDocument
]
[
action
(
savenamed
)
]
2036
\definereference
[
\v!OpenNamedDocument
]
[
action
(
opennamed
)
]
2037
\definereference
[
\v!SearchDocument
]
[
action
(
search
)
]
2038
\definereference
[
\v!SearchAgain
]
[
action
(
searchagain
)
]
2039
\definereference
[
\v!StartRendering
]
[
action
(
startrendering
)
]
2040
\definereference
[
\v!StopRendering
]
[
action
(
stoprendering
)
]
2041
\definereference
[
\v!SubmitForm
]
[
action
(
submitform
)
]
2042
\definereference
[
\v!ToggleViewer
]
[
action
(
toggle
)
]
2043
\definereference
[
\v!ViewerHelp
]
[
action
(
help
)
]
2044
\definereference
[
\v!HideField
]
[
action
(
hide
)
]
2045
\definereference
[
\v!ShowField
]
[
action
(
show
)
]
2046
\definereference
[
\v!GotoPage
]
[
action
(
gotopage
)
]
2047
\definereference
[
\v!Query
]
[
action
(
query
)
]
2048
\definereference
[
\v!QueryAgain
]
[
action
(
queryagain
)
]
2049
\definereference
[
\v!FitWidth
]
[
action
(
fitwidth
)
]
2050
\definereference
[
\v!FitHeight
]
[
action
(
fitheight
)
]
2051
\definereference
[
\v!ShowThumbs
]
[
action
(
thumbnails
)
]
2052
\definereference
[
\v!ShowBookmarks
]
[
action
(
bookmarks
)
]
2053 2054
\definereference
[
\v!HideLayer
]
[
action
(
hidelayer
)
]
2055
\definereference
[
\v!VideLayer
]
[
action
(
videlayer
)
]
2056
\definereference
[
\v!ToggleLayer
]
[
action
(
togglelayer
)
]
2057 2058
\definereference
[
\v!firstpage
]
[
page
(
firstpage
)
]
2059
\definereference
[
\v!previouspage
]
[
page
(
previouspage
)
]
2060
\definereference
[
\v!nextpage
]
[
page
(
nextpage
)
]
2061
\definereference
[
\v!lastpage
]
[
page
(
lastpage
)
]
2062
\definereference
[
\v!forward
]
[
page
(
forward
)
]
2063
\definereference
[
\v!backward
]
[
page
(
backward
)
]
2064
\definereference
[
\v!firstsubpage
]
[
page
(
firstsubpage
)
]
2065
\definereference
[
\v!previoussubpage
]
[
page
(
previoussubpage
)
]
2066
\definereference
[
\v!nextsubpage
]
[
page
(
nextsubpage
)
]
2067
\definereference
[
\v!lastsubpage
]
[
page
(
lastsubpage
)
]
2068 2069
% we can do this but only when later in resolve (else problems with \chapter[first]{...}
2070
%
2071
% \definereference [\v!first] [page(firstpage)]
2072
% \definereference [\v!previous] [page(prevpage)]
2073
% \definereference [\v!next] [page(nextpage)]
2074
% \definereference [\v!last] [page(lastpage)]
2075
% \definereference [\v!first\v!sub] [page(firstsubpage)]
2076
% \definereference [\v!previous\v!sub] [page(prevsubpage)]
2077
% \definereference [\v!next\v!sub] [page(nextsubpage)]
2078
% \definereference [\v!last\v!sub] [page(lastsubpage)]
2079 2080
%D We cannot set up buttons (not yet, this one calls a menu macro):
2081 2082
%D New (and experimental):
2083 2084
% \starttext
2085
% \chapter{test}
2086
% \placefigure[here][xx:1]{}{\framed{one}} \placefigure[here][xx:2]{}{\framed{three}}
2087
% \placetable [here][xx:3]{}{\framed{two}} \placetable [here][xx:4]{}{\framed{four}}
2088
% \start
2089
% \in{fig}[xx:1] and \in{fig}[xx:2] \in{tab}[xx:3] and \in{tab}[xx:4]
2090
% \stop \blank \start
2091
% \setupreferencestructureprefix[default][prefix=no]
2092
% \in{fig}[xx:1] and \in{fig}[xx:2] \in{tab}[xx:3] and \in{tab}[xx:4]
2093
% \stop \blank \start
2094
% \setupreferencestructureprefix[float][default][prefix=no]
2095
% \in{fig}[xx:1] and \in{fig}[xx:2] \in{tab}[xx:3] and \in{tab}[xx:4]
2096
% \stop \blank \start
2097
% \setupreferencestructureprefix[figure][default][prefix=no]
2098
% \in{fig}[xx:1] and \in{fig}[xx:2] \in{tab}[xx:3] and \in{tab}[xx:4]
2099
% \stop \blank
2100
% \stoptext
2101 2102
% todo: parameterhandler
2103 2104
\installcorenamespace
{
referencingprefix
}
2105 2106
\permanent
\def
\getreferencestructureprefix
#
kind
#
name
#
category
% name will change
2107
{
{
%
2108
prefix
{
\referencestructureprefixparameter
{
#
kind
}
{
#
name
}
{
#
category
}
\c!prefix
}
%
2109
separatorset
{
\referencestructureprefixparameter
{
#
kind
}
{
#
name
}
{
#
category
}
\c!prefixseparatorset
}
%
2110
conversion
{
\referencestructureprefixparameter
{
#
kind
}
{
#
name
}
{
#
category
}
\c!prefixconversion
}
%
2111
conversionset
{
\referencestructureprefixparameter
{
#
kind
}
{
#
name
}
{
#
category
}
\c!prefixconversionset
}
%
2112
starter
{
\referencestructureprefixparameter
{
#
kind
}
{
#
name
}
{
#
category
}
\c!prefixstarter
}
%
2113
stopper
{
\referencestructureprefixparameter
{
#
kind
}
{
#
name
}
{
#
category
}
\c!prefixstopper
}
%
2114
set
{
\referencestructureprefixparameter
{
#
kind
}
{
#
name
}
{
#
category
}
\c!prefixset
}
%
2115
segments
{
\referencestructureprefixparameter
{
#
kind
}
{
#
name
}
{
#
category
}
\c!prefixsegments
}
%
2116
connector
{
\referencestructureprefixparameter
{
#
kind
}
{
#
name
}
{
#
category
}
\c!prefixconnector
}
%
2117
}
%
2118
{
%
2119
separatorset
{
\referencestructureprefixparameter
{
#
kind
}
{
#
name
}
{
#
category
}
\c!numberseparatorset
}
%
2120
conversion
{
\referencestructureprefixparameter
{
#
kind
}
{
#
name
}
{
#
category
}
\c!numberconversion
}
%
2121
conversionset
{
\referencestructureprefixparameter
{
#
kind
}
{
#
name
}
{
#
category
}
\c!numberconversionset
}
%
2122
starter
{
\referencestructureprefixparameter
{
#
kind
}
{
#
name
}
{
#
category
}
\c!numberstarter
}
%
2123
stopper
{
\referencestructureprefixparameter
{
#
kind
}
{
#
name
}
{
#
category
}
\c!numberstopper
}
%
2124
segments
{
\referencestructureprefixparameter
{
#
kind
}
{
#
name
}
{
#
category
}
\c!numbersegments
}
%
2125
}
}
2126 2127
\permanent
\tolerant
\protected
\def
\setupreferencestructureprefix
[
#
kind
]
#
spacer
[
#
category
]
#
spacer
[
#
settings
]
%
2128
{
\ifarguments
\or
\or
2129
\getparameters
[
\??referencingprefix
:
#
kind
]
[
#
category
]
%
2130
\else
2131
\getparameters
[
\??referencingprefix
#
kind
:
#
category
]
[
#
settings
]
%
2132
\fi
}
2133 2134
\permanent
\def
\referencestructureprefixparameter
#
kind
#
name
#
category
#
parameter
%
2135
{
\ifcsname
\??referencingprefix
#
name
:
#
category
#
parameter
\endcsname
2136
\lastnamedcs
2137
\orelse
\ifcsname
\??referencingprefix
#
kind
:
#
category
#
parameter
\endcsname
2138
\lastnamedcs
2139
\orelse
\ifcsname
\??referencingprefix
:
#
category
#
parameter
\endcsname
2140
\lastnamedcs
2141
\fi
}
2142 2143
\permanent
\def
\currentreferencedefault
% for some reason we need to explicitly expand
2144
{
\normalexpanded
{
\noexpand
\clf_filterdefaultreference
2145
{
\s!default
}
%
2146
\noexpand
\getreferencestructureprefix
\clf_getcurrentprefixspec
{
\s!default
}
% returns #kind#name#category
2147
\relax
}
}
2148 2149
%D Not all support is visible by looking at the \TEX\ code; here is one of those:^
2150
%D
2151
%D \starttyping
2152
%D \startinteractionmenu[right]
2153
%D \startbut [section(first {chapter})] first chapter \stopbut
2154
%D \startbut [section(previous{chapter})] previous chapter \stopbut
2155
%D \startbut [section(next {chapter})] next chapter \stopbut
2156
%D \startbut [section(last {chapter})] last chapter \stopbut
2157
%D \blank[2*big]
2158
%D \startbut [section(first {section})] first section \stopbut
2159
%D \startbut [section(previous{section})] previous section \stopbut
2160
%D \startbut [section(next {section})] next section \stopbut
2161
%D \startbut [section(last {section})] last section \stopbut
2162
%D \stopinteractionmenu
2163
%D \stoptyping
2164 2165
%D Relatively new:
2166
%D
2167
%D \starttyping
2168
%D \chapter{The never ending story}
2169
%D
2170
%D \section{An ending story}
2171
%D
2172
%D \in{chapter}[match(complex bibliographies)]
2173
%D \in{chapter}[match(never ending)]
2174
%D \in{chapter}[match(ending)]
2175
%D \in{chapter}[match(chapter:never ending)]
2176
%D \in{chapter}[match(chapter:ending)]
2177
%D \in{section}[match(section:ending)]
2178
%D \in{figure}[match(float:mess)]
2179
%D \in{figure}[match(figure:mess)]
2180
%D \in{figure (not found)}[match(section:mess)]
2181
%D \in{figure (not found)}[match(section:xxxx)]
2182
%D \in{figure}[match(mess)]
2183
%D
2184
%D \placefigure{What a mess}{}
2185
%D
2186
%D \chapter{About complex bibliographies}
2187
%D
2188
%D \in{chapter}[match(complex bibliographies)]
2189
%D \in{chapter}[match(never ending)]
2190
%D \in{figure}[match(mess)]
2191
%D \stoptyping
2192 2193
\protect
\endinput
2194 2195
% tricky:
2196
%
2197
% \enabletrackers[nodes.references]
2198
% \setupinteraction[state=start]
2199
% \def\KnuthTest{\input knuth }
2200
% \def\KnuthTest{\input tufte }
2201
% \def\TufteTest{\input tufte }
2202
% \defineoverlay[xxx][\overlaybutton{page(3)}]
2203
% \setupbackgrounds[text][background=xxx]
2204
% \starttext
2205
% test {\red \KnuthTest} test \par
2206
% \button{test}[page(1)] \par
2207
% \goto{page 2 \TeX}[page(2)] \goto{page 2 \TeX}[page(2)] \goto{\TufteTest}[page(2)] test \page
2208
% test \goto{page 3}[page(3)] \goto{\TufteTest\space\par\TufteTest}[page(4)] test \page
2209
% \goto{page 1}[page(1)] \goto{\TufteTest\space test}[page(1)] \page
2210
% \goto{page 1}[page(1)] \goto{\KnuthTest\space test}[page(1)] \page
2211
% test \goto{page 1}[page(1)] {\goto{\KnuthTest\space test}[page(1)]} test
2212
% \goto{page 1}[page(1)] \goto{\TufteTest}[page(1)] test \page
2213
% \stoptext
2214