Changes

Jump to navigation Jump to search
2,677 bytes added ,  16:18, 19 October 2020
m
Sandboxing an intro to ConTeXt
Two rules of syntax:
# '''Curly Braces Rule''': To group some text as a single self-contained unit, enclose the text in { }.# '''Square Brackets Rule''': Enclose arguments to ConTeXt commands in [ ].
Three principles of organization (here :# '''Applying Principle'method'' refers to an arbitrary text-processing method in ConTeXt):# To apply ''methodsomething'' to some text, enclose the text in <{{code>|\start''methodsomething''</}} {{code>|\stop''something''}}.# '''Configuring Principle''': To cutstomize configure ''methodsomething'', use <{{code>|\setup''methodsomething''</code>}}.# '''Creating Principle''': To define create a named customization of ''methodsomething'', use <{{code>|\define''methodsomething''</code>}}.
== A minimal example ==To see how these rules and principles work, let'&rsquo;s start with a minimal example of a ConTeXt document:
<texcode>
\starttext
\stoptext
</texcode>
Compiling this document typesets a built-in quotation from Knuth, which is inserted with {{code|\input knuth}}. (Throughout the ConTeXt documentation, you'll find this and other similarly built-in texts used to illustrate examples.) You can already see the Applying Principle at work: the usual way of processing the entire text of the document is named {{code|text}}, so to apply it you enclose the document text in {{cmd|starttext}} {{cmd|stoptext}}.
 
When you compile this document, you'll probably immediately see some things that you want to change. For example, the default paper size in ConTeXt is A4. This works well for most of the world, but if you&rsquo;re in the United States, you might prefer your paper size to be letter. That&rsquo;s easy enough: just use {{cmd|setuppapersize|[letter]}}.
<texcode>
\setuppapersize[letter]
\starttext
\input knuth
\stoptext
</texcode>
This is in keeping with the Configuring Principle. The way that paper is sized for a document in ConTeXt is called {{code|papersize}}, so you use {{cmd|setuppapersize}} to configure it. The use of [ ] to enclose the argument is in keeping with the Square Brackets Rule.
 
Another thing you might like to change is the page numbering. By default, ConTeXt places a page number at the center of the top of the page. To put it at the center of the bottom of the page instead, you can use {{cmd|setuppagenumbering|1=[location=bottom]}}.
<texcode>
\setuppapersize[letter]
\setuppagenumbering[location=bottom]
\starttext
\input knuth
\stoptext
</texcode>
This is another example of the Configuring Principle. The way that pages are numbered in ConTeXt is called {{code|pagenumbering}}, so you use {{cmd|setuppagenumbering}} to configure it. The use of [ ] to enclose the argument is in keeping with the Square Brackets Rule.
 
You also might want to change the way that paragraphs are indented. By default, they are not indented. To make them indented by a medium amount, use {{cmd|setupindenting|[yes, medium]}}. (Here {{code|yes}} turns the indenting on, but by default the amount is still {{code|none}}, so {{code|medium}} is used to specify the amount.)
<texcode>
\setuppapersize[letter]
\setuppagenumbering[location=bottom]
\setupindenting[yes, medium]
\starttext
\input knuth
\stoptext
</texcode>
The Configuring Principle is being applied here again. The way that paragraphs are indented in a ConTeXt is called {{code|indenting}}, so you use {{cmd|setupindenting}} to configure it. The use of [ ] to enclose the arguments is again in keeping with the Square Brackets Rule.
53

edits

Navigation menu