How to use Latex / MathJax in Jekyll
- create
_include/mathjax.html
- add the below code
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
extensions: [
"MathMenu.js",
"MathZoom.js",
"AssistiveMML.js",
"a11y/accessibility-menu.js"
],
jax: ["input/TeX", "output/CommonHTML"],
TeX: {
extensions: [
"AMSmath.js",
"AMSsymbols.js",
"noErrors.js",
"noUndefined.js",
]
}
});
MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
var TEX = MathJax.InputJax.TeX;
var COLS = function (W) {
var WW = [];
for (var i = 0, m = W.length; i < m; i++)
{WW[i] = TEX.Parse.prototype.Em(W[i])}
return WW.join(" ");
};
TEX.Definitions.Add({
environment: {
psmallmatrix: ['Array',null,'(',')','c',COLS([1/3]),".2em",'S',1],
}
});
});
</script>
<script type="text/javascript" async
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js">
</script>
- edit
_layouts/default.html
add a include line before</body>
…
{% include mathjax.html %}
</body>
- that’s it. Enclose math symbols within
$$
- e.g Some random \(A_{m \times n} \cdot B^{n} = C_n\)
$$A_{m \times n} \cdot B^{n} = C_n $$
- some text \(\TeX\)