# positioning of subscript or superscript minus #1187

Closed
opened this issue May 8, 2015 · 6 comments

Projects
None yet
4 participants

### orangeplanet 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.

Member

### dpvc 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.  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.

### andreacassioli commented Sep 18, 2015

 Hi, I am experiencing something similar: \newcommand{\PSD}{\mathcal{S}_+} $\PSD^n$  is rendered perfectly with pdflatex, but with Mathjax the n superscript is too much on the right, exactly after the +.
Member

### dpvc 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.

Closed

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

 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.
 8f628e0 
Member

### dpvc commented Jun 17, 2016

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

Merged

Member

### dpvc commented Jul 8, 2016

 ==> Merged

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

 Add test for mathjax/MathJax#1187 
 6f432c6 
Member

### dpvc commented Aug 18, 2016

 ==> In testsuite MathMLToDisplay/issue1187.html