\limits is allowed only on operators

368 views
Skip to first unread message

Jelle Roorda

unread,
May 19, 2021, 7:59:41 AM5/19/21
to MathJax Users
For our application migration we currently have MathML exports that are being converted to TeX, after which it'll be rendered by the MathJAX library in the browser.

I currently have the following MathML snippet:
<math xmlns="http://www.w3.org/1998/Math/MathML"> <mstyle displaystyle="true"> <msub> <mover> <mi>w</mi> <mo>→</mo> </mover> <mi>d</mi> </msub> </mstyle> </math>

Which I believe is supposed to be rendered like this:
Schermafbeelding 2021-05-19 om 13.54.34.png

The TeX I get after converting the MathML is as follows:

w\limits^{\rightarrow }_{d}

When I try to render the above TeX with the `MathJax.tex2svg()` function, however, I get the error: "\limits is allowed only on operators"

Schermafbeelding 2021-05-19 om 13.56.46.png

Now I am neither a TeX or MathML professional, and I've looked in the forums and Github issues but couldn't find any explanations for why the above error would be displayed. Obviously the "w" in front of the \limits is not allowed, but I have the following questions:
1. Why is it not allowed?
2. How would I work around this issue to get the right display?

Thanks,
Jelle

Davide Cervone

unread,
May 19, 2021, 8:33:26 AM5/19/21
to mathja...@googlegroups.com

> For our application migration we currently have MathML exports that are being converted to TeX, after which it'll be rendered by the MathJAX library in the browser.

Since MathJax can take MathML as its input format, you might want to consider using your original MathML rather than converting too TeX. (MathJax will just have to convert it back to MathML anyway.)

> I currently have the following MathML snippet:
> <math xmlns="http://www.w3.org/1998/Math/MathML"> <mstyle displaystyle="true"> <msub> <mover> <mi>w</mi> <mo>→</mo> </mover> <mi>d</mi> </msub> </mstyle> </math>
>
> The TeX I get after converting the MathML is as follows:
>
> w\limits^{\rightarrow }_{d}

As you have found out, this is not valid TeX. You probably want

{\vec w}_d

> 1. Why is it not allowed?

The \limits macro is only allows on what TeX thinks of as "operators", like \sum, \int, \log, and so on. A "w" is just an "ordinary" symbol, and so doesn't take limits like \sum does. You can make any symbol into an operator using \mathop{}, so \mathop{w} would be allowed to have limits. (There are also other macros like \mathord{}, \mathbin{}, \mathrel{}, etc. for informing TeX of the class you want the contents to have.) That would allow you to do \mathop{w}^\rightarrow_d, but that will not get what you are looking for, since both the arrow AND the "d" will be placed as limits, so the d will be underneath the w, not in subscript position.

> 2. How would I work around this issue to get the right display?

Either

{\vec w}_d

or

\overset{\rightarrow}{w}_d

would work. But again, I would just give MathJax the MathML rather than converting to TeX, unless there is some other reason you need the TeX.

Davide

Albert van der Meer

unread,
May 19, 2021, 8:35:02 AM5/19/21
to MathJax Users
Jelle,

Have a go at: \overrightarrow{w}_{d}

Searching through: https://stackexchange.com/filters/325824/latex can also be a big help (note this is a Tex site and not really a MathJax site, there is sometimes some reluctance to anser questions when MathJax is mentioned best to formulate question in a LaTeX way.)

Albert

Albert van der Meer

unread,
May 19, 2021, 8:46:08 AM5/19/21
to MathJax Users
Davide,

For \overset doesn't one need to include ams as well?

Albert

Davide Cervone

unread,
May 19, 2021, 9:02:38 AM5/19/21
to mathja...@googlegroups.com
For \overset doesn't one need to include ams as well?

Yes.  Jelle didn't give the configuration being used (or even whether this is MathJax v2 or v3), but all the combined components (like tex-svg.js from v2, and TeX-AMS_SVG from v2) all include the AMS package automatically, so unless their configuration is loading the components individually, there is no special configuration needed.

Have a go at: \overrightarrow{w}_{d}

The arrow for this will be too large.

Here is the output for

{\vec w}_d\quad \overset{{}\rightarrow}{w}_d\quad \overrightarrow{w}_d

(the extra {} in the center one is to prevent Mathjax from substituting the vector arrow for the right arrow).


Any of them "works", but I think the \vec version is the usual one for this situation.

Davide

Jelle Roorda

unread,
May 19, 2021, 9:10:05 AM5/19/21
to mathja...@googlegroups.com

Thanks Davide, Albert,

I'm using MathJax v3, and both your suggestion seem to work to me. I'll leave our customer up to decide whether it should be the "a smaller" or "a larger" arrow. I am not a mathematician, so I'll leave it up to them to decide what would be the proper display. Your suggestions were very helpful!

Thanks again,
Jelle

Op 19-05-21 om 15:02 schreef Davide Cervone:
--
You received this message because you are subscribed to a topic in the Google Groups "MathJax Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mathjax-users/1fW8FgbZvw8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mathjax-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mathjax-users/68CC8F0A-E64E-4D8E-8D89-A7C54AD59637%40gmail.com.

David Farmer

unread,
May 19, 2021, 9:26:14 AM5/19/21
to mathja...@googlegroups.com

Davide knows this subject better than your customer, so you should
just go with \vec w.

On Wed, 19 May 2021, Jelle Roorda wrote:

> Thanks Davide, Albert,
>
> I'm using MathJax v3, and both your suggestion seem to work to me. I'll
> leave our customer up to decide whether it should be the "a smaller" or
> "a larger" arrow. I am not a mathematician, so I'll leave it up to them
> to decide what would be the proper display. Your suggestions were very
> helpful!
>
> Thanks again,
> Jelle
>
> Op 19-05-21 om 15:02 schreef Davide Cervone:
>>> For \overset doesn't one need to include ams as well?
>>
>> Yes.  Jelle didn't give the configuration being used (or even whether
>> this is MathJax v2 or v3), but all the combined components (like
>> tex-svg.js from v2, and TeX-AMS_SVG from v2) all include the AMS
>> package automatically, so unless their configuration is loading the
>> components individually, there is no special configuration needed.
>>
>>> Have a go at: \overrightarrow{w}_{d}
>>
>> The arrow for this will be too large.
>>
>> Here is the output for
>>
>> {\vec w}_d\quad \overset{{}\rightarrow}{w}_d\quad \overrightarrow{w}_d
>>
>> (the extra {} in the center one is to prevent Mathjax from
>> substituting the vector arrow for the right arrow).
>>
>>
>> Any of them "works", but I think the \vec version is the usual one for
>> this situation.
>>
>> Davide
>> --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "MathJax Users" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/mathjax-users/1fW8FgbZvw8/unsubscribe
>> <https://groups.google.com/d/topic/mathjax-users/1fW8FgbZvw8/unsubscribe>.
>> To unsubscribe from this group and all its topics, send an email to
>> mathjax-user...@googlegroups.com
>> <mailto:mathjax-user...@googlegroups.com>.
>> <https://groups.google.com/d/msgid/mathjax-users/68CC8F0A-E64E-4D8E-8D89-A7C54AD59637%40gmail.com?utm_medium=email&utm_source=footer>.
>
> --
> 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.
> To view this discussion on the web visit https://groups.google.com/d/msgid/mathjax-users/e89b9daa-9d86-0ff2-eadd-c712d46df5a6%40roordaict.nl.
>
Reply all
Reply to author
Forward
0 new messages