Set Latex on Hugo 紀錄
$$ \begin{align} \int^{1}_{0}\int^{\sqrt{1-y^2}}_{0}\int^{\sqrt{x^2+y^2}}_{x^2+y^2} xyz dz dx dy &= \int^{\frac{\pi}{2}}_{0}\int^{1}_{0}\int^{r}_{r^2} r^2z \sin{\theta}\cos{\theta} dz \cdot rdr d\theta \newline &= \frac{1}{2}\int^{1}_{0} r^5-r^7 dr \cdot \int^{\frac{\pi}{2}}_{0}\sin{\theta}\cos{\theta} d\theta \newline &= \frac{1}{2} \left[ \frac{1}{6}r^6 - \frac{1}{8}r^8 \right]^{1}_{0} \cdot \int^{0}_{\frac{\pi}{2}}\cos{\theta} d\cos{\theta} \newline &= \frac{1}{4}\cdot \left[ \frac{1}{6} - \frac{1}{8} \right] \newline &= \frac{1}{96} \end{align} $$
Step 1:
新增**/layouts/partials/MathJax.js**
<script type="text/javascript"
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-MML-AM_CHTML" async>
MathJax.Hub.Config({
tex2jax: {
inlineMath: [['$', '$'], ['\\(', '\\)']],
displayMath: [['$$', '$$'], ['\[', '\]']],
processEscapes: true,
processEnvironments: true,
skipTags: ['script', 'noscript', 'style', 'textarea', 'pre'],
TeX: {
equationNumbers: { autoNumber: "AMS" },
extensions: ["AMSmath.js", "AMSsymbols.js"]
}
}
});
MathJax.Hub.Queue(function () {
// Fix <code> tags after MathJax finishes running. This is a
// hack to overcome a shortcoming of Markdown. Discussion at
// https://github.com/mojombo/jekyll/issues/199
var all = MathJax.Hub.getAllJax(), i;
for (i = 0; i < all.length; i += 1) {
all[i].SourceElement().parentNode.className += ' has-jax';
}
});
</script>
<style>
code.has-jax {
font: inherit;
font-size: 100%;
background: inherit;
border: inherit;
color: #515151;
}
</style>
Step 2:
在外框layout的header加入
{{ partial "MathJax.html" . }}
Notes:
要用 \_ 代替 _
要用 \newline 不能用 \\