首页 > 解决方案 > 为什么 \\ 在 mathjax 中不显示换行符?

问题描述

我的印象是你应该使用\\mathjax 换行,但是我无法让它工作。我在这里做错了什么?

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8" />
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
</head>
<body>
<p><span class="math display">\[
    1 x x^2 \\
    1 y y^2 \\
    1 z z^2 \\
\]</span></p>
</div>
</body>
</html>

我希望看到 3 行,但我明白了:

意外格式

其他 stackoverflow 帖子声称\\应该可以工作,例如:https ://math.meta.stackexchange.com/questions/11720/new-line-within-mathjax

标签: javascripthtmlmathjax

解决方案


正如上面评论中所指出的,这在 mathjax 3.0 中不起作用。

作为一种解决方法,我发现以下 markdown 可以使用 pandoc 正确转换为 HTML:

you can use this:

\begin{equation}
\displaylines{I = \int \rho R^{2} dV \\ Y = 1}
\end{equation}

or alternatively an align block, e.g:

$$
\begin{alignat}{2}
I & = \int \rho R^{2} dV & + P \\
Y & = 1 & + x
\end{alignat}
$$

和:pandoc --from=markdown --to=html5 --mathjax="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js" -s file.md -o file.html


推荐阅读