Changes

Jump to navigation Jump to search
3,775 bytes added ,  16:10, 21 October 2020
m
Still sandboxing an Intro to ConTeXt
LIKE EVERYTHING IN THIS SANDBOX, THIS IS ONLY A DRAFT AND SHOULD NOT BE USED YET.
== The structure of An introduction to ConTeXt ==ConTeXt has a very logical structure. It has five Once you are familiar with its basic notational conventionsunderlying principles, you will find that many of its commands seem quite natural. == ''start-stop'', ''setup'', and ''define'' ==There are three main types of commands in ConTeXt:
# '''square brackets''': Enclose arguments to ConTeXt commands in [ ].
# '''curly braces''': Use { } as delimiters to group text as a single self-contained unit.
# '''start-stop''': To apply ''something'' to some text, enclose the text in {{code|\start''something''}} {{code|\stop''something''}}.
# '''setup''': To configure ''something'', use {{code|\setup''something''}}.
# '''define''': To create a named customization of ''something'', use {{code|\define''something''}}.
 
The usual way to use these types of commands is as follows. If you want to apply ''something'' (such as formatting) to text, enclose the text in {{code|\start''something''}} {{code|\stop''something''}}. The arguments of {{code|\start''something''}}, enclosed in [ ], can be used to configure the exact nature of the ''something'' that you want to apply. For example, in the middle of a ConTeXt document:
 
<context source="yes" text="produces">
The quick brown fox jumps over the
\startframed[corner=round]
lazy
\stopframed
dog.
</context>
 
However, setting the ''start-stop'' arguments locally like this is usually not the best way to configure the ''something'' that you are applying. The problem with modifying the arguments locally like this is that if you eventually reuse this configuration &mdash; in this document or even in other documents that you might write &mdash; you won't be able to edit and maintain the configuration consistently. You might be able to get away applying formatting lcoally like this if you use it in only one single place, but since you generally don&rsquo;t know how you might want to use the same configuration in the future, it's usually best to avoid modifying modifying the ''start-stop'' arguments locally like this.
 
A somewhat better way to configure ''something'' is to use {{code|setup''something''}} in a section of your code that is dedicated to configuration. This will configure ''something'' globally: the default configuration of this particular ''something'' throughout your document will be whatever you set it to in this way. For example:
 
<context source="yes" text="produces">
\setupframed[corner=round]
The
\startframed
quick
\stopframed
brown fox jumps over the
\startframed
lazy
\stopframed
dog.
</context>
 
Since you have set up framed to have rounded corners here, that is the default behavior throughout the document. You can still override it locally if need be, but in doing so, consider the cautions above about local modifications.
 
But this still isn't the best way to configure ''something'' because what if you might &mdash; now or in the future &mdash; have more than one type of frame in your document? In order to anticipate such possibilities, the best way to configure ''something'' is ordinarily to use {{code|define''something''}} to create a meaningful name for each of your custom configurations. These custom configurations will be easy to modify globally in a consistent way, now and into the future. And if you choose your names well, your ConTeXt code will be easier for human beings (including yourself) to read. For example:
<context source="yes" text="produces">
\defineframed[adjectiveFramed][corner=round]
\defineframed[nounFramed]
The
\startframed[adjectiveFramed]
quick brown
\stopframed
\startframed[nounFramed]
fox
\stopframed
jumps over the
\startframed[adjectiveFramed]
lazy
\stopframed
\startframed[nounFramed]
dog.
\stopframed
</context>
 
When you read this code, you can tell immediately that nouns are framed one way, and adjectives another. Since it uses {{cmd|defineframed}} and gives these customizations informative names, editing and maintaining this document is much easier. If you decide that you want to give all the adjectives some other type of frame, a simple change to the {{cmd|defineframed}} is all that is needed. There is no need to worry about going through with search and replace and trying to make sure that you find and update all the adjective frames. A single small change will make the update globally and consistently throughout the document.
 
 
== A minimal example: ''start-stop'' and ''setup'' notation ==
\stopsection
</context>
 
== Delimiters in ConTeXt ==
# '''square brackets''': Enclose arguments to ConTeXt commands in [ ].
# '''curly braces''': Use { } as delimiters to group text as a single self-contained unit.
 
53

edits

Navigation menu