ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Converting math from LaTeX to ConTeXt
@ 2004-07-26  5:31 Brooks Moses
  2004-07-27 11:42 ` Eckhart Guthöhrlein
  2004-08-07 15:12 ` Giuseppe Bilotta
  0 siblings, 2 replies; 4+ messages in thread
From: Brooks Moses @ 2004-07-26  5:31 UTC (permalink / raw)


First, by way of introduction: I've been using LaTeX for about five years 
now, but am quite new to ConTeXt.  I'm a grad student in mechanical 
engineering, so my primary uses of ConTeXt in the near future are likely to 
be for my thesis and associated presentations, all of which will likely 
have lots of complicated equations in them.

After looking at what documentation is available for this, I think I have a 
fair handle on the basics of including math in ConTeXt.  However, I do have 
some questions about things beyond the basics that I use rather frequently, 
and I haven't been able to find useful answers in the documentation or the 
list archives.

To begin with, I have the following sets of definitions in my standard 
LaTeX preamble.  I know that \newcommand and \renewcommand are 
LaTeX-specific; what's the appropriate ConTeXt equivalent?  Also, do \hat, 
\vec, and \overline work as I would expect?  And is there a direct 
equivalent to \boldsymbol from the amsmath package?  (I need something that 
will handle both roman and greek letters.)

   \renewcommand{\vec}[1]{{\boldsymbol{#1}}}
   \renewcommand{\hatn}{\hat{\vec{n}}}
   \newcommand{\filter}[1]{\overline{#1}}

Also, many of these equations run over multiple lines using the macros from 
the amsmath package (the "split" environment in particular, but also the 
"align" environment), and I haven't been able to find much documentation on 
how to do this in ConTeXt.  For an example of the sorts of things I end up 
doing:

   \begin{equation}
   \begin{split}
   \lefteqn{
     \frac{\partial (\rho (\phi u)_j)}{\partial t}
        + \nabla_k (\rho (\phi u)_k u_j)
   }\quad\quad
   \\
   = &\;
     -\nabla_j (\phi p)
     + \nabla_j (\lambda \nabla_k (\phi u_k))
     + \nabla_k \left[\mu \left( \nabla_k (\phi u)_j
     + (\nabla_j (\phi u)_k) \right) \right]
   \\&\;
     {} - \lambda (\nabla_j u_k) \nabla_k \phi
     - \mu (\nabla_k \phi) \nabla_k u_j
     - \mu (\nabla_k u_k) \nabla \phi_j
     - \tau_{\text{surface, $jk$}} \nabla_k \phi
   \end{split}
   \end{equation}

Looking at that reminds me that I also rather heavily use the \text command 
from amsmath as well, and rely on its ability to properly size things in 
subscripts and such.  Does this (or an analogue) exist in ConTeXt?

Any suggestions?  I'd like to be able to simply cut and paste the equations 
like this one from my LaTeX documents into my ConTeXt documents with as 
little editing as possible (so that I can maintain consistency between 
documents in each format), but anything that produces the same output would 
be good to know about.

Thanks much!
- Brooks

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Converting math from LaTeX to ConTeXt
  2004-07-26  5:31 Converting math from LaTeX to ConTeXt Brooks Moses
@ 2004-07-27 11:42 ` Eckhart Guthöhrlein
  2004-07-29 16:46   ` Brooks Moses
  2004-08-07 15:12 ` Giuseppe Bilotta
  1 sibling, 1 reply; 4+ messages in thread
From: Eckhart Guthöhrlein @ 2004-07-27 11:42 UTC (permalink / raw)


On Sun, Jul 25, 2004 at 10:31:24PM -0700, Brooks Moses wrote:
> First, by way of introduction: I've been using LaTeX for about five years 
> now, but am quite new to ConTeXt.  I'm a grad student in mechanical 
> engineering, so my primary uses of ConTeXt in the near future are likely to 
> be for my thesis and associated presentations, all of which will likely 
> have lots of complicated equations in them.

In general, it will be very helpful to know how things can be done in
plain tex. This should always work in context.

> After looking at what documentation is available for this, I think I have a 
> fair handle on the basics of including math in ConTeXt.  However, I do have 
> some questions about things beyond the basics that I use rather frequently, 
> and I haven't been able to find useful answers in the documentation or the 
> list archives.
> 
> To begin with, I have the following sets of definitions in my standard 
> LaTeX preamble.  I know that \newcommand and \renewcommand are 
> LaTeX-specific; what's the appropriate ConTeXt equivalent?  Also, do \hat, 
> \vec, and \overline work as I would expect?  And is there a direct 
> equivalent to \boldsymbol from the amsmath package?  (I need something that 
> will handle both roman and greek letters.)

I have been away from context for some time, but I know that Giuseppe
Bilotta has spent much effort on extending its math capabilities. I
think he has written some modules providing amsmath features. But he
will probably comment on this in more detail and in a more qualified way
than I can.

>   \renewcommand{\vec}[1]{{\boldsymbol{#1}}}
>   \renewcommand{\hatn}{\hat{\vec{n}}}
>   \newcommand{\filter}[1]{\overline{#1}}

You can use the tex primitve
\def\vec#1{{\boldsymbol{#1}}
or the context way
\define[1]\vec{{\boldsymbol{#1}}

But afaik there is no checking if a command is already defined?

-- 
Eckhart

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Converting math from LaTeX to ConTeXt
  2004-07-27 11:42 ` Eckhart Guthöhrlein
@ 2004-07-29 16:46   ` Brooks Moses
  0 siblings, 0 replies; 4+ messages in thread
From: Brooks Moses @ 2004-07-29 16:46 UTC (permalink / raw)


At 04:42 AM 7/27/2004, you wrote:
>On Sun, Jul 25, 2004 at 10:31:24PM -0700, Brooks Moses wrote:
[things I need to translate from LaTeX to ConTeXt]
> >   \renewcommand{\vec}[1]{{\boldsymbol{#1}}}
> >   \renewcommand{\hatn}{\hat{\vec{n}}}
> >   \newcommand{\filter}[1]{\overline{#1}}
>
>You can use the tex primitve
>\def\vec#1{{\boldsymbol{#1}}
>or the context way
>\define[1]\vec{{\boldsymbol{#1}}
>
>But afaik there is no checking if a command is already defined?

I started poking through the ConTeXt source to see what I could find, and 
came across the following in the syst-ext.tex file:

   \def\define#1%
     {\ifx#1\undefined
        \expandafter\def
      \else
        \message{[\noexpand#1is already defined]}%
        \expandafter\def\expandafter\gobbleddefinition
      \fi#1}

   \def\redefine#1%
     {\ifx#1\undefined\else
        \message{[\noexpand#1is redefined]}%
      \fi
      \def#1}

This appears to be doing the checks for commands being previously defined 
or not, as desired.  However, I'm completely lost as to how we get from 
here to the \define[1] syntax.  What am I missing?

- Brooks

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Converting math from LaTeX to ConTeXt
  2004-07-26  5:31 Converting math from LaTeX to ConTeXt Brooks Moses
  2004-07-27 11:42 ` Eckhart Guthöhrlein
@ 2004-08-07 15:12 ` Giuseppe Bilotta
  1 sibling, 0 replies; 4+ messages in thread
From: Giuseppe Bilotta @ 2004-08-07 15:12 UTC (permalink / raw)


Hi Brook,

sorry for the horrible delay with which I'm replying to you. I
think I have a part of the solution to your problems.

Monday, July 26, 2004 Brooks Moses wrote:

> Also, many of these equations run over multiple lines using the macros from
> the amsmath package (the "split" environment in particular, but also the
> "align" environment), and I haven't been able to find much documentation on
> how to do this in ConTeXt.

I've been working on a ConTeXt module that provides some
elementary AMS-compatible definitions, but for complex
equations I have a personal preference for the Nath package in
LaTeX, so for multiline you might have more luck using the
nath module, which is available on CTAN. There is no manual,
but you can use the LaTeX package manual as a reference.

> For an example of the sorts of things I end up
> doing:
>    \begin{equation}
>    \begin{split}
>    \lefteqn{
>      \frac{\partial (\rho (\phi u)_j)}{\partial t}
>         + \nabla_k (\rho (\phi u)_k u_j)
>    }\quad\quad
>    \\
>    = &\;
>      -\nabla_j (\phi p)
>      + \nabla_j (\lambda \nabla_k (\phi u_k))
>      + \nabla_k \left[\mu \left( \nabla_k (\phi u)_j
>      + (\nabla_j (\phi u)_k) \right) \right]
>    \\&\;
>      {} - \lambda (\nabla_j u_k) \nabla_k \phi
>      - \mu (\nabla_k \phi) \nabla_k u_j
>      - \mu (\nabla_k u_k) \nabla \phi_j
>      - \tau_{\text{surface, $jk$}} \nabla_k \phi
>    \end{split}
>    \end{equation}

With ConTeXt+nath, this could become something like

\[
\frac{\partial (\rho (\phi u)_j)}{\partial t}
    + \nabla_k (\rho (\phi u)_k u_j)
   = \wall
     -\nabla_j (\phi p)
     + \nabla_j (\lambda \nabla_k (\phi u_k))
     + \nabla_k [\mu ( \nabla_k (\phi u)_j
     + (\nabla_j (\phi u)_k) )] \\
     - \lambda (\nabla_j u_k) \nabla_k \phi
     - \mu (\nabla_k \phi) \nabla_k u_j
     - \mu (\nabla_k u_k) \nabla \phi_j
     - \tau_{\text{surface, $jk$}} \nabla_k \phi
     \return
\]

or something.

> Looking at that reminds me that I also rather heavily use the \text command
> from amsmath as well, and rely on its ability to properly size things in
> subscripts and such.  Does this (or an analogue) exist in ConTeXt?

Yes, there is a \text command in ConTeXt provided you use the
amsl or nath modules (note that the nath module needs amsl)

> Any suggestions?  I'd like to be able to simply cut and paste the equations
> like this one from my LaTeX documents into my ConTeXt documents with as
> little editing as possible (so that I can maintain consistency between
> documents in each format), but anything that produces the same output would
> be good to know about.

Well, if you can use the Nath module in your LaTeX documents
(the module is sadly incompatible with much of the AMS
features, so there are cases when it's impossible to convert an
AMS-LaTeX document to a LaTeX+Nath module) you can do it with
ease. Otherwise, some minor corrections will be necessary to
reduce the AMS forms into Nath forms; in some cases cleanups
are unnecessary (e.g., Nath will accept \left and \right which
are not necessary because of its auto-sizing features) so you
can often keep an extremely similar syntax for both forms.

Do keep in mind, in all this, that the nath package for ConTeXt
still has a few edges that needs smoothing, esp. when it comes
to arrays, multiline equations and numbering.

Hope this helps.

-- 
Giuseppe "Oblomov" Bilotta

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2004-08-07 15:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-07-26  5:31 Converting math from LaTeX to ConTeXt Brooks Moses
2004-07-27 11:42 ` Eckhart Guthöhrlein
2004-07-29 16:46   ` Brooks Moses
2004-08-07 15:12 ` Giuseppe Bilotta

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).