Math Formulas
The theme offers two ways to enable LaTeX math formula support. Both require the following setup first:
-
Remove Hexo's default markdown renderer
hexo-renderer-markedand installhexo-renderer-pandoc. Remove any other markdown renderers as well!npm uninstall hexo-renderer-markednpm install hexo-renderer-pandoc -
Install pandoc from pandoc.org.
Method 1: Built-in LaTeX renderer
Use the theme's built-in LaTeX renderer. Enable mathjax in the config:
mathjax: true # load the LaTeX math library (from the npmmirror CDN by default)
You can also pass a full script URL to override the default CDN (npmmirror, Alibaba's China mirror; if your network cannot reach it, formulas stay stuck as raw $...$ text):
# Local file (recommended: download tex-svg.js into source/vendors/ — zero external
# dependencies; the SVG output build needs no extra font files)
mathjax: /vendors/tex-svg.js
# Or a full URL of another CDN
mathjax: https://registry.npmmirror.com/mathjax/3.2.2/files/es5/tex-svg.js
When the script source is unreachable, the theme shows a visible failure notice at the top of the post body (instead of waiting forever), keeping the raw text readable.
The theme injects a config before the script loads, enabling
$...$inline math and$$...$$display math by default (MathJax 3 does not recognize the$delimiter out of the box). If you define your ownwindow.MathJaxconfig, the theme will not override it.Note: the default
hexo-renderer-markedbreaks LaTeX\\(matrix line breaks and multi-line derivations will fail). Follow the prerequisites above and switch tohexo-renderer-pandoc, or protect the formulas yourself.
Method 2: Third-party plugin (recommended)
Use the third-party plugin hexo-filter-mathjax for server-side rendering. Set mathjax: false in the config.
For performance, Method 2 is recommended.