User:Sciurus/sandbox

From Wiki
< User:Sciurus
Revision as of 16:18, 19 October 2020 by Sciurus (talk | contribs) (Sandboxing an intro to ConTeXt)
Jump to navigation Jump to search

LIKE EVERYTHING IN THIS SANDBOX, THIS IS ONLY A DRAFT AND SHOULD NOT BE USED YET.

ConTeXt has a very logical structure: there are two basic rules of syntax and three basic principles of organization.

Two rules of syntax:

  1. Curly Braces Rule: To group some text as a single self-contained unit, enclose the text in { }.
  2. Square Brackets Rule: Enclose arguments to ConTeXt commands in [ ].

Three principles of organization:

  1. Applying Principle: To apply something to some text, enclose the text in \startsomething \stopsomething.
  2. Configuring Principle: To configure something, use \setupsomething.
  3. Creating Principle: To create a named customization of something, use \definesomething.

A minimal example

To see how these rules and principles work, let’s start with a minimal example of a ConTeXt document:

\starttext
\input knuth
\stoptext

Compiling this document typesets a built-in quotation from Knuth, which is inserted with \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 text, so to apply it you enclose the document text in \starttext \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’re in the United States, you might prefer your paper size to be letter. That’s easy enough: just use \setuppapersize[letter].

\setuppapersize[letter]
\starttext
\input knuth
\stoptext

This is in keeping with the Configuring Principle. The way that paper is sized for a document in ConTeXt is called papersize, so you use \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 [[Command/[location=bottom]|\[location=bottom]]].

\setuppapersize[letter]
\setuppagenumbering[location=bottom]
\starttext
\input knuth
\stoptext

This is another example of the Configuring Principle. The way that pages are numbered in ConTeXt is called pagenumbering, so you use \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 \setupindenting[yes, medium]. (Here yes turns the indenting on, but by default the amount is still none, so medium is used to specify the amount.)

\setuppapersize[letter]
\setuppagenumbering[location=bottom]
\setupindenting[yes, medium]
\starttext
\input knuth
\stoptext

The Configuring Principle is being applied here again. The way that paragraphs are indented in a ConTeXt is called indenting, so you use \setupindenting to configure it. The use of [ ] to enclose the arguments is again in keeping with the Square Brackets Rule.