Changes

Jump to navigation Jump to search
m
pretty printing
To start with, there is the problem that ConTeXt uses <tt>\startenv ... \stopenv</tt> pairs to define environments, whereas LaTeX uses <tt>\begin{env} ... \end{env}</tt> pairs. The relative merits of these can be argued, but the fact remains that if one is importing LaTeX documents into ConTeXt, it is simpler to leave the environments in the LaTeX form. The following small set of definitions does an automatic translation.
<pretexcode>
% Commands to translate LaTeX environment calls
% into the appropriate ConTeXt macros.
\def\end#1{%
\csname stop#1\endcsname}
</pretexcode>
Thus, a command such as <tt>\begin{array}</tt> in a LaTeX equation will simply call <tt>\startarray</tt>, and we can define all of the remaining compatibility macros as <tt>\start ... \stop</tt> pairs without needing to translate the equations manually to match. However, this does not work with all ConTeXt environments; a few of them require the literal string <tt>\stopenvironment</tt> at the end of the environment.
With that framework in mind, we can start duplicating some of the basic LaTeX equation environments. To start with, the <tt>equation</tt> environment itself, along with the <tt>equation*</tt> environment from AMSmath.
<pretexcode>
\def\startequation{%
\placeformula
\expandafter\def\csname stopequation*\endcsname{%
\stopformula}
</pretexcode>
The <tt>array</tt> environment is a notably more complicated construction. Luckily, it's already been duplicated in Giuseppe Bilotta's <tt>t-amsl.tex</tt> package, so we don't have to rewrite it. (The spacing is somewhat tighter than LaTeX's <tt>array</tt>, though.) Using that simply requires the following line at the head of the ConTeXt document:
<pretexcode>
\usemodule[amsl]
</pretexcode>
Once the package is loaded, you'll be able to use <tt>\startarray ... \stoparray</tt> in pretty much the same way as <tt>\begin{array} ... \end{array}</tt> was used in LaTeX.
The <tt>t-amsl.tex</tt> package also defines equivalents for AMSmath's <tt>align</tt> and <tt>gather</tt> macros (which provide an improved version of the <tt>eqnarray</tt> functionality, and you should translate your LaTeX eqnarrays to use them anyway!), but unfortunately they are examples of the rare ConTeXt macros that do not work with our <tt>\begin{} ... \end{}</tt> translation, at least in the version current as of 2004/08/02. The following versions do work, however:
<pretexcode>
\def\startalign{\startformula
\let\\\cr
\def\stopgather{\crcr\crcr\egroup\egroup\,%
\stopformula}
</pretexcode>
These do have the problem of these environments not introducing equation numbers (which they should do for proper compatibility); that should hopefully be addressed in future versions.
We can also define a duplicate of AMSmath's <tt>split</tt> environment similarly, as
<pretexcode>
\def\startsplit{%
\let\\\cr
\crcr}
\def\stopsplit{\crcr\egroup\egroup\,}
</pretexcode>
----

Navigation menu