placement of \surd below baseline
Issue Summary
The TeX command \surd is rendered below the baseline
Code example
<script type="text/javascript"
src="https://cdn.jsdelivr.net/npm/mathjax@4/tex-mml-chtml.js?config=TeX-AMS-MML_HTMLorMML">
</script>
<div id="content">
<p>surd \( \surd \) is rendered below the text baseline vs \( \sqrt x \) and the MathML code <math xmlns="http://www.w3.org/1998/Math/MathML">
<mo stretchy="false">√<!-- √ --></mo>
</math> </p>
</div>
Steps to Reproduce:
- Visit https://codepen.io/physikerwelt/pen/KwzMePx
Technical details:
- MathJax Version: 4.0.0
- Client OS: MacOS
- Browser: Firefox
Supporting information:
- Upstream issue https://phabricator.wikimedia.org/T409110 (with screenshots)
- Possible root cause in unicode-math https://tex.stackexchange.com/questions/694490/placement-of-surd-with-unicode-math-is-incorrect
- Might be related to https://github.com/mathjax/MathJax/issues/3092
- Mitigation
window.MathJax = {
output: {
font: 'mathjax-tex'
},
However, this makes \big and \Big appear in the same size, so it's not a usable workaround.
It turns out that U+221A (the character used for this) is below the baseline in the mathjax-newcm and mathjax-modern fonts, which is why that is happening. Historically, TeX uses surds that are largely below the baseline, and uses the height of the surd above the baseline to determine the size of the overline for the radicand. I'm not sure if that's still the case or not, but that's probably why these character are placed that way. None of the other fonts have this placement, however, so they probably don't use U+221A as part of the stretchy character data for that code point.
In any case, you could either use one of the other fonts, or perhaps could redefine \surd to be \mmlToken{mo}[stretchy=false,symmetric=true]{\U221A} so that it will be placed symmetrically around the math axis, regardless of its original position. E.g.
MathJax = {
tex: {
macros: {
surd: '\\mmlToken{mo}[stretchy=false, symmetric=true]{\\U221A}',
}
}
}
@dpvc, that works well. Perhaps you want to consider making this the default in future releases.
I'm already planning a PR to take care of it.