Why is there no \textnormal support?

589 views
Skip to first unread message

Daniel

unread,
Feb 11, 2016, 2:14:08 AM2/11/16
to MathJax Users
Is there a reason why the \textnormal command is not supported? On the other hand, \text is supported by default even though it seems to be an amsmath command.

I guess I could easily implement support for \textnormal by using the Macros setting:

TeX: {
 
Macros: {
    textnormal
: ['\\text{#1}', 1]
 
}
}

I understand that \text cannot be removed from the default set of commands because it would break things for many people. But wouldn't it be reasonable to support \textnormal as well?

(If one would like to have the "pure (La)TeX experience" one could implement a setting for this. This could also remove some non-LaTeX conforming color setting which I seem to remember.)

By the way, \textsf is supported but not documented.

http://mathjax.readthedocs.org/en/latest/tex.html

Peter Krautzberger

unread,
Feb 11, 2016, 10:06:45 AM2/11/16
to mathja...@googlegroups.com
Dear Daniel,

Thanks for pointing out that textsf is not documented; I've opened https://github.com/mathjax/MathJax-docs/issues/144.

As for \textnormal, this question enters the murky waters of text-mode support in MathJax. IIUC \textnormal is supposed to switch to the font&variant determined by the surrounding text mode; but of course there is no surrounding LaTeX text mode context for MathJax so it seems problematic to have a macro that pretends otherwise. Of course there are things like the mtextFontInherit options and if you use that you can probably get away with defining \textnormal to be \text. Since the macro was never requested before, it doesn't seem a great case for it either, though that may change.

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.

Daniel

unread,
Feb 11, 2016, 10:38:54 AM2/11/16
to MathJax Users
Dear Peter,

Thanks. I think I got it.

My use case is, roughly, a website where LaTeX math code can be entered and is typeset by MathJax and then can be exported to be used in LaTeX. Since I did not include the AMSmath extension in MathJax I thought it would work out of the box. But the \text command throws an error since it relies on the amsmath LaTeX package. So I thought the obvious way would be to let people use \textnormal instead. That is how I arrived at the problem.

I guess I will just include the AMSmath extension and write in the documentation that the amsmath package has to be included for typesetting in LaTeX.

Alternatively, could one disable \text and set \textnormal to \text? I have seen your code for disabling commands.

http://codepen.io/pkra/pen/osqlD

But it does not work in my case since disabling \text in this way will also disable \textnormal defined by \text.

Best,
Daniel

Daniel

unread,
Feb 11, 2016, 2:45:27 PM2/11/16
to MathJax Users
ps. Just to be sure: I meant "But the \text command throws an error [in the LaTeX compiler] since it relies on the amsmath LaTeX package."

Daniel

unread,
Feb 12, 2016, 4:40:33 AM2/12/16
to MathJax Users

Dear Peter,

\text also matches the surrounding text. If I got this right, then your reasoning against \textnormal applies also to \text. And hence they should either both be disabled or both be enabled in MathJax. Actually, since \textnormal isn't relying on amsmath it has even an edge over \text to be included by default.

I tried two simple examples:

One in a normal article:

\documentclass{article}

\usepackage{amsmath}


\begin{document}


  This just some normal text, and here is some math:


  \begin{eqnarray*}


    \int_1^9 x dx & & \textrm{this is textrm}\\


    \sum_1^9 y    & & \textsf{this is textsf}\\


    \prod_1^9 z   & & \textnormal{this is textnormal}\\


    \prod_1^9 z   & & \text{this is text}


  \end{eqnarray*}


\end{document}


Which results in


The other a beamer document:

\documentclass{beamer}

\usepackage{amsmath}


\begin{document}


  \begin{frame}


    This just some normal text, and here is some math:


    \begin{eqnarray*}


      \int_1^9 x dx & & \textrm{this is textrm}\\


      \sum_1^9 y    & & \textsf{this is textsf}\\


      \prod_1^9 z   & & \textnormal{this is textnormal}\\


      \prod_1^9 z   & & \text{this is text}


    \end{eqnarray*}


  \end{frame}


\end{document}


Which results in


It seems that both \textnormal and \text match the sourrounding LaTeX text.


Best,
Daniel

Am Donnerstag, 11. Februar 2016 17:06:45 UTC+2 schrieb Peter Krautzberger:

Daniel

unread,
Feb 12, 2016, 4:52:34 AM2/12/16
to MathJax Users
Is there a difference between \textrm and \text in MathJax?

If not one could just use \textrm to define \textnormal and then remove the \text command to get "pure" LaTeX conformity for \text* commands:

TeX: {
 
Macros: {
    textnormal
: ['\\textrm{#1}', 1],
    text: null
 
}
}

Daniel

Am Donnerstag, 11. Februar 2016 17:38:54 UTC+2 schrieb Daniel:

Peter Krautzberger

unread,
Feb 12, 2016, 10:58:59 AM2/12/16
to mathja...@googlegroups.com

Dear Daniel,

> \text also matches the surrounding text. 

As I tried to explain, it's more complicated than that.

> Actually, since \textnormal isn't relying on amsmath it has even an edge over \text to be included by default.

Maybe from a "real" (La)TeX point of view. But MathJax is not TeX and disabling \text would break backward compatibility of MathJax because it's actually one of the few cases where MathJax is not strictly faithful to real LaTeX --  \text is a default macro in MathJax (and not even the AMS extensions are needed) . So at the earliest this could occur in MathJax 3.0.

> Is there a difference between \textrm and \text in MathJax?

No, it forces the font to rm. Why not just map \textnormal to \text?

Peter.

Daniel

unread,
Feb 12, 2016, 12:21:18 PM2/12/16
to MathJax Users
Dear Peter,


> \text also matches the surrounding text. 

As I tried to explain, it's more complicated than that.


Yes, I guess I did not get the difference between \text and \textnormal that makes the former more appropriate than the latter for MathJax. I will think a bit more about it.
 

> Actually, since \textnormal isn't relying on amsmath it has even an edge over \text to be included by default.

Maybe from a "real" (La)TeX point of view. But MathJax is not TeX and disabling \text would break backward compatibility of MathJax because it's actually one of the few cases where MathJax is not strictly faithful to real LaTeX --  \text is a default macro in MathJax (and not even the AMS extensions are needed) . So at the earliest this could occur in MathJax 3.0. 

> Is there a difference between \textrm and \text in MathJax?

No, it forces the font to rm. Why not just map \textnormal to \text?


Right, I see. As I tried to explained, the reason is that \text requires the amsmath package in LaTeX for my export functionality. So I am considering to disable the \text command. But doing so by setting the text to null in the TeX Macros, as you explained elsewhere, makes it impossible to map \textnormal to \text. Or is there another command disabling option?

But maybe this is all too complicated. Maybe I should just tell people to load the amsmath package when using my export function. I was just trying to minimize the package dependency. Maybe that is no good cause.

All the best,
Daniel
 

Davide P. Cervone

unread,
Feb 12, 2016, 5:18:46 PM2/12/16
to mathja...@googlegroups.com
Note that \textrm is defined in MathJax as a macro, and it calls on \text internally, so your suggestion won't work unless you redefine \textrm and the other \text* macros as well.

The MathJax TeX input jax is not particularly careful about separating out the various LaTeX macros into the same collections as LaTeX itself, so you will find that there are other inconsistencies.  MathJax doesn't have the LaTeX idea of document classes, and so MathJax hasn't tried to match any particular package specifically, though when a decision had to be made between two inconsistent classes, we used the amsart class as a reference, so MathJax does favor the AMS styles.  MathJax includes plain TeX macros that are deprecated in LaTeX, and includes a number of AMS macros and environments even when AMSmath is not loaded.

Davide

Daniel

unread,
Feb 13, 2016, 1:58:27 AM2/13/16
to MathJax Users, dp...@union.edu
Thanks Peter and Davide. Okay, I hope I got it now.

The \textnormal -> \textrm does not make much sense for the reasons that \textnormal is more like \text in matching the "surrounding environment" in MathJax, http://codepen.io/anon/pen/xZMPBJ, and anyway one could still not disable \text (via the MathJax TeX Extensions configuration) since \textrm does rely on it.

The \text command in MathJax should not be seen as the \text command in LaTeX amsmath but rather as a MathJax specific command. In particular, since it does not rely on the MathJax AMSmath extension and it does not behave as the \text command in LaTeX amsmath by matching surrounding text *outside* of the math environment.

By the way, there is a mistake in http://www.onemathematicalcat.org/MathJaxDocumentation/TeXSyntax.htm referred to from http://mathjax.readthedocs.org/en/latest/tex.html#supported-latex-commands http://codepen.io/anon/pen/obmoRm since it claims that for the \text command "in MathJax,  \text  is the same as:   \hbox,   \mbox" which is not true: http://codepen.io/anon/pen/obmoRm.

Okay, so whats left with my ambitions to have a "pure" LaTeX conforming MathJax? I guess it is a bit more tricky to disable the \text command and define a \textnormal command. Maybe one could match the \textnormal command to the \text command and somehow hook into the error message functionality to let MathJax produce an "undefined control sequence" error for \text but not the other \text* commands?

I am still not fully sure what is the difference in LaTeX between \textnormal and the amsmath \text command. In particular, since the \text command in MathJax is inconsistent with the \text command in LateX amsmath, I do not see why \textnormal isn't included by default (which would be inconsistent with "pure" LaTeX). Maybe it is that MathJax can be seen as, by default, using its own "package" that includes a \text command. I am not sure I find that persuasive.

Again, for the reason, Davide pointed out, that MathJax supports also a number of other commands by default that are part of the LaTeX amsmath package, it might be best to just tell people who want to use code that is valid in MathJax to use the amsmath package in LaTeX and then include the MathJax AMSmath extension as well by default.

The only other option that comes to my mind would be to check each MathJax command for their "pure" LaTeX conformity. And then somehow produce an error in MathJax if they do not conform. Wouldn't the last one be a nice configuration option to have in MathJax? Or at least an option to disable Macros, so they throw an error in MathJax, that does not break other commands relying on it. But I guess this is quite a bit of work. And since, as Peter pointed out, no one else than me seems to be interested in this...

Best,
Daniel

David Farmer

unread,
Feb 13, 2016, 7:04:53 AM2/13/16
to MathJax Users

Dear Daniel,

I have been following this thread but I still don't understand your
concerns.

If you define 'textnormal' to be 'text' in your MathJax configuration
(I think that was the suggestion), then can't you use your LaTeX
with MathJax, and you don't have to change your LaTeX source?

Whenever I run across a LaTeX command that MathJax doesn't know,
I just add something for the web version. I rarely need to change
the original source.

Regards,

David

Daniel

unread,
Feb 13, 2016, 7:23:13 PM2/13/16
to MathJax Users
Hi David,

Sorry for being hard to understand. It seems my problem is the other way around. I let people enter things on the web that are then previewed using MathJax. Then they have the option to export it to LaTeX.

Since people don't get an error message from MathJax when using \text they expect it to work when exported to LaTeX. That is not so *unless* they include the amsmath package. So *replacing* \textnormal with \text seems to be an obvious option, since \textnormal is supported by vanilla LaTeX. But that is not possible by *mapping* \textnormal to \text, since that would leave the \text command valid, i.e., non-replaced.

I hope putting it into my use context made it clearer. Please let me know if not.

Best,
Daniel

David Farmer

unread,
Feb 14, 2016, 6:10:21 AM2/14/16
to MathJax Users

Dear Daniel,

I get it now. I am always in the other direction: I get
LaTeX and then I need to make it work in HTML.

I guess you can't avoid some dependence on packages.
AMS math and AMS symbols are very common and I would be
surprised if you had complaints about requiring them.
(Well, people complain about a lot of things: I should
have inserted the word "reasonable" somewhere.)

If the export option from your site gave them a complete
document, then you could just include the packages and
probably nobody would even notice. But if they are
entering snippets and then just getting back the snippet,
then there would need to be some type of warning.

Regards,

David

Daniel

unread,
Feb 14, 2016, 10:03:33 AM2/14/16
to MathJax Users
Dear David,

Thanks. Yes, I guess your direction is actually more common. Maybe this is also why people seldom complain, as I did, about the non-vanilla LaTeX conformity or there not being an option to activate it.

I guess I will just have to go with warning people, since my app does not provide a whole LaTeX document (it provides a SVG that can be converted to PDF+LaTeX using Inkscape).

Best,
Daniel
Reply all
Reply to author
Forward
0 new messages