mathjax / MathJax

Beautiful and accessible math in all browsers
http://www.mathjax.org/
Apache License 2.0
10.02k stars 1.16k forks source link

href rendering error with underscore #192

Closed ghost closed 12 years ago

ghost commented 12 years ago

the example is http://library.geo.jp/geodesy/7_00.html ¥href{7_49.html}{7.49} is rendered as "7_4 9.html", unnecessary space is inserted.

dpvc commented 12 years ago

MathJax's TeX to MathML conversion tries to treat numbers as a single unit, so that x + 123 becomes

<mi>x</mi>
<mo>+</mo>
<mn>123</mn>

rather than something like


<mi>x</mi>
<mo>+</mo>
<mn>1</mn>
<mn>2</mn>
<mn>3</mn>

which is how TeX really thinks of it. This works fine except when the number follows a ^ or _, where this would mean x^123 would be the same as x^{123}, but in true TeX should work like x^{1}23. So MathJax prefilters the math to add a space after ^ or _ when they are followed by a digit. That has had the undesired consequence of adding a space in the middle of your URL.

I have changed this in v2.0, but that doesn't help you until that is released. A solution for now would be to include

<script type="text/x-mathjax-config">
MathJax.Hub.Config({
  TeX: { Augument: {
    prefilterMath: function (math,displaystyle,script) {
      if (HUB.Browser.isKonqueror)
        {math = math.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&")}
      return math;
    }
  }}
});
</script>

in your pages before the script that loads MathJax.js. That will remove the code that adds the space, but then you will need to be sure to use braces for your superscripts and subscripts if you want the effect of x^{1}23.

Davide

fred-wang commented 12 years ago

Thanks for the test case. I added it to our test suite.

LaTeXToMathML/non-standard/href-2.html

==> In testsuite

ghost commented 12 years ago

Thank you very much, the update solved the problem.

dpvc commented 12 years ago

OK, thanks for the confirmation.