默认情况下,MathJax不使用 $ 作为分隔符。所以你必须手动配置它们。
$
以下使用MathJax的示例来自它 文件 。
<!DOCTYPE html> <html> <head> <title>MathJax TeX Test Page</title> <script type="text/x-mathjax-config"> MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}}); </script> <script type="text/javascript" async src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_CHTML"> </script> </head> <body> When $a \ne 0$, there are two solutions to \(ax^2 + bx + c = 0\) and they are $$x = {-b \pm \sqrt{b^2-4ac} \over 2a}.$$ </body> </html>
如果您想使用KaTeX,您需要包含脚本以自动渲染并使其使用 $ 作为分隔符。看到 https://github.com/Khan/KaTeX/blob/master/contrib/auto-render/README.md 作为指示。 这里 就是一个例子。