MathJax icon indicating copy to clipboard operation
MathJax copied to clipboard

A problem in the representation of Apastarov in the formula

Open saraOrkide opened this issue 2 years ago • 3 comments

As you can see in the picture, the apostrophe above the small letters is much higher than the letter, if it is above the capital letters, it is completely correct. Screenshot from 2024-02-07 11-14-02

browser: chrome and firefox os: linux and windows mathjax version: 4

mml code:

                   <math display='inline' mathcolor='var(--midnight-blue)'>
                        <mfenced open='{' close='' separators='|'>
                            <mrow>
                                <mtable>
                                    <mtr>
                                        <mtd>
                                            <msub>
                                                <mrow>
                                                    <mtext>P</mtext>
                                                </mrow>
                                                <mrow>
                                                    <mtext>A</mtext>
                                                </mrow>
                                            </msub>
                                            <mo>=</mo>
                                            <msub>
                                                <mrow>
                                                    <mtext>ρ</mtext>
                                                </mrow>
                                                <mrow>
                                                    <mtext>gh</mtext>
                                                </mrow>
                                            </msub>
                                            <mtext> </mtext>
                                        </mtd>
                                        <mtd />
                                    </mtr>
                                    <mtr>
                                        <mtd>
                                            <msub>
                                                <mrow>
                                                    <mtext>P</mtext>
                                                </mrow>
                                                <mrow>
                                                    <mtext>B</mtext>
                                                </mrow>
                                            </msub>
                                            <mo>=</mo>
                                            <msub>
                                                <mrow>
                                                    <mtext>ρ</mtext>
                                                </mrow>
                                                <mrow>
                                                    <mtext>gh</mtext>
                                                </mrow>
                                            </msub>
                                            <mo>+</mo>
                                            <msub>
                                                <mrow>
                                                    <mtext>ρ</mtext>
                                                </mrow>
                                                <mrow>
                                                    <mtext>g</mtext>
                                                </mrow>
                                            </msub>
                                            <mfrac>
                                                <mrow>
                                                    <mtext>۵</mtext>
                                                </mrow>
                                                <mrow>
                                                    <mtext>۱۰۰</mtext>
                                                </mrow>
                                            </mfrac>
                                            <mo>+</mo>
                                            <msub>
                                                <mrow>
                                                    <mover accent='true'>
                                                        <mrow>
                                                            <mtext>ρ</mtext>
                                                        </mrow>
                                                        <mo>´</mo>
                                                    </mover>
                                                </mrow>
                                                <mrow>
                                                    <mtext>g</mtext>
                                                </mrow>
                                            </msub>
                                            <mfrac>
                                                <mrow>
                                                    <mtext>۵</mtext>
                                                </mrow>
                                                <mrow>
                                                    <mtext>۱۰۰</mtext>
                                                </mrow>
                                            </mfrac>
                                        </mtd>
                                        <mtd />
                                    </mtr>
                                </mtable>
                            </mrow>
                        </mfenced>
                        <mtext>Δ</mtext>
                        <msub>
                            <mrow>
                                <mtext>P</mtext>
                            </mrow>
                            <mrow>
                                <mtext>AB</mtext>
                            </mrow>
                        </msub>
                        <mo>=</mo>
                        <msub>
                            <mrow>
                                <mtext>ρ</mtext>
                            </mrow>
                            <mrow>
                                <mtext>g</mtext>
                            </mrow>
                        </msub>
                        <mfrac>
                            <mrow>
                                <mtext>۵</mtext>
                            </mrow>
                            <mrow>
                                <mtext>۱۰۰</mtext>
                            </mrow>
                        </mfrac>
                        <mo>+</mo>
                        <msub>
                            <mrow>
                                <mover accent='true'>
                                    <mrow>
                                        <mtext>ρ</mtext>
                                    </mrow>
                                    <mo>´</mo>
                                </mover>
                            </mrow>
                            <mrow>
                                <mtext>g</mtext>
                            </mrow>
                        </msub>
                        <mtext>Δ</mtext>
                        <msub>
                            <mrow>
                                <mover accent='true'>
                                    <mrow>
                                        <mtext>P</mtext>
                                    </mrow>
                                    <mo>´</mo>
                                </mover>
                            </mrow>
                            <mrow>
                                <mtext>AB</mtext>
                            </mrow>
                        </msub>
                        <mfrac>
                            <mrow>
                                <mtext>۵</mtext>
                            </mrow>
                            <mrow>
                                <mtext>۱۰۰</mtext>
                            </mrow>
                        </mfrac>
                    </math>

saraOrkide avatar Feb 07 '24 07:02 saraOrkide

The layout works fine for me:

accent

I note, however, that that the font being used in your equations are not the MathJax fonts. Are you using some CSS to affect that? If so, that may be the cause of the issue. There is not enough information here to tell.

dpvc avatar Feb 07 '24 13:02 dpvc

I set mtextInheritFont to true so that the Farsi text can be seen correctly in the formula, that's why this problem has arisen. If I set mtextInheritFont to false, Persian texts inside the formula will get mixed up like below Screenshot from 2024-02-07 23-42-24 It should be like this: Screenshot from 2024-02-07 23-47-16 So what should I do so that both the mathematical font of the formulas and the Persian text in the formula are correct? I use mml-chtml.js

saraOrkide avatar Feb 07 '24 20:02 saraOrkide

So what should I do so that both the mathematical font of the formulas and the Persian text in the formula are correct?

When you have mtextInheritFont as true, then any <mtext> will use the surrounding Persian font, and since MathJax doesn't know the metrics of that font, it assumes every character is assumed to be full height and depth (of the original MathJax font). That is why the accents are higher than the characters.

So the solution is to not use <mtext> for the non-Persian letters, and instead use <mi> (or <mi mathvariant="normal"> if you really need them to be upright) for those, as that is the proper encoding in any case. That is, you would use

<msub>
  <mrow>
    <mover accent='true'>
      <mrow>
        <mi>P</mi>          <!--  this line is changed ->
      </mrow>
      <mo>´</mo>
    </mover>
  </mrow>
  <mrow>
    <mi>AB</mi>          <!--  this line is changed ->
  </mrow>
 </msub>

or better yet

<msub>
  <mover accent='true'>
    <mi>P</mi>
    <mo>´</mo>
  </mover>
  <mrow>
    <mi>A</mi>  <!-- these should really be separate mi elements, unless "AB" is the variable name -->
    <mi>B</mi>
  </mrow>
 </msub>

to reduce redundancy, and to use separate <mi> for the two separate variables A and B. The <mtext> tag should lonely be used for words, not the variables in the formula.

Similarly, <mtext>۱۰۰</mtext> should be <mn>۱۰۰</mn> since this is a number, not text.

dpvc avatar Feb 07 '24 20:02 dpvc