MathJax 未在 Sphinx 中呈现

cad*_*eus 4 mathjax python-sphinx

我在 Sphinx reST 中有一个文档集。我在 conf.py 中包含了 sphinx.ext.mathjax,并包含了“mathjax_path = ' http://cdn.mathjax.org/mathjax/latest/MathJax.js '”这一行。我相信这就是在向 rst 文件添加标记之前我需要做的所有事情。但是我的方程没有被渲染。例如,

:math:`a^2 + b^2 = c^2`
Run Code Online (Sandbox Code Playgroud)

从浏览器中出来

\(a^2 + b^2 = c^2\)
Run Code Online (Sandbox Code Playgroud)

没有花哨的字体或任何东西。HTML是

<span class="math">\(a^2 + b^2 = c^2\)</span>
Run Code Online (Sandbox Code Playgroud)

FvD*_*FvD 6

您仍然需要在 conf.py 文件中声明 sphinx-doc 的扩展名。

在 conf.py 文件的顶部,在import sys, os“常规配置”下不久,您将看到有关包含扩展的注释。对于 mathjax,您需要将其添加到列出的扩展中:

 # Add any Sphinx extension module names here, as strings. They can be extensions
 # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
 extensions = ['sphinx.ext.todo', 'sphinx.ext.mathjax', 'sphinx.ext.ifconfig']
Run Code Online (Sandbox Code Playgroud)

(我刚刚复制粘贴了我自己的扩展名,您目前可能有其他扩展名或没有列出扩展名)。

与您已经设置的 mathjax_path 结合使用应该可以工作。


Mar*_*elo 5

我有同样的问题。我通过将 mathjax_path 变量(在 conf.py 文件中)设置为:

mathjax_path="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"
Run Code Online (Sandbox Code Playgroud)

  • 未来注意事项:cdn.mathjax.org 即将结束,请查看 https://mathjax.org/cdn-shutting-down 以获取迁移提示。 (3认同)