Closed hbghlyj closed 8 months ago
If the depth of | is set to 0 using \smash
, the surd will have same size as in \sqrt{a}
:
The various browsers all have (slightly different) problems with radical sizes. The variations are more than I can correct for. So I will take no action on this issue.
If you are interested in more background, keep reading.
TeX sets exponents and subscripts differently when the (exponent|subscript) is under a radical or in a stacked fraction. They are then "cramped", i.e., squeezed together vertically a little more tightly. It turns out that this affects radicals.
Radicals in math fonts come in various sizes. Typically, there is a standard size, for $\sqrt{x}$, then three (fixed) heights in ascending order, and finally a Size4 radical that can be made any height at run time. The creators of math fonts have made the four fixed sizes in heights that fit the heights of some common math expressions, like $\sqrt{f_c'}$ or $\sqrt{\frac{M_i} b}$.
Microsoft Word also cramps exponents and subscripts. In fact, it cramps them more than TeX does. Computer Modern and its clone Latin Modern have radical sizes set to fit TeX and Cambria Math has radical sizes set to fit Word. So the Cambria Math radical sizes are smaller.
Firefox apparently does not cramp exponents or subscripts at all. I don't know exactly how it picks a radical size, but it appears to be doing so with an algorithm slightly different than TeX. I suspect this is an attempt to deal with the lack of cramping, but that is just a guess.
Chromium does cramp exponents and subscripts. It should be able to pick a different cramp dimension for Latin Modern and Cambria Math. That information is supposed to be available in each math font's MATH table. But I get oddly sized radicals from Chromium when using Cambria Math. It's better with Latin Modern, but still not perfect.
I'm not even sure what Safari does.
Taken together, there is too much variation in browsers and in fonts. I can't correct for all of them, and I'm not going to try.
In my own work, I sometimes make use of \smash
, just as you do. I can't think of a better alternative.
Summary: Temml user on Firefox can make use of \smash
to get smaller surd
or use \textstyle\sqrt{|a|}
Temml user on Firefox can define a textstyle sqrt \tsqrt
, like \tfrac
is textstyle frac
\sqrt{|a|}
\def\tsqrt{\textstyle\sqrt}
\tsqrt{|a|}
and
Tests in LaTeX:
$\sqrt{x^1_1}$
$\sqrt{)}$
$\sqrt{|}$
$\sqrt{/}$
display mode off: the four expressions are of the same height display mode on: the first expression is taller
The radical size jumped between 13.8pt and 13.9pt
\sqrt{\rule1pt13.8pt}\sqrt{\rule1pt13.9pt}
In Firefox the radical size is set at nsMathMLmrootFrame.cpp
// height(radical) should be >= height(base) + psi + ruleThickness
nsBoundingMetrics radicalSize;
mSqrChar.Stretch(this, drawTarget, fontSizeInflation,
NS_STRETCH_DIRECTION_VERTICAL, contSize, radicalSize,
NS_STRETCH_LARGER,
StyleVisibility()->mDirection == StyleDirection::Rtl);
// radicalSize have changed at this point, and should match with
// the bounding metrics of the char
mSqrChar.GetBoundingMetrics(bmSqr);
and nsMathMLChar.cpp
// Larger: Critical to the sqrt code to ensure that the radical
// size is tall enough
bool isLarger = (aHint & (NS_STRETCH_LARGER | NS_STRETCH_LARGEOP)) && a >= b;
Firefox apparently does not cramp exponents or subscripts at all.
I tested rendering in Firefox v123
\sqrt{x^0} x^0
the position of exponent ^0
in \sqrt{x^0}
is lower than in x^0
. Maybe Firefox does cramp exponents?
the position of exponent ^0
in \sqrt{x^0}
is lower than in x^0
. Maybe Firefox does cramp exponents?
I found the following code in nsMathMLmrootFrame.cpp
nsMathMLmrootFrame::TransmitAutomaticData() {
// 1. The REC says:
// The <mroot> element increments scriptlevel by 2, and sets displaystyle
// to "false", within index, but leaves both attributes unchanged within
// base.
// 2. The TeXbook (Ch 17. p.141) says \sqrt is compressed
UpdatePresentationDataFromChildAt(1, 1, NS_MATHML_COMPRESSED,
NS_MATHML_COMPRESSED);
UpdatePresentationDataFromChildAt(0, 0, NS_MATHML_COMPRESSED,
NS_MATHML_COMPRESSED);
PropagateFrameFlagFor(mFrames.LastChild(), NS_FRAME_MATHML_SCRIPT_DESCENDANT);
return NS_OK;
}
Input:
\sqrt{|a|}
I notice that the surd is too tall in display mode.
Also for
/
:Input:
\sqrt{1/2}
Browser: Firefox 123.0