Page MenuHomePhabricator

MathJax: Several commands that work in texvc are not recognized
Closed, DeclinedPublic

Description

I found these:
\varcoppa, \sampi, \varstigma, \Digamma, \Sampi, \euro, \geneuro, \geneuronarrow, \geneurowide, \officialeuro, \arccot, \arcsec, \arccsc, \cancel, \bcancel, \xcancel, \cancelto

Additionally, \color doesn't recognize all color names, at least not OliveGreen:
{ \color{OliveGreen} 1 } is black.


Version: unspecified
Severity: normal
See Also:
https://bugzilla.wikimedia.org/show_bug.cgi?id=35481

Details

Reference
bz35186

Related Objects

Event Timeline

bzimport raised the priority of this task from to Low.Nov 22 2014, 12:16 AM
bzimport added a project: Math.
bzimport set Reference to bz35186.
bzimport added a subscriber: Unknown Object (MLST).

For more colors, that don't work, see http://leuksman.com/mw/index.php/Help,_Formula#Color (at least one example where the help from en.wikipedia is better than that from de).

The unrecognized colors are rendered black in Firefox 3.6, in IE 8 a [Math Processing Error] is displayed instead.

Putting this on my list, these should be addable.

\arccot, \arcsec, \arccsc were solved in Nageh version by adding some macros. See http://en.wikipedia.org/wiki/User_talk:Nageh/mathJax#Missing_functions

After a closer look at the sources: \color seems to be only a configuration issue, since there is MathJax/extensions/TeX/color.js. Probably you just have to mention it in MathJax/config/TeX-AMS-texvc_HTML.js next to the other extensions.
The missing commands that can be emulated should go in MathJax/extensions/TeX/texvc.js.

<math>\dot \vec u</math> works with tecvc but not with mathjax wihich only accepts the (correct) Latex <math>\dot{\vec u}</math>. There are a few similar bugs mentioned at http://en.wikipedia.org/w/index.php?title=User_talk:Nageh/mathJax including $$\hat \mathbf u$$, $$\underline \mathbb Z$$, $$\hat \boldsymbol \theta$$

Seems pagecolor is also not supported yet.

\cancel, \bcancel, \xcancel, \cancelto can also be enabled by adding the extension to our config.

Our defined symbols are smaller than the symbols from the AMS package due to different styling.

Our symbols get <code>font-family: STIXGeneral, 'Arial Unicode MS', serif; font-size: 85%; font-style: italic; font-weight: normal;</code>, whereas AMS symbols only get <code>font-family: MathJax_AMS;</code>

this will need fixing at some point.

From source code I extracted lists of both the commands allowed in texvc and MathJax, and diffed them. I hope this is the complete list of commands still missing:

AA
Dagger
Digamma
emph
euro
geneuro
geneuronarrow
geneurowide
H
image
officialeuro
pagecolor
Q
sampi
Sampi
sen
textsf
texttt
varcoppa
varstigma
vbox
vline

Added in https://gerrit.wikimedia.org/r/4060
\Dagger
\Digamma
\sampi
\Sampi
\varcoppa
\varstigma
\Q U+0051 doublestruck Q
\H U+8461 doublestruck H
\AA U+00C5 armstrong
\sen spanish version of \sin (bug 18912)
\image alias for \Im

Still left:
\euro
\geneuro
\geneuronarrow
\geneurowide
\officialeuro

\pagecolor ignore

Text instead of math formatting.. should we really include this ?
\emph{} text emphasize (italics)
\textsf{} text sans serif
\texttt{} text typewriter
\vbox{text} Encloses a paragraph's text to prevent it from running over a page break
\vline draws a vertical line with the height of the row at the location where it appears

mal.malego wrote:

\textsf{}, \texttt{} and \vline are implemented https://en.wikipedia.org/w/index.php?title=User%3ANageh%2FmathJax%2Fconfig%2FTeX-AMS-texvc_HTML.js&diff=486528289&oldid=485202027 here. \emph{}, while implemented as \textit{}, really shouldn't be supported because it is a text mode command and not a math mode command.

The case with the euro symbols is a different one. The \gen* commands are supposed to be generated from the 'C' letter, meant to support symbols that more closely match the font style. However, it turns out that Unicode and font designers, instead of adopting the official euro symbol, have preferred a symbol that matches the font style. Which means that the euro symbol in the font set most closely resembles \geneuro. \officialeuro is not available in the fonts, unless a specific euro font file will be added to MathJax. \euro is a link to one of the other symbols; while set to \officialeuro by default I have linked it to \geneuro.

mal.malego wrote:

This change, https://en.wikipedia.org/w/index.php?title=User%3ANageh%2FmathJax%2Fconfig%2FTeX-AMS-texvc_HTML.js&diff=486653054&oldid=486652453, adds the RGB color space so \definecolor does not fail anymore.

This change, https://en.wikipedia.org/w/index.php?title=User%3ANageh%2FmathJax%2Fconfig%2FTeX-AMS-texvc_HTML.js&diff=486652319&oldid=486638683, removes the noErrors.js extension, which, don't ask me why I have included it.

This change, https://en.wikipedia.org/w/index.php?title=User%3ANageh%2FmathJax%2Fconfig%2FTeX-AMS-texvc_HTML.js&diff=486638683&oldid=486528289, implements pretty perfect \oiint support for both HTML-CSS and MathML output, and admittedly a (still) imperfect implementation of \oiiint. I possibly would be good to directly rely on the font symbols when STIX fonts are detected.

This change, https://en.wikipedia.org/w/index.php?title=User%3ANageh%2FmathJax%2Fconfig%2FTeX-AMS-texvc_HTML.js&diff=487586044&oldid=486653054, resolves an issue where the \scriptstyle hack, which is so common on Wikipedia to effect a normal font size, is used in boxed display maths. I have updated my documentation accordingly (here: https://en.wikipedia.org/wiki/User:Nageh/mathJax#Usage_notes).

mal.malego wrote:

This change, https://en.wikipedia.org/w/index.php?title=User%3ANageh%2FmathJax.js&diff=484537614&oldid=484068957, supports mtextFontInherit for both HTML-CSS and MathML output.

Someone has complained that the vertical margin for display maths is too large. This change, https://en.wikipedia.org/w/index.php?title=User%3ANageh%2FmathJax.js&diff=487684008&oldid=486653976, reduces that margin by a tiny bit. I think it pretty closely matches that of ordinary LaTeX.

wikimedia.x.0x wrote:

So stuff like \texttt won't be supported? Should sites using these therefore be changed? Example: http://de.wikipedia.org/wiki/Lyndonwort

mal.malego wrote:

Huh? \texttt is most likely to be supported as it can be trivially implemented. See comment 14.

As nageh has said \texttt \textsf and \emph can probably be fixed by adding
MathJax.Hub.Config({

TeX: {
  Macros: { 
    texttt:             ['Macro','\\mathord{\\tt{\\text{#1}}}',1],
    textsf:             ['Macro','\\mathord{\\sf{\\text{#1}}}',1],
    emph:               ['Macro','\\textit{#1}',1],  // doesn't switch to \textrm within italic text as it should
  }
}

}
although I'm not sure if it works for doubly nested items (which don't actually work for \textbf{\textit{broken}} anyway).

mal.malego wrote:

Oh? I didn't know that \text doesn't accept nested commands. I suppose this could be easily fixed by the MathJax devs. Do you want to file a bug report at https://github.com/mathjax/MathJax/ ? Should I file one on your behalf? Thanks.

Now not convinced \textbf{\textit{broken}} is broken I can't see anywhere in latex doc which say the \textfoo commands should nest. Only source which indicates it is seems to be http://en.wikibooks.org/wiki/LaTeX/Text_Formatting which isn't that reliable.

mal.malego wrote:

Did you search on Google books? You could also try it yourself using your favorite LaTeX2e interpreter. \text* commands have been introduced in LaTeX(2e) over TeX for two reasons: old commands (\bf, \it, etc.) don't take a parameter so you always have to write {\bf text}; and they don't nest in contrast to \text*.

mal.malego wrote:

CTAN is the definite web source for information on LaTeX and packages. You may want to read the top of page 124 of http://ctan.org/tex-archive/info/lshort/english/lshort.pdf

\theta = 5^\operatorname{\omicron}

This math code is problematic but I dunno which command is the cause.

An extra pair of curly brackets sorts it out. <math>\theta = 5^{\operatorname{\omicron}}</math> works. MathJax is a bit more particular with precedence than texvc.

(In reply to comment #27)

An extra pair of curly brackets sorts it out. <math>\theta =
5^{\operatorname{\omicron}}</math> works. MathJax is a bit more particular
with precedence than texvc.

This is still some inconsistency...

(In reply to comment #27)

An extra pair of curly brackets sorts it out. <math>\theta =
5^{\operatorname{\omicron}}</math> works. MathJax is a bit more particular
with precedence than texvc.

This is reported in bug 36534.

Related URL: https://gerrit.wikimedia.org/r/61256 (Gerrit Change If6573901bafd8599a01979bcbff89e52b51e4ffd)

Related URL: https://gerrit.wikimedia.org/r/61287 (Gerrit Change If38014bde908bb202dc63213fa21a72b52a6a42d)

Still to do of things discussed in this ticket:

Revive: https://gerrit.wikimedia.org/r/4060

the euro symbols

\emph (only works if not in italics mode)
\vbox

https://en.wikipedia.org/w/index.php?title=User%3ANageh%2FmathJax.js&diff=484537614&oldid=484068957
Would like to know if it was intentional here that Nageh has changed the CSS to only affect MathML mtext elements (and no longer the HTML-CSS class .mtext)

https://en.wikipedia.org/w/index.php?title=User%3ANageh%2FmathJax.js&diff=484537614&oldid=484068957

mal.malego wrote:

DJ, you are right in your assumption that "mtext" _targets MathML elements rather than the standard HTML/CSS output. For the latter, the "mtextFontInherit" property is being used, which has become available since MathJax version 2.0.

mal.malego wrote:

I shall add that the mtext font scaling to 80% is almost certainly not correct, however, if omitted Firefox does not adapt the font size to that of the surrounding text (which is scaled to 80% by default). As MathML support has become available on Chrome, which correctly implements the scaling, I would suggest removing that part from the mtext CSS definition, i.e., simply use

styles: { "mtext": { "font-family": "sans-serif ! important" } }

Hi nageh,

MathJax can be configured to scale differently per browser. But it shouldn't have to be scaled at all (except for personal preference), so if you can produce a bug report, we'd appreciate it. https://github.com/mathjax/mathjax/issues

Oh, also: Chrome is currently removing the MathML code in Blink; the Chrome devs have hinted at a complete re-write. So MathML in Chrome is probably dead for the foreseeable future.

Peter.

mal.malego wrote:

Hi Peter,

thank you for your input. Yes, scaling should not be needed at all, and I was actually just going to suggest to ignore that custom styling altogether (there is no point in introducing something that breaks on one or the other browser). I will file a bug report.

Interesting note on Chrome's MathML support. What a pity.

mal.malego wrote:

As for \textsf and \texttt, these commands are correctly being defined but are missing styling support in the HTML/CSS output jax of TeX-AMS-texvc HTML.js when mtextFontInherit is being enabled.

This is fixed by amending the source with matches for "monospace" and "sans-serif" font variants. In explanation, you'll find code statements like

if(!j.weight&&j.mathvariant.match(/bold/)){j.weight="bold"}

Replicate these for the other font variants. I may do so in my user script sources so you can copy the changes. But possibly this would be a useful change for the official MathJax sources as well... Peter, what do you think?

Nageh, ah, I was wondering why \texttt and \textsf weren't working for me indeed.

@Nageh, sounds like a follow up of https://github.com/mathjax/MathJax/issues/226 right ? that \sf \tt fontinherit issue ?

mal.malego wrote:

Yes, indeed, the same solution is needed to fix \sf and \tt.

yes, this sounds like a bug in MathJax.

https://gerrit.wikimedia.org/r/4060 (Gerrit Change I51a72c378d3496b147eb87418c24718026306c13) | change RESTORED [by TheDJ]

Related URL: https://gerrit.wikimedia.org/r/64530 (Gerrit Change I20ac8af2253835c20431585d9caebe4066606879)

Related URL: https://gerrit.wikimedia.org/r/64531 (Gerrit Change If2fb219a1191caeecb0ed04bf0c0105621725dce)

physik wrote:

https://gerrit.wikimedia.org/r/#/c/90748/
This solves all the issues since it passes only real TeX to MathJax.
I home someone will review this one day.
I even wrote a guide how to verify the correctness of the change.
http://www.formulasearchengine.com/Verify%20texvc%20light

Even that did not help...
Maybe I should add some wrong spacing so that potential reviewers find something to comment.

The treatment of \color is very different between the two versions.
Looking at
http://docs.mathjax.org/en/latest/tex.html#color
we see
"The \color command in the core TeX input jax is not standard in that it takes the mathematics to be colored as one of its parameters, whereas the LaTeX \color command is a switch that changes the color of everything that follows it."

This means in texvc we have

<math>foo \color{Red} Red text \color{Black} bar</math>

which breaks mathjax.

You can fix things so that

<math>foo {\color{Red}{Red text}} bar</math>

which seems to work with both mathjax and also texvc. Note it needs the text to be colored in { } so mathjax recognises the first argument, and also { } around the whole thing so texvc does not get confused.

A further issue is the colors supported. LaTeX's colors are

Apricot Aquamarine Bittersweet Black
Blue BlueGreen BlueViolet BrickRed
etc

But MathJax only support colors with CSS names. So no Apricot, Bittersweet, BlueGreen or BrickRed. You can see the difference by viewing
https://en.wikipedia.org/wiki/Help:Formula#Color
with the different renderers.

There is MathJax color.js extension. Which makes the color handling like the texvc and I think define latex rather than CSS colors. It might be worth installing.

@Richard The color problems were introduced in late january: Bug 63574. It's just that nobody noticed until today.

Please try to open separate tickets for separate issues. Link them with dependencies if you want to group them.

mal.malego wrote:

Oddly enough it seems that I was the first to notice despite I'm not being active anymore.

Change 4060 abandoned by Physikerwelt:
Math: Adding archaic greek symbols from teubner set

Reason:
conserved in https://www.mediawiki.org/wiki/Extension:Math/Roadmap#Bugs_and_Roadmap_and_random_thoughts_.28From_the_discussion_page.29 feel free to restore if any development on that is planned

https://gerrit.wikimedia.org/r/4060

physik wrote:

This should be fixed within MathJax. I discussed with Peter that we don't want to have a WMF specific version of MathJax to reduce the maintenance effort.
See https://github.com/mathjax/MathJax/pull/882

physik wrote:

This should be fixed within MathJax. I discussed with Peter that we don't want to have a WMF specific version of MathJax to reduce the maintenance effort.
See https://github.com/mathjax/MathJax/pull/882

That branch was deleted, are the commits preserved or continuing somewhere?

No that was not possible due to licensing issues.
But an alternative solution was found
which made it into standard MathJax... so in principal there is no need for any server side support for mediawiki specific customization of MathJax outside from the official MathJax/MathJax repository https://github.com/mathjax/MathJax/blob/master/unpacked/extensions/TeX/mediawiki-texvc.js

Ok. Is the mediawiki-texvc.js extension already in use on Wikimedia projects?

No. Not directly. But I have hope that
https://phabricator.wikimedia.org/T97124
will make progress and mathoid will be updated.
Afterwards the MathJax client side option can be removed.
I think using source rendering in connection with a MathJax browser plugin would be a better solution.
Maintaining a MediaWiki specific clone of MathJax does not sound reasonable to me, especially given the fact that the MathJax and MediaWiki resource loader are not compatible.

@Physikerwelt, if the mediawiki-texvc.js extension has already been written, wouldn't using it become a quick fix for this task? Why is it necessary to maintain a MediaWiki specific clone of MathJax?

The extension has been written for MathJax 2.5. Client Side MathJax was updated last time to MathJax 2.3.
The resource loader issue makes it difficult to update the MathJax version.
I think a better aproach would be to use a browser plugin such as https://chrome.google.com/webstore/detail/wikipedia-with-mathjax/fhomhkjcommffnlajeemenejemmegcmi

Physikerwelt claimed this task.

MathJax will be removed T99369

  NODES
Bugs 3
Note 4
Project 2
Verify 2