Changes

Jump to navigation Jump to search
1,298 bytes added ,  18:30, 19 October 2020
m
Still sandboxing intro to ConTeXt
Two rules of syntax:
# '''Square Brackets Rule''': Enclose arguments to ConTeXt commands in [ ].
# '''Curly Braces Rule''': To Use { } as delimiters to group some text as a single self-contained unit, enclose the text in { }.
Three principles of organization:
\framed {An example of something}
</context>
 
This is an example of how the Curly Braces Rule is used on ConTeXt. In order to delimit the single unit that follows it, you use { }. Many of ConTeXt's commands involve {{code|start}}, {{code|stop}}, {{code|setup}}, or {{define}}, but a fair number of them instead operate on the single unit following them, as {{cmd|framed}} does. Some, like {{cmd|framed}}, allow you to use either syntax.
 
Another situation where text needs to be treated as a single unit is when an argument to a command takes some text that involves [ ]. For example, the following code works fine because the text for the section title doesn&rsquo;t contain [ ]:
<context source="yes">
\startsection[title=A section title]
\stopsection
</context>
 
However, because the following section title contains [ ], it won&rsquo;t work unless you do something to tell ConTeXt that those square brackets are not signaling the end of the function&rsquo;s arguments:
 
<context source="yes">
\startsection[title=a[5] and other list elements]
\stopsection
</context>
 
One way to get around this problem is to apply the Curly Brace Rule: enclose the title in { } so that ConTeXt will treat the title text as a single unit. Then it works just fine:
<context source="yes">
\startsection[title={a[5] and other list elements}]
\stopsection
</context>
 
== Summary ==
Naturally not everything in ConTeXt can be derived from these two basic Rules and three basic Principles. There are many further details to learn in order to implement them, and not everything in ConTeXt is completely consistent with these Rules and Principles. However, they serve as a useful guide, and the design of ConTeXt really is remarkably consistent with these Rules and Principles, so they serve as a useful guide when you are trying to figure out how best to use the powerful tools that ConTeXt offers.
53

edits

Navigation menu