% interface=en output=pdftex

% compile with:
%   texexec --interface=en --pdf --environment=screen --mode=screen LaTeX2ConTeXt

% To do:
% - tables/longtables/tabular/list of tables
%   table header/footers, splitting tables, repeating headers/footers.
% - breaking lines
% - expand myheadings subject a bit
% - pagestyle myheadings how to do in context missing
% - refer to fancy package
% - document \chapter*, \begin{figure*} etc.
% - \filename
% - \goto and \gotobox

%D Berend,
%D
%D compiling this document:
%D Either uncomment one of the two lines below, or start texexec
%D with the --environment switch

\environment screen
% 2003-07-19: it seems paper no longer works
%\environment paper

%D Apart from changes in the front/back, I only changed some \type{\sl} and
%D \type{\it}s into \type{\em} and removed the \type{backmatter} environment
%D
%D Groetjes, Taco

% URL's
\useURL
	[contextsupport]
	[http://www.pragma-ade.com/]
\useURL
	[contextmanualen]
	[http://www.pragma-ade.com/general/manuals/cont-eni.pdf]
\useURL
	[contextmanualnl]
	[http://www.pragma-ade.com/general/manuals/cont-nli.pdf]
\useURL
	[contextbeginner]
	[http://www.pragma-ade.com/general/manuals/ms-cb-en.pdf]
\useURL
	[contextsubscribe]
	[http://www.ntg.nl/mailman/listinfo/ntg-context]
\useURL
  [4tex]
  [http://4tex.ntg.nl/4tex5/]
\useURL
  [downloadbib]
  [http://www.elvenkind.com/~taco/bibmod/]

% mail addresses
\useURL
  [david]
  [mailto:darnold@northcoast.com]
  []
  [David Arnold]
\useURL
  [wybo]
  [mailto:wybo@servalys.hobby.nl]
  []
  [Wybo Dekker]
\useURL
  [hans]
  [mailto:pragma@wxs.nl]
  []
  [Hans Hagen]



\startTutorial
   [TitleA=\LaTeX,
    TitleB=in proper,
    TitleC=\ConTeXt,
	Author=Berend de Boer,
	Email=berend@pobox.com,
    Pagina=23,
    Date=2003-July-07,
    Periode=Winter,
    Jaar=2003]

\startmode[screen]
  \startbodymatter
\stopmode

\chapter{\ConTeXt\ for \LaTeX\ users}

\section{For who is this document}
If you are a \LaTeX\ user, switching to an entirely different
macro||package is a very big step. Everything you put so much effort
in to learn, doesn't work anymore.

I can't help but quote from that famous book ``The psychology of
computer programming'' (chapter 11):

\startquotation
	In making our adjustments to our particular programming language, we
	can easily become attached to it simply because we now have to much
	invested in it. We often listen to a man complaining about his
	nagging, slovenly, and prodigal wife, only to find that when asked
	why he doesn't leave her, he replies that he cannot live without
	her. Most people would prefer almost any amount of pain to giving up
	the familiarity of some constant companion for an unknown
	quantity. We see this effect when we try to teach a programmer his
	{\em second} language. Teaching the first is no great problem, for
	he has no investment in any other. By the time he has learned two or
	more, he is aware that more things exist in this world than he has
	dreamed of. But letting go of the first is, to him, just a promise
	of pain with no promise of compensating pleasure.
\stopquotation

To help lessen the pain for users make the switch, this document shows
short \LaTeX\ code snippets and how you do the same in \ConTeXt.

\ConTeXt\ is a macro package that's far more advanced than \LaTeX. You
can enhance \LaTeX\ with third party packages, but not all macro
packages work together with each other. \ConTeXt\ is an integrated,
powerful and flexible macro package for which you seldom need third
party packages. \ConTeXt\ also has been used to create large and
complex on||screen documents, including hyperlinks, on screen buttons,
forms, cross||document links, and so on.

This document is not a reference to the \ConTeXt\ manual. It only
shows you the \ConTeXt\ macro's for the familiar \LaTeX\ macro's. It
does not explain the \ConTeXt\ macro's in detail nor shows you the
numerous options almost every command has. You are referred to the
\from[contextmanualen] instead.


\section{References}

If you take up \ConTeXt, you probably need help. You can find it at
the following locations:
\startitemize
\item The \ConTeXt\ support site is \from[contextsupport].
\item There is a beginner's manual in english at
  \from[contextbeginner].
\item A beta version of the complete english manual (not entirely
  complete yet) can be found at \from[contextmanualen].
\item \ConTeXt\ main reference is still in dutch and can be
	found at \from[contextmanualnl].
\item The 4\TeX\ manual also contains much material on \ConTeXt, see
  \from[4tex].
\item There is a \ConTeXt\ mailling list. Subscribe by going to
  \from[contextsubscribe].
\stopitemize


\section{The July 2003 update}

The only change from the previous version released in 2000 is that
broken links are fixed.


\section{Acknowledgements}

Thanks to \from[david], \from[wybo] and \from[hans] for offering
suggestions and sending corrections to this document.




\chapter{\ConTeXt\ basics}

This chapter tells you \ConTeXt's basics.

\section{A basic document}

A basic `hello world' kind of document in \LaTeX\ looks like:

\startLATEX
\documentclass{article}

\begin{document}
Hello world.
\end{document}
\stopLATEX

In \ConTeXt\ it looks like:

\startCONTEXT
\starttext
Hello world.
\stoptext
\stopCONTEXT

\ConTeXt\ does not have a special command to load the style for a
certain document. If you have them, you can load style files and such
with the \TeX\ macro \cmdcont{input}.


\section{Compiling your document}

If your \LaTeX\ `Hello world' document is called \type|text.tex|, you probably
compile your document with:
\starttyping
latex test.tex
\stoptyping

In \ConTeXt\ you use a wrapper around the \TeX\ compiler to compile
your document. Your \ConTeXt\ document is compiled with:
\starttyping
texexec test.tex
\stoptyping

\type|texexec| also takes care of the table of contents, indexes,
references and sorted lists (see also \in{section}[sec:texexec]. It
recompiles your document as many times as necessary to make sure
references in the document are ok.

While you could use something as:
\starttyping
context test.tex
\stoptyping

to compile your document, this is not advised. Learn to use
\type|texexec|:

\starttyping
texexec test.tex
\stoptyping

The first output of \type|texexec| should look like:

\starttyping
TeXExec 1.9 - ConTeXt / PRAGMA ADE 1997-2000

           executable : pdfetex
               format : cont-en
            inputfile : testc
               output : dvips
            interface : en
         current mode : all
              TeX run : 1
\stoptyping

and then it starts compiling your document.

\ConTeXt\ supports various language specific interfaces. This document
presents the english language interface but \ConTeXt\ also has a dutch
and german based interface. If the default interface on your system is
not correct, you can either change the initialization file
\type|texexec.ini| or give a parameter to \type|texexec|:

\starttyping
texexec -interface=en test.tex
\stoptyping

\ConTeXt\ supports also various output formats like \type|.dvi| and
\type|.pdf|. To generate a \type|.pdf| document instead of a
\type|.dvi| document, change \type|texexec.ini| or call \type|texexec|
with the following parameter:

\starttyping
texexec -output=pdftex test.tex
\stoptyping

Or even shorter with:

\starttyping
texexec --pdf test.tex
\stoptyping

Probably the best option is to put the \type|texexec| parameters as
the first line in your document like:

\startCONTEXT
% interface=en output=pdftex

\starttext
This example compiles with the english interface and
generates pdf output.
\stoptext
\stopCONTEXT



\section{Chapters and sections}

Chapters and sections in \ConTeXt\ are very much like \LaTeX. In
\LaTeX\ you write:

\startLATEX
\documentclass{report}

\begin{document}

\chapter{One}
My first chapter.

\chapter{Two}
My second chapter.

\end{document}
\stopLATEX

In \ConTeXt\ this looks like:

\startCONTEXT
\starttext

\chapter{One}
My first chapter.

\chapter{Two}
My second chapter.

\stoptext
\stopCONTEXT

Not much difference here. However, referencing to chapters or sections
is done differently in \ConTeXt, see \in{section}[sec:indocreference].


\section{Table of contents}

A table of contents in \LaTeX\ is done with the
\cmdlat{tableofcontents} command:

\startLATEX
\documentclass{report}

\begin{document}

\tableofcontents

\chapter{One}
My first chapter.

\chapter{TwoOne}
My second chapter.

\end{document}
\stopLATEX

In \ConTeXt\ you get a table of contents with the
\cmdcont{completecontent} command:

\startCONTEXT
\starttext

\completecontent

\chapter{One}
My first chapter.

\chapter{Two}
My second chapter.

\stoptext
\stopCONTEXT

Remember to compile with \type|texexec|, or else you will not get the
table of contents (see \in{section}[sec:texexec]). Besides
\cmdcont{completecontent}, \ConTeXt\ also has
\cmdcont{placecontent}. \cmdcont{completecontent} starts a new page,
while \cmdcont{placecontent} doesn't. The behaviour of
\cmdcont{placecontent} also depends on the location where the table of
contents is summoned.




\chapter{Common \LaTeX\ Environments}

In the following sections the most common \LaTeX\ environments are
discussed and \ConTeXt\ alternatives are given. Environments are
discussed in alphabetic order.


\section{The abstract environment}

With \LaTeX's abstract environment you can mark one or more paragraphs
in some special way. It also depends on the documentclass you have
loaded, either article or report. Its layout is equal to the
quotation environment.

You use abstract as follows:

\startLATEX
\documentclass{article}
\begin{document}

\begin{abstract}
This is an abstract of this article.
\end{abstract}

\end{document}
\stopLATEX

There is no abstract environment in \ConTeXt, because it really is a
style option. However, you can get the same effect as \LaTeX's article
abstract environment with:

\startCONTEXT
\starttext

\startnarrower\switchtobodyfont[small]
\midaligned{\bf Abstract}\par
This is an abstract of this article.
\stopnarrower

\stoptext
\stopCONTEXT

With \cmdcont{startnarrower} you get a paragraph, left and right
indented by some white space. With \cmdcont{switchtobodyfont} you get
a font somewhat smaller than the current body font. With
\cmdcont{midaligned} you get a centered line.


\section[sec:bibliography]{The bibliography environment}

In \LaTeX\ you can create a bibliography within the \envlat{bibliography}
environment:

\startLATEX
\documentclass{article}

\begin{document}

\section{My life}

I've read only two books in my life \cite{Bekke92}, \cite{Brodie84}.

\begin{thebibliography}{Brodie84}

\bibitem[Bekke92]{Bekke92}
  J.H.~ter~Bekke, \emph{Semantic datamodeling}, Prentice Hall, Hemel
  Hempstead, ISBN~0-13-806050-9, 1992.

\bibitem[Brodie84]{Brodie84}
  L.~Brodie, \emph{Thinking Forth, a language and philosophy for
  solving problems}, Prentice Hall, ISBN 0-13-917568-7, 1984.

\end{thebibliography}

\end{document}
\stopLATEX

Entries are started with \cmdlat{bibitem} and appear in the
\envlat{bibliography} environment. Entries are referred to with the
\cmdlat{cite} command.

In \ConTeXt, bibliographies are supported by the \type{bib} module.
This module is not yet in the standard release, you have to download
it separately at \from[downloadbib]. See \in{section}[sec:doc]
on how to generate the documentation for this module. It seems the
documentation is a bit ahead of the implementation, but expect the
module to improve over the course of the next few months.

In \ConTeXt, references have to be in a separate file. For this
example it is easiest to have them in a file with the same name, but
with the \type|.bbl| extension.

An example of such a file is:

\startCONTEXT
\startpublication[k=Brodie84,
                  t=article,
                  a=L.~Brodie,
                  y=1984,
                  s=LB84]
\artauthor[]{Leo}[L.]{}{Brodie}
\arttitle{Thinking Forth, a language and philosophy for solving
          problems}
\journal{Prentice Hall}
\pubyear{1984}
\stoppublication

\startpublication[k=Bekke92,
                  t=article,
                  a=J.H.~ter~Bekke,
                  y=1992,
                  s=JB92]
\artauthor[]{Johan}[J.H.]{ter}{Bekke}
\arttitle{Semantic datamodeling}
\journal{Prentice Hall}
\pubyear{1992}
\stoppublication
\stopCONTEXT

Entries are started with the  \envcont{publication} command.

Having this file, it is now possible to use them as follows:

\startCONTEXT
\usemodule[bib]

\setuppublications
  [numbering=yes,
  sort=author]

\starttext

\section{My life}

I've read only two books in my life \cite[Bekke92,Brodie84]. But I've
to admit that I no longer think Forth \cite[Brodie84].

\completepublications

\stoptext
\stopCONTEXT

The command \cmdcont{setuppublications} is optional. It defines such
things as which entries to include, how to sort them or to include
every entry or only the referenced ones. It currently does not seem
possible to mimick the way \LaTeX\ references things.

With \cmdcont{completepublications} the list of publications is
given. And of course there is also a \cmdcont{placepublications}
command which does not add something to the table of contents.

For \BIBTEX\ information, see \in{section}[sec:bibtex].


\section[sec:description]{The description environment}

\LaTeX's \envlat{description} produces a list where each
label is a keyword instead of a bullet or a number.

\startLATEX
\documentclass{article}
\begin{document}

\begin{description}
\item[gnat] A small animal, found in the North Woods, that causes no
	end of trouble.
\item[gnu] A large animal, found in crossword puzzles, that causes no
	end of trouble.
\item[armadillo] A medium-sized animal.
\end{description}

\end{document}
\stopLATEX


In \ConTeXt\ you use the \cmdcont{definedescription} command to setup
an environment. A description is not an enumeration like it is in
\LaTeX. In the following code we first define the environment, called
\type{animal}. It's also possible to define the environment
\type{description}, but that's quite confusing. In the main text we
show how this new environment is used:

\startCONTEXT
\definedescription
  [animal]
  [location=hanging,
   margin=standard,
   headstyle=bold]

\definestartstop
  [animals]
  [before=\blank\startpacked,
   after=\stoppacked\blank]

\starttext

\startanimals
\animal{gnat} A small animal, found in the North Woods, that
  causes no end of trouble.

\animal{gnu} A large animal, found in crossword puzzles, that
  causes no end of trouble.

\startanimal{armadillo}
A medium-sized animal.
\stopanimal

\stopanimals

\stoptext
\stopCONTEXT

Within \tex{startanimals}, descriptions (animals) can be given. You
can use both \tex{animal} or \tex{startanimal} to define a
description. The start/stop pair is of course more robust. The type
\tex{animal} expects a \tex{par} (or empty line) to work.

The use of \cmdcont{definestartstop} is optional, but this helps to
clearly mark the definition of animals and to have a common point of
settings like white space before and after. With \cmdcont{blank} we
get the default blank space before (the space between
paragraphs). With \envcont{packed} we get paragraphs that do not have
white space between them.

A different solution, however without the hanging indent feature, is:

\startCONTEXT
\starttext

\startitemize[4*broad,packed]
\sym{gnat} A small animal, found in the North Woods, that causes no
  end of trouble.
\sym{gnu} A large animal, found in crossword puzzles, that causes no
  end of trouble.
\sym{armadillo} A medium-sized animal.
\stopitemize
\stoptext
\stopCONTEXT

In this example, the text \type|armadillo| overlaps with its
definition if the margin is not defined sufficiently large. So the
first solution is better.

This example also shows \ConTeXt's way of setting options. With
\type{4*broad} we set the width of the symbol to 4 times the
\type{broad} setting. With \type{packed} we specify that we don't want
white space between paragraphs.


\section[sec:enumerate]{The enumerate environment}

\LaTeX's \envlat{enumerate} is used to produce a numbered
list:

\startLATEX
\documentclass{article}
\begin{document}

\begin{enumerate}
\item First item.
\item Second item.
\end{enumerate}

\end{document}
\stopLATEX

In \ConTeXt\ lists, both numbered and unnumbered, are started with
\cmdcont{startitemize}. You use the \type|n| option to produce a
numbered list:

\startCONTEXT
\starttext

\startitemize[n]
\item First item.
\item Second item.
\stopitemize

\stoptext
\stopCONTEXT

See also the example in \in{section}[sec:itemize]. See
\in{section}[sec:setupitemize] for how to influence the layout of lists.


\section[sec:itemize]{The itemize environment}

\LaTeX's \envlat{itemize} is used to produce an unnumbered
list:

\startLATEX
\documentclass{article}
\begin{document}

\begin{itemize}
\item First item.
\item Second item.
\end{itemize}

\end{document}
\stopLATEX

Every line starts with a bullet.

In \ConTeXt\ lists, both numbered and unnumbered, are started with
\cmdcont{startitemize}. If you don't use an option, you get an
unnumbered list:

\startCONTEXT
\starttext

\startitemize
\item First item.
\item Second item.
\stopitemize

\stoptext
\stopCONTEXT

See also the example in \in{section}[sec:enumerate]. See
\in{section}[sec:setupitemize] for how to influence the layout of lists.


\section{The quotation environment}

You can quote someone in \LaTeX\ with the \envlat{quote}:

\startLATEX
\documentclass{article}
\begin{document}

\begin{quote}
  But letting go of the first is, to him, just a promise
  of pain with no promise of compensating pleasure.
\end{quote}

\end{document}
\stopLATEX

In \ConTeXt\ you achieve the same effect with the \cmdcont{startquotation}
command:

\startCONTEXT
\starttext

\startquotation
  But letting go of the first is, to him, just a promise
  of pain with no promise of compensating pleasure.
\stopquotation

\stoptext
\stopCONTEXT

\LaTeX\ also has a \envlat{quotation} used for quotations
of more than one paragraph. In \ConTeXt\ you can always use
\cmdcont{startquotation}.

\ConTeXt\ also has `inline' quotes. Use either its \cmdcont{quote} or
\cmdcont{quotation} command:

\startCONTEXT
\starttext

This is a \quote{quote} and this is a \quotation{quotation}.

\stoptext
\stopCONTEXT

\cmdcont{quote} surrounds your quote with single quote characters,
\cmdcont{quotation} surrounds your quote with double quote characters.


\section{The verbatim environment}

Verbatim text (text not subject to macro expansion) in \LaTeX\ is done
with the verbatim environment:

\startLATEX
\documentclass{article}
\begin{document}

\begin{verbatim}
This is
verbatim \LaTeX.
\end{verbatim}

\end{document}
\stopLATEX

In \ConTeXt\ you write this as:

\startCONTEXT
\starttext

\starttyping
This is
verbatim \ConTeXt.
\stoptyping

\stoptext
\stopCONTEXT




\chapter{Floats}

Floats are pieces of text that do not follow the main flow, but can go
on the same page or elsewhere. \ConTeXt\ has very extensive support
for them.

\section{Figures}

In \LaTeX\ you can include a bitmap if you use the
\type{graphics} or \type{graphicx} package. With the
\cmdlat{includegraphics} command you can include a bitmap.

If you use pdftex, you can now define a figure as simply as:

\startLATEX
\documentclass{article}

\usepackage[pdftex]{graphicx}

\begin{document}

\begin{figure}
\includegraphics{test.png}
\caption{Test picture}
\label{fig:test}
\end{figure}

\end{document}
\stopLATEX

This figure also has a caption and it has a label so you can refer to
it. In \ConTeXt\ you do this with:

\startCONTEXT
\starttext

\placefigure
  []
	[fig:test]
	{Test picture}
	{\externalfigure[test.png]}

\stoptext
\stopCONTEXT

Probably the size of the figure differs between \LaTeX\ and
\ConTeXt. In \ConTeXt\ figures have their natural size by default. You
can influence the scaling of a figure with the scale option:

\startCONTEXT
\starttext

\placefigure
  []
	[fig:test]
	{Test picture}
	{\externalfigure[test.png][scale=2000]}

\stoptext
\stopCONTEXT

The default scale is 1000 (100\%). Scale 2000 gives you a figure twice
as large. You can also specify the width of the figure in dimensions,
for example half the text width (see example below).

In \ConTeXt\ you usually define your figures at the top of your file,
above the \tex{starttext} command. You can recall them when needed:

\startCONTEXT
\useexternalfigure
	[testone]
	[test.png]
	[scale=2000]

\useexternalfigure
	[testtwo]
	[test.png]
	[width=.5\textwidth]

\starttext

\placefigure
  []
	[fig:testone]
	{Test picture: twice as large as it natural size}
	{\externalfigure[testone]}

\placefigure
  []
	[fig:testtwo]
	{Test picture: half as large as the text}
	{\externalfigure[testtwo]}

\stoptext
\stopCONTEXT

With \cmdcont{useexternalfigure} the first command is the name of the
macro you want to define, the next is the name of the file. The third
parameter are scaling and sizing options.

In \from[contextbeginner] you can find more things you can do with
figures like placing two figures together or placing text left or
right of a figure.


\section{List of figures}

A list of figures in \LaTeX\ can be given with its
\cmdlat{listoffigures} command:

\startLATEX
\documentclass{article}

\usepackage[pdftex]{graphicx}

\begin{document}

\listoffigures

\begin{figure}
\includegraphics{test.png}
\caption{Test picture}
\label{figure:test}
\end{figure}

\end{document}
\stopLATEX

In \ConTeXt\ you use the \cmdcont{completelistoffigures} command:

\startCONTEXT
\starttext

\completelistoffigures

\placefigure
	[fig:test]
	{Test picture}
	{\externalfigure[test.png]}

\stoptext
\stopCONTEXT

Just like \cmdcont{completecontent}, besides
\cmdcont{completelistoffigures} their also is a\crlf
\cmdcont{placelistoffigures} command which doesn't start a new
page.

Be aware that \cmdcont{completelistoffigures} only works at the
beginning of a document, not at the end. There probably is a
workaround, and as soon as I know it, I'll say so here.




\chapter{Tables}

\section{The tabular environment}

In \LaTeX\ tables are defined with the \envlat{tabular} environment. A
famous \LaTeX\ example demonstrating many of its features is:

\startLATEX
\documentclass{article}

\begin{document}

\begin{tabular}{|r||r@{--}l|p{1.25in}|}
\hline
\multicolumn{4}{|c|}{GG\&A Hoofed Stock}
  \\ \hline\hline
&\multicolumn{2}{c|}{Price}& \\ \cline{2-3}
\multicolumn{1}{|c||}{Year}
& \multicolumn{1}{r@{\,\vline\,}}{low}
& high & \multicolumn{1}{c|}{Comments}
  \\ \hline
1971 & 97 & 245 & Bad year for
           farmers in the west.   \\ \hline
  72 & 245 & 245 & Light trading due to a
                    heavy winter. \\ \hline
  73 & 245 & 2001 & No gnus was very
          good gnus this year.    \\ \hline
\end{tabular}

\end{document}
\stopLATEX

In \ConTeXt\ tables are created within the \envcont{table}
environment:

\startCONTEXT
\starttext

\starttable[|r|r|l|p(1.25in)|]
\HL
\VL \FOUR{GG\&A Hoofed Stock} \VL\SR
\HL
\VL \LOW{Year} \VL \TWO{Price}  \VL \LOW{Comments} \VL\SR
\DC            \DL[2]           \DC                \DR
\VL            \VL low \VL high \VL                \VL\SR
\HL
\VL 1971 \VL \TWO{97--245} \VL
  Bad year for farmers in the west. \VL\SR
\HL
\VL 72 \VL \TWO{245--245} \VL
  Light trading due to a heavy winter. \VL\SR
\HL
\VL 73 \VL \TWO{245--2001} \VL
  No gnus was very good gnus this year. \VL\SR
\HL
\stoptable

\stoptext
\stopCONTEXT

In \ConTeXt\ you can use \envcont{tables} to create a table
that can be split accross pages.. In \LaTeX\ this is provided by the
\envlat{longtable}, provided by an external package.


\section{The tabbing environment}

To align data vertically, one can use the \envlat{tabbing}
in \LaTeX. It's usage is quite complex, only a simple example is given:

\startLATEX
\documentclass{article}

\begin{document}
\begin{tabbing}
  Armadillo: \= \kill
  Gnat: \> not edible \\
  Armadillo: \> not edible\\
\end{tabbing}
\end{document}
\stopLATEX

The same example in \ConTeXt\ using its \envcont{tabulate} environment:

\startCONTEXT
\starttext
\starttabulate[|l|p|]
\NC Gnat: \NC not edible \NC\NR
\NC Armadillo: \NC not edible \NC\NR
\stoptabulate
\stoptext
\stopCONTEXT

In \LaTeX\ the first line more or less determines the format (but can
be changed in latter lines). In \ConTeXt\ the \envcont{tabulate}
environment works more or less like its \envcont{table}
environment. The header specifies the format of the columns. The
width of the columns will be equal to the row with the largest
contents. You can also explicitly specify the width.

Every row starts with \cmdcont{NC} (next column). Every row ends with a
\cmdcont{NC} and \cmdcont{NR} (next row).

The difference between \ConTeXt's \envcont{tabulate} and
\envcont{table} environments are that the former splits across
pages. And the
\type{p} column type is a bit smarter in the \envcont{tabulate}
environment. The drawback of \envcont{tabulate} is, that it does not
support vertical lines.


\section{List of tables}

In \LaTeX\ one gets the list of tables with the \cmdlat{listoftables}
command. Only tables placed within the \envlat{table} environment are
put in the table of contents.

In \ConTeXt\ one uses the \cmdcont{placelistofoftables} command. And
as in \LaTeX, only tables given as argument to \cmdcont{placetable}
are pu in the table of contents.




\chapter{Math}


\section{General}

Math in \ConTeXt\ and \LaTeX\ is not that different. Both depend
mostly on \TeX. \LaTeX\ adds some environments for doing
math. \ConTeXt\ is mostly very close to \TeX. In \ConTeXt\ probably
every \TeX\ math command just works.


\section{In-text formulas}

In \ConTeXt\ in-text formula's are produced by surrounding the formula
by the \$ character.


\section{Display style formulas}

In \ConTeXt\ display style formula's are produced by surrounding the
formula by two \$ characters. You can also use the \envcont{formula}
environment for exactly the same effect.


\section{Numbered formulas}

With \LaTeX\ numbered formula's are made within the \envlat{equation}:

\startLATEX
\documentclass{article}

\begin{document}
\begin{equation}
E = mc^2
\end{equation}
\end{document}
\stopLATEX

In \ConTeXt\ numbered formulas are produced to prefix the display
formula command with \cmdcont{placeformula}.

\startCONTEXT
\starttext
\placeformula $$ E = mc^2 $$
\stoptext
\stopCONTEXT


\section{Multiline formulas}

In \LaTeX\ multiline formula's are produced with the
\envlat{eqnarray}. A new line is started after the \type|\\| command.

In \ConTeXt\ you use \TeX's displaylines command. A new line is
started after the \cmdcont{cr} command.

\startCONTEXT
\starttext

$$\displaylines{%
   ZeroOrOne = ( ( Amount\ mod\ Currency_RoundingFactor )\cr
	+\ Currency_Boundary )\cr
	div\ Currency_RoundingFactor}$$

\stoptext
\stopCONTEXT



\section{Theorems and such}

\LaTeX\ has the \cmdlat{newtheorem} command to define environments for
theorems-like structures. You would use it as follows:

\startLATEX
\documentclass{article}

\newtheorem{guess}{Conjecture}

\begin{document}
This is the first one:
\begin{guess}
  All conjectures are interesting.
\end{guess}
\end{document}
\stopLATEX

With \ConTeXt\ you would use the \cmdcont{defineenumeration}
command. This command has many options, the following settings make it
more or less equal to \LaTeX's \cmdlat{newtheorem}:

\startCONTEXT
\defineenumeration
  [guess]
  [text=Conjecture,
  location=left,
  letter=it]

\starttext
This is the first one:
\guess All conjectures are interesting.

This is the second one:
\startguess Except this one. \stopguess
\stoptext
\stopCONTEXT

As can be seen both \tex{guess} and \tex{startguess} can be used. Also
\tex{subguess}, \tex{subsubguess} and so on are now available.

\ConTeXt's \cmdcont{defineenumeration} can be used for any kind of
thing you want to enumerate.




\chapter{Changing the layout}

As soon as you are able to write basic documents, you probably want to
change their appearance. This chapter documents the differences
between \LaTeX\ and \ConTeXt. As \ConTeXt\ is a very, very flexible
macro package, this is one of the largest chapters. Almost everything
can be customized, you just call \type|\setup|{\ttsl something}.


\section{Page size}

In \LaTeX\ you give the page size as an option to the
\cmdlat{documentclass} command:

\startLATEX
\documentclass[a4paper]{article}

\begin{document}
\end{document}
\stopLATEX

In \ConTeXt\ you use the \cmdcont{setuppapersize} command.

\startCONTEXT
\setuppapersize[A4]

\starttext
\stoptext
\stopCONTEXT

With \ConTeXt\ it is possible to do far more advanced things. You can
typeset in A5 and print on A4 for example.


\section{Fonts}

Changing the font size in \LaTeX\ is usually done with a document
class option:

\startLATEX
\documentclass[12pt]{report}

\begin{document}
\end{document}
\stopLATEX

In \ConTeXt\ you use the \cmdcont{setupbodyfont} command:

\startCONTEXT
\setupbodyfont[12pt]

\starttext
\stoptext
\stopCONTEXT

Use \cmdcont{setupbodyfont} only to set the document font. To switch
to another font during typesetting, you should use
\cmdcont{switchtobodyfont}.

To switch to a postscript font in \LaTeX, you can use certain
packages. To switch to a Helvetica body font you would type:

\startLATEX
\documentclass{article}
\usepackage{helvet}

\begin{document}
\end{document}
\stopLATEX

In \ConTeXt\ you accomplish the same with the \cmdcont{setupbodyfont}
command:

\startCONTEXT
\setupbodyfont[ber,phv,ss]

\starttext
\stoptext
\stopCONTEXT

With the option \type|ber| you specify that you want to use Karl Berry
fontnames. With \type|phv| you specify that you want to load the
Helvetica font definitions, and with \type|ss| you specify that you
want to use a sans-serif font as the body font.

To switch to the default postscript fonts times, helvetica and
courier, you would say:

\startCONTEXT
\setupbodyfont[ber,pos]

\starttext
\stoptext
\stopCONTEXT


\section{Interline spacing}

To change the interline spacing in \LaTeX\ you change the
\type|baselineskip| variable:

\startLATEX
\documentclass{article}

\setlength\baselineskip{12pt}

\begin{document}
\end{document}
\stopLATEX

This changes the distance between lines to 12pt, a good value for a
10pt font. As in \LaTeX, if you change the size of the body font in
\ConTeXt, the line skip is automatically recalculated. You can set it
yourself with \cmdcont{setupinterlinespace}:

\startCONTEXT
\setupinterlinespace[line=1.2\bodyfontsize]

\starttext
\stoptext
\stopCONTEXT

Be careful to always define the interlineskip in terms of the current
\cmdcont{bodyfontsize}, else you get unexpected results when the
\cmdcont{bodyfontsize} changes, for example in chapter headings.


\section{Spacing between paragraphs}

To change the interparagraph spacing in \LaTeX, you change the
\cmdlat{parskip} variable:

\startLATEX
\documentclass{article}

\setlength{\parskip}{3pt}

\begin{document}
This is my first paragraph.

This is my second paragraph.
\end{document}
\stopLATEX

This gives you 3 extra points of white space between paragraphs. In
\ConTeXt\ you use the \cmdcont{setupwhitespace} command.

\startCONTEXT
\setupwhitespace[3pt]

\starttext
This is my first paragraph.

This is my second paragraph.
\stoptext
\stopCONTEXT

However, instead of a fixed size specification, it is much better to
use current font size related specifications like
\type{<<medium>>} or \type{<<big>>}:

\startCONTEXT
\setupwhitespace[medium]

\starttext
This is my first paragraph.

This is my second paragraph.
\stoptext
\stopCONTEXT


\section{Paragraph indentation}

In \LaTeX\ every paragraph has some white space at the beginning of
its first line. You can disable this by setting the amount of white
space to 0:

\startLATEX
\documentclass{article}

\setlength{\parindent}{0pt}

\begin{document}
This is my first paragraph. This is my first paragraph. This is my
first paragraph. This is my first paragraph. This is my first
paragraph. This is my first paragraph.

This is my second paragraph.
\end{document}
\stopLATEX

\ConTeXt\ doesn't start with white space. To start a paragraph with
some white space say:

\startCONTEXT
\setupindenting[medium]

\starttext
This is my first paragraph. This is my first paragraph. This is my
first paragraph. This is my first paragraph. This is my first
paragraph. This is my first paragraph.

This is my second paragraph.
\stoptext
\stopCONTEXT


\section{Position of the page number}

In \LaTeX\ the position of the page number can be set with the
\cmdlat{pagestyle} command. In \ConTeXt\ you use the
\cmdcont{setuppagenumbering} command.

There are four \LaTeX\ page styles. The corresponding \ConTeXt\
settings are given below:
\startitemize[n]
\item \type|\pagestyle{plain}|:\par
\startCONTEXT
\setuppagenumbering[location={footer,middle}]
\stopCONTEXT

\item \type|\pagestyle{empty}|:\par
\startCONTEXT
\setuppagenumbering[location=]
\stopCONTEXT

\item \type|\pagestyle{headings}|:\par
\startCONTEXT
\setuppagenumbering[location={header,middle}]
\stopCONTEXT

\item \type|\pagestyle{myheadings}|:\par
\startCONTEXT
\setuppagenumbering[location=header]
\stopCONTEXT
(see ....)
\stopitemize

Note that in \ConTeXt\ a page consists of much more than \LaTeX's three
default units {\em head}, {\em body} and {\em foot}, so you have much
more options.


\section{Roman and arabic pagenumbers}

In \LaTeX\ Roman and Arabic page numbers are specified with the
\cmdlat{pagenumbering} command.

\startLATEX
\documentclass{article}

\begin{document}

\pagenumbering{roman}
\tableofcontents

\chapter{Introduction}
\pagenumbering{arabic}
This is a test.

\end{document}
\stopLATEX

In \ConTeXt\ you use the \cmdcont{setupnumbering} command.

\startCONTEXT
\startfrontmatter

\setuppagenumbering[conversion=romannumerals]
\setuppagenumber[number=1]
\completecontent

\stopfrontmatter


\startbodymatter

\setuppagenumbering[conversion=numbers]
\setuppagenumber[number=1]
\chapter{Introduction}
This is a test.

\stopbodymatter
\stopCONTEXT

This example also shows a typical document structure by its use
of \envcont{fontmatter} and \envcont{bodymatter}. The front matter has
roman page numbers, the body matter arabic ones. We also use
\cmdcont{setuppagenumber} to start counting from 1 for each of the
sections. The first \cmdcont{setuppagenumber} could be omitted, but
typically you have a front page and such, so page numbering starts a
bit later than the first physical pages.



\section{Setting up chapter and sections}

In \LaTeX\ changing the format of chapters and sections is not
possible unless you change \LaTeX\ internal commands. Therefore, no
examples of doing this in \LaTeX\ are given, but only the \ConTeXt\
options are demonstrated.

Every section heading can be setup with \ConTeXt's \cmdcont{setuphead}
command. Probably one of the first things you want to change is the
font used for the chapters and sections.

\startCONTEXT
\setuphead[chapter][letter={\switchtobodyfont[20pt,ss]\bf}]
\setuphead[section][letter={\switchtobodyfont[16pt,ss]\bf}]

\starttext

\chapter{This is a chapter}

First sentence.

\section{This is a section}

First sentence.

\stoptext
\stopCONTEXT

This gives you a 20 points, bold, sans serif font for chapter headings.

It is possible to define that you want to start a chapter on a right page:

\startCONTEXT
\setuppagenumbering[alternative=doublesided]
\setuphead[chapter]
  [page=right]

\starttext

\chapter{First thought}

First sentence.

\chapter{Second thought}

Second sentence.

\stoptext
\stopCONTEXT

You also need to turn doublesided pagenumbering on with
\cmdcont{setuppagenumbering}. Now every chapter starts on an
uneven numbered page.

The following example changes even more. The number is set in a
different font, and before and after the chapter is set, we execute
our own commands.

\startCONTEXT
\setuphead
  [chapter]
  [numberstyle=bold,
  textstyle=cap,
  before=\hairline\blank,
  after={\nowhitespace\hairline\blank[line]}]

\starttext

\chapter{This is a chapter}

A sentence.

\stoptext
\stopCONTEXT

Note that almost any(!) setup command has before and after options, so
really everything in \ConTeXt\ can be changed easily.

It is also possible to format the entire section heading yourself. The
following example formats the subsection heading. You need to write a
macro which expects two parameters: the number of that section and the
title of that section. And then you're on your own.

\startCONTEXT
\setuphead
  [subsection]
  [command=\myhead]
\def\myhead#1#2{#2}

\starttext

\chapter{This is a chapter}

\section{Section}

\subsection{Yes}

A sentence.

\stoptext
\stopCONTEXT

Note that turning off the number is a standard option, so this setup
can also be accomplished with:

\startCONTEXT
\setuphead
  [subsection]
  [number=no]

\starttext

\chapter{This is a chapter}

\section{Section}

\subsection{Yes}

A sentence.

\stoptext
\stopCONTEXT


\section[sec:setupitemize]{Setting up lists}

Enumerations in \ConTeXt\ have white space between each items. You can
disable this by using the packed option.

\startCONTEXT
\setupitemize[packed]

\starttext
\startitemize[n]
\item First line.
\item Second line, no white space above it.
\stopitemize
\stoptext
\stopCONTEXT




\chapter{References}

\section[sec:indocreference]{In document references}

\section{Cross document references}


\section{Index}

In \LaTeX\ producing indexes is a two step process. In the preamble
you put the \cmdlat{makeindex} command so an index file (\type|.idx|)
is created. The contents of every \cmdlat{index} command is put into
that file. Next the \type|makeindex| command is used to produce the
actual index which can be included in your document with the
\cmdlat{input} command.

\startLATEX
\documentclass{article}

\makeindex

\begin{document}

Put \index{this} and \index{that} in the index.

\input{testlatex.ind}

\end{document}
\stopLATEX

In \ConTeXt\ creating indexes is also a two step process, but this is
transparant if you use \type|texexec| to compile your documents. With
the \cmdcont{index} command you put entries in the index, with
\cmdcont{completeindex} you get the entire index at that point.

\startCONTEXT
\starttext

Put \index{this} and \index{that} in the index.

\completeindex
\stoptext
\stopCONTEXT


\section[sec:bibtex]{bibtex}

You can use \type{bibtex} to produce \type{.bbl} files as usual. The
new \modcont{bib} (see \in{section}[sec:bibliography]) can read
\type{.bbl} files fine. You can specify on or more databases in
\cmdcont{setuppublications} after the database keyword.

\startCONTEXT
\usemodule[bib]

\setuppublications
  [database={mybibs},
  numbering=yes,
  sort=author]

\starttext

\section{My life}

I've read only two books in my life \cite[Bekke92,Brodie84]. But I've
to admit that I no longer think Forth \cite[Brodie84].

\completepublications

\stoptext
\stopCONTEXT

However, bib support is not yet foolproof.




\chapter{Interactive documents}

\section{Defining an interactive document}

\startLATEX
\usepackage{article}
\usepackage
	[pdftitle={Test document},
	 pdfauthor={Berend de Boer},
	 pdfsubject={There is more than LaTeX},
	 pdfkeywords={LaTeX ConTeXt TeX},
	 colorlinks,
	 linkcolor=blue]
	{hyperref}

\begin{document}
\end{document}
\stopLATEX


\startCONTEXT

\setupinteraction
	[status=start,
	 title={Test document},
	 author={Berend de Boer},
	 subtitle={There is more than LaTeX},
	 keywords={LaTeX ConTeXt TeX},
	 color=blue]

\starttext
\stoptext
\stopCONTEXT


\section{References which are URLs}

In \LaTeX\ the hyperref package provides hyperlinking support. To
generate a URL reference, you use the \cmdlat{href} command:

\startLATEX
\documentclass{article}

\usepackage{hyperref}

\begin{document}

The \href{http://www.freebsd.org}{greatest server OS} on this world.

\end{document}
\stopLATEX


\startCONTEXT
\setupinteraction[state=start]

\useURL
	[contextsupport]
	[http://www.pragma-ade.nl]

\starttext

The \ConTeXt\ support site is \from[contextsupport].

\stoptext
\stopCONTEXT


\chapter{Other}

\section{Title page}


\section{Text in margin}


\section{Color}

You can enable color with the \cmdcont{setupcolors} command.

\startCONTEXT
\setupcolors[state=start]

\starttext
\stoptext
\stopCONTEXT


\section{Babel}


\section{Interfaces}


\section{Breaking lines}


\section{Vertical white space}

If you need vertical white space, \LaTeX\ has the \cmdlat{vspace}
command. This command only works between paragraphs. At the beginning
and end of a page white space `disappears', use \cmdlat{vspace*} for
white space that does not disappear.

\startLATEX
\documentclass{article}

\begin{document}
\vspace*{5cm}
This line comes first.

\vspace{2\baselineskip}

This line comes second.

\vspace{.5\baselineskip}

And this is the third line.

\end{document}
\stopLATEX

In \ConTeXt\ the \cmdcont{blank} command gives blank space. It also
ends the preceding paragraph. Use the \type|force| option to force
white space at the beginning and end of a page.

\startCONTEXT
\starttext
\blank[5cm,force]
This line comes first.
\blank[2*line]
This line comes second.
\blank[medium]
And this is the third line.
\stoptext
\stopCONTEXT



\chapter{Understanding \ConTeXt}

\section[sec:texexec]{texexec}

\ConTeXt\ uses the external program
\type{texexec}
to do lots of things which are more difficult to do directly in \TeX:
\startitemize[n]
\item \ConTeXt\ writes its table of contents entries to a
  \type{.tui} file. If the compilation went fine, \type{texexec}
  copies this to the corresponding \type{.tuo} file.\par
  This means that when a compilation does not run to completion
  (you cancel it for example), the table of contents entries and
  references have not disappeared.
\item \type{texexec} sorts indexes and sorted lists.
\stopitemize


\section[sec:doc]{Module documentation}

Generate \ConTeXt\ module documentation with:

\starttyping
texexec --module m-bib
\stoptyping

You need to have the documentation styles which can be downloaded from
\from[contextsupport], filename \type{cont-doc.zip}.



\startmode[screen]
  \stopbodymatter

  \startbackmatter
\stopmode



\chapter{\LaTeX\ commands}
% LaTeX command index

List of \LaTeX\ commands used in this document.

\placeindexcmdlat



\chapter{\ConTeXt\ commands}
% ConTeXt command index

List of \ConTeXt\ commands used in this document.

\placeindexcmdcon



\chapter{\LaTeX\ to \ConTeXt\ reference}
% Table comparing commands

\section{Standard environments}

% environment layout
\def\showlatenv#1{\ss #1}
\def\showlatcmd#1{\ss #1}
\def\showcontenv#1{\ss #1}
\def\showcontcmd#1{\ss #1}
\def\notsupported{no equivalent.}

A list of all \LaTeX\ environments and the corresponding \ConTeXt\
environment is provided below. Note that \LaTeX\ environments are
written as:

\startLATEX
\begin{environment}
\end{environment}
\stopLATEX

In \ConTeXt\ you write this as:

\startCONTEXT
\startenvironment
\stopenvironment
\stopCONTEXT

\start\setupbodyfont[9pt]

\starttabulate[|l|l|p|]
\HL
\NC \LaTeX\ environment \NC \ConTeXt\ environment \NC Remark \NC\NR
\HL
\NC \showlatenv{abstract} \NC \notsupported \NC \NC\NR
\NC \showlatenv{array} \NC \notsupported \NC \NC\NR
\NC \showlatenv{center} \NC \showcontenv{alignment} \NC \NC\NR
\NC \showlatenv{description} \NC \NC See \in{section}[sec:description] \NC\NR
\NC \showlatenv{displaymath} \NC \NC \NC\NR
\NC \showlatenv{document} \NC \showcontenv{text} \NC \NC\NR
\NC \showlatenv{enumerate} \NC \showcontenv{itemize} \NC \NC\NR
\NC \showlatenv{equation} \NC \showcontcmd{placeformula} \NC \NC\NR
\NC \showlatenv{eqnarray} \NC\showcontcmd{displaylines} \NC Use
the standard \TeX\ commands. \NC\NR
\NC \showlatenv{figure} \NC \NC Use \showcontcmd{placefigure}. \NC\NR
\NC \showlatenv{flushleft} \NC \showcontenv{alignment} \NC \NC\NR
\NC \showlatenv{flushright} \NC \showcontenv{alignment} \NC \NC\NR
\NC \showlatenv{itemize} \NC \showcontenv{itemize} \NC \NC\NR
\NC \showlatenv{letter} \NC \notsupported \NC \NC\NR
\NC \showlatenv{list} \NC \showcontenv{itemize} \NC \NC\NR
\NC \showlatenv{math} \NC \NC Use \$ before and \$ after the formula. \NC\NR
\NC \showlatenv{minipage} \NC \notsupported \NC \NC\NR
\NC \showlatenv{note} \NC \notsupported \NC \NC\NR
\NC \showlatenv{overlay} \NC \notsupported \NC \NC\NR
\NC \showlatenv{picture} \NC MPgraphic \NC In \ConTeXt\ you can
include metapost code to achieve the same and better effects.\NC\NR
\NC \showlatenv{quote} \NC \showcontenv{citaat} \NC \NC\NR
\NC \showlatenv{quotation} \NC \showcontenv{citaat} \NC \NC\NR
\NC \showlatenv{slide} \NC \notsupported \NC \NC\NR
\NC \showlatenv{sloppypar} \NC \NC \NC\NR
\NC \showlatenv{tabbing} \NC \showcontenv{tabulate} \NC \NC\NR
\NC \showlatenv{table} \NC \showcontenv{table} \NC Use together with \showcontcmd{placetable} \NC\NR
\NC \showlatenv{tabular} \NC \showcontenv{table} \NC \NC\NR
\NC \showlatenv{titlepage} \NC \notsupported \NC \NC\NR
\NC \showlatenv{thebibliography} \NC \showcontenv{publication} \NC
Requires the \modcont{bib}.\NC\NR
\NC \showlatenv{theindex} \NC \NC Use \showcontcmd{completeindex}. \NC\NR
\NC \showlatenv{trivlist} \NC \showcontenv{itemize} \NC \NC\NR
\NC \showlatenv{verbatim} \NC \showcontenv{typing} \NC \NC\NR
\NC \showlatenv{verse} \NC \NC \NC\NR
\HL
\stoptabulate

\stop


\section{Standard commands}

Many \LaTeX\ commands come from third party packages. Most of the
things they provide (or fix) are standard features in \ConTeXt.

\start\setupbodyfont[9pt]

\starttabulate[|l|l|p|]
\HL
\NC \LaTeX\ command \NC \ConTeXt\ command \NC Remark \NC\NR
\HL
\NC \showlatcmd{setlanguage} \NC  \NC Provided by the \latpkg{babel}
  package. \NC\NR
\stoptabulate

\stop


\section{Environments provided packages}

Many \LaTeX\ environments come from third party packages. Most of the
things they provide (or fix) are standard features in \ConTeXt.

\start\setupbodyfont[9pt]

\starttabulate[|l|l|p|]
\HL
\NC \LaTeX\ package \NC \ConTeXt\ environment \NC Remark \NC\NR
\HL
\NC \showlatenv{comment} \NC \showcontenv{comment} \NC Comment out
  certain parts of your document so it does not show up in the .dvi or
  .pdf file. \LaTeX's \envlat{comment} is part of Rainer Sch\"pf's
  \latpkg{verbatim} package. \NC\NR
\NC \showlatenv{longtable} \NC \showcontenv{tables} \NC The
  \latpkg{longtable} package provides tables that can be broken
  accross page.\NC\NR
\stoptabulate

\stop


\startmode[screen]
  \stopbackmatter
\stopmode


\stopTutorial
