Difference between revisions of "User:Sciurus/sandbox"

From Wiki
Jump to navigation Jump to search
m (Sandboxing an intro to ConTeXt)
m (link names again)
 
(25 intermediate revisions by the same user not shown)
Line 1: Line 1:
LIKE EVERYTHING IN THIS SANDBOX, THIS IS ONLY A DRAFT AND SHOULD NOT BE USED YET.
+
[[Introduction]]
  
ConTeXt has a very logical structure: there are two basic rules of syntax and three basic principles of organization.
+
[[Some Basic Commands]]
 
 
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:
 
# '''Applying Principle''': To apply ''something'' to some text, enclose the text in {{code|\start''something''}} {{code|\stop''something''}}.
 
# '''Configuring Principle''': To configure ''something'', use {{code|\setup''something''}}.
 
# '''Creating Principle''': To create a named customization of ''something'', use {{code|\define''something''}}.
 
 
 
== A minimal example ==
 
To see how these rules and principles work, let’s start with a minimal example of a ConTeXt document:
 
<texcode>
 
\starttext
 
\input knuth
 
\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.
 

Latest revision as of 22:44, 21 October 2020