summaryrefslogtreecommitdiff
path: root/info/context-top-ten/src/cmds.tex
blob: 50ec11249cf23aac54b6f0f7627a0828873dd9b7 (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
%% Time-stamp: <corsair 2009-07-12 22:48:27>
%% 
%% Author: Corsair <chris.corsair@gmail.com>
%% Released under GNU FDL v1.3 (http://www.gnu.org/copyleft/fdl.html)

\usemodule[pre-general]
\setuppapersize[S6][S6]
\setuplayout [width=fit,
              rightmargin=1.5cm,
              leftmargin=1.5cm,
              leftmargindistance=0pt,
              rightmargindistance=0pt,
              height=fit,
              topspace=1.8cm,
              header=0pt,
              footer=1.2cm,
              bottomspace=0.5cm,
              backspace=1.5cm,
              location=singlesided]

% \starttypescript[serif][palatino][palatino]
%   \definefontsynonym[Serif][pplr]
% \stoptypescript

\definecolor[orange][r=0.8047, g=0.3594, b=0]
\definecolor[problue][r=0.125, g=0.28906, b=0.52734]
\definecolor[litegrey][r=0.9, g=0.9, b=0.9]

% XeTeX Fonts
% Linux
\definetypeface[prof][ss][Xsans][Myriad Pro]
\definetypeface[prof][rm][Xserif][Palatino LT Std]
\definetypeface[prof][tt][Xmono][Consolas]
% Mac
% \definetypeface[prof][ss][Xsans][Myriad Pro]
% \definetypeface[prof][rm][Xserif][Palatino]
% \definetypeface[prof][tt][Xmono][Monaco][default][rscale=0.85]
\setupbodyfont
  [prof,14.4pt]
\setuphead
  [section]
  [numberstyle=\ssbf,
    textstyle=\ssbf,
    page=yes]
\setuphead
  [subject]
  [textstyle=\ssbf,color=sub]
\setupcaptions[style=\ss]
\setuptyping
  [before=\startbackground,
    after=\stopbackground]
\setupbackground[background=color, backgroundcolor=litegrey]
\setuptype
  [style=\tt, color=problue]
\setupitemize[packed]

% \setuppagenumbering[state=stop]
% \switchtobodyfont[modern,20pt]
\setuptolerance[verytolerant,stretch]
\setupinteractionscreen[option=max]
\setupwhitespace[medium]
\setupindenting[medium]
\setupinterlinespace[line=1.3\bodyfontsize]
\setupfootertexts[pagenumber]

\setupcolors[state=start]
\setupbackgrounds[page][background=color,backgroundcolor=]
\setupinteraction
  [state=start,
%     color=middlered,
    style=\rm
]
\useURL [garden][http://contextgarden.net][][Context garden]
\useURL [wiki][http://wiki.contextgarden.net/Main_Page][][\CONTEXT\
  wiki]
\useURL [wiki_table][http://wiki.contextgarden.net/Table][][table
  page]
\useURL [ctexbbs][http://bbs.ctex.org/][][CTeX BBS]
\definetyping[TEX][option=TEX,style=type]

\defineoverlay
  [bg]
  [{\externalfigure[bg-slide.pdf]}]

\defineoverlay
  [title]
  [{\externalfigure[title-slide.pdf][width=\overlaywidth,height=\overlayheight]}]

\definedescription[definition][location=left]

\starttext
\setupbackgrounds[paper][state=start,background=bg]
% \setupfooter[state=start]

% Title Slide
\page[blank]
\setupbackgrounds[paper][state=start,background=title]

\ \par
\blank[3cm]
\switchtobodyfont[sansserif,1.2cm]
\midaligned{\bf \CONTEXT\ Macros Top Ten}
\switchtobodyfont[sansserif,0.8cm]
% \midaligned{\bf An Introduction to \CONTEXT\ (draft)}
\blank[2cm]
\midaligned{Corsair {\tt\tx <chris.corsair@gmail.com>}}
\page[yes]
\setupbackgrounds[paper][state=stop]
\setupbackgrounds[paper][state=start,background=bg]
\switchtobodyfont[prof,14.4pt]

%% End of Title
\rm

\completecontent % [alternative=f]

% \setuppagenumbering[state=start]

\section{Introduction}

\CONTEXT\ has a huge quantity of commands which might shoo away
novices.  For example, there are at least 9 commands to change
characters' case and typeset them properly, including \type{\cap},
\type{\Cap}, \type{\kap}, \type{\Words}, etc..  So in the beginning of
the \CONTEXT\ manual, the author lists ten groups of them which are
considered most frequently used:

  \startitemize[n]
  \item \type{\starttext}, \type{stoptext}
  \item \type{\chapter}, \type{\section}, \type{\title},
    \type{\subject}, \type{\setuphead}, \type{\completecontent}
  \item \type{\em}, \type{\bf}, \type{\cap}
  \item \type{\startitemize}, \type{\stopitemize}, 
    \type{\item}, \type{\head}
  \item \type{\abbreviation}, \type{\infull}, 
    \type{\completelistofabbreviations}
  \item \type{\placefigure}, \type{\externalfigure}, 
    \type{\useexternalfigures}
  \item \type{\placetable}, \type{\starttable}, \type{\stoptable}
  \item \type{\definedescription}, \type{\defineenumeration}
  \item \type{\index}, \type{\completeindex}
  \item \type{\setuplayout}, \type{\setupfootertexts}, \type{\setupheadertexts}
  \stopitemize

So let's walk 'em through!

\section{The \type{text} Environment}

You just cannot typeset anything if not use this environment.  It's
like the \type{document} environment in \LaTeX.  In \CONTEXT, this
(and all) environment is issued with \type{\start} and \type{\stop}.

\startTEX
\starttext
Once there was a mountain ...  
\stoptext
\stopTEX

Like in \LaTeX, it is preferred to setup the whole document before
\type{\starttext} so that structure and style are separated.

\section[sec:struct]{Structure of An Article}

You {\em do} know that articles have structure, don't you?  Remember
when we were young and the world was in chaos, we used to typeset a
line of title in M\$ Word, by bold-ing, large-ing and centering it?
Yes, but that was bad old time.  Today we use \type{\section} and
\type{\title}!

\startTEX
\starttext
  \section[sec:mnt]{The Mountain}
  Once there was a mountain ...
\stoptext
\stopTEX

\startframedtext[middle]
  {\tfa \bf 1 \ \ The Mountain}
  \blank[0.5cm]
  Once there was a mountain \ldots
\stopframedtext

The \type{[...]} stuff is an optional label of this head, which
enables you to cross-reference it easily with \type{\in}, \type{\at}
or \type{\about}.

\type{\subject} is another unnumbered version of \type{\section}.
Some of the structure elements are listed in table~\in[tab:strele].

\placetable
  [here][tab:strele]
  {\Words{Structure elements in \CONTEXT}}
  \starttable[|c|l|l|]
    \NC level \VL numbered title \VL unnumbered title \LR
    \HL
    \NC 1 \VL \type{\part} \VL \AR
    \NC 2 \VL \type{\chapter} \VL \type{\title} \AR
    \NC 3 \VL \type{\section} \VL \type{\subject} \AR
    \NC 4 \VL \type{\subsection} \VL \type{\subsubject} \AR
    \NC 5 \VL \type{\subsubsection} \VL \type{\subsubsubject} \AR
  \stoptable

  Now we know how to typeset heads.  But what if we want to make all
  heads in a different font, for example, change them to sans-serif
  font (like in this artile)?  Must we add a \type{\ss} in every
  section, subsection, subsubsection ?  Definitely no.  \CONTEXT\
  provides a rather convenient interface to change whatever style,
  including that of titles, in your article.

\startTEX
\setuphead
  [section,subsection,subsubsection]
  [numberstyle=\ssbf, textstyle=\ssbf]
\stopTEX

Put this block of code before \type{\starttext}, and boom, we're
done.  In fact, in \CONTEXT, almost everything can be setup in this
way.  \pagereference[page:itemize] Take \type{itemize} environment as example which is used to
typeset a list, \type{\setupitemize[packed]} makes all lists be
rendered in a compact style.

Structuring elements have a bunch of other options, which are
explained in {\it \CONTEXT en} (\CONTEXT\ manual), section 8.2.

With these structures, we can form a table of contents for out article
with \type{\completecontent} which is similar to
\type{\tableofcontents} in \LaTeX, except that the former one is much
much more customizable.

\section[sec:font]{Fancy Fonts}

Why do we use different fonts in the main text?  Well, we have our
reasons.  The most common one is to emphasize something.  In \CONTEXT\
(actually in plain \TeX) we use \type{\em} to do it.  It does various
things in different environment.  Normally, it
toggles “slant-ish-ness” of the text, while in quoted text, it might
underline it.

\startTEX
Once there was a {\em mountain}, 
in the {\sl mountain {\em there} was a temple},
in which a {\bf {\em monk} was telling a story}.
\stopTEX

\startframedtext[middle]
Once there was a {\em mountain}, 
in the {\sl mountain {\em there} was a temple},
in which a {\bf {\em monk} was telling a story}.
\stopframedtext

So why bother using \type{\em} instead of \type{\sl}?  Simple.
\type{\em} tells us the text there is important while \type{\sl} does
not.  If we use \type{\sl} in all cases, what so important about a
important block of text comparing to a book's name?

Besides italic and bold fonts, \TeX\ make heavy use of {\sc small cap}
characters which are look like small upper-cased characters, though in
theory they are {\em not} upper-cased characters in small size.  \TeX
ers love small cap fonts because they look really nice in some font
families that come with their \TeX\ distributions (and small cap is
one of the many traditions in typography).  In fact, small cap faces
in those families are separately designed just like italic and bold
faces.

\pagereference[page:sc]
Generally, small cap is used to indicate that a word is an
abbreviation or an acronym.  For example, “\cap{pdf}” is produced from
\type|\cap{pdf}|, and “\cap{html}” from \type|\cap{html}|.

\section[sec:lists]{Lists}

Lists help us thinking.  There are at least two kinds of list existing
in this universe: numbered and unnumbered.  In \LaTeX, we use
\type{itemize} and \type{enumerate} environments respectively, while
in \CONTEXT, \type{itemize} rules them all.

\startTEX
\startitemize[n]
\item Atom Heart Mother
\item Dark Side of The Moon
\item Wish You Were Here
\stopitemize
\stopTEX

\startframedtext[middle]
  \startitemize[n,unpacked]
  \item Atom Heart Mother
  \item Dark Side of The Moon
  \item Wish You Were Here
  \stopitemize
\stopframedtext

The \type{[n]} tells \CONTEXT\ that this list is a numbered one.
Other options are listed in table \in[tab:listprefix].

\placetable
  [here]
  [tab:listprefix]
  {\Words{Table of all list prefixes}}
  \starttable[|c|l|c|l|]
    \NC\ \bf option \NC \bf prefix \VL \bf option \NC \bf prefix \LR
    \HL
    \NC \tt n \NC 1,2,3 \VL \tt 1 \NC dot \AR
    \NC \tt a \NC a,b,c \VL \tt 2 \NC dash \AR
    \NC \tt A \NC A,B,C \VL \tt 3 \NC star \AR
    \NC \tt KA \NC \kap{a,b,c} \VL \tt 4 \NC triangle \AR
    \NC \tt r \NC \romannumeral1,\romannumeral2,\romannumeral3 \VL \tt
    5 \NC circle \AR
    \NC \tt R \NC
    \uppercase\expandafter{\romannumeral1},\uppercase\expandafter{\romannumeral2},\uppercase\expandafter{\romannumeral3}
        \VL \tt 6 \NC big circle \AR
    \NC \tt KR \NC \cap{\romannumeral1,\romannumeral2,\romannumeral3} \VL
        \tt 7 \NC bigger circle \AR
    \NC \tt m \NC {\os 1},{\os 2},{\os 3} \VL \tt 8 \NC square \AR
    \NC \tt g \NC $\alpha$,$\beta$,$\gamma$ \VL \NC \AR
    \NC \tt G \NC $\Alpha$,$\Beta$,$\Gamma$ \VL \NC \AR
  \stoptable

Yes, every possible prefix you can think of is here for you.  And if
you think that space between lines is way too large, add a
\type{packed} option to \type{\startitemize} or set it up in the way I
discribed in section \in[sec:struct], page \at[page:itemize].

There's a \type{\head} macro also, to typeset fancy two-leveled lists
like the following:

\startTEX
\startitemize[1,packed]
  \head Pink Floyd \par
  \startitemize[g]
  \item Atom Heart Mother
  \item Dark Side of The Moon
  \item Wish You Were Here
  \stopitemize
  \head Muse \par
  \startitemize[continue]
  \item Black Holes and Revelations
  \item Absolution
  \item Hullabaloo
  \stopitemize
\stopitemize
\stopTEX

\startframedtext[middle]
\startitemize[1,packed]
  \head Pink Floyd \par
  \startitemize[g]
  \item Atom Heart Mother
  \item Dark Side of The Moon
  \item Wish You Were Here
  \stopitemize
  \head Muse \par
  \startitemize[continue]
  \item Black Holes and Revelations
  \item Absolution
  \item Hullabaloo
  \stopitemize
\stopitemize
\stopframedtext

\section{Long Things Short}

\definesynonyms[abbr][abbrs][\infull]

In section \in[sec:font], page \at[page:sc], we referred that usually
people use small cap font to indicate a synonym or abbreviation.
However, if you are writing a really formal document like a science
paper, you might want to have more control over synonyms and even had
a index of them.  In \CONTEXT, we can do this with
\type{\definesynonyms} and \type{\completelistofabbreviations}.

First off, we define a new type of synonym called \type{abbr}:

\startTEX
\definesynonyms[abbr][abbrs][\infull]
\stopTEX

The three arguments are all arbitrary.  The first two are singular and
plural name of this kind of synonym, and the third one is the command
that we will use to expand the abbreviations.

Now we define an \type{abbr}:

\startTEX
\abbr{CSS}{Cascading Style Sheets}
\stopTEX

Thus we can use this abbreviation in our article:

\startTEX
\infull{CSS} is a way of rendering the style of a web page from multiple sources with a defined order of precedence where the definitions of any style element conflict.
\stopTEX

\startframedtext[middle]
  \abbr{CSS}{Cascading Style Sheets}

  \infull{CSS} is a way of rendering the style of a web page from
  multiple sources with a defined order of precedence where the
  definitions of any style element conflict.
\stopframedtext

The newly defined macro \type{\abbr} has another usage, which can
define a macro to make our fingers comfortable:

\startTEX
\abbr[css]{CSS}{Cascading Style Sheets}
\stopTEX

Thus, \type{\css} does the same things as \type|\infull{CSS}| does.

Also, \type{\definesynonyms} has another form:

\startTEX
\definesynonyms[abbr][abbrs][\inshort][\infull]
\stopTEX

Then we have a new macro \type{\inshort} which just leave the
abbreviation be.

\startTEX
\infull{CSS} (\inshort{CSS}) is a way of rendering the style of a web page from multiple sources with a defined order of precedence where the definitions of any style element conflict.
\stopTEX

\definesynonyms[abbr][abbrs][\inshort][\infull]
\abbr{CSS}{Cascading Style Sheets}

\startframedtext[middle]
  \infull{CSS} (\inshort{CSS}) is a way of rendering the style of a
  web page from multiple sources with a defined order of precedence
  where the definitions of any style element conflict.
\stopframedtext

Like the table of contents, we can have a list of all \type{abbr}s:

\startTEX
\completelistofabbrs
\stopTEX

In case you don't know, “abbrs” in the macro above is the plural
name we defined with \type{\definesynonyms}.

\section{Figures Talk}

If you have used \LaTeX\ before, you might have noticed how hard to
work with figures in it.  It even needs an external macro package to
do that!  But in \CONTEXT, we have \type{\externalfigure}.

\startTEX
\externalfigure[sin.pdf][width=7cm]
\stopTEX

\externalfigure[sin.pdf][width=7cm]

That's it.  We inserted a figure into our article.  Normally \CONTEXT\
will identify same image file inserted multiple times, and reuse it to
save memory and reduce output file size.  If you are kind of in doubt
with it and want a fine control, \type{\useexternalfigure} is for you.

\startTEX
\useexternalfigure[sine][sin.pdf][width=3cm]
\externalfigure[sine]
\stopTEX

However, \TeX ers hardly like typesetting a figure in this way that
the picture is fixed there where the codes are.  More often do they
use a “floating environment” instead, in which position of a figure
is not fixed, but, in theory, “hanging around” in a specific area,
and the actual position is determined by an algorithm stored in the
\TeX\ compiler.  \CONTEXT\ provides \type{\placefigure} macro to place
a floating figure.

% So what's so great about this floating thing?  Simply put, have you
% ever run into such a situation that in M\$ Word, you put a figure just
% at the bottom of a page, and you made a horrible decision that you
% inserted a line of text before that figure, and then you found
% yourself in hell because the figure was pushed into the next page and
% its previous room became an area of blank which seemed to be laughing
% at you?  Do you know why we are not letting the figure be in a fixed
% position now?

\startTEX
\placefigure[here][fig:smile]{\Words{GNU post}}
  {\externalfigure[post.pdf][width=6cm]}
\stopTEX

\placefigure[here][fig:smile]{\Words{GNU post}}
  {\externalfigure[post.pdf][width=6cm]}

The \type{[here]} option tells \CONTEXT\ that we prefer this figure
right here if it is really fit.  It can also be \type{left},
\type{right}, \type{top}, \type{bottom}, \ldots  We can as well ignore
this option which leaves \type{here} as default.

Furthermore, multiple images can be placed in one block using the
\type{combination} environment.

\startTEX
\placefigure
  [bottom]
  [fig:comb]
  {\Words{Multiple figures in one floating env.}}
  {\startcombination[3*2]
     {\externalfigure[post.pdf][width=2.5cm]} {a} 
     {\externalfigure[fish.pdf][width=2.5cm]} {b}
     {\externalfigure[apple.pdf][width=2cm]} {c} 
     {\externalfigure[gnu.pdf][width=2.5cm]} {d}
     {\externalfigure[hacker.pdf][width=2.5cm]} {e}
     {\externalfigure[ctanlion.pdf][width=2.8cm]} {f}
   \stopcombination}
\stopTEX

\placefigure
  [bottom]
  [fig:comb]
  {\Words{Multiple figures in one floating env.}}
  {\startcombination[3*2]
     {\externalfigure[post.pdf][width=2.5cm]} {a} 
     {\externalfigure[fish.pdf][width=2.5cm]} {b}
     {\externalfigure[apple.pdf][width=2cm]} {c} 
     {\externalfigure[gnu.pdf][width=2.5cm]} {d}
     {\externalfigure[hacker.pdf][width=2.5cm]} {e}
     {\externalfigure[ctanlion.pdf][width=2.8cm]} {f}
   \stopcombination}

Well, that's all for figures.  Happy playing with them!  BTW., you may
have noticed that \type{[bottom]} is used in the block of code above.
Pay attention to its behavior.

\section{Tables}

The construction of a tables in \CONTEXT\ might be quite different
with what in your mind, especially if you have used \LaTeX\ before.
Let's go through an example first.

\startTEX
\starttable[|l|c|r|]
\NC {\bf Artist} \VL {\bf Album} \NC {\bf Title} \LR
\HL
\NC Pink Floyd \NC Wish You Were Here  \VL Have A Cigar \AR
\NC Muse \NC Hullabaloo \VL Forced In \AR
\NC Queen \NC A Night at The Opera \VL Death on Two Legs \LR
\stoptable
\stopTEX

\starttable[|l|c|r|]
\NC {\bf Artist} \VL {\bf Album} \NC {\bf Title} \LR
\HL
\NC Pink Floyd \NC Wish You Were Here  \VL Have A Cigar \AR
\NC Muse \NC Hullabaloo \VL Forced In \AR
\NC Queen \NC A Night at The Opera \VL Death on Two Legs \LR
\stoptable

As one can see, the formatting string which enclosed in the pair of
square brace tells \CONTEXT\ only the align of the table, though we
use \type{|} to seperate the three charactors.  In \CONTEXT, we apply
a more flexible scheme to typeset vertical lines in tables in
comparison to that in \LaTeX\ that we use \type{\VL} to separate two
cells so that \CONTEXT\ will add a vertical line between them.

If you do not prefer a vertical line there, use \type{\NC} instead of
\type{\VL}.  All these “two-cap-lettered” macros for typesetting
tables are listed in table \in[tab:cell-def].  To end a row, we
usually use a \type{\AR} macro or, instead, \type{\LR} if it is either
the last row or followed by a \type{\HL} that draw a horizontal line
across the table.

\CONTEXT\ provides a whole bunch of macros and options for column and
cell definition.  See a full list of them at the \from[wiki],
\from[wiki_table].

Like a figure, a table can be a floating object whose placement is
calculated by \CONTEXT.

\placetable[right][tab:cell-def]{Cell Definition Macros}{
  \starttable[|c|l|]
    \NC {\bf Macro} \VL {\bf Meaning} \LR
    \HL
    \NC \type{\NC} \VL next column \AR
    \NC \type{\HL} \VL horizontal line \AR
    \NC \type{\VL} \VL vertical line \AR
    \NC \type{\NR} \VL next row \LR
    \HL
    \NC \type{\SR} \VL single row \AR
    \NC \type{\FR} \VL first row \AR
    \NC \type{\MR} \VL middle row \AR
    \NC \type{\LR} \VL last row \LR
    \HL
    \NC \type{\AR} \VL automatic row \SR
  \stoptable}
\startTEX
\placetable[right][tab:cell-def]{Cell Definition Macros}{
  \starttable[|c|l|]
    \NC {\bf Macro} \VL {\bf Meaning} \LR
    \HL
    \NC \type{\NC} \VL next column \AR
    \NC \type{\HL} \VL horizontal line \AR
    \NC \type{\VL} \VL vertical line \AR
    \NC \type{\NR} \VL next row \LR
    ...
  \stoptable}
\stopTEX

\section{Descriptions}

What you will write if you want to when you want to define something
or describe stuff your readers might be interested in?  Well,
an “aaa: bbb” pair seems stupid enough to demonstrate that the
writer is without sufficient training on typesetting.  \CONTEXT\
enables us to make it more fancy.  To start with, we first use
\type{\definedescription} macro:
\startTEX
\definedescription[definition][]
\stopTEX
which defines a stuff we would like to describe in default style.
Then we can describe it like this
\startTEX
\definition{Fractal}
A fractal is an object or quantity that displays self-similarity, in a somewhat technical sense, on all scales.\par
\stopTEX
\definition{Fractal}
A fractal is an object or quantity that displays self-similarity, in a
somewhat technical sense, on all scales. \par

Note that the trailing \type{\par} or an extra newline is a must to
end the description.  If the description contains multiple paragraphs,
we can also go for an environment:

\startTEX
\startdefinition{Vimperator}
Vimperator is a free browser add-on for Firefox, which makes it look and behave like the Vim text editor. It has similar key bindings, and you could call it a modal web browser, as key bindings differ according to which mode you are in.

Vimperator was written by Martin Stubenschrott. If you appreciate my work on Vimperator and want to encourage me working on it more, you can either send me greetings, patches or make a donation.
\stopdefinition
\stopTEX

\startdefinition{Vimperator}
  Vimperator is a free browser add-on for Firefox, which makes it look
  and behave like the Vim text editor. It has similar key bindings,
  and you could call it a modal web browser, as key bindings differ
  according to which mode you are in.

  Vimperator was written by Martin Stubenschrott. If you appreciate my
  work on Vimperator and want to encourage me working on it more, you
  can either send me greetings, patches or make a donation.
\stopdefinition

We have already gone through lists in section \in[sec:lists], which is
for normal vanilla itemizaion or enumerization.  In this section, a
more powerful technique is introduced to typeset item-structured
content.  The \type{itemize} environment provides us a good start for
this kind of stuff, but what if we want a list with prefix other than
table \in[tab:listprefix] has exhibited?  \CONTEXT\ surely has macros
for this, one of which is \type{\definedescription} macro.  To use
this command, we may first define our own description style like this

\startTEX
\definedescription
  [myitemization]
  [location=serried,headstyle=bold,width=broad]
\stopTEX

Then we have the macro \type{\myitemization} to typeset the
description as we want:

\startTEX
\myitemization{icon}
What for some languages looked like a handicap has now become a feature.  Thousands of words and concepts are already layed down in characters.  These characters therefore can be considered icons. \par
\stopTEX

\startnarrower
\definedescription
  [myitemization]
  [location=serried,headstyle=bold,width=broad]
\myitemization{icon}
What for some languages looked like a handicap has now become a feature.
Thousands of words and concepts are already layed down in characters.
These characters therefore can be considered icons. \par
\stopnarrower

Even better, numerical index can be added if we use
\type{\defineenumeration} to define our listing style:

\startTEX
\defineenumeration
  [remark]
  [location=top, text=Remark, between=\blank,
   before=\blank, after=\blank]
\stopTEX

\startTEX
\remark The Mod Showroom is only for posting previews/downloads of completed or near finished mods. \par
\subremark All help topics should be posted in the Editing Discussion forums. Help topics and mod requests posted here will be locked or binned. Thank you. \par
\remark Spaceeinstein's All In One Mod v2, A lot more mods rolled into one. \par
\stopTEX

\defineenumeration
  [remark]
  [location=top, text=Remark, between=\blank,
   before=\blank, after=\blank]

\remark The Mod Showroom is only for posting previews/downloads of
completed or near finished mods. \par
\subremark All help topics should be posted in the Editing Discussion
forums. Help topics and mod requests posted here will be locked or
binned. Thank you. \par
\remark Spaceeinstein's All In One Mod v2, A lot more mods rolled into
one. \par


\section{Build a Dictionary}

\ldots\ or not.  Ok, this section is not about how to build a
dictionary, though the underlying principle is no
different---indexing.  This is not a feature that every book needs.
But when provided in a proper book, it is usually coming handy.  In
\CONTEXT, indexing is really made easy.  All you have to do is
inserting a \type{\index} at wherever the phrase you want to index is,
and placeing a \type{\placeindex} where you want the glossary be.  For
example

\startTEX
For over a thousand generations the Jedi Knights\index{Jedi} were the guardians of peace and justice in the Old Republic\index[old republic]{the old republic}. Before the dark times, before the Empire\index[empire]{the empire}.
\stopTEX

This renders just like a normal paragraph:

\startnarrower
For over a thousand generations the Jedi Knights\index{Jedi} were the
guardians of peace and justice in the Old Republic\index[old
  republic]{the old republic}. Before the dark times, before the
Empire\index[empire]{the empire}.
\stopnarrower

Note that the words in the square braces (if any) are those that are
taken into account when indexing.  Now let's place the glossary

\startTEX
\placeindex
\stopTEX

\placeindex

Like many other \CONTEXT\ commands, users can define their own series
of indexing, which pluses the default \type{\index} series are called
register.  A style of register can be defined using
\type{\defineregister}

\startTEX
\defineregister[refer][refers]
\stopTEX

in which the second argument is the plural form of the name.  Then we
can use \type{\refer} and \type{\placerefer} just as \type{\index}.

\section{Page Layout}

Here comes the final section, in which we will deal with some layout
issue.  The most import command, of course, is \type{\setuplayout}.  I
usually put one in the third line of any \CONTEXT\ document while the
first line is probably a \type{\usemodule} and the second is
\type{\setuppapersize}.

Generally, there are five areas that we put text into: main text,
header, footer, left margin and right margin.  Note that adjusting
header and footer will influence the position and height of main text,
while margins will not.  The dimensions of a page from top to bottom
are \type{topspace}, \type{header}, \type{footer}, \type{bottomspace}.
Practically, I usually set \type{width} and \type{height} to
\type{fit} which means they are calculated automatically, and adjust
the four dimensions for vertical placment, and \type{backspace} for
horizontal position of main text, which gives the distance between the
left edge of the page and that of the main text area.  Margins seem to
have nothing to do with it.  They are adjusted independently using
\type{*margin} and \type{*margindistance} in which \type{*} could be
either \type{left} or \type{right}.  The layout I use for this
document is shown below.

\startTEX
\setuppapersize[S6][S6]
\setuplayout [width=fit, height=fit,
              rightmargin=1.5cm,
              leftmargin=1.5cm,
              leftmargindistance=0pt,
              rightmargindistance=0pt,
              topspace=1.8cm,
              header=0pt,
              footer=1.2cm,
              bottomspace=0.5cm,
              backspace=1.5cm,
              location=singlesided]
\stopTEX

As you can see, I leave no space for header text and $1.2\,{\rm cm}$
for footer (pape number).  While you are tuning layout,
\type{\showlayout} and \type{\showframe} can be a {\em big} help.

Now let's start setting up header and footer.  They are generally the
same except the position, so I will focus on footer, which can be
configured with \type{\setupfootertexts} command.  This macro may take
one, two, three, four or five arguments.

\startitemize[n]
\item If only one argument is issued, it place the text in the middle
  of the page (as in this document), for example

\startTEX
\setupfootertexts{pagenumber}
\stopTEX

This argument can also be \type{date}, a section name (like
\type{chapter} or \type{subsection}), name of a mark, or some macros
that will be substituted with texts (like \type{{\pagenumber of
\totalnumberofpages}}).

\item If two arguments are given, the first one will be placed on the left
and the second one right.

\item If three arguments are given, the first one will represent the
  location of the footer text, and can be one of \type{text},
  \type{margin} and \type{edge} (outside the margins).

\item Four arguments can only be given when writing a double-sided
  document.  They will be placed at even page left, even page right,
  odd page left and odd page right, respectively.

\item If five arguments are given, the first one will represent the
  location of the texts.  Despite this, it is identical to the
  condition in which four arguments are issued.

\stopitemize

\section{Conclusion}

\CONTEXT\ rocks!

Oh, one more thing.  I thank {\it kmc} on \from[ctexbbs] and {\it
  Otared Kavian} for helping me improve this document, and {\it
  yulewang} on \from[ctexbbs] for submitting it to CTAN.

\stoptext

%%% Local Variables: 
%%% mode: context
%%% TeX-master: t
%%% TeX-PDF-mode: t
%%% End: