Last active
April 6, 2020 12:49
-
-
Save Marc-B-Reynolds/8cd39e23e09d78b6f678d7d0214dcfe7 to your computer and use it in GitHub Desktop.
MathJax 2 vs. 3 hack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% if page.mathjax3 %} | |
<script> | |
window.MathJax = { | |
options: { | |
menuOptions: { | |
settings: { | |
zoom: "None", | |
zscale: "150%" | |
} | |
}, | |
renderActions: { | |
findScript: [10, function (doc) { | |
for (const node of document.querySelectorAll('script[type^="math/tex"]')) { | |
const display = !!node.type.match(/; *mode=display/); | |
const math = new doc.options.MathItem(node.textContent, doc.inputJax[0], display); | |
const text = document.createTextNode(''); | |
node.parentNode.replaceChild(text, node); | |
math.start = {node: text, delim: '', n: 0}; | |
math.end = {node: text, delim: '', n: 0}; | |
doc.math.push(math); | |
} | |
}, ''] | |
}, | |
ignoreHtmlClass: 'tex2jax_ignore', | |
processHtmlClass: 'tex2jax_process' | |
}, | |
tex: { | |
inlineMath: [['$','$']], | |
displayMath: [['$$','$$']], | |
processEnvironments: false, | |
tags: "ams", | |
macros: { | |
abs: ['\\left\\lvert #2 \\right\\rvert_{\\text{#1}}', 2, ""], | |
abracket: ['{\\langle #1 \\rangle}', 1], | |
pbracket: ['{\\bigl #1 \\bigr}', 1], | |
bvec: ['{\\lgroup #1 \\rgroup}', 1], | |
func: ['{#1 \\left( #2 \\right)}', 2] | |
}, | |
autoload: { | |
color: [], | |
colorV2: ['color'] | |
}, | |
packages: {'[+]': ['noerrors']} | |
}, | |
loader: { | |
load: ['[tex]/noerrors'] | |
} | |
}; | |
</script> | |
<script src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js" id="MathJax-script"></script> | |
{% else %} | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script> | |
<script type="text/x-mathjax-config"> | |
MathJax.Hub.Config({ | |
showProcessingMessages: false, | |
messageStyle: 'none', | |
tex2jax: { | |
inlineMath: [['$','$']], | |
displayMath: [['$$','$$']], | |
processEnvironments: false | |
}, | |
TeX: { | |
displayAlign: "left", | |
// show equation numbers | |
equationNumbers: { | |
autoNumber: "AMS" | |
}, | |
Macros: { | |
abs: ['\\left\\lvert #2 \\right\\rvert_{\\text{#1}}', 2, ""], | |
abracket: ['{\\langle #1 \\rangle}', 1], | |
pbracket: ['{\\bigl #1 \\bigr}', 1], | |
bvec: ['{\\lgroup #1 \\rgroup}', 1], | |
func: ['{#1 \\left( #2 \\right)}', 2] | |
} | |
}, | |
MathMenu: { | |
showFontMenu: true | |
}, | |
menuSettings:{ | |
zoom: "None", | |
zscale: "150%" | |
}, | |
'HTML-CSS': { | |
imageFont: null | |
} | |
}); | |
</script> | |
{% endif %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment