Forgot password?
 Create new account
View 190|Reply 6

[MathJax]\overline里面字符为\u2015

[Copy link]

3147

Threads

8493

Posts

610K

Credits

Credits
66163
QQ

Show all posts

hbghlyj Posted at 2022-5-8 08:02:32 |Read mode
\overline经过MathJax处理成MathML后mi里面的字符为\u2015(dash,"―"),和\bar处理成MathML后的字符\u00AF(upperscore,"¯")不同,而且MathML的accent属性会使mover里面的mo和上面的mi距离变小,而"―"本来就比"¯"更低,导致前者有时显示得和下方的被修饰字符距离过小甚至重叠.
打开tex-mml-chtml.js,将
  1.         overline: [
  2.           'UnderOver',
  3.           '2015'
  4.         ],
  5.         underline: [
  6.           'UnderOver',
  7.           '2015'
  8.         ],
Copy the Code
改为
  1.         overline: [
  2.           'UnderOver',
  3.           '00AF'
  4.         ],
  5.         underline: [
  6.           'UnderOver',
  7.           '2015'
  8.         ],
Copy the Code
即可

3147

Threads

8493

Posts

610K

Credits

Credits
66163
QQ

Show all posts

 Author| hbghlyj Posted at 2022-5-8 08:03:10

3147

Threads

8493

Posts

610K

Credits

Credits
66163
QQ

Show all posts

 Author| hbghlyj Posted at 2022-5-8 21:52:44
developer.mozilla.org/en-US/docs/Web/MathML/Element/mover
accent
If true the over-script is an accent, which is drawn closer to the base expression.
If false (default value) the over-script is a limit over the base expression.
$\overline{A_i}$在mathpix中转换为:
<math xmlns="http://www.w3.org/1998/Math/MathML">
  <mover>
    <msub>
      <mi>A</mi>
      <mi>i</mi>
    </msub>
    <mo accent="false">¯</mo>
  </mover>
</math>
mo带有accent="false"标签并且mo里面的字符是¯(overscore)
在MathJax v3被转换为
<math xmlns="http://www.w3.org/1998/Math/MathML">
  <mover>
    <msub>
      <mi>A</mi>
      <mi>i</mi>
    </msub>
    <mo accent="true">―</mo>
  </mover>
</math>
mo带有accent="true"标签,并且mo里的字符是―(dash).
前者是正常的,后者的$i$或$j$上面没有点!
如图所示:

$\bar i\;\overline i\;\bar j\;\overline j$
在MathJax中转换为

在MS word中转换为

在MathJax中,暂时的解决办法:
  1. document.querySelectorAll('mover:not([accent])').forEach(e=>e.setAttribute('accent','false'))
Copy the Code
w3.org/TR/REC-MathML/chap3_4.html#sec3.4.5中关于accent属性:
The default value of accent is false, unless overscript is an <mo> element or an embellished operator (see Section 3.2.4). If overscript is an <mo> element, the value of its accent attribute is used as the default value of accent for <mover>. If overscript is an embellished operator, the accent attribute of the <mo> element at its core is used as the default value.

3147

Threads

8493

Posts

610K

Credits

Credits
66163
QQ

Show all posts

 Author| hbghlyj Posted at 2022-5-8 22:45:14
今年2月的一个issue
github.com/mathjax/MathJax/issues/2827

3147

Threads

8493

Posts

610K

Credits

Credits
66163
QQ

Show all posts

 Author| hbghlyj Posted at 2022-5-8 23:07:51
Discuz编辑器HTML模式,插入HTML代码时,尖括号和引号转义(escape):
  1. insertText(getSel().replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "'"))
Copy the Code

3147

Threads

8493

Posts

610K

Credits

Credits
66163
QQ

Show all posts

 Author| hbghlyj Posted at 2022-5-8 23:26:50


加上accent="false"就有点儿了
但是这个accent是mover的属性.不该继承到msub里面的j啊.这个属性就不该默认继承.

3147

Threads

8493

Posts

610K

Credits

Credits
66163
QQ

Show all posts

 Author| hbghlyj Posted at 2022-7-17 04:09:24

手机版Mobile version|Leisure Math Forum

2025-4-20 22:14 GMT+8

Powered by Discuz!

× Quick Reply To Top Return to the list