Overhaul mathjax configuration

Put a big effort into making much of the custom LaTeX preamble carry
over.
This commit is contained in:
TEC 2024-03-09 00:23:28 +08:00
parent 71b5299a14
commit 909230afcd
Signed by: tec
SSH Key Fingerprint: SHA256:eobz41Mnm0/iYWBvWThftS0ElEs1ftBr6jamutnXc/A
1 changed files with 60 additions and 29 deletions

View File

@ -10916,40 +10916,71 @@ very well at the moment.
***** MathJax ***** MathJax
If MathJax is used, we want to use version 3 instead of the default version 2. I want to use svg MathJax by default, and with a few of the custom commands that
Looking at a [[https://www.intmath.com/cg5/katex-mathjax-comparison.php][comparison]] we seem to find that it is ~5 times as fast, uses a are part of my LaTeX preamble.
single file instead of multiple, but seems to be a bit bigger unfortunately.
Thankfully this can be mitigated my adding the ~async~ attribute to defer loading.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(setq org-html-mathjax-options (setcdr (assoc 'path org-html-mathjax-options)
'((path "https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js" ) (list "https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js"))
(scale "1")
(autonumber "ams")
(multlinewidth "85%")
(tagindent ".8em")
(tagside "right")))
(setq org-html-mathjax-template (setq org-html-mathjax-template
"<script> "<script>
MathJax = { window.MathJax = {
chtml: { loader: {
scale: %SCALE load: ['[tex]/mathtools'],
}, },
svg: { tex: {
scale: %SCALE, ams: {
fontCache: \"global\" multlineWidth: '%MULTLINEWIDTH'
}, },
tex: { tags: '%TAGS',
tags: \"%AUTONUMBER\", tagSide: '%TAGSIDE',
multlineWidth: \"%MULTLINEWIDTH\", tagIndent: '%TAGINDENT',
tagSide: \"%TAGSIDE\", packages: {'[+]': ['mathtools']},
tagIndent: \"%TAGINDENT\" macros: {
} RR: ['\\\\ifstrempty{#1}{\\\\mathbb{R}}{\\\\mathbb{R}^{#1}}', 1, ''],
}; NN: ['\\\\ifstrempty{#1}{\\\\mathbb{N}}{\\\\mathbb{N}^{#1}}', 1, ''],
ZZ: ['\\\\ifstrempty{#1}{\\\\mathbb{Z}}{\\\\mathbb{Z}^{#1}}', 1, ''],
QQ: ['\\\\ifstrempty{#1}{\\\\mathbb{Q}}{\\\\mathbb{Q}^{#1}}', 1, ''],
CC: ['\\\\ifstrempty{#1}{\\\\mathbb{C}}{\\\\mathbb{C}^{#1}}', 1, ''],
EE: '\\\\mathbb{E}',
Lap: '\\\\operatorname{\\\\mathcal{L}}',
Var: '\\\\operatorname{Var}',
Cor: '\\\\operatorname{Cor}',
E: '\\\\operatorname{E}',
},
mathtools: {
pairedDelimiters: {
abs: ['\\\\lvert', '\\\\rvert'],
norm: ['\\\\lVert', '\\\\rVert'],
ceil: ['\\\\lceil', '\\\\rceil'],
floor: ['\\\\lfloor', '\\\\rfloor'],
round: ['\\\\lfloor', '\\\\rceil'],
}
}
},
chtml: {
scale: %SCALE,
displayAlign: '%ALIGN',
displayIndent: '%INDENT'
},
svg: {
scale: %SCALE,
displayAlign: '%ALIGN',
displayIndent: '%INDENT'
},
output: {
font: '%FONT',
displayOverflow: '%OVERFLOW'
}
};
</script> </script>
<script id=\"MathJax-script\" async
src=\"%PATH\"></script>") <script
id=\"MathJax-script\"
async
src=\"%PATH\">
</script>")
#+end_src #+end_src
*** LaTeX Export *** LaTeX Export