Search code examples
mathjaxmathml

MathML tag: "stretchy" attribute issue


I was wondering, in the following example why the stretchy attribute of mo tag is giving similar display. I thought the second MathML below (with <mo stretchy="false">∑</mo> would display the upper and lower limits on top and bottom of the summation symbol (as shown in figure 2 below). But both the examples (with <mo stretchy="true">∑</mo> and <mo stretchy="false">∑</mo> respectively) are displaying the limits on sides of summation symbol instead:

Remark: I'm using MathJax

HTML with MathML

<!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">∑</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">∑</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>

Display of the above HTML [using MathJax]:

enter image description here

Desired display of second MathML (with <mo stretchy="false">∑</mo>):

enter image description here


Solution

  • You have used the wrong attribute. It is not strethy="false" that you want, but movablelimits="false" (or use <math display="block"> or <mstyle displaystyle="true"> around the expression).

    For example:

    <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">∑</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>∑</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>∑</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>

    Note, however, that these generate different output. The first uses a smaller summation sign (since it is in-line math style), the second uses a separate line with the math centered on it, and the third is in-line, but uses the display-mode layout rules.