Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect MathML is generated from LaTeX vmatrix #2105

Closed
abnerlee opened this issue Dec 31, 2018 · 1 comment
Closed

Incorrect MathML is generated from LaTeX vmatrix #2105

abnerlee opened this issue Dec 31, 2018 · 1 comment
Labels
Expected Behavior This is how MathJax works

Comments

@abnerlee
Copy link

version 2.7.5

TeX input:

\begin{vmatrix}
\mathbf{i} & \mathbf{j} & \mathbf{k} \\
1 &  2 & 3 \\
1 &  2 & 3 \\
\end{vmatrix}

MathJax will generate following MathML from it

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
  <mrow>
    <mo>|</mo>
    <mtable rowspacing="4pt" columnspacing="1em">
      <mtr>
        <mtd>
          <mrow class="MJX-TeXAtom-ORD">
            <mi mathvariant="bold">i</mi>
          </mrow>
        </mtd>
        <mtd>
          <mrow class="MJX-TeXAtom-ORD">
            <mi mathvariant="bold">j</mi>
          </mrow>
        </mtd>
        <mtd>
          <mrow class="MJX-TeXAtom-ORD">
            <mi mathvariant="bold">k</mi>
          </mrow>
        </mtd>
      </mtr>
      <mtr>
        <mtd>
          <mn>1</mn>
        </mtd>
        <mtd>
          <mn>2</mn>
        </mtd>
        <mtd>
          <mn>3</mn>
        </mtd>
      </mtr>
      <mtr>
        <mtd>
          <mn>1</mn>
        </mtd>
        <mtd>
          <mn>2</mn>
        </mtd>
        <mtd>
          <mn>3</mn>
        </mtd>
      </mtr>
    </mtable>
    <mo>|</mo>
  </mrow>
</math>

But if you copy the generated MathML code into http://www.wiris.com/editor/demo/en/developers#mathml-latex or MS Word, the actually rendered math equation is like:

screen shot 2019-01-01 at 00 58 31

So I think the generate MathML is incorrect for vmatrix, maybe

<math xmlns="http://www.w3.org/1998/Math/MathML"><mfenced open="|" close="|"><mtable><mtr><mtd><mi>i</mi></mtd><mtd><mi>j</mi></mtd><mtd><mi>k</mi></mtd></mtr><mtr><mtd><mn>1</mn></mtd><mtd><mn>2</mn></mtd><mtd><mn>3</mn></mtd></mtr><mtr><mtd><mn>1</mn></mtd><mtd><mn>2</mn></mtd><mtd><mn>3</mn></mtd></mtr></mtable></mfenced></math>

is more correct.

@dpvc
Copy link
Member

dpvc commented Dec 31, 2018

The MathML produced by MathJax is actually correct; but it seems that the WIRIS renderer does not implement the default attributes from the MathML Operator Dictionary, even for parentheses and other standard delimiters. WIRIS seems to require <mo stretchy="true">|</mo> in order to have the delimiters be stretchy, despite the entries in the operator dictionary for '|' in the prefix and postfix positions.

Although the Operator Dictionary given at the link above is non-normative, some form of default attributes for things like stretchy operators is essential to making MathML work as expected. If you add stretchy="true" to the <mo>|</mo> elements, WIRIS renders it as expected, but this attribute should be the default (according to the Operator Dictionary), so should not be needed explicitly. So it seems that WIRIS is at fault, here, not MathJax.

Note also that the MathML specification indicates that <mfenced> is equivalent to an expanded <mrow>-with-<mo> construction:

Thus, any mfenced element is completely equivalent to an expanded form described below.... A MathML renderer is required to render either of these forms in exactly the same way.

The fact that the WIRIS renderer treats <mfenced open="|" close="|">...</mfenced> differently from <mrow><mo>|</mo>...<mo>|</mo></mrow> (even if the fence="true" attribute is applied explicitly to the <mo> elements) indicate that WIRIS is not following the MathML specification.

@dpvc dpvc added the Expected Behavior This is how MathJax works label Dec 31, 2018
@dpvc dpvc closed this as completed May 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Expected Behavior This is how MathJax works
Projects
None yet
Development

No branches or pull requests

2 participants