tensor package in mathjax

297 views
Skip to first unread message

hemm...@gmail.com

unread,
Oct 21, 2015, 5:08:58 PM10/21/15
to MathJax Users
Hi,

There is the tensor package ftp://ftp.dante.de/pub/tex/macros/latex/contrib/tensor/tensor.pdf.
Is there already a way in mathjax to achieve at least upper and lower multi-scripts on the right of a symbol?

In other words I'd like to render

  M\indices{^a_b^{cd}_e}

as described on page 2 of the above PDF.

Any suggestions?

Thanks in advance
Ralf

Peter Krautzberger

unread,
Oct 22, 2015, 4:16:55 AM10/22/15
to mathja...@googlegroups.com
Hi Ralf,

As mentioned on page 2, you can handle simple cases for \mathop's by using \sideset from the amsmath extension, e.g., 

$$ \sideset{_*^*}{_*^*}\prod $$

Next you can abuse the mhchem extension which aligns prescripts to the right, e.g.,

$\require{mhchem} \ce{^{227}_{90}Th+} $

For those interested in giving it a try, it should not be terribly difficult to implement the tensor package since MathJax uses MathML internally which has multiscript element for this kind of layout. See the documentation and other TeX extensions for starting points.

Regards,
Peter.

--
You received this message because you are subscribed to the Google Groups "MathJax Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mathjax-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Davide P. Cervone

unread,
Oct 22, 2015, 5:16:04 AM10/22/15
to mathja...@googlegroups.com
Note that both of these only produce a SINGLE script in each of the four positions (pre-superscript, pre-subscript, superscript, and subscript).  The tensor notation would require being able to specify several superscripts and sever subscripts.  That does require MathML's mprescripts with multiple super- and subscripts, and there currently is no way to do that in the TeX input.  This would require an extension that parses the \indices{} macro and creates the needed internal mprescripts element.  That is certainly possible, but it doesn't currently exist.

Davide

Ralf Hemmecke

unread,
Oct 22, 2015, 5:26:40 AM10/22/15
to mathja...@googlegroups.com
> As mentioned on page 2, you can handle simple cases for \mathop's by using
> \sideset from the amsmath extension, e.g.,
>
> $$ \sideset{_*^*}{_*^*}\prod $$

That's not what I want. I would like to have multiple indices on the
right and aligned even if the upper or lower index is missing.

> Next you can abuse the mhchem extension which aligns prescripts to the
> right, e.g.,
>
> $\require{mhchem} \ce{^{227}_{90}Th+} $

No, I cannot. It allows only numbers as scripts as far as I understood.
I've experimented already with this.

> For those interested in giving it a try, it should not be terribly
> difficult to implement the tensor package since MathJax uses MathML
> internally which has multiscript element for this kind of layout. See the
> documentation <http://docs.mathjax.org/en/latest/extension-writing.html>
> and other TeX extensions for starting points.

MathJax uses MathML internally? Aha.

Since my TeX output comes from a computer algebra system FriCAS and I am
currently writing a converter for it to generate output that is easily
rendered by MathJax, I should, maybe generate the respective TeX
commands that correspond to the MathML output.

What would I have to generate? In particular, it's not exactly clear how
to produce the mathml tags by using LaTeX commands. I've read that
yesterday somewhere but I didn't pay attention and now cannot find it
anymor. :-(

Also, since I can generate the respective TeX for MathJax to process,
My example

M\indices{^a_b^{cd}_e}

could be generated instead as

M_a^b\vphantom{M}^{cd}\vphantom{M}_e

I found that after a lot of experiments and it renders reasonably well.

That would be a workaround for me, but if the expression "M" were more
complicated it would have to be processed by MathJax several times in
order to get its height. That's certainly wasted time.
Unfortunately, I don't have enough knowledge to write the respective
MathJax extension. Is there anyone who would do that? It's certainly
helpful not only for me.

Thanks
Ralf

William F Hammond

unread,
Oct 22, 2015, 11:33:18 AM10/22/15
to mathja...@googlegroups.com

On Thu, Oct 22, 2015 at 2:26 AM, Ralf Hemmecke <hemm...@gmail.com> wrote:
MathJax uses MathML internally? Aha.

Since my TeX output comes from a computer algebra system FriCAS and I am
currently writing a converter for it to generate output that is easily
rendered by MathJax, I should, maybe generate the respective TeX
commands that correspond to the MathML output.

What would I have to generate? In particular, it's not exactly clear how
to produce the mathml tags by using LaTeX commands. I've read that
yesterday somewhere but I didn't pay attention and now cannot find it
anymor. :-(

I think that recent versions of latexml support mathtools.

Gellmu has \mscript taking 5 arguments (base, pre-super, pre-sub, sub, super), and any of the scripts can be a list formed using \vect (which takes one argument for each list entry).  See
          -- Bill

Peter Krautzberger

unread,
Feb 5, 2016, 6:11:30 AM2/5/16
to mathja...@googlegroups.com
Hi,

Seems I never posted this because once I had finished, I realized I was "doing it wrong" -- and never got back to it. So here it is

Ralf, if you want to work on expanding it towards a tensor-like implementation, either comment on codepen or write to me directly.

Peter.

Reply all
Reply to author
Forward
0 new messages