\startcomponent ma-cb-en-document

\product ma-cb-en

\chapter{How to create a document}

\index{input file}

Let's assume you want to create a simple document. It has
some structure and contains a title page, a few chapters,
sections and sub sections. Of course there is a table of
contents and an index.

\CONTEXT\ can create such a document automatically if you
offer the right input by means of a file. So first you have
to create an input file. An input file consists of a name
and an extension. You can choose any name you want but the
extension has to be \type{tex}. If you create a file with
the name \type{myfile.tex} you will find no difficulties in
running \CONTEXT.

An \pagereference[inputfile] input file could look like
this:

\startbuffer
\starttext

\startstandardmakeup
  \midaligned{How to make a document.}
  \midaligned{by}
  \midaligned{The Author}
\stopstandardmakeup

\completecontent

\chapter{Introduction}

... your text\index{indexentry} ...

\chapter{One Chapter}

\section[firstsection]{The first section}

... your text ...

\section{The second section}

\subsection{the first sub section}

... your text\index{another indexentry} ...

\subsection{the second sub section}

... your text ...

\section{The third section}

... your text ...

\chapter{Another Chapter}

... your text ...

\chapter[lastchapter]{The Last Chapter}

... your text ...

\completeindex

\stoptext
\stopbuffer

{\switchtobodyfont[9pt]\typebuffer}

\CONTEXT\ expects a plain \ASCII\ input file. Of course you
can use any text|-|editor or word|-|processor you want, but you
should not forget that \CONTEXT\ can only read \ASCII\
input. Most text|-|editors or word|-|processors can export your
file as plain \ASCII.

The input file should contain the text you want to be
processed by \CONTEXT\ and the \CONTEXT\ commands. A
\CONTEXT\ command begins with a backslash~\type{\}. With
the command \type{\starttext} you indicate the beginning of
your text. The area before \type{\starttext} is called the
set up area and is used for defining new commands and setting up
the layout of your document.

A command is usually followed by a left and right bracket
pair \type{[]} and|/|or a left and right brace \type{{}}. In
\type{\chapter[lastchapter]{The Last Chapter}} the command
\type{\chapter} for example tells \CONTEXT\ to perform a
few actions concerning design, typography and structure.
These actions may be:

\startitemize[n,packed]
\item start a new page
\item increase chapter number by one
\item place chapter number in front of chapter title
\item reserve some vertical space
\item use a big font
\item put chapter title (and page number) in table of contents
\stopitemize

These actions will be performed on the argument that is
given between the left and right braces: {\em The Last
Chapter}.

The \type{[lastchapter]} between brackets has not been
mentioned yet. This is a label with a logical name that can
be used for referring to that specific chapter. This can be
done with yet some other \CONTEXT\ commands:
\type{\in{chapter}[lastchapter]} that typesets the chapter
number, while \type{\about[lastchapter]} returns the title.

So now the list of actions can be extended with:

\startitemize[continue]
\item let label \type{lastchapter} be chapter number
      and title (and store these for later use)
\stopitemize

Other actions concerning running heads, number resetting and
interactivity are disregarded at this moment.

If you have \CONTEXT\ process this example file, you would
obtain a very simple document with a few numbered chapters
and section headers.

While processing the file \CONTEXT\ takes care of many
things. One of these things is for example page numbering.
But in order to make a table of contents \CONTEXT\ needs
page numbers that are not yet known to \CONTEXT\ at the
first run. So you have to process this file twice (a two
pass job). \CONTEXT\ will produce a few auxiliary files to
store this kind of information. In some instances you have
to process an input file thrice (a three pass job). One can
use \TEXEXEC\ to run \CONTEXT\ from the command line. This
\RUBY\ script also takes care of the multiple passes and
processing of auxiliary files. \TEXEXEC\ is part of the
standard \CONTEXT\ distribution.

\stopcomponent
