Install
Hexo supports the TeX or the LaTex by plugin MathJax
. We only need 3 steps to install it:
npm install hexo-math --save
- cd to the dictionary of your local blog, input:
hexo math install
- 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:
npm uninstall hexo-renderer-marked --save
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 $$