LaTeX Math in ConTeXt

From Wiki
Revision as of 20:31, 2 August 2004 by 171.66.165.208 (talk) (Initial draft of page.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

< Main Page, Math

One of the barriers to using ConTeXt is that the equation syntax is quite different from LaTeX equation syntax. As a result, one cannot copy equations from LaTeX documents (whether existing documents, or articles for journals that request LaTeX submissions) into ConTeXt documents, or vice versa. Without some solution to this, producing a set of ConTeXt slides to go with a LaTeX article would require completely rewriting all of the equations.

Thus, the intent of this page is to document some methods for importing LaTeX equations into ConTeXt documents.

To start with, there is the problem that ConTeXt uses \startenv ... \stopenv pairs to define environments, whereas LaTeX uses \begin{env} ... \end{env} 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.

% The \end of a \begin,\end pair is problematic,
% since \stoptext depends on TeX's \end.  We fix
% that as follows, with a slightly edited copy
% of \stoptext from core-job.tex.
\let\therealdocumentend\end
\def\stoptekst
  {\doglobal\decrement\textlevel\relax
   \ifnum\textlevel>\zerocount \else
     \the\everystoptext
     \expandafter\therealdocumentend
   \fi}
\let\stoptext \stoptekst
% Translate \begin{env} into \startenv, etc.
\def\begin#1{%
  \begingroup\csname start#1\endcsname}
\def\end#1{%
  \csname stop#1\endcsname\endgroup}

Thus, a command such as \begin{array} in a LaTeX equation will simply call \startarray, and we do not need to translate the equations manually. However, this does not work with all ConTeXt environments.

(Er, I should save this in case anyone clicks on the link before I finish it.)