summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/context/manuals/reference/en/co-blocks.tex
blob: 8d6f4ad067d9aaa2167df1b593d11020dd13c89a (plain)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
\startcomponent co-en-13

\environment contextref-env
\product contextref

\chapter[blocks]{Blocks}

\section{Introduction}
\index{blocks}
\index{floats}
\index{placing+blocks}

A block in \CONTEXT\ is defined as typographical unit
that needs specific handling. We distinguish the following
block types:

\startitemize

\head floats

      Examples of floats are figures, tables, graphics,
      intermezzos etc. The locations of these blocks are
      determined by \TEX\ and depends on the available space
      on a page.

\head textblocks

      Examples of textblocks are questions and answers in a
      studybook, summaries, definitions or derivatives of
      formulas. The location of these kind of blocks in the
      final document cannot be determined beforehand. And
      the information may be used repeatedly in several
      settings.

\head opposite blocks

      Opposite (or spread) blocks are typeset on the
      left||hand page when a single sided output is
      generated. The layout of the right||hand side page is
      influenced by the blocks on the left.

\head margin blocks

      Margin blocks are more extensive than single margin
      words. Text and figures can be placed in the margin
      with this feature.

\stopitemize

There are a number of commands that support the use of these
block types. These are discussed in this chapter.
Furthermore we will discuss other forms of text
manipulation. Formulas can also be seen as blocks. Since
formulas are covered in a separate chapter we don't go into
details here.

This chapter is typeset with the option \type {\version
[temporary]}. This does not refer to the content but to the
typesetting. With this option, design information is placed
in the margin.

\start    % in verband met \versie[voorlopig]

\version[temporary] \overfullrule=0pt

\section[floats]{Floats}
\index{figures+placing}
\index{tables+placing}
\index{figures+numbering}
\index{tables+numbering}
\index{figures+listing}
\index{tables+listing}
\index{placing+figures}
\index{placing+tables}
\index{numbering+figures}
\index{numbering+tables}
\index{listing+figures}
\index{listing+tables}
\macro{\tex{definefloat}}
\macro[placefloat]{\tex{place<<float>>}}
\macro[placelistoffloats]{\tex{placelistof<<floats>>}}
\macro[completelistoffloats]{\tex{completelistof<<floats>>}}
\macro[reservefloat]{\tex{reserve<<float>>}}
\macro[setupfloat]{\tex{setup<<floats>>}}
\macro[startfloattest]{\tex{start<<float>>text}}
\macro{\tex{setupfloats}}
\macro{\tex{setupcaptions}}

Floats are composed of very specific commands. For example a
table in \CONTEXT\ is typeset using a shell around \TABLE.
Drawings and graphics are made with external packages, as
\TEX\ is only capable of reserving space for graphics.

Most floats are numbered and may have a caption. A float is
defined with the command:

\showsetup{definefloat}

In \CONTEXT, figures, graphics, tables, and intermezzos are
predefined with:

\startexample
\starttyping
\definefloat [figure]     [figures]
\definefloat [table]      [tables]
\definefloat [graphic]    [graphics]
\definefloat [intermezzo] [intermezzos]
\stoptyping
\stopexample

As a result of these definitions you can always use \type
{\placefigure}, \type {\placetable}, \type {\placegraphic}
and \type {\placeintermezzo}. Of course, you can define your
own floats with \type {\definefloat}. You place your newly
defined floats with the command:

\showsetup{place<<float>>}

When a float cannot be placed at a specific location on a
page, \CONTEXT\ will search for the most optimal
alternative. \CONTEXT\ provides a number of placement options
for floats. These are listed in \in {table} [tab:floats].

\placetable
  [here][tab:floats]
  {Preferences for float placement.}
\starttable[|l|l|]
\HL
\VL \bf preference                \VL
    \bf result                    \VL\SR
\HL
\VL \type{left}                   \VL
    left of text                  \VL\FR
\VL \type{right}                  \VL
    right of text                 \VL\MR
\VL \type{here}                   \VL
    preferably here               \VL\MR
\VL \type{top}                    \VL
    at top of page                \VL\MR
\VL \type{bottom}                 \VL
    at bottom of page             \VL\MR
\VL \type{inleft}                 \VL
    in left margin                \VL\MR
\VL \type{inright}                \VL
    in right margin               \VL\MR
\VL \type{inmargin}               \VL
    in the margin (left or right) \VL\MR
\VL \type{margin}                 \VL
    in the margin (margin float)  \VL\MR
\VL \type{page}                   \VL
    on a new (empty) page         \VL\MR
\VL \type{opposite}               \VL
    on the left page              \VL\MR
\VL \type{always}                 \VL
    precedence over stored floats \VL\MR
\VL \type{force}                  \VL
    per se here                   \VL\LR
\HL
\stoptable

The commands can be used without the left and right brackets.
For example:

\startexample
\starttyping
\place...{<<caption>>}{<<content>>}
\stoptyping
\stopexample

When the caption is left out, the float number is generated
anyway. When the number is not needed you type \type {none},
like in:

\starttyping
\placefigure{none}{.....}
\stoptyping

It is mandatory to end this command by an empty line or a
\type {\par}. You don't have to embed a table in braces,
since the \type {\start} and \type {\stop} commands have
them built in:

\startbuffer
\placetable
  [here][tab:example]
  {A very simple example of a table.}
  \starttable[|c|c|]
  \HL
  \VL this \VL is     \VL\FR
  \VL a    \VL table  \VL\LR
  \HL
  \stoptable
\stopbuffer

\startexample
\typebuffer
\stopexample

\start
\setuptables[VL=medium,HL=medium]
\getbuffer
\stop

The vertical whitespace for a float can be reserved with:

\showsetup{reserve<<float>>}

This command can be used without the left and right bracket.
An example of a reservation is:

\startbuffer
\reservefigure
  [height=4cm,width=10cm,frame=on][here][fig:reservation]
  {An example of a reservation.}
\stopbuffer

\startexample
\typebuffer
\stopexample

Which results in \in{figure}[fig:reservation].

\getbuffer

When the content of a float is not yet available, you can type
\type {\empty...} instead of \type {\place...}. In this way
you can also reserve vertical whitespace. When no option is
added, so \argchars\ is typed, the default empty float is
used. However, whether the figure or table is available is
not that important. You can always type:

\startexample
\starttyping
\placefigure{This is a figure caption.}{}
\stoptyping
\stopexample

As a first argument you can specify a key \type {left} or
\type {right} that will cause \CONTEXT\ to let the text flow
around the float. The second optional parameter can be a
cross reference, to be used later, like \type {\at {page}
[fig:schematic process]}.

\startexample
\starttyping
\placefigure[here][fig:demo]{This a figure caption.}{}
\stoptyping
\stopexample

As we will later see, you can also use the next command:

\showsetup{start<<float>>text}

Preferences are \type {left}, \type {right} or \type
{middle}. Furthermore you can specify \type {offset} in case
the text should align with the float. Both setups can be
combined: \type {[left,offset]}.

A list of used floats is generated with the command:

\showsetup{placelistof<<floats>>}

For example, the command \type {\placelistoffigures} would
typeset a list of figures. The list follows the numbering
convention that is set with the command \type
{\setupnumbering}, which was discussed at \at {page}
[numbering].

The next command generates a list of floats on a separate
page.

\showsetup{completelistof<<floats>>}

Pagebreaks that occur at unwanted locations can be enforced
in the same way that is done with a table of contents (see
\in{section}[toc]):

\startexample
\starttyping
\completelistof<<floats>>[pageboundaries={8.2,20.4}]
\stoptyping
\stopexample

As with tables of content the default local lists are
generated. Recalling a list within a chapter produces a list
for that specific chapter. So, if you want a list of all
figures, you need to specify \type {criterium} as \type
{all}.

\startbuffer
\placelistoffigures[criterium=chapter]
\stopbuffer

\getbuffer

The previous list was produced by saying:

\typebuffer

The characteristics of a specific class of floats are
specified with the command:

\showsetup{setupfloat}

The (predefined) floats can also be set up with the more
meaningful commands \type {\setupfigures}, \type
{\setuptables} etc.

The height and width relate to the vertical whitespace that
should be reserved for an empty float. All settings of \type
{\framed} can be used, so when \type {frame} is set to \type
{on}, we get a framed float.

The next two commands relate to {\em all} floats. The first
command is used for setting the layout including the caption:

\showsetup{setupfloats}

The second command is used for setting the enumerated
captions of figures, tables, intermezzos, etc.

\showsetup{setupcaptions}

You can also set up captions for a specific class of floats,
like figures. The first argument of the next command is the
name of that class of floats.

\showsetup{setupcaption}

The commands assigned to \type {before}, \type {after} are
are executed before and after placing the float. The
parameter \type {inbetween} is executed between the float
and the caption. All three normally have a \type {\blank}
command assigned.

The parameter \type {style} is used for numbering ({\bf
Figure~x.y}) and \type {width} for the width of the caption
label. The parameter \type {margin} specifies the margin
space around a float when it is surrounded by text. The
float macros optimize the width of the caption (at \type
{top} or \type {bottom}) related to the width of the figure
or table.

\start
\setupcaptions[location=high]
\setupfloats[location=left]
\placefigure[force]{}
\startframedtext
\starttyping
\setupcaptions[location=high]
\setupfloats[location=left]
\stoptyping
\stopframedtext
\stop

With the three variables \type{ntop}, \type{nbottom} and
\type{nlines} the float storage mechanism can be influenced.
The first two variables specify the maximum number of floats
that are saved per page at the top or the bottom of a page.

By default these variables have the values ~2 and~0. Assume
that ten figures, tables and|/|or other floats are stored,
then by default two floats will be placed at each new page
(if possible). For example, at a forced pagebreak or at the
beginning of a new chapter, all stored floats are placed.

The parameter \type {nlines} has the default value~4. This
means that never less than four lines will be typeset on the
page where the floats are placed.

We continue with a few examples of floats (figures) placed
next to the running text. This looks like:


\startexample
\starttyping
\placefigure[right]{none}{}

... here is where the text starts ....
\stoptyping
\stopexample

For illustrating the mechanism we do need some text.
Therefore the examples are used to explain some issues on the
float mechanism.

Floats are placed automatically. The order of appearance
follows the order you have keyed in the source. This means
that larger floats are placed somewhere else in your
document. When \type{\version[temporary]} is set, you can
get information on the float mechanism. By consulting that
information you get some insight into the process.

\placefigure[right]{none}{\externalfigure[rb00006]}

Floats can be surrounded by text. The float at the right was
set with \type {\placefigureright[right]{none}{...}}. The
float mechanism works automatically. Should it occur that
pages are left blank as a result of poor float placement,
you will need to make some adaptations manually. You can
downsize your figure or table or alter your text. It is also
a good practice to define your float some paragraphs up in
your source. However, all of this should be done at the
final production stage.

With the key \type{force} you can force a float to be placed
at that exact location. Tables or figures that are preceded
by text like: \quote{as we can see in the figure below} may
be defined with this option.

\placefigure[left]{none}{\externalfigure[rb00008]}

In manuals and study books we encounter many illustrations.
It is almost unavoidable to manually adapt these for optimal
display. However, the float commands in \CONTEXT\ are
optimized in such a way that you can produce books with
hundreds of floats effortlessly. The worst case is that some
floats are stored and placed at the end of the chapter. But
this can be influenced with the command \type
{\startpostponing}. Postponing is done with the keys \type
{always} which can be combined with the location, like \type
{[left,always]} or \type {[here,always]}. Because the order
of the floats is changed several parses are necessary for
the document. These processes can be traced via messages
on the terminal.

This brings us to a figure that is placed at the left side
of a page. The side float mechanism in inspired and based on
a mechanism of D.~Comenetz. In the background three
mechanisms are active. A mechanism to typeset a figure on
top, inbetween, of under existing text. There is a mechanism
to place figures on the right or left of a page. And there
is a third mechanism to typeset text next to a figure.

\startfiguretext[right]{none}{\externalfigure[rb00015]}

We see an example of the last mechanism. The text is
enclosed by the commands:

\starttyping
\startfiguretext
   [right]{none}{\externalfigure[rb00015]}
....
\stopfiguretext
\stoptyping

\stopfiguretext

\startfiguretext[left,offset]{none}{\externalfigure[vos1082]}

It is obvious that we can also place the figure at the left.
With \type {\start...text} we can add the key \type
{offset}. Here we used \type {[left,offset]}.

When the text is longer than expected, then it will {\em not}
flow around the float. By default the floats are handled in the
same order they are typed in the source file. This means that the
stored figures are placed first. If this is not desired you
can type the key \type{always}. The actual float will get
priority.
\stopfiguretext

\startfiguretext[right,middle]{none}{\externalfigure[vos1083]}

There are more options. In this case the setup \type
{[right,middle]} is given. In the same way we place text
\type {high} and \type {low}.

When the key \type {long} is used the rest of the text is
filled out with empty lines, as here.

\stopfiguretext

When several figures are set under each other, making them
the same width makes for a nice presentation on the page.
This looks better.

\section{Combining figures}
\index{figures+combining}
\index{combining}
\macro{\tex{startcombination}}
\macro{\tex{setupcombinations}}
\macro{\tex{placesidebyside}}
\macro{\tex{placeontopofeachother}}

For reasons of convenience we now discuss a command
that enables us to combine floats into one.

\showsetup{startcombination}

This command is used to place the figures under or next to
each other.

\startbuffer
\placefigure
  [here]
  [fig:combinations]
  {An example of \type{\startcombination...}.}
  {\startcombination[3*2]
     {\externalfigure[lb00220]} {a} {\externalfigure[lb00221]} {b}
     {\externalfigure[lb00222]} {c} {\externalfigure[lb00223]} {d}
     {\externalfigure[lb00225]} {e} {\externalfigure[lb00226]} {f}
   \stopcombination}
\stopbuffer

\getbuffer

The example in \in{figure}[fig:combinations] is typeset
with the commands:

\startexample
\typebuffer
\stopexample

Between \setchars\ we specify how the combination is
combined: \type{[3*2]}, \type{[4*2]} etc. When we put two
floats next to each other it is sufficient to specify
\type{[2]}, \type{[4]} etc.

The floats, mostly figures or tables, are specified within
two arguments. The first content is placed over the second
content: \type{{xxx}{yyy}}. The second argument can be
empty: \type{{xxx}{}}. The general construct looks like
this:

\startexample
\starttyping
\startcombination[n*m]
  {text 1} {subcaption 1}
  {text 2} {subcaption 2}
  ........ ..............
\stopcombination
\stoptyping
\stopexample

The combination can be set up with:

\showsetup{setupcombinations}

With \type{distance} you specify the horizontal distance
between objects. The parameters \type{align} relates to
the subcaption. By default the text and objects are centered.
The width is the total width of the combination.

The three parameters \type{before}, \type{after} and
\type{between} are processed in the order of specification
in \in{figure}[fig:order of combinations]. There are some
examples in \in{figure}[fig:spacing in combinations]. We can
see in \in{figure}[fig:no subcaptions] that when the title
in the second argument is empty the spacing adapted.

\startbuffer
\startcombination[4]
  {\framed{test}} {\framed{a}}
  {\framed{test}} {\framed{b}}
  {\framed{test}} {\framed{c}}
  {\framed{test}} {\framed{d}}
\stopcombination
\stopbuffer

\setbox4=\vbox
  {\setupcombinations[inbetween={\blank[big]}]\getbuffer}

\setbox6=\vbox
  {\setupcombinations[inbetween={\blank[medium]}]\getbuffer}

\setbox8=\vbox
  {\setupcombinations[inbetween={\blank[small]}]\getbuffer}

\placefigure
  [here][fig:spacing in combinations]
  {The spacing within combinations (1).}
\startcombination[3]
   {\box4} {\arg{\blank[big]}}
   {\box6} {\arg{\blank[medium]}}
   {\box8} {\arg{\blank[small]}}
\stopcombination

\placefigure
  [here][fig:order of combinations]
  {The spacing within combinations (2).}
  {\forgetall
   \setupframed[width=4cm]
   \framed[height=3cm,frame=on]{figure}%
   \framed[frame=off]{\type{<inbetween>}}%
   \framed[height=1cm,frame=on]{subtitle}%
   \framed[frame=off]{\type{<after>}}%
   \framed[frame=off]{\type{<before>}}}

\placefigure
  [here][fig:no subcaptions]
  {Combinations without captions.}
\startcombination[3]
  {\externalfigure[vew1095]} {}
  {\externalfigure[vew1096]} {}
  {\externalfigure[vew1097]} {}
\stopcombination

Using combinations require figures that have the correct
dimensions or equal proportions. Unequally proportioned
figures are hard to combine.

The simple version of combining is this:

\showsetup{placesidebyside}

\showsetup{placeontopofeachother}

We use them in this way:

\starttyping
\placesidebyside       {\framed{\Logo[ADE]}} {\framed{\Logo[BUR]}}
\placeontopofeachother {\framed{\Logo[ADE]}} {\framed{\Logo[BUR]}}
\stoptyping

\section[textblocks]{Text blocks}
\index{moving text}
\index{blocks+moving}
\index{blocks+numbering}
\index{numbering+blocks}
\macro{\tex{defineblocks}}
\macro[beginblock]{\tex{begin<<block>>}}
\macro{\tex{hideblocks}}
\macro{\tex{selectblocks}}
\macro{\tex{useblocks}}
\macro{\tex{keepblocks}}
\macro{\tex{processblocks}}
\macro{\tex{setupblock}}
\macro{\tex{reset}}

For practical reasons we sometimes want to key text
somewhere in the source that should be typeset at a
completely different location in the typeset document. It is
also useful to be able to use text more than once. The
commands described below are among the eldest of \CONTEXT.
They were one of the reasons to start writing the
macropackage.

\stop  \message{[check i.v.m. versie voorlopig]}

You can mark text (a text block) and hide or move that block,
but first you have to define it using:

\showsetup{defineblock}

If necessary you can pass several names in a comma||delimited
list. After the definition you can mark text with:

\startexample
\starttyping
\begin<<name>>
....................
....................
\end<<name>>
\stoptyping
\stopexample

Between the \type{begin}|| and \type{end} command you can
use any command you want.

The commands below tell \CONTEXT\ to hide or recall text
blocks:

\showsetup{hideblocks}

\showsetup{useblocks}

\showsetup{keepblocks}

\showsetup{selectblocks}

\showsetup{processblocks}

These commands make it necessary to process your text at
least twice. You can also recall more than one text block,
for example \type {[question,answer]}.

In hidden and re||used blocks commands for numbering
can be used. Assume that you use questions and answers in
your document. By defining the questions as text blocks
you can:

\startitemize[n,packed,stopper]
\item at that location typeset the questions
\item[item:reuse] only use the questions and use the answers in
      a separate chapter
\item use questions and answers in a separate chapter
\item hide the answers
\item etc.
\stopitemize

When we choose \in{option}[item:reuse] the definitions look
like this:

\startexample
\starttyping
\defineenumeration[question][location=top,text=Question]
\defineenumeration[answer][location=top,text=Answer]

\defineblock[question,answer]

\hideblocks[answer]
\stoptyping
\stopexample

A question and answer in the source look like this:

\startexample
\starttyping
\beginquestion
\question Why do we use blocks? \par
\endquestion

\beginanswer
\answer I really don't know. \par
\endanswer
\stoptyping
\stopexample

The questions are only used in the text. Questions and
answers are both numbered. Answers are summoned by:

\startexample
\starttyping
\chapter{Answers}

\reset[answer]
\useblocks[answer]
\stoptyping
\stopexample

The command \type{\reset...} is necessary for resetting the
numbering mechanism. When the answers are used in the same
chapter you can use the following commands:

\startexample
\starttyping
\section{Answers}

\reset[answer]
\selectblocks[answer][criterium=chapter]
\stoptyping
\stopexample

You must be aware of the fact that it may be necessary to
(temporarily) disable the reference mechanism also:

\startexample
\starttyping
\setupreferencing[state=stop]
\stoptyping
\stopexample

A more complex situation is this one. Assume that you have
several mathematical formulas in your document, and that you
want to recapitulate the more complex ones in a separate
chapter at the end of the document. You have to specify an
\type{[-]} at formulas you do not want repeated.

\startexample
\starttyping
\defineblock[formula]

\beginformula
\placeformula[newton 1]$$f=ma$$
\endformula

This can also be written as:

\beginformula[-]
\placeformula[newton 2]$$m=f/a$$
\endformula
\stoptyping
\stopexample

When you re||use the formulas only the first one is typeset.
The rest of the formulas is processed, so the numbering
will not falter.

The opposite is also possible. By default all local
specifications are undone automatically. This means for
example that the enumeration of text elements like
questions, answers, definitions, etc. can be temporarily
stopped. When numbering should continue you specify: \type
{[+]}.\footnote {When you use enumerations within text
blocks you can best use the \type {\start...stop}
alternative (see~\at {page} [numbering]).}

Among the parameters of the number mechanism we (in some
cases) use the parameter \type{blockwise}. This parameter
relates to numbering within a set of blocks, for example per
chapter.

You may have a document in which the questions and answers
are collected in text blocks. The questions are typeset in the
document and the answers in a separate appendix. Answers and
question are put at the same location in the source file.
When we number the questions and answers per chapter, then
question~4.12 is the 12th question in chapter~4. The correct
number is used in the appendix. In this example answer~4.12
refers to question~4.12 and not the appendix number.

In case we do want the appendix number to be the prefix of
the blocknumber we set the parameter \type{blockwise} at
\type{no}. This is a rather complex situation and will
seldom occur.

Earlier we discussed the initializing and resetting of
counters. For reasons of uniformity we also have:

\showsetup{reset}

In future there will be an option to sort blocks. For that
purpose a second set of optional \setchars\ in {\useblocks}
and \type {\selectblocks} is available. The first argument
is used for \quote {tags}. These tags are logical labels
that enable us to recall the blocks.

\startexample
\starttyping
\beginremark[important]
This is an important message!
\endremark
\stoptyping
\stopexample

Now we can recall the \quote {important} messages by:

\startexample
\starttyping
\useblocks[remark][important]
\stoptyping
\stopexample

or:

\startexample
\starttyping
\selectblocks[remark][important][criterium=chapter]
\stoptyping
\stopexample

Here, \type {criterium} has the same function as in lists
(like tables of content) and registers: it limits the
search. In this case, only the blocks belonging to this
chapter will be typeset.

More than one \quote {tag} is allowed in a comma delimited
list. Text blocks may be nested:

\startexample
\starttyping
\beginpractice
\beginquestion
\question Is that clear? \par
\endquestion
\beginanswer
\answer Yes it is! \par
\endanswer
\endpractice
\stoptyping
\stopexample

In this case we use three blocks. Such blocks are stored in
a file. This file must be available when the blocks are
re||used. This means that the document must be processed at
least twice. When blocks are summoned at the end of your
source file only one processing step is sufficient but then
you have to type the command \type {nomoreblocks} before the
blocks are recalled:

\showsetup{nomoreblocks}

After this command no blocks should be specified. In the
future commands will be developed for local adaptations of the
layout of text blocks. Until that moment the following
command is all there is:

\showsetup{setupblock}

A block is being processed within a group, in other words:
within \argchars. The setup of \type{before} and
\type{after} are used outside this group, and the setup of
\type{inner} is used within the group. For example if we
mark a re||used text block in the margin we can use the
following setup:

\startbuffer
\defineblock[exampletext]

\beginexampletext
If you wonder why this mechanism was implemented consider an educational
document with hundreds of \quote {nice to know} and \quote {need to know}
text blocks at several ability levels.
\endexampletext

\setupblock[exampletext][inner=\margintitle{reused}]
\useblocks[exampletext]
\stopbuffer

\typebuffer

The first text is set without an indicator in the margin and
the second is. If we would have used \type {before} instead
of \type {inner} some grouping problems had occurred.

\getbuffer

You can import text blocks from other source files. For
example if you want to use text blocks from a manual for
students in a manual for teachers, you can specify:

\startexample
\starttyping
\setupblock
  [homework]
  [file=student,
   before=\startbackground,
   after=\stopbackground]
\stoptyping
\stopexample

In that case the blocks are imported from the file \type
{student.tex}. In this example these blocks are typeset
differently, with a background. When the student material is
specified with:

\startexample
\starttyping
\beginhomework[meeting 1]
..........
\endhomework
\stoptyping
\stopexample

we can summon the blocks in the teacher's manual with:

\startexample
\starttyping
\useblocks[homework][meeting 1]
\stoptyping
\stopexample

In extensive documents it will take some time to generate
these products. But this mechanism garantees we use the same
homework descriptions in the students and teachers manual.
Furthermore it saves typing and prevents errors.

Questions and answers are good examples of text blocks that
can be hidden and moved. The example below will illustrate
this. Because commands like \type {\question} have a
paragraph as an argument the \type {\par}'s and/or empty
lines are essential.

In the setup we see that questions and answers are coupled.
A coupling has a meaning in interactive documents.

\startexample
\starttyping
\defineblock[question]
\defineblock[answer]

\defineenumeration[question][location=inmargin,coupling=answer]
\defineenumeration[answer][location=top,coupling=question]

\hideblocks[answer]

\starttext

\chapter{\CONTEXT}

\CONTEXT\ is a macropackage that is based on \TEX. \TEX\ is a typesetting
system and a programm. This unique combination is used extensively in
\CONTEXT.

\beginquestion
  \startquestion
  To date, the fact that \TEX\ is a programming language enables \CONTEXT\
  to do text manipulations that cannot be done with any other known package.

  Can you mention one or two features of \CONTEXT\ that are based on the
  fact that \TEX\ is programming language?
  \stopquestion
\endquestion

\beginanswer
  \answer You can think of features like floating blocks and text block
  manipulation. \par
\endanswer

\beginquestion
  \question Are there any limitations in \TEX ? \par
\endquestion

\beginanswer
  \answer Yes and no. The implementation of \TEXEXEC\ is done in
  \PERL\ rather than in \TEX.
\endanswer

\TEX\ is a very powerful tool, but much of its power is yet to be
unleashed. \CONTEXT\ tries to make a contribution with its user||friendly
interface and its support of many features, like interactivety.

\chapter{Answers}

\useblocks[question,answer]

\stoptext
\stoptyping
\stopexample

With \type {\processblocks} blocks are processed but
not typeset. Assume that we have two types of questions:

\starttyping
\defineblock[easyquestion,hardquestion]
\stoptyping

When both types of questions use the same numbering
mechanism, we can recall the hard questions in their original
order by hiding the easy questions.

\starttyping
\processblocks[easyquestion]
\useblocks[hardquestion]
\stoptyping

\section[opposite blocks]{Opposite blocks}
\index{mirroring}
\index{blocks+moving}
\index{moving text}
\macro{\tex{startopposite}}

In future versions of \CONTEXT\ there will be support of spread based
typesetting. For the moment the only command available is:

\showsetup{startopposite}

Everything between \type{start} and \type{stop} is typeset
at the left page in such a way that it is aligned with the
last paragraph that is typeset on the right page.

\showsetup{setupoppositeplacing}

\section[marginblocks]{Margin blocks}
\index{margin+blocks}
\macro{\tex{startmarginblock}}
\macro{\tex{setupmarginblocks}}

Within limits you can place text and figures in the margin.
In this case the margin is handled as a separate (very
narrow) page next to the actual page.

\showsetup{startmarginblock}

This can be setup with:

\showsetup{setupmarginblocks}

{\em The mechanism to place blocks is still under
construction.}

\section[texthiding]{Hiding text}
\index{hiding text}
\macro{\tex{starthiding}}

It is possible to hide text (skip during processing) by:

\showsetup{starthiding}

\section[postponing]{Postponing text}
\index{postponing text}
\macro{\tex{startpostponing}}

Text elements can be postponed (stored) and placed at the
next empty page. This option is needed in case \CONTEXT\
encounters large figures or tables. The postponed
textelement is placed at the next page generated by \TEX\ or
forced by the user with a manual page break.

\showsetup{startpostponing}

Several text blocks can be postponed and stored. This proces
can be followed on screen during document generation.

\startexample
\starttyping
\startpostponing
\placefigure{A rather large figure.}{...}
\stoppostponing
\stoptyping
\stopexample

When a lot of text elements are postponed or when a figure
uses a complete page we advise you to add \type{\page} after
the postponing. Otherwise there is the possibility that a
blank page is inserted. This is caused by the fact that the
postponing mechanism and the float mechanism are completely
independent.

\startexample
\starttyping
\startpostponing
\placefigure{A very large figure.}{...}
\page
\stoppostponing
\stoptyping
\stopexample

\section[buffers]{Buffers}
\index{buffers}
\index{moving text}
\macro{\tex{startbuffer}}
\macro{\tex{setupbuffer}}
\macro{\tex{getbuffer}}
\macro{\tex{typebuffer}}

Buffers simplify the moving of text blocks. They are stored
in a file with the extension \type {tmp} and are used to
bring readability to your source. Furthermore they can be
recalled at any location without retyping them.

\showsetup{startbuffer}

\showsetup{getbuffer}

\showsetup{typebuffer}

The example below shows the use of these commands.

\startbuffer
\startbuffer
We see that a {\em buffer} works something like a {\em block}.\par
\stopbuffer

\startlines
{\tf \getbuffer}
{\bf \getbuffer}
{\sl \getbuffer}
\stoplines
\stopbuffer

\startexample
\typebuffer
\stopexample

This results in:

\startreality
\getbuffer
\stopreality

The name is optional. A name makes sense only when several
buffers are used. Most of the time the default buffer will
do. Most examples in this manual are typed in buffers.

In \in {chapter} [tables] we can see that the last argument
of a \type {\place<<block>>} can be rather extensive. A
buffer can be useful when such large tables are defined.

\startexample
\setuptyping[option=commands]
\starttyping
\startbuffer
... <</rm many lines>> ...
\stopbuffer

\placetable{A table.}{\getbuffer}
\stoptyping
\stopexample

The buffer is set up with:

\showsetup{setupbuffer}

The first argument is optional and relates to the buffers you
defined yourself. You can define your own buffer with:

\showsetup{definebuffer}

Be aware of possible conflicting names and use capital
letters. After this command \type {/get<<buffer>>} and \type
{/type<<buffer>>} are available where \type{<<buffer>>} is
the name of the buffer.

\stopcomponent