首页 > 解决方案 > MathML 标签:“stretchy”属性问题

问题描述

我想知道,在下面的示例中,为什么标签的弹性属性mo给出了类似的显示。我认为MathML下面的第二个(with<mo stretchy="false">∑&lt;/mo>将在求和符号的顶部和底部显示上限和下限(如下图 2 所示)。但两个示例(分别为<mo stretchy="true">∑&lt;/mo><mo stretchy="false">∑&lt;/mo>)都显示求和符号两侧的限制:

备注:我正在使用MathJax

带有 MathML 的 HTML

<!DOCTYPE html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <title>MathJax TeX to MathML Page</title>
    <script type="text/javascript" async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-MML-AM_CHTML">
    </script>
</head>
<body>
    <p>With stretchy="true"</p>
    <math xmlns="http://www.w3.org/1998/Math/MathML"><mrow><msubsup><mo stretchy="true">∑&lt;/mo><mrow><mi>k</mi><mo>=</mo><mn>0</mn></mrow><mrow><mi>n</mi></mrow></msubsup><mrow><mfenced separators="|"><mrow><mfrac linethickness="0pt"><mrow><mi>n</mi></mrow><mrow><mi>k</mi></mrow></mfrac></mrow></mfenced><msup><mrow><mi>x</mi></mrow><mrow><mi>k</mi></mrow></msup><msup><mrow><mi>a</mi></mrow><mrow><mi>n</mi><mo>-</mo><mi>k</mi></mrow></msup></mrow></mrow></math>
    <p>With stretchy="false"</p>
    <math xmlns="http://www.w3.org/1998/Math/MathML"><mrow><munderover><mo stretchy="false">∑&lt;/mo><mrow><mi>k</mi><mo>=</mo><mn>0</mn></mrow><mrow><mi>n</mi></mrow></munderover><mrow><msup><mrow><mi>r</mi></mrow><mrow><mi>k</mi></mrow></msup></mrow></mrow></math>
</body>
</html>

显示上述 HTML [使用 MathJax]:

在此处输入图像描述

第二个 MathML 的所需显示(带有<mo stretchy="false">∑&lt;/mo>):

在此处输入图像描述

标签: mathjaxmathml

解决方案


您使用了错误的属性。这不是strethy="false"您想要的,而是movablelimits="false"(或使用<math display="block"><mstyle displaystyle="true">围绕表达式)。

例如:

<script src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/mml-chtml.js"></script>

<p>
<b>movablelimits="false"</b>
<br>

<math xmlns="http://www.w3.org/1998/Math/MathML">
  <munderover>
    <mo movablelimits="false">∑&lt;/mo>
    <mrow>
      <mi>k</mi>
      <mo>=</mo>
      <mn>0</mn>
    </mrow>
    <mi>n</mi>
  </munderover>
  <msup>
    <mi>r</mi>
    <mi>k</mi>
  </msup>
</math>

</p><p>

<b>display="block"</b>
<br>

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
  <munderover>
    <mo>∑&lt;/mo>
    <mrow>
      <mi>k</mi>
      <mo>=</mo>
      <mn>0</mn>
    </mrow>
    <mi>n</mi>
  </munderover>
  <msup>
    <mi>r</mi>
    <mi>k</mi>
  </msup>
</math>

</p><p>

<b>mstyle displaystyle="true"</b>
<br>

<math xmlns="http://www.w3.org/1998/Math/MathML">
  <mstyle displaystyle="true">
  <munderover>
    <mo>∑&lt;/mo>
    <mrow>
      <mi>k</mi>
      <mo>=</mo>
      <mn>0</mn>
    </mrow>
    <mi>n</mi>
  </munderover>
  <msup>
    <mi>r</mi>
    <mi>k</mi>
  </msup>
  </mstyle>
</math>

</p>

但是请注意,这些会产生不同的输出。第一个使用较小的求和符号(因为它是内联数学样式),第二个使用单独的行,以数学为中心,第三个是内联,但使用显示模式布局规则。


推荐阅读