MathJax 3 fix for Jekyll hosted on Github pages

Issues and workarounds for MatchJax 3.0.
blogging
jekyll
kramdown
mathjax
Author

Oren Bochman

Published

Sunday, April 4, 2021

less Jekyll and more Hyde

less Jekyll and more Hyde

Here is an issue I opened:

I’ve had a too many issues to list trying to cram mathjax v.3 down kramdown’s throat without it choking latex code on a new jekyll blog hosted by github pages.

Here are a few that if fixed should make it much simpler to use mathjax.

  1. | used for absolute values and norm trigger a markdown table.
    • desired behavior o not replace | in non markdown blocks i.e. within the MathJax delimiters
    • my workaround is replace | with instead of ‘|’ in equations
  2. \\ as line breaks are replaced with hard line breaks and then ignored within the MathJax delimiters
    • desired behavior o not replace \\ in non markdown blocks i.e. within the mathjax delimiters
    • workaround use instead of ’\ in math
  3. mathjax now looks for its delimiters rather then the tags being used.
    • add a math_engine_opts entry: say dollars_untaxed to suppress replacement of the mathjax $ delimiters
    • my workaround replace $ and $$ to say $ and $$ respectively. here is my current integration:
<script>
  window.MathJax = {
    loader: {load: ['[tex]/ams']},
    tex: {
      inlineMath: [['$', '$']],
      displayMath: [['$$', '$$'],],
      tags: 'ams',
      multlineWidth: '85%',      // width of multline environment
      packages: {'[+]': ['ams']}},
      formatError:               // function called when TeX syntax errors occur
        (jax, err) => jax.formatError(err),
  };
</script>
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax$3/es5/tex-mml-chtml.js"></script>`

note: migration to Quarto has rended this issue obsolete!?

Citation

BibTeX citation:
@online{bochman2021,
  author = {Bochman, Oren},
  title = {MathJax 3 Fix for {Jekyll} Hosted on {Github} Pages},
  date = {2021-04-04},
  url = {https://orenbochman.github.io/posts/2021/2021-04-06-jekyll-mathjax-3.0-fix/2021-04-06-jekyll-mathjax-3.0-fix.html},
  langid = {en}
}
For attribution, please cite this work as:
Bochman, Oren. 2021. “MathJax 3 Fix for Jekyll Hosted on Github Pages.” April 4, 2021. https://orenbochman.github.io/posts/2021/2021-04-06-jekyll-mathjax-3.0-fix/2021-04-06-jekyll-mathjax-3.0-fix.html.