第二次渲染时 MathJax 错误

Фил*_*ков 0 mathjax

我使用 MathJax 动态渲染以下代码:

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}.$$  

In equation \eqref{eq:sample}, we find the value of an interesting integral:
\begin{equation}
  \int_0^\infty \frac{x^3}{e^x-1}\,dx = \frac{\pi^4}{15}
  \label{eq:sample}
\end{equation}
Run Code Online (Sandbox Code Playgroud)

使用 Hub.Queue

MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
Run Code Online (Sandbox Code Playgroud)

第一次渲染效果很好。但是,当我尝试使用相同的代码再次渲染时,仅渲染第一部分,但第二部分(从 \begin 开始)不会解析并显示在黑框中。为什么会发生这种情况?

Dav*_*one 5

问题是使用\label. 当数学重新排版时,标签已经存在(从第一次排版开始),因此 TeX 输入 jax 会将其报告为错误(禁用 noErrors 扩展以查看错误消息)。

在再次排版之前,您需要重置标签(大概还有方程式编号)。为此,请使用

MathJax.Hub.Queue(
  ["resetEquationNumbers",MathJax.InputJax.TeX],
  ["Typeset",MathJax.Hub]
);
Run Code Online (Sandbox Code Playgroud)

而不是MathJax.Hub.Queue(["Typeset",MathJax.Hub])打电话。