GithubHelp home page GithubHelp logo

Comments (4)

pkra avatar pkra commented on May 3, 2024

Are you after msup+msub, msub+msup, or msubsup constructions?

from asciimathml.

drlippman avatar drlippman commented on May 3, 2024

For clarification, those expressions render fairly differently in stock AsciiMathML vs MathJax's two renderings, at least on my computer. Which rendering are you looking at?

primerendering

FWIW, z'_0 runs into a symantic problem that ASCIIMathML treats ' (prime) as standard token, so it's going to parse that as 0 as a subscript on only the prime, not on the whole z'. The semantically correct approach for what you're wanting is {:z':}_0, as that treats 0 as a subscript on the whole z' expression. But it displays fairly similar to your z'_0, so no big benefit.

from asciimathml.

dpvc avatar dpvc commented on May 3, 2024

@drlippman, the differences in your images is due mostly to the font in use. The prime (U+2032) is one of the "pseudo-scripts" described in section 7.2.2 of the MathML specification. These are problematic because in some fonts, the character is already reduced in size and placed in a superscript position, and in others it is normal sized and not in the superscript position (and so needs to be handled like other superscripts). The difference between your first two (stock AsciiMathML and MathJax NativeMML) is that the font used in the first case has the pre-rdeuced and script-positioned U+2032 while the second does not. I suspect the first is the STIX font, while the second is the MathJax TeX fonts. In recent versions of Firefox, the font selection prefers the MathJax_Main font to STIXGeneral, so depending on how you created the image, it might be that MathJax had already loaded MathJax_Main, and so it was available to the native MathML in that case, but not in the original. The actual MathML in the page is identical. I will discuss the third case momentarily.

The MathML generated for the three forms are:

z_0'

  <msub>
    <mi>z</mi>
    <mn>0</mn>
  </msub>
  <mo>&#x2032;</mo>

z'_0

  <mi>z</mi>
  <msub>
    <mo>&#x2032;</mo>
    <mn>0</mn>
  </msub>

and

z_0^'

  <mrow>
    <msubsup>
      <mi>z</mi>
      <mn>0</mn>
      <mo>&#x2032;</mo>
    </msubsup>
  </mrow>

As you can see, the first treats it as {z_0}', the second as z{'_0}, and the third as z_0^' in TeX. I don't know what the OP's original intent was, but as you say, the second is better semantically as {:z':}_0.

The MathML specification link above talks about the preferred rendering for these constructs. The suggestion is that "x prime" should be

<msup><mi>x</mi><mo>&#x2032;</mo></msup>

that is, it should be rendered with an explicit <msup>, not as

<mi>x</mi><mo>&#x2032;</mo>

by itself. So neither of the first two are rendered as the spec suggests, and that is part of why there are differences in the renderings in your image.

Because the spec suggests that the prime character should be part of an <msup> or <msubsup>, the MathJax font has a normal sized and un-raised prime at U+2032, because the <msup> will reduce its size and raise it as it would any other character. But this means that when it is used (incorrectly) as <mi>z</mi><mo>&#x2032;</mo>, it is too large. So when <mo>&#x2032;</mo> appears outside of a superscript, MathJax's HTML-CSS output replaces the U+2032 with a version from another font that is reduced in size and raised. (This was a featured added somewhere in v2.x for some x, and the proper character is not really available in the MathJax web fonts, but this is as close as I could come without modifying the fonts. The STIX fonts includes both styles for this character, and so HTML-CSS output with the STIX fonts will do a better job in this case.) This accounts for the difference between the HTML-CSS and NativeMML output of MathJax.

So my personal preference would be to use z_0^' as it is the only one that is translated into MathML properly, and it is rendered properly by MathJax in all its output formats. The fact that the stock AsciiMathML output has the prime too small and too high is due to the font in use, and is (in my opinion) a bug in FireFox's native MathML rendering.

from asciimathml.

drlippman avatar drlippman commented on May 3, 2024

Interesting. Thanks for all the detail @dpvc. Since ASCIIMathML uses a strictly forward-parsing approach, I don't think there's any non-hacky way to get it to convert x' as <msup><mi>x</mi><mo>&#x2032;</mo></msup>. I guess z_0^' is the most appropriate option, then.

Good to know that MathJax automatically adjusts the <mi>x</mi><mo>&#x2032;</mo> rendering.

from asciimathml.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.