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

positioning of subscript or superscript minus #1187

orangeplanet opened this issue May 8, 2015 · 6 comments


None yet
4 participants
Copy link

commented May 8, 2015

A subscript or superscript minus sometimes (but not always) wanders too far from the target. It seems to especially happen when the neighboring superscript/subscript slot is occupied at the same time. Adding curly braces to whatever is on text line seems to negate the effect, but I'm not sure why.


@pkra pkra added the Investigate label May 8, 2015


This comment has been minimized.

Copy link

commented May 8, 2015

The issue is a little complicated. TeX's spacing rules sometimes rely on the font metrics being set up in a particular way, and this turns out to be one of them. In the TeX fonts, the height and depth of the minus are set to be the same as that of a plus (even though the minus doesn't take up that amount of vertical space), and that has an impact in the case of a base with both super and subscript (where the spacing between the two is based on the height and depth of the subscript and superscript). MathJax's fonts don't have the extra space around the minus sign (the bounding boxes are tight for all the characters).

It is possible to adjust the bounding box information used by MathJax, but in this case, you have to be a bit careful, as the minus sign is used for several purposes (like extending arrows, and making horizontal lines for things like square roots, \overline, and \underline. So while changing the bounding box information for the minus would fix the super- and sub-script problem, it would cause other things to be spaced improperly.

It is easy to change the character used for the horizontal line to a different one (like U+00AF), so that is not really a problem. But changing the height and depth of the minus will affect the height and depth of stretched arrows, and that is harder to fix.

Here is a work-around you can use for now, if you don't mind the slight change in positioning of stretched arrows. Add the following to your page just before the script that loads MathJax.js itself.

MathJax = {
  AuthorInit: function() {
    MathJax.Hub.Register.LoadHook("[MathJax]/jax/output/HTML-CSS/fonts/TeX/fontdata.js",function () {
      var FONTDATA = MathJax.OutputJax["HTML-CSS"].FONTDATA;
      var MAIN = FONTDATA.FONTS.MathJax_Main;
      MAIN[0x2212][0] = MAIN[0x002B][0];
      MAIN[0x2212][1] = MAIN[0x002B][1];
      FONTDATA.DELIMITERS[0x2212] = {alias: 0x00AF, dir: "H"};
    MathJax.Hub.Register.LoadHook("[MathJax]/jax/output/HTML-CSS/fonts/STIX/fontdata.js",function () {
      var FONTDATA = MathJax.OutputJax["HTML-CSS"].FONTDATA;
      var STIX = FONTDATA.FONTS.STIXGeneral;
      STIX[0x2212][0] = STIX[0x002B][0];
      STIX[0x2212][1] = STIX[0x002B][1];

This adjusts the height and depth of the minus is the TeX font (local or web based) and local STIX font (the two that are used by MathJax by default). It also fixes the horizontal lines in the TeX font (this is not needed for STIX since it already uses a different one). If you plan to use one of the other web fonts, similar changes would need to be added for them as well.

@pkra pkra added this to the A future font release milestone May 11, 2015


This comment has been minimized.

Copy link

commented Sep 18, 2015

I am experiencing something similar:



is rendered perfectly with pdflatex, but with Mathjax the n superscript is too much on the right, exactly after the +.


This comment has been minimized.

Copy link

commented Sep 19, 2015

@andreacassioli, I am not sure i understand the problem you are seeing. These are what I see:


I don't see a significant difference between them. Perhaps you can link to a page that exhibits the problem.

@dpvc dpvc modified the milestones: A future font release, MathJax v2.x.x Apr 17, 2016

dpvc pushed a commit to dpvc/MathJax that referenced this issue Jun 17, 2016

Davide P. Cervone
Adjust height and depth of minus to match plus, and fix arrow rep to …
…remove the extra when it is used as an arrow extender. Fix up some spacing and use shorthands for some font names. Resolves issue mathjax#1187.

This comment has been minimized.

Copy link

commented Jun 17, 2016

The font-fixes branch of my fork of MathJax includes fixes for the minus-sign height/depth problem.


This comment has been minimized.

Copy link

commented Jul 8, 2016

==> Merged

@dpvc dpvc added Merged and removed Ready for Review labels Jul 8, 2016

@dpvc dpvc closed this Jul 8, 2016

dpvc pushed a commit to mathjax/MathJax-test that referenced this issue Aug 18, 2016


This comment has been minimized.

Copy link

commented Aug 18, 2016

==> In testsuite


@dpvc dpvc added Test Available and removed Test Needed labels Aug 18, 2016

@dpvc dpvc added v2.7 Fixed and removed Merged labels Jan 5, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.