mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-05 11:18:39 +00:00
TeX and CSS treat line heights in fundamentally different ways. In TeX, every character is treated as a box of its precise height and depth; the line height (\baselineskip) applies after characters have been assembled into lines. In CSS, in contrast, every character creates a "line box" corresponding to the accompanying font. When characters of different fonts and sizes are placed into the same span, the resulting line box contains the line boxes of all children. This is unfortunate because, for example, we want `\frac{1}{2}` to behave in vertical spacing contexts like it is exactly as tall and deep as the visible fraction (which is the TeX behavior). Given CSS constraints, though, in most contexts the fraction has extra vertical space: the line boxes for the numerator and denominator create padding. For small boxes, this isn't so bad. To really see the problem put a tall rule in the denominator of a fraction, or check out the VerticalSpacing screenshotter test, which has way more space than it should. Solving this problem in CSS is difficult. There is no easy way to get rid of the extra line boxes. But there is *a* way, namely tables. A table-cell with vertical-align top, bottom, or middle is ignored for the purposes of line height calculation. So in this commit, makeVList puts its contents into a vertical-align:bottom table-cell (to clear unwanted line boxes), with an extra row used to represent depth. Many Chrome screenshotter tests change. This is because Chrome rounds table dimensions to integral numbers of pixels, while it uses sub-pixel positioning for non-table displayed tabs. That makes many vlists a fraction of a pixel wider than they used to be.
14 KiB
1024x768px
14 KiB
1024x768px
