Skip to content

Commit

Permalink
Upgrade from MathJax v2.7 to v3.
Browse files Browse the repository at this point in the history
The first part of the config is easy to upgrade using this tool:
http://docs.mathjax.org/en/latest/upgrading/v2.html#upgrading-from-v2-to-v3

The second part, I added to implement the "\psmallmatrix" environment
from the "mathtools" package (which MathJax doesn't support), because I used
it in the blog posts
https://quuxplusone.github.io/blog/2018/08/05/quantum-circuits/
https://quuxplusone.github.io/blog/2018/08/05/mathjax-in-jekyll/

This solution is due to Davide Cervone:
https://groups.google.com/g/mathjax-users/c/lWj4CeN70oY/m/Prox7m85AgAJ
https://stackoverflow.com/questions/63428119/
  • Loading branch information
Quuxplusone committed Aug 19, 2020
1 parent d716963 commit 420dbab
Showing 1 changed file with 20 additions and 33 deletions.
53 changes: 20 additions & 33 deletions _includes/mathjax.html
Original file line number Diff line number Diff line change
@@ -1,36 +1,23 @@
<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",
]
<script type="text/javascript">
window.MathJax = {
tex: {
packages: ['base', 'ams']
},
loader: {
load: ['ui/menu', '[tex]/ams']
},
startup: {
ready() {
MathJax.startup.defaultReady();
const Macro = MathJax._.input.tex.Symbol.Macro;
const MapHandler = MathJax._.input.tex.MapHandler.MapHandler;
const Array = MathJax._.input.tex.ams.AmsMethods.default.Array;
const env = new Macro('psmallmatrix', Array, [null, '(', ')', 'c', '.333em', '.2em', 'S', 1]);
MapHandler.getMap('AMSmath-environment').add('psmallmatrix', env);
}
});
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 type="text/javascript" id="MathJax-script" async
src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js">
</script>

0 comments on commit 420dbab

Please sign in to comment.