Yongfu's Blog

# MathJax Setup

Jan 27, 2018

THIS POST IS OUTDATED

MathJax is a JavaScript display engine for mathematics that works in all browsers. By including MathJax support on the website, LaTeX mathematical expressions are rendered as pretty mathematical equations.

## GitHub Page Support

You can take a look at MathJax support of my page here, it’s in the file mathjax.html.

mathjax.html contains two part. The first starts with {% raw %}{% if site.mathjax == true or page.mathjax == true %}{% endraw %}, and the code below it is the same as the code in the section, Add MathJax Support.

The second starts with {% raw %}{% if page.mathjax2 == true %}{% endraw %}, and the code below it is the same as the code in the section, Equation autoNumber.

Note the variables mathjax and mathjax22 in the liquid tags. You can set them globally3 in _config.yml, or individually in the yaml header of each post/page. For example, I set the code below in _config.yml.

mathjax: true
mathjax2: false


This allows mathjax support without equation auto-numbering to be the default setting of my site. When I want auto-numbering for some post (or page), I can set mathjax2: true in the yaml header of the post.

When I was typing this post, I found that GitHub Pages may have trouble rendering pages containing Latex. This is because GitHub Pages sometimes confuses several curly braces ({) written together as Jekyll liquid tags, which could cause page build failure. You can avoid this by not using too complicated Latex syntax, especially those with many { (or }) connected together. If you want to explicitely include liquid tags in your posts, look here for more details.
1. Note that \label & \notag can’t be used together (You can’t label a numbering-escaped equation).
2. Which is in site.mathjax, page.mathjax,and page.mathjax2, and are all set to true.
3. The base template of my blog imports scripts from mathjax.html(line 18), so the whole site supports mathjax (as long as the page uses the template of my blog).