我有一个基于 minimal-mistakes Jekyll 主题构建的个人博客。一些帖子使用由 MathJax 解析的 LaTex。我一直在使用 MathJax v2 并进行以下配置:
MathJax.Hub.Config({
showProcessingMessages: false,
messageStyle: "none",
tex2jax: {
inlineMath: [ ['$','$'], ["\\(","\\)"] ],
displayMath: [ ['$$','$$'], ["\\[","\\]"] ],
processEscapes: true
},
TeX: {
MultLineWidth: "100%",
equationNumbers: { autoNumber: "AMS" }
},
"HTML-CSS": { fonts: ["Latin-Modern"] }
});
MathJax.js?config=TeX-AMS-MML_HTMLorMML
这是一个方程及其输出。
$$
E[X] = \sum_{i=1}^{k-1}\sum_{j=i+1}^{k} X_{ij}Pr[\text{i and j have the same birthday}]
$$
$$ Pr[\text{i and j have unique birthdays}] = 365/365 * 364/365 $$ ($$ i $$ may have been born on any of the $$ 365 $$ days, and $$ j $$ on any of the remaining $$ 364 $$ days).
$$
\therefore Pr[\text{i and j have the same birthday}] = 1 - \frac{364}{365} = \frac{1}{365} \\
\begin{equation*}
\begin{aligned}
E[X] & = \frac{1}{365} * \sum_{i=1}^{k-1}\sum_{j=i+1}^{k} X_{ij} \\
& = \frac{1}{365} * \sum_{i=1}^{k-1} (k - i - 1 + 1) \\
& = \frac{1}{365} * \sum_{i=1}^{k-1} (k - i) \\
& = \frac{1}{365} * (\sum_{i=1}^{k-1} k - \mathop{\sum_{i=1}^{k-1}} i) \\
& = \frac{1}{365} * (k(k - 1) - (1 + 2 +...+ k - 1)) \\
& = \frac{1}{365} * (k(k - 1) - \frac{k(k - 1)}{2}) \\
& = \frac{k(k - 1)}{(365 * 2)}
\end{aligned}
\end{equation*}
$$
我将MaxJax升级到v3,并使用MathJax提供的转换工具获取v3配置。
v3 配置:
window.MathJax = {
tex: {
inlineMath: [ ['$','$'], ["\\(","\\)"] ],
displayMath: [ ['$$','$$'], ["\\[","\\]"] ],
processEscapes: true,
multlineWidth: "100%",
tags: "ams"
},
options: {
ignoreHtmlClass: 'tex2jax_ignore',
processHtmlClass: 'tex2jax_process'
}
};
如您所见,方程移至最右侧,并覆盖在其上方的文本之上。我该如何解决这个问题?
我实际上升级到了 v4.0.0-beta.7,以获得更好的验证,以及换行符支持。
对于上面的问题,我最终得到了以下结果。感谢 Davide P. Cervone 查看我在 MathJax GitHub 存储库上打开的ticket。
$$
\\ X = \begin{cases}
1 & \text{if the pair has the same birthday} \\
0 & \text{otherwise}
\end{cases} \\
\begin{aligned}
E[X] = \sum_{i=1}^{k-1}\sum_{j=i+1}^{k} X_{ij}Pr[\text{i and j have the same birthday}]
\end{aligned} \\
Pr[\text{i and j have unique birthdays}] = 365/365 * 364/365 $$ ($$ i $$ may have been born on any of the $$ 365 $$ days, and $$ j $$ on any of the remaining $$ 364 $$ days).
$$\\
\therefore Pr[\text{i and j have the same birthday}] = 1 - \frac{364}{365} = \frac{1}{365}
$$
$$
\begin{equation*}
\begin{aligned}
E[X] & = \frac{1}{365} * \sum_{i=1}^{k-1}\sum_{j=i+1}^{k} X_{ij} \\
& = \frac{1}{365} * \sum_{i=1}^{k-1} (k - i - 1 + 1) \\
& = \frac{1}{365} * \sum_{i=1}^{k-1} (k - i) \\
& = \frac{1}{365} * (\sum_{i=1}^{k-1} k - \mathop{\sum_{i=1}^{k-1}} i) \\
& = \frac{1}{365} * (k(k - 1) - (1 + 2 +...+ k - 1)) \\
& = \frac{1}{365} * (k(k - 1) - \frac{k(k - 1)}{2}) \\
& = \frac{k(k - 1)}{(365 * 2)}
\end{aligned}
\end{equation*}
$$
可以在我的博客的此页面上看到实时渲染。