MathJax 方程包含多个带索引的求和

MathJax equation containing multiple summations with index

背景:

以下是我在页面中包含 MathJax 库的方式:

<script src='https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.4/MathJax.js?config=TeX-MML-AM_CHTML' async></script>

问题:

MathJax 字符串(我相信)将显示我想要的内容:

$$\sum_{s=1}^{1000} p_s  \sum_{c=1}^{4} x_c$$


我可以开始工作(正确显示)的最接近的 MathJax 字符串:

$$\sum_{s=1}^{1000} p_s  \sum_c^{4} x_c$$

作为调试的一部分,我已将第二个求和简化为 'x_c',但它仍然不起作用。这使我相信问题是由第二个求和索引定义引起的。当我尝试将 'c=1' 位添加到第二个求和符号时,似乎 MathJax 将不再呈现方程式。这种行为看起来很奇怪,因为第一个求和可以具有定义的索引(例如,'i=1')。在这一点上任何想法表示赞赏。

正如@Peter_Krautzberger 所指出的,Markdown 解析器似乎已将一些文本转换为斜体。这可能是导致问题的原因。

下面的代码片段是为了验证问题不是出在 MathJax 上。

<script async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML-full&latest"></script>

$$\sum_{s=1}^{1000} p_s  \sum_{c=1}^{4} x_c$$

根据 https://divadnojnarg.github.io/blog/mathjax/ MathJax \sum_ 在 markdown 中不能正常工作,你必须使用 \sum\_.

Latex rendering errors There are some differences with classical Latex expressions and the syntax to use in a markdown document. For example, \sum_ does not render with Hugo and you should use \sum_ instead (notice the second backslash before the underscore).

尝试转义下划线。

或者:

$$\sum\_{s=1}^{1000} p\_s \sum\_{c=1}^{4} x\_c$$

$$\sum\_{s=1}^{1000} p_s \sum\_{c=1}^{4} x_c$$

可能会成功。

文章中还提到了一些可能需要的额外配置:

<script type="text/javascript" async
  src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
  MathJax.Hub.Config({
  tex2jax: {
    inlineMath: [['$','$'], ['\(','\)']],
    displayMath: [['$$','$$']],
    processEscapes: true,
    processEnvironments: true,
    skipTags: ['script', 'noscript', 'style', 'textarea', 'pre'],
    TeX: { equationNumbers: { autoNumber: "AMS" },
         extensions: ["AMSmath.js", "AMSsymbols.js"] }
  }
  });
  MathJax.Hub.Queue(function() {
    // https://github.com/mojombo/jekyll/issues/199
    var all = MathJax.Hub.getAllJax(), i;
    for(i = 0; i < all.length; i += 1) {
        all[i].SourceElement().parentNode.className += ' has-jax';
    }
  });

  MathJax.Hub.Config({
  // Autonumbering by mathjax
  TeX: { equationNumbers: { autoNumber: "AMS" } }
  });
</script>