LaTeX 数学公式指南(KaTeX 版)

本文章最后更新日期为:2021-08-29

Powered by

TeXLaTeXKaTeX\TeX \quad \LaTeX \quad \KaTeX

声调 / 变音 / 上下标 / 上下括号 / 向量

aa' a'a~\tilde{a} \tilde{a}g˚\mathring{g} \mathring{g}
aa'' a''ac~\widetilde{ac}\widetilde{ac}AB\overgroup{AB}\overgroup{AB}
aa^{\prime} a^{\prime}AB~\utilde{AB} \utilde{AB}AB\undergroup{AB} \undergroup{AB}
aˊ\acute{a} \acute{a}F\vec{F}\vec{F}AB\Overrightarrow{AB}\Overrightarrow{AB}
yˉ\bar{y} \bar{y}AB\overleftarrow{AB}\overleftarrow{AB}AB\overrightarrow{AB}\overrightarrow{AB}
a˘\breve{a} \breve{a}AB\underleftarrow{AB} \underleftarrow{AB}AB\underrightarrow{AB} \underrightarrow{AB}
aˇ\check{a} \check{a}ac\overleftharpoon{ac}\overleftharpoon{ac}ac\overrightharpoon{ac}\overrightharpoon{ac}
a˙\dot{a} \dot{a}AB\overleftrightarrow{AB}\overleftrightarrow{AB}AB\overbrace{AB}\overbrace{AB}
a¨\ddot{a} \ddot{a}AB\underleftrightarrow{AB} \underleftrightarrow{AB}AB\underbrace{AB} \underbrace{AB}
aˋ\grave{a} \grave{a}AB\overline{AB} \overline{AB}ABundefined\overlinesegment{AB}\overlinesegment{AB}
θ^\hat{\theta} \hat{\theta}AB\underline{AB} \underline{AB}ABundefined\underlinesegment{AB} \underlinesegment{AB}
ac^\widehat{ac}\widehat{ac}acˇ\widecheck{ac}\widecheck{ac}\underbar{X} \underbar{X}

\text{...} 中的声调 / 变音符号

aˊ\text{\'{a}} \'{a}a˜\text{\~{a}} \~{a}a˙\text{\.{a}} \.{a}a˝\text{\H{a}} \H{a}
a˚\text{\r{a}} \r{a}aˉ\text{\={a}} \={a}a¨\text{\"{a}} \"{a}aˇ\text{\v{a}} \v{a}
aˆ\text{\^{a}} \^{a}a˘\text{\u{a}} \u{a}

分隔符 / 括号 / 箭头

()( ) ( )()\lparen \rparen \lparen \rparen⌈ ⌉ ⌈ ⌉\lceil \rceil \lceil \rceil\uparrow \uparrow
[][ ] [ ][]\lbrack \rbrack \lbrack \rbrack⌊⌋ ⌊ ⌋\lfloor \rfloor \lfloor \rfloor\downarrow \downarrow
{}\{ \} \{ \}{}\lbrace \rbrace \lbrace \rbrace⎰⎱ ⎰⎱\lmoustache \rmoustache \lmoustache \rmoustache\updownarrow \updownarrow
⟨ ⟩ ⟨ ⟩\langle \rangle \langle \rangle⟮ ⟯ ⟮ ⟯\lgroup \rgroup \lgroup \rgroup\Uparrow \Uparrow
|$$\vert \vert┌ ┐ ┌ ┐\ulcorner \urcorner \ulcorner \urcorner
\|\|\Vert \Vert└ ┘ └ ┘\llcorner \lrcorner \llcorner \lrcorner\Updownarrow \Updownarrow
\lvert \rvert \lvert \rvert\lVert \rVert \lVert \rVert$$ ``\left. \right. \left. \right.(相信眼睛)\\backslash \backslash
\lang \rang \lang \rang<>\lt \gt \lt \gt⟦ ⟧ ⟦ ⟧\llbracket \rrbracket ``\llbracket \rrbracket\lBrace \rBrace \lBrace \rBrace

分隔符大小

(AB)\left(\LARGE{AB}\right) \left(\LARGE{AB}\right)

(((((( \big( \Big( \bigg( \Bigg( ( \big( \Big( \bigg( \Bigg(

\left\big\bigl\bigm\bigr
\middle\Big\Bigl\Bigm\Bigr
\right\bigg\biggl\biggm\biggr
\Bigg\Biggl\Biggm\Biggr

环境 / 形式

1
2
3
4
5
6
7
8
9
\begin{matrix}
a & b \\
c & d
\end{matrix}
or
\begin{array}{cc}
a & b \\
c & d
\end{array}

abcd\begin{matrix} a & b \\ c & d \end{matrix}

1
2
3
4
\begin{pmatrix}
a & b \\
c & d
\end{pmatrix}

(abcd)\begin{pmatrix} a & b \\ c & d \end{pmatrix}

1
2
3
4
\begin{bmatrix}
a & b \\
c & d
\end{bmatrix}

[abcd]\begin{bmatrix} a & b \\ c & d \end{bmatrix}

1
2
3
4
\begin{vmatrix}
a & b \\
c & d
\end{vmatrix}

abcd\begin{vmatrix} a & b \\ c & d \end{vmatrix}

1
2
3
4
\begin{Vmatrix}
a & b \\
c & d
\end{Vmatrix}

abcd\begin{Vmatrix} a & b \\ c & d \end{Vmatrix}

1
2
3
4
\begin{Bmatrix}
a & b \\
c & d
\end{Bmatrix}

{abcd}\begin{Bmatrix} a & b \\ c & d \end{Bmatrix}

1
2
3
4
5
6
7
\def\arraystretch{1.5}
\begin{array}{c:c:c}
a & b & c \\ \hline
d & e & f \\
\hdashline
g & h & i
\end{array}

abcdefghi\def\arraystretch{1.5} \begin{array}{c:c:c} a & b & c \\ \hline d & e & f \\ \hdashline g & h & i \end{array}

此处显示有误

1
2
3
4
5
x =
\begin{cases}
a &\text{if } b \\
c &\text{if } d
\end{cases}

x={aif bcif dx = \begin{cases} a &\text{if } b \\ c &\text{if } d \end{cases}

1
2
3
4
\begin{rcases}
a &\text{if } b \\
c &\text{if } d
\end{rcases}

Error to display.(Will be fixed soon.)\text{Error to display.(Will be fixed soon.)}

1
2
3
4
\begin{smallmatrix}
a & b \\
c & d
\end{smallmatrix}

Error to display.(Will be fixed soon.)\text{Error to display.(Will be fixed soon.)}

1
2
3
4
5
6
\sum_{
\begin{subarray}{l}
i\in\Lambda\\
0<j<n
\end{subarray}
}

Error to display.(Will be fixed soon.)\text{Error to display.(Will be fixed soon.)}

HTML

KaTeX\href{https://katex.org/}{\KaTeX}\href{https://katex.org/}{\KaTeX}
https://katex.org/\url{https://katex.org/}\url{https://katex.org/}

字母与 Unicode

希腊字母

A\Alpha \AlphaB\Beta \BetaΓ\Gamma \GammaΔ\Delta \DeltaE\Epsilon \EpsilonZ\Zeta \Zeta
H\Eta \EtaΘ\Theta \ThetaI\Iota \IotaK\Kappa \KappaΛ\Lambda \LambdaM\Mu \Mu
N\Nu \NuΞ\Xi \XiO\Omicron \OmicronΠ\Pi \PiP\Rho \RhoΣ\Sigma \Sigma
T\Tau \TauΥ\Upsilon \UpsilonΦ\Phi \PhiX\Chi \ChiΨ\Psi \PsiΩ\Omega \Omega
Γ\varGamma \varGammaΔ\varDelta \varDeltaΘ\varTheta \varThetaΛ\varLambda \varLambdaΞ\varXi \varXiΠ\varPi \varPi
Σ\varSigma \varSigmaΥ\varUpsilon \varUpsilonΦ\varPhi \varPhiΨ\varPsi \varPsiΩ\varOmega \varOmega
α\alpha \alphaβ\beta \betaγ\gamma \gammaδ\delta \deltaϵ\epsilon \epsilonζ\zeta \zeta
η\eta \etaθ\theta \thetaι\iota \iotaκ\kappa \kappaλ\lambda \lambdaμ\mu \mu
ν\nu \nuξ\xi \xiο\omicron \omicronπ\pi \piρ\rho \rhoρ\rho \rho
σ\sigma \sigmaτ\tau \tauυ\upsilon \upsilonϕ\phi \phiχ\chi \chiψ\psi \psi
ω\omega \omegaε\varepsilon \varepsilonϰ\varkappa \varkappaϑ\vartheta \varthetaϑ\thetasym \thetasymϖ\varpi \varpi
ϱ\varrho \varrhoς\varsigma \varsigmaφ\varphi \varphiϝ\digamma \digamma

其他字母

ı\imath \imath\nabla \nabla\Im \ImR\Reals \RealsŒ\text{\OE} \text{\OE}ȷ\jmath \jmath
\partial \partial\image \image\wp \wpø\text{\o} \text{\o}\aleph \aleph\Game \Game
k\Bbbk \Bbbk\weierp \weierpØ\text{\O} \text{\O}\alef \alef\Finv \FinvN\N \N
Z\Z \Zß\text{\ss} \text{\ss}\alefsym \alefsymC\cnums \cnumsN\natnums \natnumsa˚\text{\aa} \text{\aa}
ı\text{\i} \text{\i}\beth \bethC\Complex \ComplexR\R \RA˚\text{\AA} \text{\AA}ȷ\text{\j} \text{\j}
\gimel \gimel\ell \ell\Re \Reæ\text{\ae} \text{\ae}\daleth \daleth\hbar \hbar
\real \realÆ\text{\AE} \text{\AE}ð\eth \eth\hslash \hslashR\reals \realsœ\text{\oe} \text{\oe}

布局

注解

5\cancel{5} \cancel{5}a+b+cnote\overbrace{a+b+c}^{\text{note}} \overbrace{a+b+c}^{\text{note}}
5\bcancel{5} \bcancel{5}a+b+cnote\underbrace{a+b+c}_{\text{note}} \underbrace{a+b+c}_{\text{note}}
ABC\xcancel{ABC}\xcancel{ABC}\not = \not =
abc\sout{abc} \sout{abc}π=cd\boxed{\pi=\frac c d} \boxed{\pi=\frac c d}
1
\tag{hi} x+y^{2x}

x+y2x(hi)\tag{hi} x+y^{2x}

1
\tag*{hi} x+y^{2x}

x+y2xhi\tag*{hi} x+y^{2x}

垂直

xnx_n x_n=!\stackrel{!}{=} \stackrel{!}{=}aba \atop b a \atop b
exe^x e^x=!\overset{!}{=} \overset{!}{=}=!\underset{!}{=} \underset{!}{=}
uo_u^o _u^o

重叠和间距

=/{=}\mathllap{/\,} {=}\mathllap{/\,}(x2)\left(x^{\smash{2}}\right) \left(x^{\smash{2}}\right)
/=\mathrlap{\,/}{=} \mathrlap{\,/}{=}y\sqrt{\smash[b]{y}} \sqrt{\smash[b]{y}}
1
\sum_{\mathclap{1\le i\le j\le n}} x_{ij}

1ijnxij\sum_{\mathclap{1\le i\le j\le n}} x_{ij}

间距

公式结果公式结果
\,³∕₁₈ em 空格\kern{distance}空格,宽度 = distance
\thinspace³∕₁₈ em 空格\mkern{distance}空格,宽度 = distance
\>⁴∕₁₈ em 空格\mskip{distance}空格,宽度 = distance
\:⁴∕₁₈ em 空格\hskip{distance}空格,宽度 = distance
\medspace⁴∕₁₈ em 空格\hspace{distance}空格,宽度 = distance
\;⁵∕₁₈ em 空格\hspace*{distance}空格,宽度 = distance
\thickspace⁵∕₁₈ em 空格\phantom{content}间隔 content 的宽度和高度
\enspace½ em 空格\hphantom{content}间隔 content 的宽度
\quad1 em 空格\vphantom{content}间隔 content 的高度
\qquad2 em 空格\!– ³∕₁₈ em 空格
~non-breaking 的空格\negthinspace– ³∕₁₈ em 空格
\<space>空格\negmedspace– ⁴∕₁₈ em 空格
\nobreakspacenon-breaking 的空格\negthickspace– ⁵∕₁₈ em 空格
\space空格\mathstrut\vphantom{(}

逻辑与集合论

\forall \forall\complement \complement\therefore \therefore\emptyset \emptyset
\exists \exists\subset \subset\because \because\empty \empty
\exist \exist\supset \supset\mapsto \mapsto\varnothing \varnothing
\nexists \nexists\mid \mid\to \to    \implies \implies
\in \in\land \land\gets \gets    \impliedby \impliedby
\isin \isin\lor \lor\leftrightarrow \leftrightarrow    \iff \iff
\notin \notin\ni \ni\notni \notni¬\neg \neg\lnot

x2+x2\def\foo{x^2} \foo + \foo\def\foo{x^2} \foo + \foo
\gdef\bar#1{#1^2} \bar{y} + \bar{y}
\edef\macroname#1#2…{definition to be expanded}
\xdef\macroname#1#2…{definition to be expanded}
\let\foo=\bar
\futurelet\foo\bar x
\global\def\macroname#1#2…{definition}
\newcommand\macroname[numargs]{definition}
\renewcommand\macroname[numargs]{definition}
\providecommand\macroname[numargs]{definition}

运算符

巨大的运算符!

\sum \sum\prod \prod\bigotimes \bigotimes\bigvee \bigvee\int \int
\coprod \coprod\bigoplus \bigoplus\bigwedge \bigwedge\iint \iint\intop \intop
\bigodot \bigodot\bigcap \bigcap\iiint \iiint\smallint \smallint\biguplus \biguplus
\bigcup \bigcup\oint \oint\oiint \oiint\oiiint \oiiint\bigsqcup \bigsqcup

二元运算符

单位

KaTeX 单位KaTeX 单位
emCSS embp1/72 inch × F × G
exCSS expc12 KaTeX pt
mu1/18 CSS emdd1238/1157 KaTeX pt
pt1/72.27 inch × F × Gcc14856/1157 KaTeX pt
mm1 mm × F × Gnd685/642 KaTeX pt
cm1 cm × F × Gnc1370/107 KaTeX pt
in1 inch × F × Gsp1/65536 KaTeX pt

其中的:

  • F = (周围 HTML 文本的字体大小)/(10 pt)
  • G = 默认为 1.21, 因为 KaTeX 的默认字体大小为 1.21 × 周围字体大小。这个值可以被 HTML 页面的 CSS 覆盖。