Now we’ve build our Hexo site on GitHub and seen Hexo’s “Hello World” post, it’s time to embed KaTeX.
1. hexo-math
Install
1 | $ npm install hexo-math --save |
If it doesn’t work on your Mac, try sudo
.
1 | $ sudo npm install hexo-math --save |
Config
In your Hexo root directory, find _config.yml
, add this code at the end. Don’t change those indents.
1 | math: |
2. hexo-theme-next
“«NexT» is a high quality elegant Hexo theme. It is crafted from scratch, with love.” Let’s install it. Change dir to your local Hexo root directory, make sure you see subdirectories like node_modules
, source
, themes
, etc.
1 | $ cd MyBlog |
Clone the whole theme repository to your local Hexo root directory.
1 | $ git clone https://github.com/theme-next/hexo-theme-next themes/next |
3. hexo-theme-next Math Equations
Install hexo-renderer-markdown-it-plus
You need to uninstall the original renderer hexo-renderer-marked
first.
1 | npm un hexo-renderer-marked --save |
Config
In your themes/next/_config.yml
, below Third Party Services Settings
, find the following parts and change some of them.
1 | # Math Equations Render Support |
Make sure the KaTeX version you set in both _config.yml
and themes/next/_config.yml
are 0.10.0, the default version 0.7.1 doesn’t work. “copy_tex” is enabled and it will bring us a bonus(see the bottom of this page).
Don’t Forget:
In your Hexo root directory, open _config.yml
, then replace theme: landscape with theme: next.
4. Usage
Inline
1 | Aha! $E = mc^{2}$. |
Output:
Aha! .
Block
1 | $$ |
Output:
Bonus: Select this funcion and paste it in a text editor. What do you get? It’s a KaTeX format text! COOL!
More info: KaTeX Supported Functions