Skip to content

数学公式

Obsidian 原生支持 LaTeX 数学公式渲染,无需安装任何插件。你可以使用标准的 LaTeX 数学语法在笔记中编写公式。

启用数学公式

数学公式默认已启用。如需确认:

  1. 打开设置 → 编辑器
  2. 确认「数学公式渲染」已开启

基本语法

行内公式

使用单个 $ 包裹:

markdown
质能方程 $E = mc^2$ 是物理学最著名的公式之一。

渲染效果:质能方程 $E = mc^2$ 是物理学最著名的公式之一。

块级公式

使用双 $$ 包裹(单独成行):

markdown
$$
E = mc^2
$$

排版建议

块级公式的 $$ 建议各占一行,这样在源码模式下更易阅读,也方便后续编辑。

常用数学符号

上下标

语法效果说明
x^2$x^2$上标
x_i$x_i$下标
x^{10}$x^{10}$多字符上标需花括号
x_{ij}$x_{ij}$多字符下标需花括号

希腊字母

语法效果语法效果
\alpha$\alpha$\beta$\beta$
\gamma$\gamma$\delta$\delta$
\epsilon$\epsilon$\theta$\theta$
\lambda$\lambda$\mu$\mu$
\pi$\pi$\sigma$\sigma$
\omega$\omega$\Omega$\Omega$
\phi$\phi$\psi$\psi$

运算符

语法效果说明
\frac{a}{b}$\frac{a}{b}$分数
\sqrt{x}$\sqrt{x}$平方根
\sqrt[n]{x}$\sqrt[n]{x}$n 次根
\sum$\sum$求和
\prod$\prod$连乘
\int$\int$积分
\lim$\lim$极限
\infty$\infty$无穷
\pm$\pm$加减
\times$\times$乘号
\div$\div$除号
\cdot$\cdot$点乘

关系符号

语法效果说明
=$=$等于
\neq$\neq$不等于
<$<$小于
>$>$大于
\leq$\leq$小于等于
\geq$\geq$大于等于
\approx$\approx$约等于
\equiv$\equiv$恒等于
\in$\in$属于
\subset$\subset$子集
\supset$\supset$超集

箭头

语法效果说明
\rightarrow$\rightarrow$右箭头
\leftarrow$\leftarrow$左箭头
\Rightarrow$\Rightarrow$双线右箭头
\Leftrightarrow$\Leftrightarrow$双线双向箭头
\mapsto$\mapsto$映射箭头

公式示例

求和与连乘

markdown
$$
\sum_{i=1}^{n} i = \frac{n(n+1)}{2}
$$
markdown
$$
\prod_{i=1}^{n} i = n!
$$

积分

markdown
$$
\int_{0}^{\infty} e^{-x^2} dx = \frac{\sqrt{\pi}}{2}
$$

极限

markdown
$$
\lim_{n \to \infty} \left(1 + \frac{1}{n}\right)^n = e
$$

矩阵

markdown
$$
\begin{pmatrix}
a & b \\
c & d
\end{pmatrix}
$$

不同括号风格:

环境效果
pmatrix圆括号 $( )$
bmatrix方括号 $[ ]$
Bmatrix花括号 ${ }$
vmatrix竖线 $| |$

大型矩阵:

markdown
$$
\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}
$$

方程组

markdown
$$
\begin{cases}
x + y = 5 \\
2x - y = 1
\end{cases}
$$

分段函数

markdown
$$
f(x) = \begin{cases}
x^2 & \text{if } x \geq 0 \\
-x^2 & \text{if } x < 0
\end{cases}
$$

多行公式对齐

使用 align 环境以 & 对齐:

markdown
$$
\begin{aligned}
(a + b)^2 &= (a + b)(a + b) \\
          &= a^2 + ab + ba + b^2 \\
          &= a^2 + 2ab + b^2
\end{aligned}
$$

常用公式模板

物理学

markdown
牛顿第二定律:$F = ma$

万有引力:$F = G\frac{m_1 m_2}{r^2}$

薛定谔方程:$i\hbar\frac{\partial}{\partial t}\Psi = \hat{H}\Psi$

麦克斯韦方程组:
$$
\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}
$$

统计学

markdown
正态分布:$X \sim N(\mu, \sigma^2)$

概率密度函数:
$$
f(x) = \frac{1}{\sigma\sqrt{2\pi}} e^{-\frac{(x-\mu)^2}{2\sigma^2}}
$$

贝叶斯定理:
$$
P(A|B) = \frac{P(B|A)P(A)}{P(B)}
$$

线性代数

markdown
行列式:
$$
\det(A) = \begin{vmatrix}
a & b \\
c & d
\end{vmatrix} = ad - bc
$$

特征值方程:$A\mathbf{v} = \lambda\mathbf{v}$

格式技巧

字体

语法效果说明
\mathbf{x}$\mathbf{x}$粗体
\mathbb{R}$\mathbb{R}$实数集
\mathcal{L}$\mathcal{L}$花体
\hat{x}$\hat{x}$帽子
\bar{x}$\bar{x}$上横线
\vec{x}$\vec{x}$向量箭头
\tilde{x}$\tilde{x}$波浪号
\dot{x}$\dot{x}$一阶导数点
\ddot{x}$\ddot{x}$二阶导数点

间距

语法宽度说明
\,窄间距微调
\:中等间距适中
\;宽间距较宽
\quad1em标准间距
\qquad2em双倍间距

文字

在公式中插入普通文字:

markdown
$$
\text{当 } x > 0 \text{ 时,} f(x) = x^2
$$

常见问题

公式不渲染?

  1. 检查设置中「数学公式渲染」是否开启
  2. 确认 $ 符号配对正确
  3. 行内公式 $ 与文字之间需要有空格或换行
  4. 块级公式 $$ 建议各占一行

公式太长溢出?

使用 alignaligned 环境拆分多行:

markdown
$$
\begin{aligned}
f(x) &= a_0 + a_1x + a_2x^2 \\
     &\quad + a_3x^3 + a_4x^4
\end{aligned}
$$

特殊字符转义

在公式中使用 _^{} 等字符时,需要用 \ 转义:

markdown
$$
\{x \in \mathbb{R} \mid x > 0\}
$$

与其他功能配合

在 Callout 中使用

markdown
> [!note] 重要公式
> 欧拉公式:$e^{i\pi} + 1 = 0$

配合属性

markdown
---
tags: [数学, 线性代数]
---

# 线性代数笔记

矩阵乘法定义:
$$
(AB)_{ij} = \sum_{k=1}^{n} a_{ik}b_{kj}
$$

在表格中使用

markdown
| 公式名称 | 表达式 |
|----------|--------|
| 勾股定理 | $a^2 + b^2 = c^2$ |
| 欧拉公式 | $e^{i\pi} + 1 = 0$ |

相关资源

最后更新:2026年4月11日编辑此页反馈问题