KaTeX数学公式语法

Supported Functions 支持功能


This is a list of TeX functions supported by KaTeX. It is sorted into logical groups.
这是一组KaTeX支持的TeX函数列表。按照功能逻辑分类。

There is a similar Support Table, sorted alphabetically, that lists both supported and un-supported functions.

还有一个类似的功能列表,按字母顺序排列,列出了受支持和不受支持的函数。

Accents 强调

a ′ a' a a' a ~ \tilde{a} a~ \tilde{a} g ˚ \mathring{g} g˚ \mathring{g}
a ′ ′ a'' a a'' a c ~ \widetilde{ac} ac \widetilde{ac} A B ⏠ \overgroup{AB} AB \overgroup{AB}
a ′ a^{\prime} a a^{\prime} A B ~ \utilde{AB} AB \utilde{AB} A B ⏡ \undergroup{AB} AB \undergroup{AB}
a ˊ \acute{a} aˊ \acute{a} F ⃗ \vec{F} F \vec{F} A B ⇒ \Overrightarrow{AB} AB \Overrightarrow{AB}
y ˉ \bar{y} yˉ \bar{y} A B ← \overleftarrow{AB} AB \overleftarrow{AB} A B → \overrightarrow{AB} AB \overrightarrow{AB}
a ˘ \breve{a} a˘ \breve{a} A B ← \underleftarrow{AB} AB \underleftarrow{AB} A B → \underrightarrow{AB} AB \underrightarrow{AB}
a ˇ \check{a} aˇ \check{a} a c ↼ \overleftharpoon{ac} ac \overleftharpoon{ac} a c ⇀ \overrightharpoon{ac} ac \overrightharpoon{ac}
a ˙ \dot{a} a˙ \dot{a} A B ↔ \overleftrightarrow{AB} AB \overleftrightarrow{AB} A B ⏞ \overbrace{AB} AB \overbrace{AB}
a ¨ \ddot{a} a¨ \ddot{a} A B ↔ \underleftrightarrow{AB} AB \underleftrightarrow{AB} A B ⏟ \underbrace{AB} AB \underbrace{AB}
a ˋ \grave{a} aˋ \grave{a} A B ‾ \overline{AB} AB \overline{AB} A B undefined \overlinesegment{AB} AB \overlinesegment{AB}
θ ^ \hat{\theta} θ^ \hat{\theta} A B ‾ \underline{AB} AB \underline{AB} A B undefined \underlinesegment{AB} AB \underlinesegment{AB}
a c ^ \widehat{ac} ac \widehat{ac} a c ˇ \widecheck{ac} ac \widecheck{ac}

Accent functions inside \text{…}
\text{…}格式的强调函数

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

See also letters
另见 letters

Delimiters 分隔符

(   ) (~) ( ) ( ) (   ) \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 \vert ┌ ┐ ┌ ┐ ┌ ┐ ┌ ┐ \ulcorner \urcorner \ulcorner
     ~~~~     \urcorner
⇓ \Downarrow \Downarrow
∥ \Vert \| ∥ \Vert \Vert └ ┘ └ ┘ └ ┘ └ ┘ \llcorner \lrcorner \llcorner
     ~~~~     \lrcorner
⇕ \Updownarrow \Updownarrow
∣   ∣ \lvert~\rvert   \lvert
     ~~~~     \rvert
∥   ∥ \lVert~\rVert   \lVert
      ~~~~~      \rVert
\left.\right. \ \backslash \ \backslash
⟨   ⟩ \lang~\rang   \lang
     ~~~~     \rang
<   > \lt~\gt < > \lt \gt ⟦   ⟧ ⟦~⟧ [[ ]] ⟦ ⟧ ⟦   ⟧ \llbracket~\rrbracket [[ ]] \llbracket
     ~~~~     \rrbracket
⦃   ⦄ \lBrace~\rBrace {[ ]} \lBrace \rBrace

Delimiter Sizing
分隔符大小

( A B ) \left(\LARGE{AB}\right) (AB) \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

Environments 环境

a b c d \begin{matrix} a & b \\ c & d \end{matrix} acbd\begin{matrix}
   a & b \\
   c & d
\end{matrix}
a b c d \begin{array}{cc}a & b\\c & d\end{array} acbd\begin{array}{cc}
   a & b \\
   c & d
\end{array}
( a b c d ) \begin{pmatrix} a & b \\ c & d \end{pmatrix} (acbd)\begin{pmatrix}
   a & b \\
   c & d
\end{pmatrix}
[ a b c d ] \begin{bmatrix} a & b \\ c & d \end{bmatrix} [acbd]\begin{bmatrix}
   a & b \\
   c & d
\end{bmatrix}
∣ a b c d ∣ \begin{vmatrix} a & b \\ c & d \end{vmatrix} acbd\begin{vmatrix}
   a & b \\
   c & d
\end{vmatrix}
∥ a b c d ∥ \begin{Vmatrix} a & b \\ c & d \end{Vmatrix} acbd\begin{Vmatrix}
   a & b \\
   c & d
\end{Vmatrix}
{ a b c d } \begin{Bmatrix} a & b \\ c & d \end{Bmatrix} {acbd}\begin{Bmatrix}
   a & b \\
   c & d
\end{Bmatrix}
a b c d e f g h i \def\arraystretch{1.5}\begin{array}{c:c:c} a & b & c \\ \hline d & e & f \\ \hdashline g & h & i \end{array} adgbehcfi\def\arraystretch{1.5}
   \begin{array}{c:c:c}
   a & b & c \\ \hline
   d & e & f \\
   \hdashline
   g & h & i
\end{array}
a = b + c d + e = f \begin{aligned} a&=b+c \\ d+e&=f \end{aligned} ad+e=b+c=f\begin{aligned}
   a&=b+c \\
   d+e&=f
\end{aligned}
10 x + 3 y = 2 3 x + 13 y = 4 \begin{alignedat}{2}10&x+&3&y=2\\3&x+&13&y=4\end{alignedat} 103x+x+313y=2y=4\begin{alignedat}{2}
   10&x+ &3&y = 2 \\
   3&x+&13&y = 4
\end{alignedat}
a = b e = b + c \begin{gathered} a=b \\ e=b+c \end{gathered} a=be=b+c\begin{gathered}
   a=b \\
   e=b+c
\end{gathered}
x = { a if  b c if  d x = \begin{cases} a &\text{if } b \\ c &\text{if } d \end{cases} x={acif bif dx = \begin{cases}
   a &\text{if } b \\
   c &\text{if } d
\end{cases}
KaTeX parse error: No such environment: smallmatrix at position 7: \begin{̲s̲m̲a̲l̲l̲m̲a̲t̲r̲i̲x̲}̲ a & b \\ c & d…\begin{smallmatrix}
   a & b \\
   c & d
\end{smallmatrix}
KaTeX parse error: No such environment: rcases at position 7: \begin{̲r̲c̲a̲s̲e̲s̲}̲ a &\text{if } …\begin{rcases}
   a &\text{if } b \\
   c &\text{if } d
\end{rcases}⇒…

KaTeX also supports darray, dcases, and drcases.
KaTeX还支持darraydcasesdrcases

Acceptable line separators include: \\, \cr, \\[distance], and \cr[distance]. Distance can be written with any of the KaTeX units.
支持的行分隔符包括:\\, \cr, \\[distance], 和 \cr[distance]Distance可以用任何KaTeX units表示。

The {array} environment supports | and : vertical separators.
{array}环境支持|:垂直分隔符。

The {array} environment does not yet support \cline or \multicolumn.
{array}环境当前不支持\cline\multicolumn

HTML

The following “raw HTML” features are potentially dangerous for untrusted inputs, so they are disabled by default, and attempting to use them produces the command names in red (which you can configure via the errorColor option). To fully trust your LaTeX input, you need to pass an option of trust: true; you can also enable just some of the commands
or for just some URLs via the trust option.
下面的“原始HTML”特性对于不受信任的输入可能是危险的,因此它们在默认情况下是禁用的,尝试使用它们会产生红色的命令名(您可以通过errorColor option来配置)。要完全信任LaTeX输入,您需要传递一个trust: true选项;您还可以启用其中的一些命令或者只是通过’信任’选项的一些URL。(PS:此处配置是针对Katex开发者)

KaTeX \href{https://katex.org/}{\KaTeX} KATEX\href{https://katex.org/}{\KaTeX}
https://katex.org/ \url{https://katex.org/} https://katex.org/\url{https://katex.org/}
KaTeX parse error: Undefined control sequence: \includegraphics at position 1: \̲i̲n̲c̲l̲u̲d̲e̲g̲r̲a̲p̲h̲i̲c̲s̲[height=0.8em, …\includegraphics[height=0.8em, totalheight=0.9em, width=0.9em, alt=KA logo]{https://katex.org/img/khan-academy.png}
KaTeX parse error: Undefined control sequence: \htmlId at position 1: \̲h̲t̲m̲l̲I̲d̲{bar}{x}\htmlId{bar}{x}
KaTeX parse error: Undefined control sequence: \htmlClass at position 1: \̲h̲t̲m̲l̲C̲l̲a̲s̲s̲{foo}{x}\htmlClass{foo}{x}
KaTeX parse error: Undefined control sequence: \htmlStyle at position 1: \̲h̲t̲m̲l̲S̲t̲y̲l̲e̲{color: red;}{x…\htmlStyle{color: red;}{x}
KaTeX parse error: Undefined control sequence: \htmlData at position 1: \̲h̲t̲m̲l̲D̲a̲t̲a̲{foo=a, bar=b}{…\htmlData{foo=a, bar=b}{x}

\includegraphics supports height, width, totalheight, and alt in its first argument. height is required.
\includegraphics 第一个参数支持 height, width, totalheight, 和 alt . height 是必需的。

HTML extension (\html-prefixed) commands are non-standard, so loosening strict option for htmlExtension is required.
HTML扩展(\ HTML前缀)命令是非标准的,因此需要对设置中的strict->htmlExtension参数进行配置才能用。(PS:此处配置是针对Katex开发者)

Letters and Unicode 字母和Unicode

Greek Letters
希腊字母

Direct Input : A B Γ Δ E Z H Θ I K Λ M N Ξ O Π P Σ T Υ Φ X Ψ Ω Α Β Γ Δ Ε Ζ Η Θ Ι \allowbreak Κ Λ Μ Ν Ξ Ο Π Ρ Σ Τ Υ Φ Χ Ψ Ω ABΓΔEZHΘIKΛMNΞOΠPΣTΥΦXΨΩ α β γ δ ϵ ζ η θ ι κ λ μ ν ξ o π ρ σ τ υ ϕ χ ψ ω ε ϑ ϖ ϱ ς φ ϝ \allowbreak α β γ δ ϵ ζ η θ ι κ λ μ ν ξ o π \allowbreak ρ σ τ υ ϕ χ ψ ω ε ϑ ϖ ϱ ς φ ϝ αβγδϵζηθικλμνξoπρστυϕχψωεϑϖϱςφϝ
可以直接输入上面的字母

A \Alpha A \Alpha B \Beta B \Beta Γ \Gamma Γ \Gamma Δ \Delta Δ \Delta
E \Epsilon E \Epsilon Z \Zeta Z \Zeta H \Eta H \Eta Θ \Theta Θ \Theta
I \Iota I \Iota K \Kappa K \Kappa Λ \Lambda Λ \Lambda M \Mu M \Mu
N \Nu N \Nu Ξ \Xi Ξ \Xi O \Omicron O \Omicron Π \Pi Π \Pi
P \Rho P \Rho Σ \Sigma Σ \Sigma T \Tau T \Tau Υ \Upsilon Υ \Upsilon
Φ \Phi Φ \Phi X \Chi X \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 σ \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

Other Letters
其他字母

ı \imath ı \imath ∇ \nabla \nabla ℑ \Im \Im R \Reals R \Reals Œ \text{\OE} Œ \text{\OE}
ȷ \jmath ȷ \jmath ∂ \partial \partial ℑ \image \image ℘ \wp \wp ø \text{\o} ø \text{\o}
ℵ \aleph \aleph ⅁ \Game \Game k \Bbbk k \Bbbk ℘ \weierp \weierp Ø \text{\O} Ø \text{\O}
ℵ \alef \alef Ⅎ \Finv \Finv N \N N \N Z \Z Z \Z ß \text{\ss} ß \text{\ss}
ℵ \alefsym \alefsym C \cnums C \cnums N \natnums N \natnums a ˚ \text{\aa} a˚ \text{\aa} ı \text{\i} ı \text{\i}
ℶ \beth \beth C \Complex C \Complex R \R R \R A ˚ \text{\AA} A˚ \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 \hslash R \reals R \reals œ \text{\oe} œ \text{\oe}

Direct Input: ∂ ∇ ℑ Ⅎ ℵ ℶ ℷ ℸ ⅁ ℏ ð ∂ ∇ ℑ Ⅎ ℵ ℶ ℷ ℸ ⅁ ℏ ð ðÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖÙÚÛÜÝÞßàáâãäåçèéêëìíîïðñòóôöùúûüýþÿ
可以直接输入上面的字母

Unicode Mathematical Alphanumeric Symbols
Unicode数学字母数字符号

下图是原符号,看样子CSDN的KaTex版本不支持显示

ItemRangeItemRange
Bold𝐀-𝐙 𝐚-𝐳 𝟎-𝟗Double-struck𝔸-ℤ 𝕜
Italic𝐴-𝑍 𝑎-𝑧Sans serif𝖠-𝖹 𝖺-𝗓 𝟢-𝟫
Bold Italic𝑨-𝒁 𝒂-𝒛Sans serif bold𝗔-𝗭 𝗮-𝘇 𝟬-𝟵
Script𝒜-𝒵Sans serif italic𝘈-𝘡 𝘢-𝘻
Fractur𝔞-𝔷Monospace𝙰-𝚉 𝚊-𝚣 𝟶-𝟿

Unicode

The letters listed above will render properly in any KaTeX rendering mode.
上面列出的字母将在KaTeX渲染模式下渲染。

In addition, Brahmic, Georgian, Chinese, Japanese, and Korean glyphs are always accepted in text mode. However, these glyphs will be rendered from system fonts (not KaTeX-supplied fonts) so their typography may clash.
You can provide rules for CSS classes .latin-fallback, .cyrillic-fallback, .brahmic-fallback, .georgian-fallback, .cjk-fallback, and .hangul-fallback to provide fallback fonts for these languages.
此外,梵文、格鲁吉亚文、中文、日文和韩文的字形可以在文本模式下显示。然而,这些字形将从系统字体(而不是katex提供的字体)呈现,因此它们的排版可能会冲突。
你可以设置.latin-fallback, .cyrillic-fallback, .brahmic-fallback, .georgian-fallback, .cjk-fallback, and .hangul-fallback这些CSS类规则,以给这些语言支持提供备用字体。

Use of these glyphs may cause small vertical alignment issues: KaTeX has detailed metrics for listed symbols and most Latin, Greek, and Cyrillic letters, but other accepted glyphs are treated as if they are each as tall as the letter M in the current KaTeX font.
使用这些符号可能会导致垂直对齐的小问题:KaTeX对列出的符号和大多数拉丁、希腊和西里尔字母都有详细的度量,但是其他公认的符号都被视为与当前KaTeX字体中的字母M一样高。

If the KaTeX rendering mode is set to strict: false or strict: "warn" (default), then KaTeX will accept all Unicode letters in both text and math mode.
如果KaTeX渲染模式设置为strict: falsestrict: "warn"(默认),那么KaTeX将接受所有的Unicode字符,包括文本和数学模式。

All unrecognized characters will be treated as if they appeared in text mode, and are subject to the same issues of using system fonts and possibly using incorrect vertical alignment.
所有无法识别的字符将被视为在文本模式下出现的字符,并受到系统字体和垂直对齐问题的影响。

For Persian composite characters, a user-supplied plug-in is under development.
对于波斯语合成字符,用户提供的 插件 正在开发中。

Layout 布局

Annotation 注释

5 \cancel{5} 5 \cancel{5} a + b + c ⏞ note \overbrace{a+b+c}^{\text{note}} a+b+c note \overbrace{a+b+c}^{\text{note}}
5 \bcancel{5} 5 \bcancel{5} a + b + c ⏟ note \underbrace{a+b+c}_{\text{note}} note a+b+c \underbrace{a+b+c}_{\text{note}}
A B C \xcancel{ABC} ABC \xcancel{ABC} ≠ \not = = \not =
a b c \sout{abc} abc \sout{abc} π = c d \boxed{\pi=\frac c d} π=dc \boxed{\pi=\frac c d}

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

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

Line Breaks 换行符

KaTeX 0.10.0+ will insert automatic line breaks in inline math after relations or binary operators such as “=” or “+”. These can be suppressed by \nobreak or by placing math inside a pair of braces, as in {F=ma}. \allowbreak will allow automatic line breaks at locations other than relations or operators.
KaTeX 0.10.0之后的版本将在关系或二进制操作符(如“=”或“+”)之后插入自动换行符。可以通过 \nobreak或用大括号来阻止,如{F=ma}\allowbreak将允许在关系或操作符以外的位置自动换行。

Hard line breaks are \\ and \newline.
硬换行符是\\\newline

In display math, KaTeX does not insert automatic line breaks. It ignores display math hard line breaks when rendering option strict: true.
在显示数学公式时,KaTeX不插入自动换行符。当渲染选项strict: true时,它会忽略硬换行符。

Vertical Layout 垂直布局

x n x_n xn x_n = ! \stackrel{!}{=} =! \stackrel{!}{=} a b a \atop b ba a \atop b
e x e^x ex e^x = ! \overset{!}{=} =! \overset{!}{=} a b c a\raisebox{0.25em}{b}c abc a\raisebox{0.25em}{b}c
u o _u^o uo _u^o = ! \underset{!}{=} != \underset{!}{=} ∑ 0 < i < m 0 < j < n \sum\limits_{0<i<m\atop0<j<n} 0<j<n0<i<m \sum\limits_{0<i<m\atop0<j<n}

PS:下面这个用不了,用\sum\limits_{0<i<m\atop0<j<n}代替 ∑ 0 < i < m 0 < j < n \sum\limits_{0<i<m\atop0<j<n} 0<j<n0<i<m
KaTeX parse error: Undefined control sequence: \substack at position 7: \sum_{\̲s̲u̲b̲s̲t̲a̲c̲k̲{0<i<m\\0<j<n}} \sum_{\substack{0<i<m\\0<j<n}}

The second argument of \raisebox can contain math if it is nested within $…$ delimiters, as in \raisebox{0.25em}{$\frac a b$}
'\raisebox’的第二个参数可以包含数学,如果它嵌套在$…$分隔符内,如\raisebox{0.25em}{$\frac a b$}

Overlap and Spacing 重叠和间距

= /   {=}\mathllap{/\,} =/ {=}\mathllap{/\,} ( x 2 ) \left(x^{\smash{2}}\right) (x2) \left(x^{\smash{2}}\right)
  / = \mathrlap{\,/}{=} /= \mathrlap{\,/}{=} y \sqrt{\smash[b]{y}} y \sqrt{\smash[b]{y}}

∑ 1 ≤ i ≤ j ≤ n x i j \displaystyle\sum_{\mathclap{1\le i\le j\le n}} x_{ij} 1ijnxij \sum_{\mathclap{1\le i\le j\le n}} x_{ij}

KaTeX also supports \llap, \rlap, and \clap, but they will take only text, not math, as arguments.
KaTeX也支持\llap, \rlap, and \clap,但是它们的参数只接受文本,不接受数学。

Spacing
间距

FunctionProducesFunctionProduces
\,³∕₁₈ em space\kern{distance}space, width = distance
\thinspace³∕₁₈ em space\mkern{distance}space, width = distance
\>⁴∕₁₈ em space\mskip{distance}space, width = distance
\:⁴∕₁₈ em space\hskip{distance}space, width = distance
\medspace⁴∕₁₈ em space\hspace{distance}space, width = distance
\;⁵∕₁₈ em space\hspace*{distance}space, width = distance
\thickspace⁵∕₁₈ em space\phantom{content}space the width and height of content
\enspace½ em space\hphantom{content}space the width of content
\quad1 em space\vphantom{content}a strut the height of content
\qquad2 em space\!– ³∕₁₈ em space
~non-breaking space\negthinspace– ³∕₁₈ em space
\<space>space\negmedspace– ⁴∕₁₈ em space
\nobreakspacenon-breaking space\negthickspace– ⁵∕₁₈ em space
\spacespace

Notes:
注意:
distance will accept any of the KaTeX units.
distance接受任何KaTeX单位

\kern, \mkern, \mskip, and \hspace accept unbraced distances, as in: \kern1em.
\kern, \mkern, \mskip, and \hspace 接受宽松的写法如: \kern1em.

\mkern and \mskip will not work in text mode and both will write a console warning for any unit except mu.
\mkern\mskip在文本模式下无效,除了 mu,其他的单位都会在控制台输出警告。

Logic and Set Theory 逻辑与集合论

∀ \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 or \lnot

Direct Input: ∀ ∴ ∁ ∵ ∃ ∣ ∈ ∉ ∋ ⊂ ⊃ ∧ ∨ ↦ → ← ↔ ¬ ∀ ∴ ∁ ∵ ∃ ∣ ∈ ∉ ∋ ⊂ ⊃ ∧ ∨ ↦ → ← ↔ ¬ /¬ ℂ ℍ ℕ ℙ ℚ ℝ
可以直接输入上面的符号

Macros 宏

x 2 + x 2 \def\foo{x^2} \foo + \foo x2+x2\def\foo{x^2} \foo + \foo
y 2 + y 2 \gdef\bar#1{#1^2} \bar{y} + \bar{y} y2+y2\gdef\bar#1{#1^2} \bar{y} + \bar{y}
\global\def\macroname#1#2…{definition}
\newcommand\macroname[numargs]{definition}
\renewcommand\macroname[numargs]{definition}
\providecommand\macroname[numargs]{definition}

Macros can also be defined in the KaTeX rendering options.
宏也可以在KaTeX渲染选项中定义。

Macros accept up to nine arguments: #1, #2, etc.
宏最多接受9个参数:#1,#2等。

\gdef and \global\def macros will persist between math expressions.
\gdef and \global\def宏具有全局性,在数学表达式之间持久存在。

Available functions include:
可用函数有:

\char \mathchoice \TextOrMath \@ifstar \@ifnextchar \@firstoftwo \@secondoftwo \relax

@ is a valid character for commands, as if \makeatletter were in effect.
@是命令的有效字符,就好像 \makeatletter 是有效的一样。

Operators 运算符

Big Operators 大运算符

∑ \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

Direct Input: ∫ ∬ ∭ ∮ ∏ ∐ ∑ ⋀ ⋁ ⋂ ⋃ ⨀ ⨁ ⨂ ⨄ ⨆ ∫ ∬ ∭ ∮ ∏ ∐ ∑ ⋀ ⋁ ⋂ ⋃ ⨀ ⨁ ⨂ ⨄ ⨆
也可以直接输入上述符号

Binary Operators 二元运算符

+ + + + ⋅ \cdot \cdot ⋗ \gtrdot \gtrdot x ( m o d a ) x \pmod a x(moda) x \pmod a
− - - ⋅ \cdotp \cdotp ⊺ \intercal \intercal x ( a ) x \pod a x(a) x \pod a
/ / / / ⋅ \centerdot \centerdot ∧ \land \land ⊳ \rhd \rhd
∗ * * ∘ \circ \circ ⋋ \leftthreetimes \leftthreetimes ⋌ \rightthreetimes \rightthreetimes
⨿ \amalg ⨿ \amalg ⊛ \circledast \circledast . \ldotp . \ldotp ⋊ \rtimes \rtimes
& \And & \And ⊚ \circledcirc \circledcirc ∨ \lor \lor ∖ \setminus \setminus
∗ \ast \ast ⊝ \circleddash \circleddash ⋖ \lessdot \lessdot ∖ \smallsetminus \smallsetminus
⊼ \barwedge \barwedge ⋓ \Cup \Cup ⊲ \lhd \lhd ⊓ \sqcap \sqcap
◯ \bigcirc \bigcirc ∪ \cup \cup ⋉ \ltimes \ltimes ⊔ \sqcup \sqcup
  m o d   \bmod mod \bmod ⋎ \curlyvee \curlyvee x m o d    a x \mod a xmoda x\mod a × \times × \times
⊡ \boxdot \boxdot ⋏ \curlywedge \curlywedge ∓ \mp \mp ⊴ \unlhd \unlhd
⊟ \boxminus \boxminus ÷ \div ÷ \div ⊙ \odot \odot ⊵ \unrhd \unrhd
⊞ \boxplus \boxplus ⋇ \divideontimes \divideontimes ⊖ \ominus \ominus ⊎ \uplus \uplus
⊠ \boxtimes \boxtimes ∔ \dotplus \dotplus ⊕ \oplus \oplus ∨ \vee \vee
∙ \bullet \bullet ⩞ \doublebarwedge \doublebarwedge ⊗ \otimes \otimes ⊻ \veebar \veebar
⋒ \Cap \Cap ⋒ \doublecap \doublecap ⊘ \oslash \oslash ∧ \wedge \wedge
∩ \cap \cap ⋓ \doublecup \doublecup ± \pm ± \pm or \plusmn ≀ \wr \wr

Direct Input: + − / ∗ ⋅ ± × ÷ ∓ ∔ ∧ ∨ ∩ ∪ ≀ ⊎ ⊓ ⊔ ⊕ ⊖ ⊗ ⊘ ⊙ ⊚ ⊛ ⊝ + - / * ⋅ ± × ÷ ∓ ∔ ∧ ∨ ∩ ∪ ≀ ⊎ ⊓ ⊔ ⊕ ⊖ ⊗ ⊘ ⊙ ⊚ ⊛ ⊝ +/±×÷
也可以直接输入上述符号

Fractions and Binomials 分数和二项式

a b \frac{a}{b} ba \frac{a}{b} a b \tfrac{a}{b} ba \tfrac{a}{b} ( a a + 1 ] \genfrac ( ] {2pt}{1}a{a+1} (a+1a] \genfrac ( ] {2pt}{1}a{a+1}
a b {a \over b} ba {a \over b} a b \dfrac{a}{b} ba \dfrac{a}{b} a b + 1 {a \above{2pt} b+1} b+1a {a \above{2pt} b+1}
a / b a/b a/b a/b a 1 + 1 b \cfrac{a}{1 + \cfrac{1}{b}} 1+b1a \cfrac{a}{1 + \cfrac{1}{b}}
( n k ) \binom{n}{k} (kn) \binom{n}{k} ( n k ) \dbinom{n}{k} (kn) \dbinom{n}{k} { n k } {n\brace k} {kn} {n\brace k}
( n k ) {n \choose k} (kn) {n \choose k} ( n k ) \tbinom{n}{k} (kn) \tbinom{n}{k} [ n k ] {n\brack k} [kn] {n\brack k}

Math Operators 数学运算符

arcsin ⁡ \arcsin arcsin \arcsin cotg ⁡ \cotg cotg \cotg ln ⁡ \ln ln \ln det ⁡ \det det \det
arccos ⁡ \arccos arccos \arccos coth ⁡ \coth coth \coth log ⁡ \log log \log gcd ⁡ \gcd gcd \gcd
arctan ⁡ \arctan arctan \arctan csc ⁡ \csc csc \csc sec ⁡ \sec sec \sec inf ⁡ \inf inf \inf
arctg ⁡ \arctg arctg \arctg ctg ⁡ \ctg ctg \ctg sin ⁡ \sin sin \sin lim ⁡ \lim lim \lim
arcctg ⁡ \arcctg arcctg \arcctg cth ⁡ \cth cth \cth sinh ⁡ \sinh sinh \sinh lim inf ⁡ \liminf liminf \liminf
arg ⁡ \arg arg \arg deg ⁡ \deg deg \deg sh ⁡ \sh sh \sh lim sup ⁡ \limsup limsup \limsup
ch ⁡ \ch ch \ch dim ⁡ \dim dim \dim tan ⁡ \tan tan \tan max ⁡ \max max \max
cos ⁡ \cos cos \cos exp ⁡ \exp exp \exp tanh ⁡ \tanh tanh \tanh min ⁡ \min min \min
cosec ⁡ \cosec cosec \cosec hom ⁡ \hom hom \hom tg ⁡ \tg tg \tg Pr ⁡ \Pr Pr \Pr
cosh ⁡ \cosh cosh \cosh ker ⁡ \ker ker \ker th ⁡ \th th \th sup ⁡ \sup sup \sup
cot ⁡ \cot cot \cot lg ⁡ \lg lg \lg arg max ⁡ \argmax argmax \argmax arg min ⁡ \argmin argmin \argmin
p l i m plim plim \plim f ⁡ \operatorname{f} f \operatorname{f} * ⁡ f \operatorname*{f} *f \operatorname*{f}

(PS:不支持 p l i m plim plim
Functions on the right column of this table can take \limits.
此表右列中的函数可以接受\limits

\sqrt 平方根

x \sqrt{x} x \sqrt{x}

x 3 \sqrt[3]{x} 3x \sqrt[3]{x}

Relations 关系符

= ! \stackrel{!}{=} =! \stackrel{!}{=}

= = = = ≖ \eqcirc \eqcirc ⋚ \lesseqgtr \lesseqgtr ⊐ \sqsupset \sqsupset
< < < < ∹ \eqcolon : \eqcolon ⪋ \lesseqqgtr \lesseqqgtr ⊒ \sqsupseteq \sqsupseteq
> > > > − ∷ \Eqcolon :: \Eqcolon ≶ \lessgtr \lessgtr ⋐ \Subset \Subset
: : : : ≕ \eqqcolon =: \eqqcolon ≲ \lesssim \lesssim ⊂ \subset \subset or \sub
≈ \approx \approx = ∷ \Eqqcolon =:: \Eqqcolon ≪ \ll \ll ⊆ \subseteq \subseteq or \sube
≊ \approxeq \approxeq ≂ \eqsim \eqsim ⋘ \lll \lll ⫅ \subseteqq \subseteqq
≍ \asymp \asymp ⪖ \eqslantgtr \eqslantgtr ⋘ \llless \llless ≻ \succ \succ
∍ \backepsilon \backepsilon ⪕ \eqslantless \eqslantless < \lt < \lt ⪸ \succapprox \succapprox
∽ \backsim \backsim ≡ \equiv \equiv ∣ \mid \mid ≽ \succcurlyeq \succcurlyeq
⋍ \backsimeq \backsimeq ≒ \fallingdotseq \fallingdotseq ⊨ \models \models ⪰ \succeq \succeq
≬ \between \between ⌢ \frown \frown ⊸ \multimap \multimap ≿ \succsim \succsim
⋈ \bowtie \bowtie ≥ \ge \ge ∋ \owns \owns ⋑ \Supset \Supset
≏ \bumpeq \bumpeq ≥ \geq \geq ∥ \parallel \parallel ⊃ \supset \supset
≎ \Bumpeq \Bumpeq ≧ \geqq \geqq ⊥ \perp \perp ⊇ \supseteq \supseteq or \supe
≗ \circeq \circeq ⩾ \geqslant \geqslant ⋔ \pitchfork \pitchfork ⫆ \supseteqq \supseteqq
: ≈ \colonapprox : \colonapprox ≫ \gg \gg ≺ \prec \prec ≈ \thickapprox \thickapprox
∷ ≈ \Colonapprox :: \Colonapprox ⋙ \ggg \ggg ⪷ \precapprox \precapprox ∼ \thicksim \thicksim
: − \coloneq : \coloneq ⋙ \gggtr \gggtr ≼ \preccurlyeq \preccurlyeq ⊴ \trianglelefteq \trianglelefteq
∷ − \Coloneq :: \Coloneq > \gt > \gt ⪯ \preceq \preceq ≜ \triangleq \triangleq
≔ \coloneqq := \coloneqq ⪆ \gtrapprox \gtrapprox ≾ \precsim \precsim ⊵ \trianglerighteq \trianglerighteq
∷ = \Coloneqq ::= \Coloneqq ⋛ \gtreqless \gtreqless ∝ \propto \propto ∝ \varpropto \varpropto
: ∼ \colonsim : \colonsim ⪌ \gtreqqless \gtreqqless ≓ \risingdotseq \risingdotseq △ \vartriangle \vartriangle
∷ ∼ \Colonsim :: \Colonsim ≷ \gtrless \gtrless ∣ \shortmid \shortmid ⊲ \vartriangleleft \vartriangleleft
≅ \cong \cong ≳ \gtrsim \gtrsim ∥ \shortparallel \shortparallel ⊳ \vartriangleright \vartriangleright
⋞ \curlyeqprec \curlyeqprec ∈ \in \in or \isin ∼ \sim \sim : \vcentcolon : \vcentcolon
⋟ \curlyeqsucc \curlyeqsucc ⋈ \Join \Join ≃ \simeq \simeq ⊢ \vdash \vdash
⊣ \dashv \dashv ≤ \le \le ⌢ \smallfrown \smallfrown ⊨ \vDash \vDash
∷ \dblcolon :: \dblcolon ≤ \leq \leq ⌣ \smallsmile \smallsmile ⊩ \Vdash \Vdash
≐ \doteq \doteq ≦ \leqq \leqq ⌣ \smile \smile ⊪ \Vvdash \Vvdash
≑ \Doteq \Doteq ⩽ \leqslant \leqslant ⊏ \sqsubset \sqsubset
≑ \doteqdot \doteqdot ⪅ \lessapprox \lessapprox ⊑ \sqsubseteq \sqsubseteq

Direct Input: = < > : ∈ ∋ ∝ ∼ ∽ ≂ ≃ ≅ ≈ ≊ ≍ ≎ ≏ ≐ ≑ ≒ ≓ ≖ ≗ ≜ ≡ ≤ ≥ ≦ ≧ ≫ ≬ ≳ ≷ ≺ ≻ ≼ ≽ ≾ ≿ ⊂ ⊃ ⊆ ⊇ ⊏ ⊐ ⊑ ⊒ ⊢ ⊣ ⊩ ⊪ ⊸ ⋈ ⋍ ⋐ ⋑ ⋔ ⋙ ⋛ ⋞ ⋟ ⌢ ⌣ ⩾ ⪆ ⪌ ⪕ ⪖ ⪯ ⪰ ⪷ ⪸ ⫅ ⫆ ≲ ⩽ ⪅ ≶ ⋚ ⪋ ⊥ ⊨ = < > : ∈ ∋ ∝ ∼ ∽ ≂ ≃ ≅ ≈ ≊ ≍ ≎ ≏ ≐ ≑ ≒ ≓ ≖ ≗ ≜ ≡ ≤ ≥ ≦ ≧ ≫ ≬ ≳ ≷ ≺ ≻ ≼ ≽ ≾ ≿ ⊂ ⊃ ⊆ ⊇ ⊏ ⊐ ⊑ ⊒ ⊢ ⊣ ⊩ ⊪ ⊸ ⋈ ⋍ ⋐ ⋑ ⋔ ⋙ ⋛ ⋞ ⋟ ⌢ ⌣ ⩾ ⪆ ⪌ ⪕ ⪖ ⪯ ⪰ ⪷ ⪸ ⫅ ⫆ ≲ ⩽ ⪅ ≶ ⋚ ⪋ ⟂ ⊨ =<>: ≔ ≕ ⩴
上述符号可以直接输入

Negated Relations 否定关系

≠ \not = = \not =

⪊ \gnapprox \gnapprox ≱ \ngeqslant \ngeqslant ⊈ \nsubseteq \nsubseteq ⪵ \precneqq \precneqq
⪈ \gneq \gneq ≯ \ngtr \ngtr ⊈ \nsubseteqq \nsubseteqq ⋨ \precnsim \precnsim
≩ \gneqq \gneqq ≰ \nleq \nleq ⊁ \nsucc \nsucc ⊊ \subsetneq \subsetneq
⋧ \gnsim \gnsim ≰ \nleqq \nleqq ⋡ \nsucceq \nsucceq ⫋ \subsetneqq \subsetneqq
≩ \gvertneqq \gvertneqq ≰ \nleqslant \nleqslant ⊉ \nsupseteq \nsupseteq ⪺ \succnapprox \succnapprox
⪉ \lnapprox \lnapprox ≮ \nless \nless ⊉ \nsupseteqq \nsupseteqq ⪶ \succneqq \succneqq
⪇ \lneq \lneq ∤ \nmid \nmid ⋪ \ntriangleleft \ntriangleleft ⋩ \succnsim \succnsim
≨ \lneqq \lneqq ∉ \notin / \notin ⋬ \ntrianglelefteq \ntrianglelefteq ⊋ \supsetneq \supsetneq
⋦ \lnsim \lnsim ∌ \notni \notni ⋫ \ntriangleright \ntriangleright ⫌ \supsetneqq \supsetneqq
≨ \lvertneqq \lvertneqq ∦ \nparallel \nparallel ⋭ \ntrianglerighteq \ntrianglerighteq ⊊ \varsubsetneq \varsubsetneq
≆ \ncong \ncong ⊀ \nprec \nprec ⊬ \nvdash \nvdash ⫋ \varsubsetneqq \varsubsetneqq
≠ \ne = \ne ⋠ \npreceq \npreceq ⊭ \nvDash \nvDash ⊋ \varsupsetneq \varsupsetneq
≠ \neq = \neq ∤ \nshortmid \nshortmid ⊯ \nVDash \nVDash ⫌ \varsupsetneqq \varsupsetneqq
≱ \ngeq \ngeq ∦ \nshortparallel \nshortparallel ⊮ \nVdash \nVdash
≱ \ngeqq \ngeqq ≁ \nsim \nsim ⪹ \precnapprox \precnapprox

Direct Input: ∉ ∌ ∤ ∦ ≁ ≆ ≠ ≨ ≩ ≮ ≯ ≰ ≱ ⊀ ⊁ ⊈ ⊉ ⊊ ⊋ ⊬ ⊭ ⊮ ⊯ ⋠ ⋡ ⋦ ⋧ ⋨ ⋩ ⋬ ⋭ ⪇ ⪈ ⪉ ⪊ ⪵ ⪶ ⪹ ⪺ ⫋ ⫌ ∉ ∌ ∤ ∦ ≁ ≆ ≠ ≨ ≩ ≮ ≯ ≰ ≱ ⊀ ⊁ ⊈ ⊉ ⊊ ⊋ ⊬ ⊭ ⊮ ⊯ ⋠ ⋡ ⋦ ⋧ ⋨ ⋩ ⋬ ⋭ ⪇ ⪈ ⪉ ⪊ ⪵ ⪶ ⪹ ⪺ ⫋ ⫌ /=
上述符号可以直接输入

Arrows 箭头

↺ \circlearrowleft \circlearrowleft ↼ \leftharpoonup \leftharpoonup ⇒ \rArr \rArr
↻ \circlearrowright \circlearrowright ⇇ \leftleftarrows \leftleftarrows → \rarr \rarr
↶ \curvearrowleft \curvearrowleft ↔ \leftrightarrow \leftrightarrow ↾ \restriction \restriction
↷ \curvearrowright \curvearrowright ⇔ \Leftrightarrow \Leftrightarrow → \rightarrow \rightarrow
⇓ \Darr \Darr ⇆ \leftrightarrows \leftrightarrows ⇒ \Rightarrow \Rightarrow
⇓ \dArr \dArr ⇋ \leftrightharpoons \leftrightharpoons ↣ \rightarrowtail \rightarrowtail
↓ \darr \darr ↭ \leftrightsquigarrow \leftrightsquigarrow ⇁ \rightharpoondown \rightharpoondown
⇠ \dashleftarrow \dashleftarrow ⇚ \Lleftarrow \Lleftarrow ⇀ \rightharpoonup \rightharpoonup
⇢ \dashrightarrow \dashrightarrow ⟵ \longleftarrow \longleftarrow ⇄ \rightleftarrows \rightleftarrows
↓ \downarrow \downarrow ⟸ \Longleftarrow \Longleftarrow ⇌ \rightleftharpoons \rightleftharpoons
⇓ \Downarrow \Downarrow ⟷ \longleftrightarrow \longleftrightarrow ⇉ \rightrightarrows \rightrightarrows
⇊ \downdownarrows \downdownarrows ⟺ \Longleftrightarrow \Longleftrightarrow ⇝ \rightsquigarrow \rightsquigarrow
⇃ \downharpoonleft \downharpoonleft ⟼ \longmapsto \longmapsto ⇛ \Rrightarrow \Rrightarrow
⇂ \downharpoonright \downharpoonright ⟶ \longrightarrow \longrightarrow ↱ \Rsh \Rsh
← \gets \gets ⟹ \Longrightarrow \Longrightarrow ↘ \searrow \searrow
⇔ \Harr \Harr ↫ \looparrowleft \looparrowleft ↙ \swarrow \swarrow
⇔ \hArr \hArr ↬ \looparrowright \looparrowright → \to \to
↔ \harr \harr ⇔ \Lrarr \Lrarr ↞ \twoheadleftarrow \twoheadleftarrow
↩ \hookleftarrow \hookleftarrow ⇔ \lrArr \lrArr ↠ \twoheadrightarrow \twoheadrightarrow
↪ \hookrightarrow \hookrightarrow ↔ \lrarr \lrarr ⇑ \Uarr \Uarr
   ⟺    \iff \iff ↰ \Lsh \Lsh ⇑ \uArr \uArr
   ⟸    \impliedby \impliedby ↦ \mapsto \mapsto ↑ \uarr \uarr
   ⟹    \implies \implies ↗ \nearrow \nearrow ↑ \uparrow \uparrow
⇐ \Larr \Larr ↚ \nleftarrow \nleftarrow ⇑ \Uparrow \Uparrow
⇐ \lArr \lArr ⇍ \nLeftarrow \nLeftarrow ↕ \updownarrow \updownarrow
← \larr \larr ↮ \nleftrightarrow \nleftrightarrow ⇕ \Updownarrow \Updownarrow
⇝ \leadsto \leadsto ⇎ \nLeftrightarrow \nLeftrightarrow ↿ \upharpoonleft \upharpoonleft
← \leftarrow \leftarrow ↛ \nrightarrow \nrightarrow ↾ \upharpoonright \upharpoonright
⇐ \Leftarrow \Leftarrow ⇏ \nRightarrow \nRightarrow ⇈ \upuparrows \upuparrows
↢ \leftarrowtail \leftarrowtail ↖ \nwarrow \nwarrow
↽ \leftharpoondown \leftharpoondown ⇒ \Rarr \Rarr

Direct Input: ← ↑ → ↓ ↔ ↕ ↖ ↗ ↘ ↙ ↚ ↛ ↞ ↠ ↢ ↣ ↦ ↩ ↪ ↫ ↬ ↭ ↮ ↰ ↱ ↶ ↷ ↺ ↻ ↼ ↽ ↾ ↾ ↿ ⇀ ⇁ ⇂ ⇃ ⇄ ⇆ ⇇ ⇈ ⇉ ⇊ ⇋ ⇌ ⇍ ⇎ ⇏ ⇐ ⇑ ⇒ ⇓ ⇔ ⇕ ⇚ ⇛ ⇝ ⇠ ⇢ ⟵ ⟶ ⟷ ⟸ ⟹ ⟺ ⟼ ← ↑ → ↓ ↔ ↕ ↖ ↗ ↘ ↙ ↚ ↛ ↞ ↠ ↢ ↣ ↦ ↩ ↪ ↫ ↬ ↭ ↮ ↰ ↱↶ ↷ ↺ ↻ ↼ ↽ ↾ ↾ ↿ ⇀ ⇁ ⇂ ⇃ ⇄ ⇆ ⇇ ⇈ ⇉ ⇊ ⇋ ⇌⇍ ⇎ ⇏ ⇐ ⇑ ⇒ ⇓ ⇔ ⇕ ⇚ ⇛ ⇝ ⇠ ⇢ ⟵ ⟶ ⟷ ⟸ ⟹ ⟺ ⟼
上述符号可以直接输入

Extensible Arrows
扩展箭头

← a b c \xleftarrow{abc} abc \xleftarrow{abc} → u n d e r o v e r \xrightarrow[under]{over} over under \xrightarrow[under]{over}
⇐ a b c \xLeftarrow{abc} abc \xLeftarrow{abc} ⇒ a b c \xRightarrow{abc} abc \xRightarrow{abc}
↔ a b c \xleftrightarrow{abc} abc \xleftrightarrow{abc} ⇔ a b c \xLeftrightarrow{abc} abc \xLeftrightarrow{abc}
↩ a b c \xhookleftarrow{abc} abc \xhookleftarrow{abc} ↪ a b c \xhookrightarrow{abc} abc \xhookrightarrow{abc}
↞ a b c \xtwoheadleftarrow{abc} abc \xtwoheadleftarrow{abc} ↠ a b c \xtwoheadrightarrow{abc} abc \xtwoheadrightarrow{abc}
↼ a b c \xleftharpoonup{abc} abc \xleftharpoonup{abc} ⇀ a b c \xrightharpoonup{abc} abc \xrightharpoonup{abc}
↽ a b c \xleftharpoondown{abc} abc \xleftharpoondown{abc} ⇁ a b c \xrightharpoondown{abc} abc \xrightharpoondown{abc}
⇋ a b c \xleftrightharpoons{abc} abc \xleftrightharpoons{abc} ⇌ a b c \xrightleftharpoons{abc} abc \xrightleftharpoons{abc}
⇄ a b c \xtofrom{abc} abc \xtofrom{abc} ↦ a b c \xmapsto{abc} abc \xmapsto{abc}
= a b c \xlongequal{abc} abc \xlongequal{abc}

Extensible arrows all can take an optional argument in the same manner
as \xrightarrow[under]{over}.
可扩展箭头都可以接受可选参数,如\xrightarrow[under]{over}

Style, Color, Size, and Font 样式、颜色、大小和字体

Class Assignment

\mathbin \mathclose \mathinner \mathop

\mathopen \mathord \mathpunct \mathrel

Color
颜色

F = m a \color{blue} F=ma F=ma \color{blue} F=ma

Note that KaTeX \color acts like a switch. This aligns with LaTeX and differs from MathJax.
Other KaTeX color functions expect the content to be a function argument:
注意,KaTeX的\color就像一个开关。这与LaTeX一致,与MathJax不同。
其他KaTeX颜色函数是将文字作为参数使用的:

F = m a \textcolor{blue}{F=ma} F=ma \textcolor{blue}{F=ma}

F = m a \textcolor{#228B22}{F=ma} F=ma \textcolor{#228B22}{F=ma}

A \colorbox{aqua}{A} A \colorbox{aqua}{A}

A \fcolorbox{red}{aqua}{A} A \fcolorbox{red}{aqua}{A}

For color definition, KaTeX color functions will accept the standard HTML predefined color names. They will also accept an RGB argument in CSS hexa­decimal style. The “#” is optional before a six-digit specification.
对于颜色定义,KaTeX颜色函数将接受标准的HTML预定义颜色名称。也接受CSS十六进制风格的RGB参数。“#”是六位数字规范之前的可选选项。

Font
字体

A b 0 \mathrm{Ab0} Ab0 \mathrm{Ab0} A b 0 \mathbf{Ab0} Ab0 \mathbf{Ab0} A b 0 \mathit{Ab0} Ab0 \mathit{Ab0}
A b 0 \mathnormal{Ab0} Ab0 \mathnormal{Ab0} Ab0 \textbf{Ab0} Ab0 \textbf{Ab0} Ab0 \textit{Ab0} Ab0 \textit{Ab0}
Ab0 \textrm{Ab0} Ab0 \textrm{Ab0} A b 0 \bf Ab0 Ab0 \bf Ab0 A b 0 \it Ab0 Ab0 \it Ab0
A b 0 \rm Ab0 Ab0 \rm Ab0 A b 0 \bold{Ab0} Ab0 \bold{Ab0} Ab0 \textup{Ab0} Ab0 \textup{Ab0}
Ab0 \textnormal{Ab0} Ab0 \textnormal{Ab0} A b 0 \boldsymbol{Ab0} Ab0 \boldsymbol{Ab} A B \Bbb{AB} AB \Bbb{AB}
Ab0 \text{Ab0} Ab0 \text{Ab0} A b 0 \bm{Ab0} Ab0 \bm{Ab0} A B \mathbb{AB} AB \mathbb{AB}
A b 0 \mathsf{Ab0} Ab0 \mathsf{Ab0} Ab0 \textmd{Ab0} Ab0 \textmd{Ab0} A b 0 \frak{Ab0} Ab0 \frak{Ab0}
Ab0 \textsf{Ab0} Ab0 \textsf{Ab0} A b 0 \mathtt{Ab0} Ab0 \mathtt{Ab0} A b 0 \mathfrak{Ab0} Ab0 \mathfrak{Ab0}
A b 0 \sf Ab0 Ab0 \sf Ab0 Ab0 \texttt{Ab0} Ab0 \texttt{Ab0} A B 0 \mathcal{AB0} AB0 \mathcal{AB0}
A b 0 \tt Ab0 Ab0 \tt Ab0 A B \mathscr{AB} AB \mathscr{AB}

One can stack font family, font weight, and font shape by using the \textXX versions of the font functions. So \textsf{\textbf{H}} will produce H \textsf{\textbf{H}} H. The other versions do not stack, e.g., \mathsf{\mathbf{H}} will produce H \mathsf{\mathbf{H}} H.
可以使用\textXX版本的字体函数来堆叠字体种类、权重和形状。所以 \textsf{\textbf{H}}将会产生 H \textsf{\textbf{H}} H。其他版本不堆叠,例如, \mathsf{\mathbf{H}}}将产生 H \mathsf{\mathbf{H}} H

In cases where KaTeX fonts do not have a bold glyph, \pmb can simulate one. For example, \pmb{\mu} renders as : μ \pmb{\mu} μμμ
在KaTeX字体没有粗体字形的情况下,\pmb可以模拟一个。例如,\pmb{\mu}呈现为: μ \pmb{\mu} μμμ

Size
大小

A B \Huge AB AB \Huge AB A B \normalsize AB AB \normalsize AB
A B \huge AB AB \huge AB A B \small AB AB \small AB
A B \LARGE AB AB \LARGE AB A B \footnotesize AB AB \footnotesize AB
A B \Large AB AB \Large AB A B \scriptsize AB AB \scriptsize AB
A B \large AB AB \large AB A B \tiny AB AB \tiny AB

Style
风格

∑ i = 1 n \displaystyle\sum_{i=1}^n i=1n \displaystyle\sum_{i=1}^n
∑ i = 1 n \textstyle\sum_{i=1}^n i=1n \textstyle\sum_{i=1}^n
x \scriptstyle x x \scriptstyle x         (The size of a first sub/superscript)
x \scriptscriptstyle x x \scriptscriptstyle x (The size of subsequent sub/superscripts)
lim ⁡ x \lim\limits_x xlim \lim\limits_x
lim ⁡ x \lim\nolimits_x limx \lim\nolimits_x
x^2 \verb!x^2! x^2 \verb!x^2!

\text{…} will accept nested $…$ fragments and render them in math mode.
\text{…}将接受嵌套的$…$片段,并以数学模式呈现它们。

Symbols and Punctuation 符号和标点符号

% comment … \dots \dots KaTeX \KaTeX KATEX \KaTeX
% \% % \% ⋯ \cdots \cdots LaTeX \LaTeX LATEX \LaTeX
# \# # \# ⋱ \ddots \ddots TeX \TeX TEX \TeX
& \& & \& … \ldots \ldots ∇ \nabla \nabla
_ \_ _ \_ ⋮ \vdots \vdots ∞ \infty \infty
_ \text{\textunderscore} _ \text{\textunderscore} ⋯ \dotsb \dotsb ∞ \infin \infin
– \text{--} \text{--} … \dotsc \dotsc ✓ \checkmark \checkmark
– \text{\textendash} \text{\textendash}  ⁣ ⋯ \dotsi \dotsi † \dag \dag
— \text{---} \text{---} ⋯ \dotsm \dotsm † \dagger \dagger
— \text{\textemdash} \text{\textemdash} … \dotso \dotso † \text{\textdagger} \text{\textdagger}
~ \text{\textasciitilde} ~ \text{\textasciitilde} ⋅ \sdot \sdot ‡ \ddag \ddag
^ \text{\textasciicircum} ^ \text{\textasciicircum} … \mathellipsis \mathellipsis ‡ \ddagger \ddagger
‘ ` ` … \text{\textellipsis} \text{\textellipsis} ‡ \text{\textdaggerdbl} \text{\textdaggerdbl}
‘ \text{\textquoteleft} text{\textquoteleft} □ \Box \Box ‡ \Dagger \Dagger
‘ \lq \lq □ \square \square ∠ \angle \angle
’ \text{\textquoteright} \text{\textquoteright} ■ \blacksquare \blacksquare ∡ \measuredangle \measuredangle
′ \rq \rq △ \triangle \triangle ∢ \sphericalangle \sphericalangle
“ \text{\textquotedblleft} \text{\textquotedblleft} ▽ \triangledown \triangledown ⊤ \top \top
" " " " ◃ \triangleleft \triangleleft ⊥ \bot \bot
” \text{\textquotedblright} \text{\textquotedblright} ▹ \triangleright \triangleright$$$ \$
 ⁣ : \colon : \colon ▽ \bigtriangledown \bigtriangledown $ \text{\textdollar} $ \text{\textdollar}
‵ \backprime \backprime △ \bigtriangleup \bigtriangleup £ \pounds £ \pounds
′ \prime \prime ▲ \blacktriangle \blacktriangle £ \mathsterling £ \mathsterling
< \text{\textless} < \text{\textless} ▼ \blacktriangledown \blacktriangledown £ \text{\textsterling} £ \text{\textsterling}
> \text{\textgreater} > \text{\textgreater} ◀ \blacktriangleleft \blacktriangleleft ¥ \yen ¥ \yen
| \text{\textbar} | \text{\textbar} ▶ \blacktriangleright \blacktriangleright √ \surd \surd
∥ \text{\textbardbl} \text{\textbardbl} ⋄ \diamond \diamond ° \degree ° \degree
{ \text{\textbraceleft} { \text{\textbraceleft} ◊ \Diamond \Diamond ° \text{\textdegree} ° \text{\textdegree}
} \text{\textbraceright} } \text{\textbraceright} ◊ \lozenge \lozenge ℧ \mho \mho
\ \text{\textbackslash} \ \text{\textbackslash} ⧫ \blacklozenge \blacklozenge ╲ \diagdown \diagdown
¶ \text{\P} \text{\P} ⋆ \star \star ╱ \diagup \diagup
§ \text{\S} § \text{\S} ★ \bigstar \bigstar ♭ \flat \flat
§ \text{\sect} § \text{\sect} ♣ \clubsuit \clubsuit ♮ \natural \natural
© \copyright c \copyright ♣ \clubs \clubs ♯ \sharp \sharp
® \circledR ® \circledR ♢ \diamondsuit \diamondsuit ♡ \heartsuit \heartsuit
® \text{\textregistered} R \text{\textregistered} ♢ \diamonds \diamonds ♡ \hearts \hearts
Ⓢ \circledS \circledS ♠ \spadesuit \spadesuit ♠ \spades \spades
a ◯ \text{\textcircled a} a \text{\textcircled a} ✠ \maltese \maltese

Direct Input: £ ¥ ∇ ∞ ⋅ ∠ ∡ ∢ ♠ ♡ ♢ ♣ ♭ ♮ ♯ ✓ … ⋮ ⋯ ⋱ ! £ ¥ ∇ ∞ · ∠ ∡ ∢ ♠ ♡ ♢ ♣ ♭ ♮ ♯ ✓ … ⋮ ⋯ ⋱ ! £¥!
上述符号可以直接输入

Units单位

In KaTeX, units are proportioned as they are in TeX.
在KaTeX中,单位的比例与在TeX中一样。

KaTeX units are different than CSS units.
KaTeX单位不同于CSS单位。

KaTeX UnitValueKaTeX UnitValue
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

where:

F = (font size of surrounding HTML text)/(10 pt)

G = 1.21 by default, because KaTeX font-size is normally 1.21 × the surrounding font size. This value can be overridden by the CSS of an HTML page.

此处:
F = (周围HTML文本的字体大小)/10pt
默认情况下G = 1.21,因为KaTeX的字体大小通常是1.21×周围的字体大小。这个值可以被HTML页面的CSS覆盖

The effect of style and size:
风格和大小的影响:

Unittextstylescriptscripthuge
em or ex \rule{1em}{1em} \scriptscriptstyle\rule{1em}{1em} \huge\rule{1em}{1em}
mu \rule{18mu}{18mu} \scriptscriptstyle\rule{18mu}{18mu} \huge\rule{18mu}{18mu}
others \rule{10pt}{10pt} \scriptscriptstyle\rule{10pt}{10pt} \huge\rule{10pt}{10pt}
KaTeX 是一款基于 TeX 的 JavaScript 引擎,用于在 Web 中渲染数学公式和数学符号。KaTeX 能够快速渲染数学公式,而且渲染出来的公式非常漂亮。本文将详细介绍 KaTeX 的使用方法。 ## 安装 KaTeX KaTeX 可以通过 npm 包管理工具进行安装,也可以通过 CDN 引入。本文将介绍两种安装方式。 ### 通过 npm 安装 KaTeX 可以通过以下命令在项目中安装 KaTeX: ``` npm install katex ``` ### 通过 CDN 引入 KaTeX 可以通过以下方式引入 KaTeX: ```html <head> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex/dist/katex.min.css" /> <script src="https://cdn.jsdelivr.net/npm/katex/dist/katex.min.js"></script> </head> ``` ## 渲染数学公式 ### 使用 KaTeX 渲染数学公式 在 HTML 中使用 KaTeX 渲染数学公式非常简单。只需要在需要渲染的数学公式所在的标签中添加 `katex` 类名,然后在标签内部添加 TeX 语法数学公式即可。 ```html <!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>KaTeX Demo</title> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex/dist/katex.min.css" /> <script src="https://cdn.jsdelivr.net/npm/katex/dist/katex.min.js"></script> </head> <body> <p class="katex">$$\sum_{i=1}^n i = \frac{n(n+1)}{2}$$</p> <p class="katex">\[\int_{-\infty}^{+\infty} e^{-x^2} dx = \sqrt{\pi}\]</p> </body> </html> ``` 在上面的代码中,我们在两个不同的段落中使用了 `katex` 类名,并在标签内部添加了 TeX 语法数学公式。 ### 使用 KaTeX API 渲染数学公式 KaTeX 提供了一组 API,可以在 JavaScript 中渲染数学公式。 ```html <!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>KaTeX Demo</title> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex/dist/katex.min.css" /> <script src="https://cdn.jsdelivr.net/npm/katex/dist/katex.min.js"></script> </head> <body> <p id="formula1"></p> <p id="formula2"></p> <script> const formula1 = document.getElementById("formula1"); katex.render("\\sum_{i=1}^n i = \\frac{n(n+1)}{2}", formula1); const formula2 = document.getElementById("formula2"); katex.render("\\int_{-\\infty}^{+\\infty} e^{-x^2} dx = \\sqrt{\\pi}", formula2); </script> </body> </html> ``` 在上面的代码中,我们在两个不同的段落中使用了 `id` 属性,并在 JavaScript 中使用 `katex.render` 方法渲染了数学公式。 ## KaTeX TeX 语法 KaTeX 使用 TeX 语法渲染数学公式,因此熟悉 TeX 语法可以帮助我们更好地使用 KaTeX。下面是一些常用的 TeX 语法: ### 希腊字母 ``` \alpha, \beta, \gamma, \delta, \epsilon, \varepsilon, \zeta, \eta, \theta, \vartheta, \iota, \kappa, \lambda, \mu, \nu, \xi, \pi, \varpi, \rho, \varrho, \sigma, \varsigma, \tau, \upsilon, \phi, \varphi, \chi, \psi, \omega ``` ### 上标和下标 ``` x^2, x_{1}, x_{i+1}, x^{2}_{i+1} ``` ### 分数 ``` \frac{a}{b} ``` ### 开平方 ``` \sqrt{2}, \sqrt[n]{a} ``` ### 求和、积分、极限 ``` \sum_{i=1}^n i, \int_{a}^{b} f(x) dx, \lim_{x\to\infty} f(x) ``` ### 矩阵 ``` \begin{matrix}a & b \\ c & d\end{matrix} ``` ### 其他符号 ``` \infty, \pm, \times, \div, \neq, \leq, \geq, \approx, \equiv, \subset, \subseteq, \cup, \cap, \forall, \exists, \in, \notin, \rightarrow, \leftarrow ``` ## 总结 本文介绍了 KaTeX 的安装和使用方法,并介绍了一些常用的 TeX 语法KaTeX 是一款非常强大的 JavaScript 引擎,可以帮助我们在 Web 中快速渲染数学公式和数学符号,非常适合用于科技类网站和博客。
评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值