Reputation: 4537
I use MathJax 3.2.0 to display MathML formulæ on web pages:
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
<mrow data-mjx-texclass="INNER">
<mo data-mjx-texclass="OPEN">{</mo>
<mtable columnspacing="1em" rowspacing="4pt">
<mtr>
<mtd>
<mi>x</mi>
</mtd>
<mtd>
<mi>y</mi>
</mtd>
</mtr>
<mtr>
<mtd>
<mi>z</mi>
</mtd>
<mtd>
<mi>v</mi>
</mtd>
</mtr>
</mtable>
<mo data-mjx-texclass="CLOSE">}</mo>
</mrow>
</math>
And it is displayed by MathJax (not natively by the browser) as expected, with context menu, etc.
The MathML code for this formula is also generated from TeX by MathJax as a server-side node.js module.
However, after I try to inject (server-side, by editing the HTML) the original TeX code as a semantic annotation (see below), MathJax fails client-side: Math output error, with this floating tooltip: this.variant[t] is undefined
. This happens only if the <annotation>
tag is not empty.
I was able to find out that this.variant[t]
was undefined in the functions getVariant
and getChar
and t
was ""
in some cases and undefined
in other.
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
<mrow data-mjx-texclass="INNER">
<mo data-mjx-texclass="OPEN">{</mo>
<mtable columnspacing="1em" rowspacing="4pt">
<mtr>
<mtd>
<mi>x</mi>
</mtd>
<mtd>
<mi>y</mi>
</mtd>
</mtr>
<mtr>
<mtd>
<mi>z</mi>
</mtd>
<mtd>
<mi>v</mi>
</mtd>
</mtr>
</mtable>
<mo data-mjx-texclass="CLOSE">}</mo>
</mrow>
<semantics>
<annotation encoding="application/x-tex">\begin{Bmatrix} x & y \\ z & v \end{Bmatrix}</annotation>
</semantics>
</math>
MathJax is attached so:
<script>
window.MathJax = {
"loader":{"load":["ui\/safe"]},
"options":{
"skipHtmlTags":["script","noscript","style","textarea","pre","code","annotation","annotation-xml","tt","nowiki","kbd","syntaxhighlight"],
"ignoreHtmlClass":["tex2jax_ignore","diff"],
"menuOptions":{
"settings":{
"zoom":"DoubleClick",
"semantics":true
},
"annotationTypes":{
"TeX":["application\/x-tex"],
"OpenMath":["OpenMath"]
}
},
"enableEnrichment":true
}
};
</script>
<script src="(skipped)/node_modules/mathjax-full/es5/mml-chtml.js?locale=ru"></script>
What could be wrong?
UPD: moving opening <semantics>
just after <math>
, i.e., wrapping the MathML code with <semantics>
resolved the issue.
Upvotes: 0
Views: 462
Reputation: 12280
Your <semantics>
node is invalid. The first child of <semantics>
should be a presentation MathML node, not an <annotation>
node. That is, the first child of <semantics>
should be the mathematics being annotated, and the second and subsequent nodes should be annotation nodes. See the MathML specifcation for details. So
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
<semantics>
<mrow data-mjx-texclass="INNER">
<mo data-mjx-texclass="OPEN">{</mo>
<mtable columnspacing="1em" rowspacing="4pt">
<mtr>
<mtd>
<mi>x</mi>
</mtd>
<mtd>
<mi>y</mi>
</mtd>
</mtr>
<mtr>
<mtd>
<mi>z</mi>
</mtd>
<mtd>
<mi>v</mi>
</mtd>
</mtr>
</mtable>
<mo data-mjx-texclass="CLOSE">}</mo>
</mrow>
<annotation encoding="application/x-tex">\begin{Bmatrix} x & y \\ z & v \end{Bmatrix}</annotation>
</semantics>
</math>
is the correct way to annotate this math, as you point out in your update.
It appears that you are using MathJax to produce the original MathML. If you are doing this in a browser using the MathJax contextual menu, note that there is an item in the "Show As" menu that you can select in order to include the original TeX as an annotation, so you don't have to do this yourself. If you are using mathjax-node
, you could configure mathjax-node
to set that option as well.
Upvotes: 0