TeX macros/extensions

246 views
Skip to first unread message

RobertM

unread,
Oct 28, 2010, 4:38:49 PM10/28/10
to MathJax Users
[Previously posted at http://sourceforge.net/projects/mathjax/forums/forum/948701/topic/3677825]

net-buoy

One of the things that continues to be a pain in addressing online
math for younger students is the inability to implement US style long
division unless one hacks ones own Tex install to include \longdiv
etc. I saw a phrase somewhere that lead me to believe that MathJax
includes quite a few extensions, but was disappointed that polynum
was apparently not supported.... Is there an existing apparatus to
handle this or is this something that is a ways down the pike?
dpvc



2010-04-18 13:36:49 UTC

MathJax does have extensions that implement some of the lesser-used
macros, but certainly not all LaTeX packages are available. The
polynom.sty package is one that is not available.

The underlying format that MathJax uses is MathML, so everything that
MathJax produces must be representable in MathML. The MathML3.0
specificaiton for elementary math structures should be able to handle
what you are looking for, but MathJax hasn't implemented them yet
(there are still gaps in MathJax's MathML support that we are trying
to fill). When that is ready, it may be possible to implement at
least parts of the polynom package, though I can't tell you when that
will happen.

For now, I don't see a straight-forward way to accomplish the output
that you need. Sorry! You will have to wait for more of MathJax to
be completed before that is possible.

Davide

--------------

starbuc2
2010-10-06 15:48:34 UTC

I'm finding that there are some common (to us) TeX codes that aren't
working and was wondering if this is related to the previous comments
here. I'm getting errors so far with \eqno and \hfill. We use these
within many of our equations.
-Dave

--------------

dpvc
2010-10-08 21:52:10 UTC

@starbuc2:

You are right, MathJax doesn't currently have \eqno, but that could be
added without too much problem. If your use of \eqno includes braces
around the number (like \eqno{1.3}) then it would be easy to set up a
macro that translates \eqno into equivalent \tag calls, but I suspect
that you probably don't use the braces. In that case, it would be a
bit harder to do, but I'll add it to the to-do list for things to add
to MathJax.

For \hfill, that is not likely to become available, as MathML (which
underlies MathJax) does not have anything corresponding to it. Can
you tell us about how you are using \hfill? Perhaps we can suggest
something equivalent.

Davide

--------------

starbuc2
2010-10-08 22:24:52 UTC

Hi Davide,

Our source files are XML from ArborText EPIC, but we used TeX, for
example:

<formula><tex>$ x + y = a$</tex></formula>

with a few of our own custom macros which I haven't had any problem
adding to the config files so far. We could probably get around the
\hfill somehow by manually spacing those instances, but we are trying
to avoid manual intervention. I'll try to find some samples for you.
Our use of \eqno tends to be for single line display equations where
the equation might be coded $$ x+y = z \hbox{\eqno{(1)}}$$ to flush
the eq number flush out to the right. On multiline equations, we use
\eqalignno at the beginning and just & for the alignments.

Robert is probably familiar with the math we do at the IEEE. I think
we sent him some samples a year or so ago.

-David

--------------

dpvc
2010-10-08 22:39:24 UTC

OK, if your use of \eqno is like the one you listed, then the simple
macro approach should work. You could try defining the equivalent of

\def\eqno#1{\tag*{$#1$}}

so you could add

Macros: {
eqno: ['\\tag*{$#1$}',1]
}

to the TeX block of your configuration. See if that works.

Davide

--------------

dpvc
2010-10-08 22:43:46 UTC

I just realized that the \hbox is going to mess it up. MathJax won't
interpret the macros inside the \hbox.

Are you sure that is the right code? When I try to TeX it, I get the
error

! You can't use `\eqno' in restricted horizontal mode.

but it works correctly when I remove the \hbox. I would not expect
\eqno to be valid inside an \hbox (because you are in text mode not
math mode).

Davide

--------------

starbuc2
2010-10-09 00:33:04 UTC

Hi,

This might work better. Here is some code that I lifted from the demo
article I'm working on. There may be quite a bit of this so the less
we have to touch the math code the better. These are fairly "light
weight" equations. We have a few journals where the equations
sometimes take up 1/4 to 1/3 of the page.

$$\max_{x \geq 0}\left\{U(x) - x \cdot p\right\},\qquad p \in \Re^{+}.
\eqno{\hbox{(1)}}$$

$$U_{c}(x, \theta) = \cases{0, & if $x &lt; \theta$\cr \exp\left[-{(x
- \theta)^{2}\over 2\theta^{2}}\right], & otherwise} \eqno{\hbox{(2)}}$
$

$$B(x, \theta) = \exp\left[-{4(x - \theta)^{2}\over \theta^{2}}
\right].\eqno{\hbox{(3)}}$$

$$\eqalignno{\sum_{i}\left\{r_{i}\phi_{i}\left[\eta + \alpha\sum_{j =
1}^{N_{s}}g_{j}p_{j}\right]\right\} = & \, \sum_{i}[W + \alpha r_{i}
\phi_{i}]g_{i}p_{i}\cr \approx &\, \sum_{i}Wg_{i}p_{i}. & \hbox{(13)}}$
$

$$\displaylines{L(\lambda, r_{i}, \gamma_{i}\vert \forall\, i) =
\sum_{i}B_{i}\left(r_{i}p_{i}(\gamma_{i}), R_{i}p_{i}(\phi_{i})\right)
\hfill\cr\hfill +\ \lambda\left(\sum_{i}r_{i} \gamma_{i} - {W\over
\alpha}\right).\quad\hbox{(23)}}$$

$$\displaylines{L(\lambda, r_{i}, \gamma_{i}\vert \forall\, i) =
\sum_{i}\exp\left(-{4\left(r_{i}p_{i}(\gamma_{i}) - R_{i}p_{i}
(\phi_{i})\right)^{2}\over R_{i}^{2}p_{i}( \phi_{i})^{2}}\right)\hfill
\cr\hfill +\ \sum_{i}\lambda r_{i}\gamma_{i} - \lambda{W\over \alpha}.
\quad\hbox{(24)}}$$

These all work in ArborText EPIC. I haven't tried them in real TeX.

thanks for your help.
-David


--------------

starbuc2
2010-10-09 00:40:29 UTC

I ran them through TeX and found an error in eq (2). It's too late in
the evenin to troubleshoot this. But please look at the others.
thanks,
David


--------------

dpvc
2010-10-09 14:01:06 UTC

The problem in (2) is the &lt; in place of < (which TeX won't be happy
about, as it will try to treat the & as a column separator, but it
will be inside an \hbox{} for the second half of the \cases).

In any case, since your \eqno use braces, you can use the simple
definition that I suggested above to handle that. I have tested that
it works with these examples.

For \hfill, a possible approach is to use

\def\hfill{\hskip 5em}

or something like that to get some space, even though it is not quite
the same as in TeX. It is better than nothing.

Davide

--------------

starbuc2
2010-10-22 16:39:49 UTC

Hi, thanks, the def for the \eqno works, thank you.
-David

net-buoy

unread,
May 14, 2012, 3:49:35 PM5/14/12
to mathja...@googlegroups.com
to return to the top of the thread, it might be appropriate to place some added disclaimer regarding the preamble extension in that while it may serve as a preamble, it will not have the same effect as in a LaTex preamble (i.e. the newb would simply reference the extension and add \usepackage{polynom} and would be disappointed..... (although I thought the "key" to long division in MathML under FF was menclose which is now supported in FF....

Davide P. Cervone

unread,
May 14, 2012, 4:46:53 PM5/14/12
to mathja...@googlegroups.com
The key to long division is the MathML3 <mlongdiv> element, which I don't think is implemented in FF yet (nor is it in MathJax for that matter).  The <menclose notation="longdiv"> puts a division sign over some math, but doesn't do anything about the tabular format needed for the long division.  That is what <mlongdiv> would do.

The polynom package also does a lot of mathematical computation, if I remember correctly, like actually doing all th eintermediate steps of the long division, and factoring polynomials, and so on.  All of that would need to be re-implemented in javascript, and is not a small task.  And at the moment, laying out the answers as a long division table would be difficult, even if you implemented the division algorithm.

Davide
Reply all
Reply to author
Forward
0 new messages