mathjax / MathJax-node

MathJax for Node
Apache License 2.0
609 stars 96 forks source link

Correct mapping for prime symbol #486

Closed anthonymuau closed 1 year ago

anthonymuau commented 1 year ago

With mathJax library 2.7 prime symbol (2032) displays as a apostrophe and not a prime symbol when output is SVG. Would you be open to PR that when font STIX is selected we remap to current symbol.

MathJax.OutputJax.SVG.FONTDATA.VARIANT["-STIX-Web-variant"].remap[0xB0]= [0x25E6, "normal"];
dpvc commented 1 year ago

You don't provide the expression your are processing, but I suspect you are using MathML and have done something like

<math>
  <mi>f</mi>
  <mo>&#x2032;</mo>
</math>

or maybe

<math>
  <mi>f&#x2032;</mi>
</math>

and are using the default MathJax TeX font. For these constructions, MathJax would need to have a prime character that is small and raised to the superscript position, but the MathJax TeX fonts don't include such a character, and the apostrophe in the sans-serif font is the closest substitute. (The STIX font does include the needed character, so you could switch to that if you need to.)

Note, however, that the MathML specification suggests that the correct encoding for f' is

<math>
  <msup>
    <mi>f</mi>
    <mo>&#x2032;</mo>
  </msup>
</math>

or

<math>
  <msup>
    <mi>f</mi>
    <mo>'</mo>
  </msup>
</math>

and discourages the two previous encodings. MathJax is set up to render these properly in its default font set.

Note also that the code change you are suggesting will not fix this issue, as it seems to be addressing the degree symbol, not the prime symbol. As I mentioned, there is no appropriate symbol in the MathJax fonts to remap to, so you will not be able to produce a proper replacement for the prime symbol.

Finally, mathjax-node is no longer being updated, since MathJax v3 can be used in node directly, without the need of the hacks involved in mathjax-node.

anthonymuau commented 1 year ago

@dpvc Thank you for your help i found the issue was caused by encoding issue, do you know if MathJax 3 will get support to use STIX-Web as be nice to use it for node service and not use mathjax-node

dpvc commented 1 year ago

The next release will include a number of new fonts, STIX2 included. We hope for a beta release at the end of the month.