Changes

Jump to navigation Jump to search
2,770 bytes added ,  20:50, 2 August 2004
More of the initial draft, saved to avoid losing work.
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. Eventually, they will end up in a third-party ConTeXt package (<i>or such is my intent --Brooks Moses</i>), but for now they are simply given here in full.
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.
% Commands to translate LaTeX environment calls
% into the appropriate ConTeXt macros.
%
% The \end of a \begin,\end pair is problematic,
% since \stoptext depends on TeX's \end. We fix
\fi}
\let\stoptext \stoptekst
% % Translate \begin{env} into \startenvWith that out of the way, etcthe actual trans- % lation macros are straightforward.
\def\begin#1{%
\begingroup\csname start#1\endcsname}
\csname stop#1\endcsname\endgroup}
Thus, a command such as <tt>\begin{array}</tt> in a LaTeX equation will simply call <tt>\startarray</tt>, and we do not need can define all of the remaining compatibility macros as <tt>\start ... \stop</tt> pairs without needing to translate the equations manuallyto 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.  \def\startequation{% \placeformula \startformula} \def\stopequation{% \stopformula} % \expandafter\def\csname startequation*\endcsname{% \placeformula[-] \startformula} \expandafter\def\csname stopequation*\endcsname{% \stopformula} 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:  \usemodule[amsl] The <tt>t-amsl.tex</tt> package also defined 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:  \def\startalign{\startformula \let\\\cr \null\vcenter\bgroup \openup\jot {\mathsurround=0pt}% \everycr={}\tabskip=4pt plus1fil% \halign to \displaywidth\bgroup \strut\hfil$\displaystyle{##}$% \tabskip=0pt &$\displaystyle{{}##}$\hfil% \tabskip=4pt plus1fil &&\hfil$\displaystyle{##}$% \tabskip=0pt &$\displaystyle{{}##}$\hfil% \tabskip=4pt plus1fil \crcr} \def\stopalign{\crcr\crcr\egroup\egroup\stopformula} % \def\startgather{\startformula \let\\\cr \null\,\vcenter\bgroup \openup\jot {\mathsurround=0pt}% \ialign\bgroup \strut\hfil$\displaystyle{##}$\hfil \crcr} \def\stopgather{\crcr\crcr\egroup\egroup\,% \stopformula} We can also define a duplicate of AMSmath's <tt>split</tt> environment similarly, as
(Er \def\startsplit{% \let\\\cr \null\, I should save this in case anyone clicks on the link before I finish it.)\vcenter\bgroup \openup\jot {\mathsurround=0pt}% \ialign\bgroup \strut\hfil$\displaystyle{##}$% &$\displaystyle{{}##}$\hfil \crcr} \def\stopsplit{\crcr\egroup\egroup\,}
Anonymous user

Navigation menu