这是一篇测试文章,用来检验 Hugo + Reimu 主题对 LaTeX 数学公式与 Markdown 混合排版的支持情况。
一、行内公式(Inline Math)
爱因斯坦的质能方程 $E = mc^2$ 是最著名的物理公式之一。
二次方程求根公式 $x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}$ 大家应该都很熟悉。
欧拉的恒等式被誉为最美的数学公式:$e^{i\pi} + 1 = 0$
二、独立公式(Display Math)
2.1 基础微积分
$$ \int_{a}^{b} f(x) \, dx = F(b) - F(a) $$2.2 泰勒展开
$$ f(x) = \sum_{n=0}^{\infty} \frac{f^{(n)}(a)}{n!} (x - a)^n $$2.3 线性代数 —— 矩阵
$$ \mathbf{A} = \begin{pmatrix} a_{11} & a_{12} & \cdots & a_{1n} \\ a_{21} & a_{22} & \cdots & a_{2n} \\ \vdots & \vdots & \ddots & \vdots \\ a_{m1} & a_{m2} & \cdots & a_{mn} \end{pmatrix} $$矩阵乘法:
$$ (\mathbf{AB})_{ij} = \sum_{k=1}^{n} a_{ik} b_{kj} $$2.4 概率论 —— 正态分布
$$ f(x \mid \mu, \sigma^2) = \frac{1}{\sqrt{2\pi\sigma^2}} e^{-\frac{(x-\mu)^2}{2\sigma^2}} $$2.5 群论
一个群 $(G, \cdot)$ 满足:
- 封闭性:$\forall a,b \in G,; a \cdot b \in G$
- 结合律:$\forall a,b,c \in G,; (a \cdot b) \cdot c = a \cdot (b \cdot c)$
- 单位元:$\exists e \in G,; \forall a \in G,; e \cdot a = a \cdot e = a$
- 逆元:$\forall a \in G,; \exists a^{-1} \in G,; a \cdot a^{-1} = a^{-1} \cdot a = e$
2.6 最速降线问题(泛函分析)
$$ T[y] = \int_{x_1}^{x_2} \frac{\sqrt{1 + (y\')^2}}{\sqrt{2gy}} \, dx $$解为摆线(cycloid):
$$ \begin{cases} x(\theta) = R(\theta - \sin\theta) \\[4pt] y(\theta) = R(1 - \cos\theta) \end{cases} $$三、公式与 Markdown 混排测试
3.1 列表 + 公式
- 牛顿第二定律:$\mathbf{F} = m\mathbf{a}$
- 麦克斯韦方程组: $$ \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 \mathbf{J} + \mu_0\varepsilon_0 \frac{\partial \mathbf{E}}{\partial t} \end{aligned} $$
- 薛定谔方程: $$ i\hbar\frac{\partial}{\partial t}|\Psi(t)\rangle = \hat{H}|\Psi(t)\rangle $$
3.2 引用块 + 公式
费曼曾说:“如果我不能把它讲给一个外行听,那说明我自己也没搞懂。”
用数学语言来说,这相当于要求一个映射 $\varphi: \text{知识} \to \text{语言}$ 满足:
$$ > \forall \varepsilon > 0,\; \exists \delta > 0,\; \text{使得听众的疑惑度} < \varepsilon > $$
3.3 表格 + 公式
| 概念 | 表达式 | 说明 |
|---|---|---|
| 导数 | $\frac{df}{dx} = \lim_{h\to0} \frac{f(x+h)-f(x)}{h}$ | 瞬时变化率 |
| 梯度 | $\nabla f = \left(\frac{\partial f}{\partial x}, \frac{\partial f}{\partial y}\right)$ | 方向导数最大值 |
| 散度 | $\nabla \cdot \mathbf{F} = \frac{\partial F_x}{\partial x} + \frac{\partial F_y}{\partial y}$ | 通量密度 |
| 旋度 | $\nabla \times \mathbf{F}$ | 旋转强度 |
3.4 代码块 + 公式混合
用 Python 验证欧拉公式:
import cmath
# e^(iπ) + 1 = 0
result = cmath.exp(1j * cmath.pi) + 1
print(f"e^(iπ) + 1 = {result}")
# 输出接近 0+0j
而数学上,这写为:
$$ e^{i\theta} = \cos\theta + i\sin\theta $$代入 $\theta = \pi$ 得 $e^{i\pi} = -1$,移项即得 $e^{i\pi} + 1 = 0$。
四、复杂公式大集合
4.1 黎曼 ζ 函数
$$ \zeta(s) = \sum_{n=1}^{\infty} \frac{1}{n^s} = \prod_{p \text{ prime}} \frac{1}{1 - p^{-s}}, \quad \Re(s) > 1 $$4.2 傅里叶变换
$$ \hat{f}(\xi) = \int_{-\infty}^{\infty} f(x) \, e^{-2\pi i x \xi} \, dx $$$$ f(x) = \int_{-\infty}^{\infty} \hat{f}(\xi) \, e^{2\pi i x \xi} \, d\xi $$4.3 多行方程组
$$ \begin{cases} \displaystyle \frac{dx}{dt} = \sigma(y - x) \\[8pt] \displaystyle \frac{dy}{dt} = x(\rho - z) - y \\[8pt] \displaystyle \frac{dz}{dt} = xy - \beta z \end{cases} $$(Lorenz 系统,$\sigma=10,\ \beta=\frac{8}{3},\ \rho=28$ 时进入混沌)
4.4 物理中的路径积分
$$ Z = \int \mathcal{D}[\phi] \, e^{iS[\phi]/\hbar} $$其中 $S[\phi] = \int d^4x , \mathcal{L}(\phi, \partial_\mu\phi)$ 是作用量。
五、结论
如果这篇文章中的所有公式都正确渲染(没有乱码、没有原样输出 LaTeX 源码、LaTeX 分隔符没有破坏 Markdown 结构),说明 Hugo + Reimu 主题对 LaTeX 支持良好 ✅
否则需要排查:
- 主题是否加载了 MathJax / KaTeX
- Markdown 渲染器是否转义了
_、*、\等特殊字符 $/$$在代码块中是否被误解析
