找回密码
 快速注册
搜索
查看: 127|回复: 0

[MathJax]浏览器的最小字号 与 MathML scriptminsize

[复制链接]

3147

主题

8381

回帖

6万

积分

$\style{scale:11;fill:#eff}꩜$

积分
65357
QQ

显示全部楼层

hbghlyj 发表于 2022-4-11 12:05 |阅读模式
测试代码(我使用的renderer是chtml):

14pt: \(2 * x_2\)

13pt: \(2 * x_2\)

12pt: \(2 * x_2\)

11pt: \(2 * x_2\)

10pt: \(2 * x_2\)

9pt: \(2 * x_2\)

8pt: \(2 * x_2\)

7pt: \(2 * x_2\)

6pt: \(2 * x_2\)

5pt: \(2 * x_2\)

4pt: \(2 * x_2\)

3pt: \(2 * x_2\)

2pt: \(2 * x_2\)

1pt: \(2 * x_2\)

最初,我的Chrome浏览器上显示是这样的:
40px-Text_document_with_red_question_mark.svg[1].png
抛开MathJax公式不谈,只看左边的文字,就会发现,当字号≤8px时,都显示为8px,无法再小了,这是因为浏览器设置了最小字号.
我在这篇文章中发现,这是Chrome的中文客户端UI的默认设置:
A minimum font-size of 12px is set for Chrome users with a special, foreign UI locale (language) - e.g. Chinese, Korean, Japanese, Thai etc. If however, the font-size for any content on your website is set to a value that is less than 12px, it will automatically be resized to 12px.
⋯⋯
Using Chrome's native developer tools I had discovered that the font-size was set at 12px even though I had specifically defined it as 11px in the stylesheet for that particular element. There were also no overriding styles that could set it at 12px. It was indeed a browser specific problem and upon research, I found out it was due to my client's use of the Chinese UI locale on Chrome.
于是我在Chrome设置中把最小字号调成0px
Screenshot 2022-04-11 063717.png
然后变成了这样:
Screenshot 2022-04-09 040038.png
这还是有点问题:角标2在字号小于9px的时候就不跟着前面一起缩小了.
我在GitHub找到了MathJax issue 2356: the superscript or subscript stop shrinking below a certain size, around 9pt.
原来是MathML的默认设置:
MathJax converts your TeX into MathML internally and displays that, so some of the display is controlled by MathML parameters. There is one of those called scriptminsize that controls the minimum size that a script can use (it does not affect the main font size, however). The default value in MathJax is 8px, so that is why our seeing the issue appear just before that value (where the scripts are starting to go below 8px).


于是使用MathJax设置:
  1. MathJax = {
  2. startup: {
  3. ready: function () {
  4. var math = MathJax._.core.MmlTree.MmlNodes.math.MmlMath;
  5. math.defaults.scriptminsize = '0px';
  6. MathJax.startup.defaultReady();
  7. }
  8. }
  9. };
复制代码
终于达到了预期的效果!
Screenshot 2022-04-11 065125.png

手机版|悠闲数学娱乐论坛(第3版)

GMT+8, 2025-3-4 19:45

Powered by Discuz!

× 快速回复 返回顶部 返回列表