Display Maths Correctly in Hexo

How to escape markdown parser

Mathjax

As we all know, or at least we should know, Hexo does not support math well. I basically tried every plugin I could find online and was still unable to get my most basic maths displayed correctly.

Well, turns out that these equations all happen to contain subscripts!

Take this one for example:
$$Y_{index} = x_*^2$$ is rendered as
$$Y_{index} = x_*^2$$
Pretty simple, huh? Not necessarily. The _s and \*s in any maths expression have a potential of being interpreted by Hexo’s markdown interpreter as markdown syntax of italic and bold. Thus we will need to use \ to escape any of these signs.

So, if you want to display maths, just install any plugin online. They will do fine to send a request to mathjax and render a proper maths display, given that you use the escape sign \.

Whenever you get an error in maths display, check for markdown-specific characters!

Here is a list of math plugins for Hexo.

Also, if you want to try generating static maths expressions, see this repository. I personally have not used it but may check it out some time.

Also some themes, such as Hueman, have their own math-display feature.

Share