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

\ncong and \overrightarrow not typeset properly #2497

Closed
jano-m opened this issue Aug 13, 2020 · 5 comments
Closed

\ncong and \overrightarrow not typeset properly #2497

jano-m opened this issue Aug 13, 2020 · 5 comments
Labels
Accepted Issue has been reproduced by MathJax team Fixed Test Needed v3 v3.1
Milestone

Comments

@jano-m
Copy link

jano-m commented Aug 13, 2020

Issue Summary

Mathjax typesets \ncong and \overrightarrow{ab} differently from Latex.
\ncong: in Latex whole \cong is crossed out, while in Mathjax only = is crossed out (which has different meaning)
\overrightarrow{ab}: the arrow above is short, equivalent to \vec{ab}, Latex would make the arrow span from left to right boundary of the (imaginary) box containing ab
Note: if the argument of the command gets longer, it will start working properly

Mathjax:
image
Latex:
image

Technical details:

  • MathJax Version: 3.0.5
  • Client OS: Windows 10
  • Browser: Chrome 84.0.4147.125
@dpvc
Copy link
Member

dpvc commented Aug 14, 2020

Thanks for the report.

The first issue (with \ncong) is due to a bad mapping of the glyphs in the original MathJax TeX fonts: U+2247 was inadvertently placed at U+2246, and \ncong was set to U+2246 (see issue #1994). The font data for version 3 maps the glyph to U+2247 correctly, but we neglected to redefine \ncong to map to the correct location. I have made a pull request to fix the issue. In the meanwhile, you could add

<script>
MathJax = {
  startup: {
    ready() {
      if (MathJax.version === '3.0.5') {
        const MapHandler = MathJax._.input.tex.MapHandler.MapHandler;
        const Symbol = MathJax._.input.tex.Symbol.Symbol;
        MapHandler.getMap('AMSsymbols-mathchar0m0').add('ncong', new Symbol('nconfg', '\u2247'));
        MathJax.startup.defaultReady();
      }
    }
  }
};
</script>

before the script that loads the MathJax component you are using in order to fix the errant definition.


The second issue, with \overrightarrow is more significant. MathJax will remap some accent characters to other ones (mostly for MathML input where people use the wrong characters frequently). In particular, the right arrow U+2192 is remapped to the vector arrow U+20D7, so that <mover><mi>x</mi><mo>&#x2192;</mo></mover> will produce the output you would get from \vec x. When the accent is stretchy, U+20D7 is converted back to U+2192, but it turns out that MathJax was applying the remapping again and it ended up U+20D7 after all. I have submitted a pull request to fix that, but it is not so easy to patch it. The straight-forward solution is to remove the remapping of the U+2192 so that neither remapping occurs. That can be done with

<script>
MathJax = {
  startup: {
    ready() {
      if (MathJax.version === '3.0.5') {
        MathJax.startup.defaultReady();
        delete MathJax.startup.output.font.remapChars.accent[0x2192];
      }
    }
  }
};
</script>

Of course, you can combine these two into one configuration:

<script>
MathJax = {
  startup: {
    ready() {
      if (MathJax.version === '3.0.5') {
        const MapHandler = MathJax._.input.tex.MapHandler.MapHandler;
        const Symbol = MathJax._.input.tex.Symbol.Symbol;
        MapHandler.getMap('AMSsymbols-mathchar0m0').add('ncong', new Symbol('nconfg', '\u2247'));
        MathJax.startup.defaultReady();
        delete MathJax.startup.output.font.remapChars.accent[0x2192];
      }
    }
  }
};
</script>

@dpvc dpvc added Accepted Issue has been reproduced by MathJax team Ready for Review Test Needed v3 labels Aug 14, 2020
dpvc added a commit to mathjax/MathJax-src that referenced this issue Aug 17, 2020
@dpvc dpvc added Merged Merged into develop branch and removed Ready for Review labels Aug 17, 2020
dpvc added a commit to mathjax/MathJax-src that referenced this issue Aug 17, 2020
@jano-m
Copy link
Author

jano-m commented Aug 18, 2020

Thank you!

@jano-m
Copy link
Author

jano-m commented Aug 21, 2020

Actually, I have just noticed. The proposed fix will break command \vec.
For example, \vec{a}

  • in Mathjax (with the above code):
    image
  • in Latex:
    image

@dpvc
Copy link
Member

dpvc commented Aug 22, 2020

OK, here is an updated configuration that takes care of that as well.

<script>
MathJax = {
  startup: {
    ready() {
      if (MathJax.version === '3.0.5') {
        const MapHandler = MathJax._.input.tex.MapHandler.MapHandler;
        MapHandler.getMap('AMSsymbols-mathchar0m0').lookup('ncong')._char = '\u2247';
        MapHandler.getMap('macros').lookup('vec')._args = ['20D7'];
        MathJax.startup.defaultReady();
        delete MathJax.startup.output.font.remapChars.accent[0x2192];
      }
    }
  }
};
</script>

It is slightly simpler than the earlier one as well.

@dpvc dpvc added this to the 3.1.0 milestone Aug 25, 2020
@dpvc dpvc added Fixed v3.1 and removed Merged Merged into develop branch labels Aug 25, 2020
@dpvc
Copy link
Member

dpvc commented Aug 25, 2020

Fixed in v3.1 released today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Accepted Issue has been reproduced by MathJax team Fixed Test Needed v3 v3.1
Projects
None yet
Development

No branches or pull requests

2 participants