Complete Guide to LaTeX Support in VSC4T | VSC4T中LaTeX支持完全指南

LaTeX Support in Hexo Themes | Hexo主题中的LaTeX支持

Original reference | 原始参考: hexo-math GitHub Repository

Quick Start | 快速开始

Installation | 安装

1
$ npm i hexo-math --save

Usage Guide | 使用指南

KaTeX Implementation | KaTeX实现

KaTeX offers fast and reliable mathematical typesetting. Use the following syntax:

KaTeX提供快速可靠的数学排版。使用以下语法:

1
2
3
{% katex %}
Your LaTeX formula here
{% endkatex %}

Basic Example | 基本示例

c=±a2+b2c = \pm\sqrt{a^2 + b^2}

Advanced Usage with Options | 带选项的高级用法

1
2
3
{% katex '{ "output": "mathml", "felqn": true }' %}
c = \pm\sqrt{a^2 + b^2}
{% endkatex %}

MathJax Implementation | MathJax实现

MathJax provides comprehensive math rendering. Use as follows:

MathJax提供全面的数学渲染。使用方法如下:

1
2
3
{% mathjax %}
Your LaTeX formula here
{% endmathjax %}

Basic Example | 基本示例

Configuration | 配置

Article-Level Settings | 文章级别设置

1
2
3
4
5
6
7
---
title: Your Article Title
...
...
katex: false
mathjax: false
---

Global Configuration | 全局配置

Add to your _config.yml | 添加到您的_config.yml中:

1
2
3
4
5
6
7
8
9
10
math:
katex:
css: 'https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.min.css'
options:
throwOnError: false
mathjax:
css: 'https://cdn.jsdelivr.net/npm/hexo-math@4.0.0/dist/style.css'
options:
conversion:
display: false

Common LaTeX Examples | 常见LaTeX示例

Inline Math | 行内数学公式

You can write inline math like this:

您可以这样编写行内数学公式:

Block Math | 块级数学公式

For block equations, use:

对于块级方程式,使用:

Matrices | 矩阵

Matrix example:

矩阵示例:

VSC4T-Specific Tips | VSC4T特定提示

Dark Mode Compatibility | 暗色模式兼容性

The VSC4T theme’s dark mode is fully compatible with LaTeX rendering, ensuring comfortable reading of mathematical content.

VSC4T主题的暗色模式与LaTeX渲染完全兼容,确保数学内容的舒适阅读。

Performance Considerations | 性能注意事项

For blogs with many math equations, consider using KaTeX for better performance on mobile devices.

对于包含大量数学方程的博客,考虑使用KaTeX以获得更好的移动设备性能。

Troubleshooting | 故障排除

If equations aren’t rendering:

  1. Check that hexo-math is properly installed
  2. Verify that mathjax/katex is enabled in your post’s front matter
  3. Make sure there are no syntax errors in your LaTeX code

如果方程式未渲染:

  1. 检查hexo-math是否正确安装
  2. 验证在文章的前置信息中是否启用了mathjax/katex
  3. 确保您的LaTeX代码中没有语法错误