Using Hexo MathJax and Writing LaTex Equations

Install

Hexo supports the TeX or the LaTex by plugin MathJax. We only need 3 steps to install it:

  1. npm install hexo-math --save
  2. cd to the dictionary of your local blog, input:hexo math install
  3. Add plugins: hexo-math into the _config.yml

    Fix the Conflict between Hexo and Mathjax

    When Hexo render a webpage, it regards _ between the ‘$$’ as HTML’s <i>. But we need to use the _ to write the LaTex formula. Thus we need to fix this problem.

Actually this problem bothered me for nearly 2 days. Finally I found a perfect solution:

  1. npm uninstall hexo-renderer-marked --save
  2. npm install hexo-renderer-kramed --save

These 2-line commands means uninstall the default hexo render first and then install hexo-renderer-kramed. As its Gitbub page said, hexo renderer karmed is a fork of hexo renderer marked, focusing on solving the conflict between the Hexo and Mathjax. And it works quite well :)

Now everything goes well and we can write any formula as we want.

Usage

Use “$$” to quote a LaTex equation like:

1
$$ e^{ix}=\cos x + i\sin x $$

$$ e^{ix}=\cos x + i\sin x $$

Useful websites