-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontext_tutorial.tex
More file actions
652 lines (472 loc) · 17.8 KB
/
Copy pathcontext_tutorial.tex
File metadata and controls
652 lines (472 loc) · 17.8 KB
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
\usemodule[chart]
\setupFLOWcharts[height=2\lineheight, width=3cm]
\setupinteraction[state=start, color=darkblue, contrastcolor=]
\setupindenting[yes, medium]
\setupcaptions[table][location=top, width=.8\textwidth]
\setupcolors[state=start]
\definecolor[mamu][r=.9, g=0, b=.9 ]
\definecolor[mamu1][r=.3, g=.3, b=.3]
\definecolor[darkyellow][y=.625] % a CMYK color
\definecolor[darkred][r=.625] % a RGB color
\definecolor[darkgray] [s=.925] % a gray scale
\setuptyping[color=darkgreen]
\setuptype[color=darkmagenta, style=bold]
\setupexternalfigures
[location=default]
\starttext
\startstandardmakeup[rigth]
{\bfb Learn \CONTEXT~for scientific writing:\\ ---The hard way}
\blank[big]
by
Lizardo Reyna\\
farliz@disroot.org
\vfill
{\externalfigure [by-sa][width=3cm]}\\
{\em Approved for free cultural works}\\
% \startuseMPgraphic{color demo}
% path p ; p := fullcircle xscaled 10cm yscaled 2cm ;
% fill p withcolor \MPcolor{mamu} ;
% for i=0 step 2 until 20 :
% draw (0,i) withcolor \MPcolor{darkgrey} ;
% endfor ;
% numeric done[][], i, j, n ; n := 0 ;
% forever :
% i := round(uniformdeviate(10)) ; j := round(uniformdeviate(2)) ;
% if unknown done[i][j] :
% drawdot (i*cm,j*cm) ; n := n + 1 ; done[i][j] := n ;
% fi ;
% exitif n = 10 ;
% endfor ;
%\stopuseMPgraphic
%\useMPgraphic{color demo}
\stopstandardmakeup
% \startMPpage
% StartPage ;
% pickup pencircle scaled 2mm ;
% % fill Page enlarged 2mm withcolor \MPcolor{mamu} ;
% for i=1 upto 3000:
% v := uniformdeviate(300) + 1 ;
% h := uniformdeviate(v) / 900 * normaldeviate ;
% l := uniformdeviate(900) ;
% drawdot ((-l,0)--(l,0)) rotated uniformdeviate(180) shifted (h,-v)
% withcolor darkgray ;
% endfor
% picture p, q, t;
% p := textext("Learn \CONTEXT~for scientific writing:") xsized 16cm ;
% t := textext("---The Basics") xsized 7cm ;
% q := textext("Lizardo Reyna") xsized 4cm ;
% % r := textext("Lizardo Reyna") xsized 6cm ;
% draw anchored.rt (p, center rightboundary Page shifted (-3cm, 4cm)) ;
% draw anchored.rt (t, center rightboundary Page shifted (-12cm, 2cm)) ;
% draw anchored.rt(q, center rightboundary Page shifted ( -2cm, -12cm)) ; % \MPcolor{darkred} ;
% draw
% unitsquare shifted (3,.8) xscaled 5cm yscaled 2cm
% withpen pencircle scaled 3.0mm withcolor .625yellow ;
% StopPage ;
% % draw externalfigure "utm_logo.png" scaled 4cm shifted (1cm,25cm);
% \stopMPpage
\chapter{---The Basics}
\blank[3cm]
\placecontent
\blank[2cm]
\section{What is \CONTEXT?}
\CONTEXT~is a typesetting system developed in 1992 by Hans Hagen from PRAGMA-ADE
in Hasselt, The Netherlands. Is an advanced macro package for creating
professional quality documents in pdf, html and, xml formats. The traditional
word processors such as Writer, AbiWord, or MS word, may be limited with large and
complex documents and when we need to type many text, mathematical and chemical
formulas, insert figures and create complex tables. \CONTEXT~ is a professional
typesetting software with many commands that will help you make your papers look
like a high quality scientific journal. This will increase your motivation and
creativity in the writing process.
\blank[big]
\CONTEXT~official site:
\blank[big]
\goto{\tfb https://wiki.contextgarden.net}[url(https://wiki.contextgarden.net)]
\section{How \CONTEXT~works?}
Think in \CONTEXT~as a programming language, this means that you need to
write a source code and then compile the source to get a pdf file.
The file containing the source code must to be named with {\tt .tex}
extension. An useful habit is to create an independent directory for
each document; into this directory or folder the {\tt .tex} file have
to be saved. To avoid potential conflicts the name of the file must not
contain spaces or special characters such as \#, \&,
etc (e.g. {\tt main.tex}). Underscore can be used to separate words in the file names.
\startFLOWchart[c1]
\startFLOWcell
\name {file}
\location {1,1}
\text {main.tex}
\connection [rl] {ctx}
\stopFLOWcell
\startFLOWcell
\name {ctx}
\location {2,1}
\text {context main.tex}
\connection [rl] {pdf}
\comment[t]{Compile}
\stopFLOWcell
\startFLOWcell
\name {pdf}
\location {3,1}
\text {PDF}
%\connection [rl] {file}
\stopFLOWcell
\stopFLOWchart
\FLOWchart[c1]
\CONTEXT~works with commands which are words preceded by a backslash
(\backslash) The {\tt main.tex} is the file where the commands
will be written and you can use any text editor. However the
TeXworks editor is recommended for beginners and can be downloaded from
the official page
\goto{https://www.tug.org/texworks/}[url(https://www.tug.org/texworks/)].
\section{Try online}
Before install \CONTEXT~and TeXworks and use it in you own computer,
you can follow this guide in the online version in a web browser. Copy
the following link and paste it in your web browser,
\goto{https://context-on-web.eu/}[url(https://context-on-web.eu/)]. In
\in{Fig.}[fig:f1] the online version is showed. You can click the
typeset button and the pdf will be created with Hello World! text.
\placefigure[]
[fig:f1] {\CONTEXT~online version.}
{\externalfigure [coweb][width=\textwidth]}
\startframedtext[width=\textwidth]
The examples presented in this chapter (green text) can be copied
and pasted into the textbox in the online version of \CONTEXT.
\stopframedtext
\section{The commands}
The commands have {\em arguments} and {\em options}, although some commands can
be use without arguments and options. The first pair of commands you
need to learn is \type{\starttext \stoptext}. Between these commands
we will write all the content of our document. As is showed in
\in{Fig.}[fig:f1] the sentence Hello world! is between the commands.
All text outside the commands will not appear in the document. The
form \type{\start ... \stop} indicate the beginning and the end of
the commands. In our first document we will write these commands with
some blank spaces between them to avoid confusion with the main text
of the document.
\starttyping
\starttext
....
\stoptext
\stoptyping
Now we can write a paragraph. The format of the text in the source code does not
matter, however for optimal readability, the optimal length of the lines in the
source file is about 70 characters per line.
\starttyping
\starttext
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec
hendrerit tempor tellus. Donec pretium posuere tellus.
nisl, tincidunt et, mattis eget, convallis nec, purus. Cum sociis
natoque penatibus et magnis dis parturient montes, nascetur
ridiculus mus. Nulla posuere. Donec vitae dolor. Nullam tris
diam non turpis. Cras placerat accumsan nulla. Nullam rutrum.
vestibulum accumsan nisl.
\stoptext
\stoptyping
Let's try with two paragraphs. \CONTEXT~knows that there are two
paragraphs because of the space between them.
\starttyping
\starttext
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec
hendrerit tempor tellus. Donec pretium posuere tellus. Proin quam
nisl, tincidunt et, mattis eget, convallis nec, purus. Cum sociis
natoque penatibus et magnis dis parturient montes, nascetur
ridiculus mus. Nulla posuere. Donec vitae dolor. Nullam tristique
diam non turpis. Cras placerat accumsan nulla. Nullam rutrum. Nam
vestibulum accumsan nisl.
Nullam eu ante vel est convallis dignissim. Fusce suscipit, wisi
nec facilisis facilisis, est dui fermentum leo, quis tempor ligula
erat quis odio. Nunc porta vulputate tellus. Nunc rutrum turpis
sed pede. Sed bibendum. Aliquam posuere. Nunc aliquet, augue nec
adipiscing interdum, lacus tellus malesuada massa, quis varius mi
purus non odio. Pellentesque condimentum, magna ut suscipit
hendrerit, ipsum augue ornare nulla, non luctus diam neque sit amet
urna. Curabitur vulputate vestibulum lorem. Fusce sagittis, libero
non molestie mollis, magna orci ultrices dolor, at vulputate neque
nulla lacinia eros. Sed id ligula quis est convallis tempor.
Curabitur lacinia pulvinar nibh. Nam a sapien.
\stoptext
\stoptyping
\subsection{Sample text}
\CONTEXT~comes with text for testing, we can use these paragraphs with
the command \type{\input} following to the name of the file (internal
file). We can use the command several times.
The following files names are possible.
\startitemize[packed, columns, three]
\item knuth
\item tufte
\item reich
\item materie
\item douglas
\item dawkins
\item ward
\item zapf
\item bryson
\item davis
\item thuan
\item hawking
\item linden
\item weisman
\item montgomery
\item carrol
\item schwarzenegger
\item carey
\item waltham
\item sapolsky
\item mcnish
\item klein
\item greenfield
\item poe
\stopitemize
\starttyping
\starttext
\input davis
\blank
\input knuth
\stoptext
\stoptyping
We now use the command \type{\blank} to separate two paragraphs with a
white space.
\section{Document structure}
The typical structure of an article is conformed by the following sections:
\startitemize[packed]
\item Title
\item Abstract
\item Introduction
\item Methods
\item Results
\item Discussion
\item Conclusions
\stopitemize
The references section was intentionally omitted, it will be explained latter.
Two cases are possible; numbered sections and no numbered sections. In
\in{Tab.}[tab:t1] the commands for creating sections are listed.
\placetable[]
[tab:t1]
{Commands for document structure. Inside the curly brackets the title of the section must be written}
{
\bTABLE[frame=off]
\bTR\bTD[style=\bf] Numbered \eTD \bTD[style=\bf] No numbered \eTD \eTR
\bTR\bTD \type{\chapter{}} \eTD \bTD \type{\title{}} \eTD \eTR
\bTR\bTD \type{\section{}} \eTD \bTD \type{\subject{}} \eTD \eTR
\bTR\bTD \type{\subsection{}} \eTD \bTD \type{\subsubject{}} \eTD \eTR
\bTR\bTD \type{\subsubsection{}} \eTD \bTD \type{\subsubsubject{}} \eTD \eTR
\eTABLE
}
Now we can define the structure of the document as follow.
\starttyping
\starttext
\chapter{Title of the paper}
\subject{Abstract}
\section{Introduction}
\section{Methods}
\section{Results}
\section{Discussion}
\section{Conclusions}
\stoptext
\stoptyping
We can see in the pdf the number is assigned automatically to each
numbered section. Now we can fill our paper with the sample text.
\starttyping
\starttext
\chapter{Title of the paper}
\subject{Abstract}
\input ward
\section{Introduction}
\input davis
\section{Methods}
\input knuth
\section{Results}
\input klein
\section{Discussion}
\input carey
\section{Conclusions}
\input lindey
\stoptext
\stoptyping
For code readability we can use tabs to indicate that such section is inside
other section. These tabs are only for orgnizing the source code and have not
influence on the pdf.
\section{Font sizes and styles}
The font size and style commans must to be used inside curly brackets. The
commands are showed in Tables \in[tab:t2] and \in[tab:t3].
\placetable[]
[tab:t2]
{Commands to modify the font size}
{ \bTABLE[frame=off, width=5cm]
\bTR\bTD {\bf Command} \eTD \bTD {\bf effect} \eTD\eTR
\bTR\bTD \type{{\tfxx texto}} \eTD \bTD {\tfxx texto} \eTD\eTR
\bTR\bTD \type{{\tfx texto}} \eTD \bTD {\tfx texto} \eTD\eTR
\bTR\bTD \type{{\tfa texto}} \eTD \bTD {\tfa texto} \eTD\eTR
\bTR\bTD \type{{\tfb texto}} \eTD \bTD {\tfb texto} \eTD\eTR
\bTR\bTD \type{{\tfc texto}} \eTD \bTD {\tfc texto} \eTD\eTR
\bTR\bTD \type{{\tfd texto}} \eTD \bTD {\tfd texto} \eTD\eTR
\eTABLE
}
\placetable[]
[tab:t3]
{Commands to modify the font style}
{
\bTABLE[frame=off, width=5cm]
%\bTR\bTD {\bfc Comando} \eTD \bTD {\bfc Resultado} \eTD \bTD {\bfc Estilo} \eTD
%\eTR
\bTR\bTD \eTD \eTR
\bTR\bTD \type{{\bf texto}} \eTD \bTD {\tfc \bf texto} \eTD \bTD
{\tfb Bold face} \eTD \eTR
\bTR\bTD \type{{\it texto}} \eTD \bTD {\tfc \it texto} \eTD \bTD
{\tfb Italic} \eTD \eTR
\bTR\bTD \type{{\sl texto}} \eTD \bTD {\tfc \sl texto} \eTD \bTD
{\tfb Slanted} \eTD \eTR
\bTR\bTD \type{{\sc texto}} \eTD \bTD {\tfc \sc texto} \eTD \bTD
{\tfb Smallcaps} \eTD \eTR
\bTR\bTD[width=5cm] \type{{\overstrike texto}} \eTD \bTD {\bfc \overstrike texto} \eTD \bTD
{\tfb Overstrike} \eTD \eTR
\bTR\bTD \type{{\ss texto}} \eTD \bTD {\tfc \ss texto} \eTD \bTD
{\tfb Sans serif} \eTD \eTR
\bTR\bTD \type{{\roman texto}} \eTD \bTD {\tfc \roman texto} \eTD \bTD
{\tfb Roman} \eTD \eTR
\eTABLE
}
\starttyping
\starttext
This is a {\tfb Big word} and this a {\bf bold face} style, and the
italic {\it style}
\stoptext
\stoptyping
\section{Lists}
The command for creating a list is:
\starttyping
\startitemize
...
\stopitemize
\stoptyping
Use the command \type{\item} following the text of the list to create a item, every
\type{\item} represents one element of the list. The elements can be a simple
word, line, paragraph or image, see the example.
\starttyping
\starttext
\startitemize
\item The first element of the list
\item The second element of the list
\item The third element of the list
\item \cdots
\stopitemize
\stoptext
\stoptyping
Now let's use the options for this command. The options must be written
in brackets at the end of \type{\start...}. In the following example, we
tell to \CONTEXT~to put numbers instead of symbols in beginning of the list. In
addition, the option {\it packed} reduce the space between lines.
\starttyping
\starttext
\startitemize[n, packed]
\item The first element of the list
\item The second element of the list
\item The third element of the list
\item \cdots
\stopitemize
\stoptext
\stoptyping
Check the following examples and analyze the options.
\starttyping
\starttext
\startitemize[n, packed]
\item The first element of the list
\item The second element of the list
\item The third element of the list
\item \cdots
\stopitemize
\input knuth
\startitemize[n, packed, continue]
\item The fourth element of the list
\item The fifth element of the list
\item The sexth element of the list
\item \cdots
\stopitemize
\stoptext
\stoptyping
If there are too many elements to list, we can divide into columns as follow.
\starttyping
\starttext
\startitemize[n, packed, columns, three]
\item The first element of the list
\item The second element of the list
\item The third element of the list
\item \cdots
\item The fourth element of the list
\item The fifth element of the list
\item The sixth element of the list
\item \cdots
\stopitemize
\stoptext
\stoptyping
There are several symbols that can be use in a list. You can change
the \type{[n]} (numeration) for any of the following alternatives:
\type{a, A, r, R, 1, 2, 3}. Try and see the results.
\section{Sub/superscript}
The command \type{\low{}} and \type{\high{}} put the text as sub or
superscript form. See the examples.
\starttyping
\starttext
The H\low{2}O is the water formula. The area is 80 m\high{2}.
\stoptext
\stoptyping
\section{Equations}
Inline math symbols are written between two \$ \$. \CONTEXT~will print the
math symbols with an adequate font.
\starttyping
\starttext
Solve the following equation $y = a + b - c$
\stoptext
\stoptyping
If we need isolate the equation in the document, we will use the
\type{\startformula...\stopformula} commands. This will print the
equation in an new line and centered.
\starttyping
\starttext
Solve the following equation
\startformula
y = a + b - c
\stopformula
\stoptext
\stoptyping
Note when we use the \type{\start...\stop} form, there is not needed
the \$ symbol.
\section{Figures}
To insert a figure we will use the command \type{\externalfigure
[ ][width=]}. In the first pair of brackets you will write the name
of the image without extension. If the image is in the same folder
there is not needed write the entire path.
\CONTEXT supports the image formats listed below. The image format is determined from the file extension (case insensitive).
\startitemize[packed]
\item PDF: File extension .pdf
\item MPS (MetaPost output): File extension .mps or .<digits>
\item JPEG: File extension .jpg or .jpeg
\item PNG: File extension .png
\item JPEG 2000: File extension .jp2
\item JBIG or JBIG2: File extension .jbig, .jbig2, or .jb2
\stopitemize
\starttyping
\starttext
This is an inline figure \externalfigure [cow][width=2cm], more text here.
\stoptext
\stoptyping
Captions are important to describe the figure, the command \type{\placefigure}
can use captions and labels. See carefully the brackets types.
\starttyping
\starttext
This is a figure with captions and label.
\placefigure[]
[fig:f1]
{This is the caption space. A cow}
{\externalfigure [cow][width=9cm]}
More text can be written here.
Cross-references are used with the label \in{Fig.}[fig:f1]
\stoptext
\stoptyping
In the previous example, the first pair of square brackets is for
location, leave it empty to let \CONTEXT place it. The second square brackets is for
label, this label will be use latter for cross-reference. The first pair of
curly brackets is for captions, and the second one is for the command.
\stoptext