mhchem / MathJax-mhchem

3rd-party extension to MathJax for typesetting chemical equations
Apache License 2.0
95 stars 13 forks source link

Raise \tripledash #7

Closed ronkok closed 5 years ago

ronkok commented 5 years ago

This PR makes a minor adjustment to the vertical alignment of \tripledash.

In the MathJax_Main-Regular font, the glyph for hyphen-minus, U+002D, is slightly lower than the math minus, U+2212. This PR raises \tripledash by 2.56mu instead of 2mu as formerly done. The 2mu distance would have been correct for the math minus, but\tripledash uses the hyphen-minus.

To check the numbers, one can use opentype.js to inspect the font file downloaded from https://github.com/mathjax/MathJax/blob/master/fonts/HTML-CSS/TeX/otf/MathJax_Main-Regular.otf.

mhchem commented 5 years ago

Wow! Can you explain how you derive the 2.56mu? It doesn't make any difference on my monitor. I guess this is to get glyph 14 (002D, hypen) to the same height as glyph 146 (2013, endash). While the latter starts at y=248, the former starts at y=179. But how do you convert the difference of 69 into mu?

ronkok commented 5 years ago

To clarify, we are raising not -, but \tiny\text{-}. And \tiny reduces the font size in half. And my calculation was working from the centerline of each dash, not the bottom. So our raise distance is:

Δ = math axis elevation - [(normal hyphen centerline elevation) ÷ 2] 
  = 0.25em - [(0.179em + 0.252em)/2) ÷ 2] 
  = 0.14225em 
  = 2.5605mu
ronkok commented 5 years ago

On my screen, this change gives us a benefit that varies. Sometimes 2mu looks okay. Sometimes 2mu is a little too low. I suppose that's the browser doing some rounding. The 2.56mu figure gives more consistently well placed bonds.

mhchem commented 5 years ago

I am not an expert in all of these measurements, so I trust you there. But, your change has no effect on my screen whatsoever, even in highest zoom levels. I am pretty sure to observe MathJax ignoring all the decimals, treating 2mu = 2.56mu = 2.9mu.

ronkok commented 5 years ago

You might try 0.14225em instead of 2.56mu. In KaTeX 1em = 18mu, but maybe MathJax rounds anything written in mu units to an integer.

mhchem commented 5 years ago

This doesn't make any difference. Even when using em, I am not able to get a value between 2mu and 3mu. There seems to be an internal rounding to mu.

ronkok commented 5 years ago

Okay, then I'll withdraw the pull request. However, we should keep the 2.56mu in the KaTeX version of mhchem. Without it, KaTeX produces a noticeable difference.