MathJax icon indicating copy to clipboard operation
MathJax copied to clipboard

Problem displaying the formula

Open saraOrkide opened this issue 2 years ago • 2 comments

The displayed formula is not the same as what was typed in the Word environment

In the word file it is like this: wordFileScreenShot But when it is converted from word to mml, it is displayed like this: Screenshot from 2024-02-28 14-51-47 As you can see, the formula should have gone to the next line, but it didn't mathjax version: mathjax-4.0.0-beta.4 using mml-chtml.js os: windows and linux browser: chrome and firefox setting :

chtml: {
                    displayAlign: 'right',
                    scale: 1,
                    merrorInheritFont: !0,
                    matchFontHeight: false,
                    mtextFont: 'fontRegular, Noto Sans, sans-serif',
                    mtextInheritFont: false,
                    unknownFamily: 'fontRegular, Noto Sans, sans-serif',
                    font: 'mathjax-fira',
                },

word file: sample.docx

mml code for this section:

    <div class='chistaItem' style='text-align:right;justify-content:right;/*MARK-BY-CHISTA-PARSER*/;direction:rtl;/*MARK-BY-CHISTA-PARSER*/;'><span class='chistaText'><span dir=rtl><span style='color:#000000;'>الف)</span></span></span></div><div class='chistaItem' style='text-align:left;justify-content:left;/*MARK-BY-CHISTA-PARSER*/;direction:ltr;/*MARK-BY-CHISTA-PARSER*/;'><span class='chistaText'><span class='chistaFormula'><math xmlns='http://www.w3.org/1998/Math/MathML' display='inline' mathcolor='#050038'><mtable xmlns='http://www.w3.org/1998/Math/MathML' ><mtr><mtd><menclose notation='box'><mn>3000</mn></menclose></mtd><mtd><mo>⇐</mo></mtd><mtd><mn>7600</mn><mo>-</mo><mn>4300</mn></mtd><mtd><mo>⇒</mo></mtd><mtd><menclose notation='box'><mn>4000</mn></menclose></mtd></mtr><mtr><mtd><mo>…</mo></mtd><mtd><mo>⇐</mo></mtd><mtd><mn>2300</mn><mo>+</mo><mn>4200</mn></mtd><mtd><mo>⇒</mo></mtd><mtd><mo>…</mo></mtd></mtr><mtr><mtd><mo>…</mo></mtd><mtd><mo>⇐</mo></mtd><mtd><mn>3400</mn><mo>+</mo><mn>2100</mn></mtd><mtd><mo>⇒</mo></mtd><mtd><mo>…</mo></mtd></mtr></mtable></math></span></span></div><div class='chistaItem' style='text-align:right;justify-content:right;/*MARK-BY-CHISTA-PARSER*/;direction:rtl;/*MARK-BY-CHISTA-PARSER*/;'><span class='chistaText'><span dir=rtl><span style='color:#000000;'>ب)</span></span></span></div><div class='chistaItem' style='text-align:left;justify-content:left;/*MARK-BY-CHISTA-PARSER*/;direction:ltr;/*MARK-BY-CHISTA-PARSER*/;'><span class='chistaText'><span class='chistaFormula'><math xmlns='http://www.w3.org/1998/Math/MathML' display='inline' mathcolor='#050038'><mtable xmlns='http://www.w3.org/1998/Math/MathML' ><mtr><mtd><menclose notation='box'><mn>3000</mn></menclose></mtd><mtd><mo>⇐</mo></mtd><mtd><munder><mrow><munder accentunder='false'><mrow><mn>7600</mn><mo>-</mo><mn>4300</mn></mrow><mo>⏟</mo></munder></mrow><mrow><mn>3300</mn></mrow></munder></mtd><mtd><mo>⇒</mo></mtd><mtd><menclose notation='box'><mn>4000</mn></menclose></mtd></mtr></mtable><mtable xmlns='http://www.w3.org/1998/Math/MathML' ><mtr><mtd><mo>…</mo></mtd><mtd><mo>⇐</mo></mtd><mtd><munder><mrow><munder accentunder='false'><mrow><mn>2300</mn><mo>+</mo><mn>4200</mn></mrow><mo>⏟</mo></munder></mrow><mrow><mn>6500</mn></mrow></munder></mtd><mtd><mo>⇒</mo></mtd><mtd><mo>…</mo></mtd></mtr></mtable><mtable xmlns='http://www.w3.org/1998/Math/MathML' ><mtr><mtd><mo>…</mo></mtd><mtd><mo>⇐</mo></mtd><mtd><munder><mrow><munder accentunder='false'><mrow><mn>3400</mn><mo>+</mo><mn>2100</mn></mrow><mo>⏟</mo></munder></mrow><mrow><mn>5500</mn></mrow></munder></mtd><mtd><mo>⇒</mo></mtd><mtd><mo>…</mo></mtd></mtr></mtable></math></span></span></div><div class='chistaItem' style='text-align:right;justify-content:right;/*MARK-BY-CHISTA-PARSER*/;direction:rtl;/*MARK-BY-CHISTA-PARSER*/;'><span class='chistaText'><span dir=rtl><span style='color:#000000;'>ج)</span></span></span></div><div class='chistaItem' style='text-align:left;justify-content:left;/*MARK-BY-CHISTA-PARSER*/;direction:ltr;/*MARK-BY-CHISTA-PARSER*/;'><span class='chistaText'><span class='chistaFormula'><math xmlns='http://www.w3.org/1998/Math/MathML' display='inline' mathcolor='#050038'><mtable xmlns='http://www.w3.org/1998/Math/MathML' ><mtr><mtd><menclose notation='box'><mn>3000</mn></menclose></mtd><mtd><mo>⇐</mo></mtd><mtd><munder><mrow><munder accentunder='false'><mrow><mn>7600</mn><mo>-</mo><mn>4300</mn></mrow><mo>⏟</mo></munder></mrow><mrow><mn>3300</mn></mrow></munder></mtd><mtd><mo>⇒</mo></mtd><mtd><menclose notation='box'><mn>4000</mn></menclose></mtd></mtr></mtable><mtable xmlns='http://www.w3.org/1998/Math/MathML' ><mtr><mtd><menclose notation='box'><mn>6000</mn></menclose></mtd><mtd><mo>⇐</mo></mtd><mtd><munder><mrow><munder accentunder='false'><mrow><mn>2300</mn><mo>+</mo><mn>4200</mn></mrow><mo>⏟</mo></munder></mrow><mrow><mn>6500</mn></mrow></munder></mtd><mtd><mo>⇒</mo></mtd><mtd><menclose notation='box'><mn>7000</mn></menclose></mtd></mtr></mtable><mtable xmlns='http://www.w3.org/1998/Math/MathML' ><mtr><mtd><menclose notation='box'><mn>5000</mn></menclose></mtd><mtd><mo>⇐</mo></mtd><mtd><munder><mrow><munder accentunder='false'><mrow><mn>3400</mn><mo>+</mo><mn>2100</mn></mrow><mo>⏟</mo></munder></mrow><mrow><mn>5500</mn></mrow></munder></mtd><mtd><mo>⇒</mo></mtd><mtd><menclose notation='box'><mn>6000</mn></menclose></mtd></mtr></mtable></math></span></span></div>

saraOrkide avatar Feb 28 '24 11:02 saraOrkide

MathJax's rendering is correct for the MathML that you have supplied. Three mtable elements in a row, with no intervening elements, as in your second and third expressions, should be rendered horizontally as MathJax does. As these fall within a single inline math element, there are no valid in-line breakpoints for MathJax's in-line breaking algorithm. It may be that Word allows line breaks at these points (the MathML specification does not specify an in-line breaking algorithm).

You probably want to combine the three separate mtable elements into a single table, as in your first expression. For example:

<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline" mathcolor="#050038">
  <mtable>
    <mtr>
      <mtd>
        <menclose notation="box">
          <mn>3000</mn>
        </menclose>
      </mtd>
      <mtd>
        <mo>&#x21D0;</mo>
      </mtd>
      <mtd>
        <munder>
          <mrow>
            <munder>
              <mrow>
                <mn>7600</mn>
                <mo>-</mo>
                <mn>4300</mn>
              </mrow>
              <mo>&#x23DF;</mo>
            </munder>
          </mrow>
          <mrow>
            <mn>3300</mn>
          </mrow>
        </munder>
      </mtd>
      <mtd>
        <mo>&#x21D2;</mo>
      </mtd>
      <mtd>
        <menclose notation="box">
          <mn>4000</mn>
        </menclose>
      </mtd>
    </mtr>
    <mtr>
      <mtd>
        <mo>&#x2026;</mo>
      </mtd>
      <mtd>
        <mo>&#x21D0;</mo>
      </mtd>
      <mtd>
        <munder>
          <mrow>
            <munder>
              <mrow>
                <mn>2300</mn>
                <mo>+</mo>
                <mn>4200</mn>
              </mrow>
              <mo>&#x23DF;</mo>
            </munder>
          </mrow>
          <mrow>
            <mn>6500</mn>
          </mrow>
        </munder>
      </mtd>
      <mtd>
        <mo>&#x21D2;</mo>
      </mtd>
      <mtd>
        <mo>&#x2026;</mo>
      </mtd>
    </mtr>
    <mtr>
      <mtd>
        <mo>&#x2026;</mo>
      </mtd>
      <mtd>
        <mo>&#x21D0;</mo>
      </mtd>
      <mtd>
        <munder>
          <mrow>
            <munder>
              <mrow>
                <mn>3400</mn>
                <mo>+</mo>
                <mn>2100</mn>
              </mrow>
              <mo>&#x23DF;</mo>
            </munder>
          </mrow>
          <mrow>
            <mn>5500</mn>
          </mrow>
        </munder>
      </mtd>
      <mtd>
        <mo>&#x21D2;</mo>
      </mtd>
      <mtd>
        <mo>&#x2026;</mo>
      </mtd>
    </mtr>
  </mtable>
</math>

Note that I've also removed the accentunder="false" attributes, which are not what you want, here. The underprices are accents, and want to be rendered at the same size as the expression they are under, not at a reduced size (as non-accents are), and accents get placed closer to the material they are under (or over), rather than on a separate baseline as non-accents are.

An alternative would be to place <mo linebreak="newline"></mo> between the tables, but the spacing between the lines will not be as good.

dpvc avatar Feb 28 '24 15:02 dpvc

I'm sorry, I had sent the mml for only one mtable complete mml: <div class='chistaItem' style='text-align:right;justify-content:right;/*MARK-BY-CHISTA-PARSER*/;direction:rtl;/*MARK-BY-CHISTA-PARSER*/;'> <span class='chistaText'><span dir=rtl><span style='color:#000000;'>الف)</span></span></span></div> <div class='chistaItem' style='text-align:left;justify-content:left;/*MARK-BY-CHISTA-PARSER*/;direction:ltr;/*MARK-BY-CHISTA-PARSER*/;'> <span class='chistaText'><span class='chistaFormula'><math xmlns='http://www.w3.org/1998/Math/MathML' display='inline' mathcolor='#050038'> <mtable xmlns='http://www.w3.org/1998/Math/MathML'> <mtr> <mtd> <menclose notation='box'> <mn>3000</mn> </menclose> </mtd> <mtd> <mo>⇐</mo> </mtd> <mtd> <mn>7600</mn> <mo>-</mo> <mn>4300</mn> </mtd> <mtd> <mo>⇒</mo> </mtd> <mtd> <menclose notation='box'> <mn>4000</mn> </menclose> </mtd> </mtr> <mtr> <mtd> <mo>…</mo> </mtd> <mtd> <mo>⇐</mo> </mtd> <mtd> <mn>2300</mn> <mo>+</mo> <mn>4200</mn> </mtd> <mtd> <mo>⇒</mo> </mtd> <mtd> <mo>…</mo> </mtd> </mtr> <mtr> <mtd> <mo>…</mo> </mtd> <mtd> <mo>⇐</mo> </mtd> <mtd> <mn>3400</mn> <mo>+</mo> <mn>2100</mn> </mtd> <mtd> <mo>⇒</mo> </mtd> <mtd> <mo>…</mo> </mtd> </mtr> </mtable> </math></span></span></div> <div class='chistaItem' style='text-align:right;justify-content:right;/*MARK-BY-CHISTA-PARSER*/;direction:rtl;/*MARK-BY-CHISTA-PARSER*/;'> <span class='chistaText'><span dir=rtl><span style='color:#000000;'>ب)</span></span></span></div> <div class='chistaItem' style='text-align:left;justify-content:left;/*MARK-BY-CHISTA-PARSER*/;direction:ltr;/*MARK-BY-CHISTA-PARSER*/;'> <span class='chistaText'><span class='chistaFormula'><math xmlns='http://www.w3.org/1998/Math/MathML' display='inline' mathcolor='#050038'> <mtable xmlns='http://www.w3.org/1998/Math/MathML'> <mtr> <mtd> <menclose notation='box'> <mn>3000</mn> </menclose> </mtd> <mtd> <mo>⇐</mo> </mtd> <mtd> <munder> <mrow> <munder accentunder='false'> <mrow> <mn>7600</mn> <mo>-</mo> <mn>4300</mn> </mrow> <mo>⏟</mo> </munder> </mrow> <mrow> <mn>3300</mn> </mrow> </munder> </mtd> <mtd> <mo>⇒</mo> </mtd> <mtd> <menclose notation='box'> <mn>4000</mn> </menclose> </mtd> </mtr> </mtable> <mtable xmlns='http://www.w3.org/1998/Math/MathML'> <mtr> <mtd> <mo>…</mo> </mtd> <mtd> <mo>⇐</mo> </mtd> <mtd> <munder> <mrow> <munder accentunder='false'> <mrow> <mn>2300</mn> <mo>+</mo> <mn>4200</mn> </mrow> <mo>⏟</mo> </munder> </mrow> <mrow> <mn>6500</mn> </mrow> </munder> </mtd> <mtd> <mo>⇒</mo> </mtd> <mtd> <mo>…</mo> </mtd> </mtr> </mtable> <mtable xmlns='http://www.w3.org/1998/Math/MathML'> <mtr> <mtd> <mo>…</mo> </mtd> <mtd> <mo>⇐</mo> </mtd> <mtd> <munder> <mrow> <munder accentunder='false'> <mrow> <mn>3400</mn> <mo>+</mo> <mn>2100</mn> </mrow> <mo>⏟</mo> </munder> </mrow> <mrow> <mn>5500</mn> </mrow> </munder> </mtd> <mtd> <mo>⇒</mo> </mtd> <mtd> <mo>…</mo> </mtd> </mtr> </mtable> </math></span></span></div> <div class='chistaItem' style='text-align:right;justify-content:right;/*MARK-BY-CHISTA-PARSER*/;direction:rtl;/*MARK-BY-CHISTA-PARSER*/;'> <span class='chistaText'><span dir=rtl><span style='color:#000000;'>ج)</span></span></span></div> <div class='chistaItem' style='text-align:left;justify-content:left;/*MARK-BY-CHISTA-PARSER*/;direction:ltr;/*MARK-BY-CHISTA-PARSER*/;'> <span class='chistaText'><span class='chistaFormula'><math xmlns='http://www.w3.org/1998/Math/MathML' display='inline' mathcolor='#050038'> <mtable xmlns='http://www.w3.org/1998/Math/MathML'> <mtr> <mtd> <menclose notation='box'> <mn>3000</mn> </menclose> </mtd> <mtd> <mo>⇐</mo> </mtd> <mtd> <munder> <mrow> <munder accentunder='false'> <mrow> <mn>7600</mn> <mo>-</mo> <mn>4300</mn> </mrow> <mo>⏟</mo> </munder> </mrow> <mrow> <mn>3300</mn> </mrow> </munder> </mtd> <mtd> <mo>⇒</mo> </mtd> <mtd> <menclose notation='box'> <mn>4000</mn> </menclose> </mtd> </mtr> </mtable> <mtable xmlns='http://www.w3.org/1998/Math/MathML'> <mtr> <mtd> <menclose notation='box'> <mn>6000</mn> </menclose> </mtd> <mtd> <mo>⇐</mo> </mtd> <mtd> <munder> <mrow> <munder accentunder='false'> <mrow> <mn>2300</mn> <mo>+</mo> <mn>4200</mn> </mrow> <mo>⏟</mo> </munder> </mrow> <mrow> <mn>6500</mn> </mrow> </munder> </mtd> <mtd> <mo>⇒</mo> </mtd> <mtd> <menclose notation='box'> <mn>7000</mn> </menclose> </mtd> </mtr> </mtable> <mtable xmlns='http://www.w3.org/1998/Math/MathML'> <mtr> <mtd> <menclose notation='box'> <mn>5000</mn> </menclose> </mtd> <mtd> <mo>⇐</mo> </mtd> <mtd> <munder> <mrow> <munder accentunder='false'> <mrow> <mn>3400</mn> <mo>+</mo> <mn>2100</mn> </mrow> <mo>⏟</mo> </munder> </mrow> <mrow> <mn>5500</mn> </mrow> </munder> </mtd> <mtd> <mo>⇒</mo> </mtd> <mtd> <menclose notation='box'> <mn>6000</mn> </menclose> </mtd> </mtr> </mtable> </math></span></span></div>

saraOrkide avatar Feb 29 '24 08:02 saraOrkide