添加插件
pnpm --filter @notes/docs i remark-math rehype-katex -r
import remarkToc from "remark-toc";
import remarkMath from "remark-math";
import { defineConfig } from "astro/config";
//***
export default defineConfig({
// ***
markdown: {
remarkPlugins: [
remarkMath,
],
rehypePlugins: [
rehypeKatex,
],
})
使用
$$
\frac{abc123}{xyz123}
$$
$$
\overline{X}=\frac{1}{n}\sum_{i=1}^{n}x_i
$$
xyz123abc123
X=n1i=1∑nxi
隐藏原始语法
.katex-html{
display:none;
}
语法
希腊字母 | 语法 |
---|
B | $\Beta$ |
Γ | $\Gamma$ |
Θ | $\Theta$ |
Λ | $\Lambda$ |
Σ | $\Sigma$ |
Φ | $\Phi$ |
Ψ | $\Psi$ |
Ω | $\Omega$ |
Γ | $\varGamma$ |
Θ | $\varTheta$ |
Λ | $\varLambda$ |
Φ | $\varPhi$ |
Ψ | $\varPsi$ |
Ω | $\varOmega$ |
α | $\alpha$ |
β | $\beta$ |
ϵ | $\epsilon$ |
θ | $\theta$ |
ρ | $\rho$ |
σ | $\sigma$ |
特殊呈现 | 语法 |
---|
aprime | $$a^{prime}$$ |
a’ | $a’$ |
yˉ | $\bar{y}$ |
θ^ | $\hat{\theta}$ |
F | $\vec{F}$ |
AB | $\overline{AB}$ |
a+b+ca+b+c+d+ed+e | $\overbrace{a+b+c}^{\text{note}}$ |
a+b+cnote | $\underbrace{a+b+c}^{\text{note}}$ |
xn | $x_{n}$ |
x2 | $x^{2}$ |
ba | $\frac{a}{b}$ |
ba | $\dfrac{a}{b}$ |
(ba) | $\binom{a}{b}$ |
(ba) | $\dbinom{a}{b}$ |
(x) | $\lparen x \rparen$ |
[x] | $\lbrack x \rbrack$ |
{x} | $\lbrace x \rbrace$ |
∣x∣ | $\lvert x \rvert$ |
符号 | 语法 |
---|
∑ | $\sum$ |
∑i=1n | $\sum_{i=1}^{n}$ |
i=1∑n | $\displaystyle \sum_{i=1}^{n}$ |
∏i=1n | $\prod_{i=1}^{n}$ |
x | $\sqrt{x}$ |
nx | $\sqrt[n]{x}$ |
= | $\ne$ |
= | $\neq$ |
∼ | $\sim$ |
∼ | $\thicksim$ |
≤ | $\le$ |
≥ | $\ge$ |
≧ | $\geqq$ |
≦ | $\leqq$ |
α(tag)
$$
\alpha \tag{tag}
$$
adgbehcfi
$$
\left|\begin{matrix}
a & b & c \\
d & e & f \\
g & h & i
\end{matrix} \right|
$$
⋂⋃⨁⨂∑∫∮∬
$$
\bigcap\bigcup\bigoplus\bigotimes\sum\int\oint\iint
$$
←、⇐、⇍、⇄
$\leftarrow$、$\Leftarrow$、$\nLeftarrow$、$\rightleftarrows$
Tj1j2…jqi1i2…ip=T(xi1,…,xip,ej1,…,ejq)
$T^{i_1 i_2 \dots i_p}_{j_1 j_2 \dots j_q} = T(x^{i_1},\dots,x^{i_p},e_{j_1},\dots,e_{j_q})$
链接