我通过在footer.php
中添加以下代码来使MathJax与WordPress配合使用。它适用于简单的数学符号和方程。
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
tex2jax: {
inlineMath: [ ['$','$'], ["\\(","\\)"] ],
processEscapes: true
}
});
</script>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
但是它不能处理多行方程,例如: 它被渲染为如下所示的一行。 这是由于WordPress或Markdown编辑器默认将
\\
渲染为\
所致。一个可能的解决方案是将$$...$$
中所有的\\
替换为\\\\
。我希望可以直接使用
\\
作为换行符。在StackEdit上可以使用,但我不知道如何实现,可能需要对MathJax进行转义。
这是源代码(我使用Markdown编辑器)。
$$
\begin{bmatrix}
PR(p_1) \\
PR(p_2) \\
\vdots \\
PR(p_N)
\end{bmatrix} =
\begin{bmatrix}
{(1-d)/ N} \\
{(1-d) / N} \\
\vdots \\
{(1-d) / N}
\end{bmatrix}
+ d
\begin{bmatrix}
\ell(p_1,p_1) & \ell(p_1,p_2) & \cdots & \ell(p_1,p_N) \\
\ell(p_2,p_1) & \ddots & & \vdots \\
\vdots & & \ell(p_i,p_j) & \\
\ell(p_N,p_1) & \cdots & & \ell(p_N,p_N)
\end{bmatrix}
\cdot
\begin{bmatrix}
PR(p_1) \\
PR(p_2) \\
\vdots \\
PR(p_N)
\end{bmatrix}
$$