Changes

Jump to navigation Jump to search
5 bytes added ,  22:40, 21 October 2020
m
changed the section levels
__NOTITLE__
{{DISPLAYTITLE:An Introduction to ConTeXt}}
<!--
= An introduction to ConTeXt =
-->
ConTeXt has a very logical structure. Once you&rsquo;re familiar with its basic underlying principles, you will find that many of its commands seem quite natural. In this introduction, we&rsquo;ll look at two aspects of ConTeXt&rsquo;s structure:
Let&rsquo;s start with the commands...
== ''start-stop'', ''setup'', and ''define'' ==
There are three main types of commands in ConTeXt:
== Your first ConTeXt document ==
Now that you know the three main types of ConTeXt commands, let&rsquo;s look at how you use that structure to make documents. Here is a very minimal example of a ConTeXt document:
You can think of the code here this way: ConTeXt&rsquo;s way of formatting the entire text of the document is called {{code|text}}, so to apply that way of formatting you enclose the document text in {{cmd|starttext}} {{cmd|stoptext}}.
== Starting to customize things ==
When you compile this document, you&rsquo;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. The way that paper is sized for a document in ConTeXt is called {{code|papersize}}. You could use {{cmd|definepapersize}} to define a {{code|letter}} configuration for {{code|papersize}}, but the page size {{code|letter}} is already built-in, so you don&rsquo;t need to do that. So since you want to configure {{code|papersize}} globally for the entire document, use {{cmd|setuppapersize|[letter]}} at the start of your document:
Note that ConTeXt does not have a {{code|\startindenting}} or {{code|\stopindenting}} command. Instead, the named indenting configurations that you have defined with {{cmd|defineindenting}} can be used in other commands that define regions that can have indenting.
== Custom highlighting ==
For another example of what you might want to customize, suppose that in a book you are writing, you want to italicize terms that you will define later in the book. At first glance, it might be tempting just to italicize each one individually, as in:
<context source="yes" text="which produces">
Even though this example contains some extra complications, it gives another illustration of how you can use ''define'' commands to make more readable and reusable code in ConTeXt.
== Delimiters in ConTeXt ==
One other useful thing to understand about ConTeXt is what it uses for delimiters. There are three main delimiters in ConTeXt:
# '''curly braces''': in ConTeXt, { } are used as delimiters to group text as a single self-contained unit.
=== Square brackets ===
You have already seen lots of examples of how arguments to ConTeXt commands are enclosed in [ ]. ConTeXt commands usually have one, two, or three (occasionally more) arguments, and each one is enclosed in [ ]. For example, this use of {{cmd|definehighlight}} has two arguments:
<texcode>
In this example, there are two arguments and three parameters (each item in a comma-separated list being counted as a parameter).
=== Curly braces ===
There are three main ways that { } are used as delimiters to group text as a single unit:
== Summary ==
You have now seen the three main types of ConTeXt commands (''start-stop'', ''setup'', and ''define'') and how to use them. You have also seen the three main types of delimiters that ConTeXt uses (''start-stop'' commands, [ ], and { }) and how to use them. Understanding only these things will get you pretty far in ConTeXt.
Of course, the basic concepts described in this introduction are by no means exhaustive. There is plenty more in ConTeXt to explore! But hopefully this introduction will at least help you make your way through the other documentation more readily.
53

edits

Navigation menu