Skip to content

markdown中使用数学公式

Posted on:September 5, 2023 at 03:15 AM
预计阅读时长:1 min read 字数:169

添加插件

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
$$
abc123xyz123\frac{abc123}{xyz123}
X=1ni=1nxi\overline{X}=\frac{1}{n}\sum_{i=1}^{n}x_i

隐藏原始语法

.katex-html{
    display:none;
}

语法

希腊字母语法
B\Beta$\Beta$
Γ\Gamma$\Gamma$
Θ\Theta$\Theta$
Λ\Lambda$\Lambda$
Σ\Sigma$\Sigma$
Φ\Phi$\Phi$
Ψ\Psi$\Psi$
Ω\Omega$\Omega$
Γ\varGamma$\varGamma$
Θ\varTheta$\varTheta$
Λ\varLambda$\varLambda$
Φ\varPhi$\varPhi$
Ψ\varPsi$\varPsi$
Ω\varOmega$\varOmega$
α\alpha$\alpha$
β\beta$\beta$
ϵ\epsilon$\epsilon$
θ\theta$\theta$
ρ\rho$\rho$
σ\sigma$\sigma$
特殊呈现语法
aprimea^{prime}$$a^{prime}$$
aa’$a’$
yˉ\bar{y}$\bar{y}$
θ^\hat{\theta}$\hat{\theta}$
F\vec{F}$\vec{F}$
AB\overline{AB}$\overline{AB}$
a+b+ca+b+c+d+ed+e\overbrace{a+b+c}^{\text{a+b+c}}+\overbrace{d+e}^{\text{d+e}}$\overbrace{a+b+c}^{\text{note}}$
a+b+cnote\underbrace{a+b+c}^{\text{note}}$\underbrace{a+b+c}^{\text{note}}$
xnx_{n}$x_{n}$
x2x^{2}$x^{2}$
ab\frac{a}{b}$\frac{a}{b}$
ab\dfrac{a}{b}$\dfrac{a}{b}$
(ab)\binom{a}{b}$\binom{a}{b}$
(ab)\dbinom{a}{b}$\dbinom{a}{b}$
(x)\lparen x \rparen$\lparen x \rparen$
[x]\lbrack x \rbrack$\lbrack x \rbrack$
{x}\lbrace x \rbrace$\lbrace x \rbrace$
x\lvert x \rvert$\lvert x \rvert$
符号语法
\sum$\sum$
i=1n\sum_{i=1}^{n}$\sum_{i=1}^{n}$
i=1n\displaystyle \sum_{i=1}^{n}$\displaystyle \sum_{i=1}^{n}$
i=1n\prod_{i=1}^{n}$\prod_{i=1}^{n}$
x\sqrt{x}$\sqrt{x}$
xn\sqrt[n]{x}$\sqrt[n]{x}$
\ne$\ne$
\neq$\neq$
\sim$\sim$
\thicksim$\thicksim$
\le$\le$
\ge$\ge$
\geqq$\geqq$
\leqq$\leqq$
α(tag)\alpha \tag{tag}
$$
\alpha \tag{tag}
$$
abcdefghi \left|\begin{matrix} a & b & c \\ d & e & f \\ g & h & i \end{matrix} \right|
$$
 \left|\begin{matrix}
    a & b & c \\
    d & e & f \\
    g & h & i
   \end{matrix} \right|
 $$
\bigcap\bigcup\bigoplus\bigotimes\sum\int\oint\iint
 $$
\bigcap\bigcup\bigoplus\bigotimes\sum\int\oint\iint
$$

\leftarrow\Leftarrow\nLeftarrow\rightleftarrows

 $\leftarrow$、$\Leftarrow$、$\nLeftarrow$、$\rightleftarrows$

Tj1j2jqi1i2ip=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})

$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})$

链接