How to enable LaTeX support in hexo-next theme
Tonight, when I revising slides preparing for the first examination of “The principle of Toxicology”, the first exam in my Master program, I input some formula in my blog via Typora. After rendering, I found the LaTeX content cannot be rendered. So I searched and found how to solve this issue.
How to enable
Edit your theme config.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15math:
# Default (false) will load mathjax / katex script on demand.
# That is it only render those page which has `mathjax: true` in front-matter.
# If you set it to true, it will load mathjax / katex script EVERY PAGE.
every_page: false
mathjax:
enable: true
# Available values: none | ams | all
tags: none
katex:
enable: false
# See: https://github.com/KaTeX/KaTeX/tree/master/contrib/copy-tex
copy_tex: falseThere are two different latex render software to choose only one of them. For me, I choose mathjax, which is slow but more powerful as it supports more grammar of LaTeX.
Go into your blog fold in terminal.
1
2npm uninstall hexo-renderer-marked --save
npm install hexo-renderer-pandoc --saveFor mac: Install the latest version of Pandoc in Pandoc official release. Then restart your computer.
For Linux(Ubuntu): Log into your server as root
1
2wget https://github.com/jgm/pandoc/releases/download/3.4/pandoc-3.4-1-amd64.deb # find the link of latest version in https://pandoc.org/installing.html
sudo dpkg -i pandoc-3.4-1-amd64.debInsert
mathjax: true
in front-matter of which post you want to use LaTeX. Then render it via git push.
Reference
- https://roro4ever.github.io/2019/12/01/hexo-Next%E4%B8%BB%E9%A2%98%E6%B8%B2%E6%9F%93-latex-%E5%85%AC%E5%BC%8F%E7%9A%84%E9%85%8D%E7%BD%AE%E6%96%B9%E6%B3%95/hexo-next%E4%B8%BB%E9%A2%98%E6%B8%B2%E6%9F%93-latex-%E5%85%AC%E5%BC%8F%E7%9A%84%E9%85%8D%E7%BD%AE%E6%96%B9%E6%B3%95/
- https://blog.csdn.net/weixin_45073562/article/details/120289648
- https://www.codewoody.com/posts/3690/