Improve rule coding, including for \sqrt.#776
Conversation
|
Example difference, using Note that the rules are less unruly. |
|
@kohler I'll review this evening. The screenshots look good. |
I was overly optimistic. I'll try to get to it this weekend. |
|
The \sqrt rule looks a lot better. I've found the smaller font sizes to be more troublesome. Here are some renderings using 12px sized font. I tried out some other font sizes. 18px was the worst. My guess is that the |
* Rule widths (overline, underline, fraction, sqrt) actually scale with the current font size in AMS-TeX. Implement that. (Sqrt is a special case: the rule width depends on the font size *of the surd*.) * Change the CSS coding for rules. The old, complex coding prevented variable-width lines and may have contributed to issues like KaTeX#696. Its purpose, according to 0a3a227, was IE8 support; but KaTeX no longer supports IE8.
Smaller sizes seem more important.
|
Hi @kevinbarabash, I rebased on top of the current master & pushed. I cannot replicate a missing \sqrt rule on Chrome, with either 11px or 18px, at any mag. Here's the diff I made to main.css. Version 59.0.3071.115 (Official Build) (64-bit) on Mac. Can you help me replicate? There's no clipping in the CSS coding, so your proposed explanation doesn't make sense to me. |
|
I'm running a dev version of Chrome. It said it was ready to upgrade so I upgraded and the problem went away. This also resulted in better positioning at 12px. The sort-line is no longer floating a little bit above the square root symbol. |
k4b7
left a comment
There was a problem hiding this comment.
Looks good, just a few questions in the comments. I'm surprised that the position of the some of the subscripts changed in the screenshots. Any idea of why that happened?
| options); | ||
| const delimChar = delimiter.customSizedDelim("\\surd", minDelimiterHeight, | ||
| false, options, group.mode); | ||
| const delim = makeSpan(["sqrt-sign"], [delimChar], options); |
| const ruleWidth = line.height; | ||
| // Calculate the minimum size for the \surd delimiter | ||
| const metrics = options.fontMetrics(); | ||
| const theta = metrics.defaultRuleThickness; |
There was a problem hiding this comment.
Is theta the official name for this metric in the TeXBook?
src/buildHTML.js
Outdated
| let ruleWidth; | ||
| if (group.value.hasBarLine) { | ||
| rule = makeLineSpan("frac-line", options); | ||
| ruleWidth = ruleSpacing = rule.height; |
There was a problem hiding this comment.
Can you change this to:
ruleWidth = rule.height;
ruleSpacing = ruleWidth;
I misread this and thought that ruleSpacing wasn't being defined in this block.
| const makeLineSpan = function(className, options) { | ||
| const baseOptions = options.havingBaseStyle(); | ||
| const line = makeSpan( | ||
| [className].concat(baseOptions.sizingClasses(options)), |
There was a problem hiding this comment.
Are the sizing classes not necessary b/c we're manually figuring setting the borderBottomWidth?
There was a problem hiding this comment.
Yes. The sizing classes were necessary because previously we wanted all rules to have the same thickness, and that thickness was specified in katex.less in base-sized em units. Now that we're specifying the thickness in local em units, no sizing classes.
|
When a nucleus has both sub & sub, the The previous KaTeX implementation differed. It used 0.04em as the thickness for purposes of separating sup+sub, but it should have used 0.04em base-size units for consistency with the TeXbook (since previously all rules were 0.04em base-size units thick). Instead it used 0.04em script-size units (in scriptscript mode). |
|
@kohler thanks for the PR. The updated horizontal rules look great. |








with the current font size in AMS-TeX. Implement that. (Sqrt is
a special case: the rule width depends on the font size of the
surd.)
variable-width lines and may have contributed to issues like poor spacing in fraction inside square root (depends on rendering environment) #696.
Its purpose, according to 0a3a227,
was IE8 support; but KaTeX no longer supports IE8.