# Add latex support to your hexo theme

#### Deprecated, next theme have built in mathjax support

### How to use mathjax in hexo

Well, I need maths equation in next post, but hexo does not support latex naturally, I goolge a little bit, find this, which use mathjax with hexo. I try it out, it’s total working, here are some test.

Multi-line equation.

\begin{aligned}

\dot{x} & = \sigma(y-x) \\

\dot{y} & = \rho x - y - xz \\

\dot{z} & = -\beta z + xy

\end{aligned}Matrix

\begin{bmatrix}

1 & 2\\

3 & 4

\end{bmatrix}Complex equation

$$\frac{\partial u}{\partial t}=

h^2 \left( \frac{\partial^2 u}{\partial x^2}+

\frac{\partial^2 u}{\partial y^2}+

\frac{\partial^2 u}{\partial z^2}\right)$$

Cool, all works well. Only one thing to notice, do not begin with +,=,- in your equation, it may conflicts with markdown parser in hexo.

### Make mathjax integrate with hexo theme

But for hexo theme developer, it’s probably not a good idea to enable mathjax by default, it’s better letting user choose whether they want to enable it. So it’s important to integrate mathjax with hexo theme. It can be easily done by adding a few lines from above method. In mathjax.ejs file, add one line in front of it.

1 | <% if (theme.mathjax.enable){ %> |

Note that there is a if sentence on the top, it reads the theme config to see if mathjax is enabled. And in the theme config file, there should be some lines like:

1 | mathjax: |

Then it is done, you can choose to enable mathjax by modify config file.