mirror of
https://github.com/imfing/hextra.git
synced 2025-06-18 22:13:35 -04:00

* feat: add MathJax option * docs: move math engine note * refactor: update LaTeX documentation and improve MathJax integration - Adjusted LaTeX documentation for clarity and formatting. - Enhanced MathJax configuration in the templates to support both KaTeX and MathJax rendering. - Removed deprecated comments and streamlined the script loading process for MathJax. - Updated the passthrough extension settings in the Hugo configuration for better compatibility with LaTeX math expressions. * docs: simplify LaTeX documentation and clarify configuration steps - Updated LaTeX documentation to reflect that KaTeX is enabled by default, removing the need for manual activation. - Added examples for using LaTeX math expressions and clarified the configuration for the passthrough extension in Hugo. - Enhanced MathJax section to emphasize its use as an alternative rendering engine.
2.6 KiB
2.6 KiB
title, weight, math
title | weight | math |
---|---|---|
数学公式 | 4 | true |
默认情况下,(\KaTeX) 用于渲染 LaTeX 数学表达式。 无需手动激活,您可以直接在 Markdown 内容中开始使用 LaTeX 数学表达式。
示例
Markdown 内容中支持内联和独立段落的 LaTeX 数学表达式。
内联
这个 \(\sigma(z) = \frac{1}{1 + e^{-z}}\) 是内联的。
这个 (\sigma(z) = \frac{1}{1 + e^{-z}}) 是内联的。
独立段落
$$F(\omega) = \int_{-\infty}^{\infty} f(t) e^{-j\omega t} \, dt$$
将渲染为:
F(\omega) = \int_{-\infty}^{\infty} f(t) e^{-j\omega t} \, dt
例如,使用对齐环境:
$$
\begin{aligned}
\nabla \cdot \mathbf{E} &= \frac{\rho}{\varepsilon_0} \\
\nabla \cdot \mathbf{B} &= 0 \\
\nabla \times \mathbf{E} &= -\frac{\partial \mathbf{B}}{\partial t} \\
\nabla \times \mathbf{B} &= \mu_0 \left( \mathbf{J} + \varepsilon_0 \frac{\partial \mathbf{E}}{\partial t} \right)
\end{aligned}
$$
将渲染为:
\begin{aligned}
\nabla \cdot \mathbf{E} &= \frac{\rho}{\varepsilon_0} \\
\nabla \cdot \mathbf{B} &= 0 \\
\nabla \times \mathbf{E} &= -\frac{\partial \mathbf{B}}{\partial t} \\
\nabla \times \mathbf{B} &= \mu_0 \left( \mathbf{J} + \varepsilon_0 \frac{\partial \mathbf{E}}{\partial t} \right)
\end{aligned}
配置
Important
请在 Hugo 配置文件中启用并配置 passthrough 扩展,以便 Hugo 可以检测 Markdown 内容中的 LaTeX 数学表达式。
markup:
goldmark:
extensions:
passthrough:
delimiters:
block: [['\[', '\]'], ["$$", "$$"]]
inline: [['\(', '\)']]
enable: true
支持的函数
有关支持的函数列表,请参阅 KaTeX 支持的函数。
化学
通过 mhchem 扩展支持化学表达式。
内联:(\ce{H2O}) 是水。
独立段落:
$$\ce{Hg^2+ ->[I-] HgI2 ->[I-] [Hg^{II}I4]^2-}$$
将渲染为:
\ce{Hg^2+ ->[I-] HgI2 ->[I-] [Hg^{II}I4]^2-}
数学引擎
MathJax
默认情况下,使用 KaTeX 在构建过程中渲染 LaTeX 数学表达式,这是首选方式。 或者,您可以使用 MathJax 来渲染数学表达式。
要使用 MathJax,请将以下内容添加到 hugo.yaml
配置文件中:
params:
math:
engine: mathjax