typora常用的数学公式编辑语法

基本格式

上下标

\[A_1^2 \\ B_{12} \\ 2^{x^2+y} \]

A_1^2
\\
B_{12}
\\
2^{x^2+y}

分数

\[\frac{x}{1+x^2} \\ \frac{\frac{1}{2}+x}{y} \\ \tfrac{a}{b} \frac{a}{b} \]

\frac{x}{1+x^2}
\\
\frac{\frac{1}{2}+x}{y}
\\
\tfrac{a}{b}
\frac{a}{b}

开根

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

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

组合数

\[\binom{n}{k} \tbinom{n}{k} \]

\binom{n}{k}
\tbinom{n}{k}

导数

\[a' a'' a^{\prime} \]

偏微分

\[\partial \\ \nabla \]

a'
a''
a^{\prime}

取模

\[x \pmod a \\ 2\mod{x} \]

x \pmod a
\\
2\mod{x}

积分

\[\int_{1}^{2} \intop_{2}^{1} \oint \smallint \\ \iint \oiint \iiint \oiiint \]

\oiint和\oiiint在博客园中不能使用,对应的是带圆圈的二重和三重积分

\int_{1}^{2}
\intop_{2}^{1}
\oint
\smallint
\\
\iint
\oiint
\iiint
\oiiint

累加/累乘/极限

\[\sum_{i=1}^{k} \displaystyle\sum_{i=1}^n \textstyle\sum_{i=1}^n \\ \prod_{i=1}^{k} \displaystyle\prod_{i=1}^n \textstyle\prod_{i=1}^n \\ \lim_{k \to \infty} \lim\limits_{k \to \infty} \lim\nolimits_{k \to \infty} \]

\sum_{i=1}^{k}
\displaystyle\sum_{i=1}^n
\textstyle\sum_{i=1}^n
\\
\prod_{i=1}^{k}
\displaystyle\prod_{i=1}^n
\textstyle\prod_{i=1}^n
\\
\lim_{k \to \infty}
\lim\limits_{k \to \infty}
\lim\nolimits_{k \to \infty}

修饰符号

简单的帽子

\[\hat{\theta} \widehat{AB} \\ \bar{y} \overline{AB} \\ \tilde{a} \widetilde{ac} \\ \bar{a} \acute{a} \check{a} \grave{a} \\ \dot{a} \ddot{a} \]

\hat{\theta}
\widehat{AB}
\\
\bar{y}
\overline{AB}
\\
\tilde{a}
\widetilde{ac}
\\
\bar{a}
\acute{a}
\check{a}
\grave{a}
\\
\dot{a}
\ddot{a}

帽子和袜子

\[\overleftarrow{AB} \overrightarrow{AB} \overleftrightarrow{AB} \\ \underleftarrow{AB} \underrightarrow{AB} \underleftrightarrow{AB} \\ \overbrace{AB} \underbrace{AB} \\ \overline{AB} \underline{AB} \]

\overleftarrow{AB}
\overrightarrow{AB}
\overleftrightarrow{AB}
\\
\underleftarrow{AB}
\underrightarrow{AB}
\underleftrightarrow{AB}
\\
\overbrace{AB}
\underbrace{AB}
\\
\overline{AB}
\underline{AB}

盖子和盒子

\[\overbrace{a+b+c}^{\text{note}} \\ \underbrace{a+b+c}_{\text{note}} \\ \boxed{\pi=3.14} \]

\overbrace{a+b+c}^{\text{note}}
\\
\underbrace{a+b+c}_{\text{note}}
\\
\boxed{\pi=3.14}

各种括号

\[( \big( \Big( \bigg( \Bigg( \]

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

\[[] <> |-2| \{\} \]

[]
<>
|-2|
\{\}

\[\lgroup x \rgroup \lVert a \rVert \lceil 2.6 \rceil \lfloor 1.2 \rfloor \]

\lgroup x \rgroup
\lVert a \rVert
\lceil 2.6 \rceil
\lfloor 1.2 \rfloor

\[\ulcorner \urcorner \llcorner \lrcorner \]

\ulcorner
\urcorner
\llcorner
\lrcorner

希腊字母

希腊字母

算术运算符

\[+ - \times / \div \cdot \# \% \]

+
-
\times
/
\div
\cdot
\#
\%

\[\cap \cup \land \lor \sqcup \sqcap \]

\cap
\cup
\land
\lor
\sqcup
\sqcap

\[\circ \ast \star \otimes \oplus \odot \]

\circ
\ast
\star
\otimes
\oplus
\odot

\[\pm \mp \dotplus \divideontimes \]

\pm
\mp
\dotplus
\divideontimes

比较运算符

\[= = \not \equiv \approx \approxeq \cong \sim \]

=
= \not
\equiv
\approx
\approxeq
\cong
\sim

\[< > \le \ge \gg \ll \]

<
>
\le
\ge
\gg
\ll

\[\curlyeqprec \curlyeqsucc \prec \succ \preceq \succeq \]

\curlyeqprec
\curlyeqsucc
\prec
\succ
\preceq
\succeq

集合/逻辑相关

\[\in \owns \not \subset \not \supset \subseteq \supseteq \\ \cap \cup \land \lor \\ \neg \emptyset \varnothing \\ \because \forall \exists \therefore \]

\in
\owns \not
\subset \not
\supset
\subseteq
\supseteq
\\
\cap
\cup
\land
\lor
\\
\neg
\emptyset
\varnothing
\\
\because
\forall
\exists
\therefore

各种箭头

细箭头

\[\gets \leftarrow \to \rightarrow \leftrightarrow \\ \uparrow \downarrow \updownarrow \]

\gets
\leftarrow
\to
\rightarrow
\leftrightarrow
\\
\uparrow
\downarrow
\updownarrow

粗箭头

\[\Leftarrow \Rightarrow \Leftrightarrow \iff \\ \Uparrow \Downarrow \Updownarrow \]

\Leftarrow
\Rightarrow
\Leftrightarrow
\iff
\\
\Uparrow
\Downarrow
\Updownarrow

斜箭头

\[\nearrow \searrow \swarrow \nwarrow \]

\nearrow
\searrow
\swarrow
\nwarrow

半边箭头

\[\leftharpoonup \leftharpoondown \rightharpoonup \rightharpoondown \rightleftharpoons \]

\leftharpoonup
\leftharpoondown
\rightharpoonup
\rightharpoondown
\rightleftharpoons

特殊箭头

\[\mapsto \leadsto \hookleftarrow \hookrightarrow \]

\mapsto
\leadsto
\hookleftarrow
\hookrightarrow

加长箭头

\[\longleftarrow \longrightarrow \longleftrightarrow \Longleftarrow \Longrightarrow \Longleftrightarrow \longmapsto \]

\longleftarrow
\longrightarrow
\longleftrightarrow
\Longleftarrow
\Longrightarrow
\Longleftrightarrow
\longmapsto

带文本箭头

\[\xrightarrow{over} \xrightarrow[over]{} \xrightarrow[under]{over} \\ \xleftarrow[]{over} \xleftarrow[under]{} \xleftarrow[under]{over} \]

\xrightarrow{over}
\xrightarrow[over]{}
\xrightarrow[under]{over}
\xleftarrow[]{over}
\xleftarrow[under]{}
\xleftarrow[under]{over}

空格间距

\[A\!B \\ AB \\ A\thinspace B \\ A\:B \\ A\ B \\ A \enspace B \\ A\quad B \\ A\qquad B \]

A\!B
\\
AB
\\
A\thinspace B
\\
A\:B
\\
A\ B
\\
A \enspace B
\\
A\quad B
\\
A\qquad B

矩阵

\[A = \begin{matrix} a & b\\ c & d \end{matrix} \]

A = \begin{matrix}
a & b\\
c & d
\end{matrix}

\[B = \begin{pmatrix} a & b\\ c & d \end{pmatrix} \]

B = \begin{pmatrix}
a & b\\
c & d
\end{pmatrix}

\[C = \begin{vmatrix} a & b\\ c & d \end{vmatrix} \]

C = \begin{vmatrix}
a & b\\
c & d
\end{vmatrix}

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

D = \begin{bmatrix}
a & b\\
c & d
\end{bmatrix}

\[E = \begin{Vmatrix} a & b\\ c & d \end{Vmatrix} \]

E = \begin{Vmatrix}
a & b\\
c & d
\end{Vmatrix}

\[F = \begin{Bmatrix} a & b\\ c & d \end{Bmatrix} \]

F = \begin{Bmatrix}
a & b\\
c & d
\end{Bmatrix}

\[[A\ b] = \begin{bmatrix} \begin{array}{c c c|c} a_{11} & a_{12} & a_{13} & b_1\\ a_{21} & a_{22} & a_{23} & b_2\\ a_{31} & a_{32} & a_{33} & b_3\\ \end{array} \end{bmatrix} \]

[A\ b] = 
\begin{bmatrix}
\begin{array}{c c c|c}
a_{11} & a_{12} & a_{13} & b_1\\
a_{21} & a_{22} & a_{23} & b_2\\
a_{31} & a_{32} & a_{33} & b_3\\
\end{array}
\end{bmatrix}

\[\begin{array}{c:c:c} a & b & c \\ \hline d & e & f \\ \hdashline g & h & i \end{array} \]

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

\[L_{n\times n} = \begin{bmatrix} a_{11} & a_{12} & \cdots & a_{1n} \\ a_{21} & a_{22} & \cdots & a_{2n} \\ \vdots & \vdots &\ddots & \vdots\\ a_{n1} & a_{n2} & \cdots & a_{nn} \\ \end{bmatrix} \]

L_{n\times n} = \begin{bmatrix}
a_{11} & a_{12} & \cdots & a_{1n} \\ 
a_{21} & a_{22} & \cdots & a_{2n} \\ 
\vdots & \vdots &\ddots & \vdots\\
a_{n1} & a_{n2} & \cdots & a_{nn} \\ 
\end{bmatrix}

列式/方程组

\[\begin{aligned} f(x) &= (x+1)^2\\ &= x^2 + 2x + 1 \end{aligned} \]

\begin{aligned}
f(x) &= (x+1)^2\\
&= x^2 + 2x + 1
\end{aligned}

\[f(x) = \begin{cases} a &\text{if b}\\ b &\text{if a}\\ \end{cases} \]

f(x) = \begin{cases}
a &\text{if b}\\
b &\text{if a}\\
\end{cases}

\[\begin{cases} \begin{aligned} x + 2y &= 1\\ 3x - y &= 5 \end{aligned} \end{cases} \]

\begin{cases}
\begin{aligned}
x + 2y &= 1\\
3x - y &= 5
\end{aligned}
\end{cases}

字体操作

修改字体

修改大小

\[d \Huge AB d \\ d \normalsize AB \]

\Huge AB
d
\\
d
\normalsize AB

修改字体的操作影响效果到行末。

\[AB \Huge AB \huge AB \\ AB \LARGE AB \Large AB \large AB \\ AB \small AB \tiny AB \]

AB
\Huge AB
\huge AB
\\
AB
\LARGE AB
\Large AB
\large AB
\\
AB
\small AB
\tiny AB

修改颜色

\[\textcolor{blue}{F=ma} \\ \textcolor{#00ff00}{F=ma} \\ \textcolor{#ff0000}{F=ma} \\ \color{blue} one\ line \\ nothing \]

博客园的MD不能使用,给大伙一张在typora中的演示图康康

\textcolor{blue}{F=ma}
\\
\textcolor{#00ff00}{F=ma}
\\
\textcolor{#ff0000}{F=ma}
\\
\color{blue} one\ line
\\
nothing

\[\colorbox{#00ff00}{F=ma} \\ \colorbox{aqua}{A} \\ \fcolorbox{red}{aqua}{A} \]

博客园的MD同样不能使用

\colorbox{#00ff00}{F=ma}
\\
\colorbox{aqua}{A}
\\
\fcolorbox{red}{aqua}{A}

划掉

\[\cancel{5} \bcancel{5} \xcancel{ABC} \not = \]

博客园的MD同样不能使用

\cancel{5}
\bcancel{5}
\xcancel{ABC}
\not =

常见图形

\[\Box \square \blacksquare \triangle \triangledown \blacktriangle \diamond \Diamond \star \bigstar \circ \bullet \bigcirc \bigodot \]

\Box
\square
\blacksquare
\triangle
\triangledown
\blacktriangle
\diamond
\Diamond
\star
\bigstar
\circ
\bullet
\bigcirc
\bigodot

\[\diamondsuit \clubsuit \heartsuit \spadesuit \]

\diamondsuit
\clubsuit
\heartsuit
\spadesuit

\[\angle \measuredangle \top \bot \infty \]

\angle
\measuredangle
\top
\bot
\infty

\[\checkmark \dagger \ddagger \yen \$ \]

\checkmark
\dagger
\ddagger
\yen
\$

声明宏

对于一些复杂但只是有少许不同的表达式,可以声明一个函数来调用,提高原码的可读性,减少出错。

基本的语法为

\def\macroname#1#2{
your command
}

宏允许带任意数量的参数(也可以不带参),必须是#1,#2,……这样的命名格式,同时注意再定义宏的时候注意让#1\中间隔一个空格,否则会解析成#。再调用的时候格式为\macroname{x}{y}{z},可以参考一下的例子:

\[\def\Normal#1#2#3{ \frac{1}{\sqrt{2\pi}\ #3}\exp{[-\frac{(#1 - #2)^2}{2\ #3^2}]} } f(x)=\Normal{x}{u_1}{\sigma_1}\\ f(y)=\Normal{y}{u_2}{\sigma_2}\\ \]

\def\Normal#1#2#3{
\frac{1}{\sqrt{2\pi}\ #3}\exp{[-\frac{(#1 - #2)^2}{2\ #3^2}]}
}
f(x)=\Normal{x}{u_1}{\sigma_1}\\
f(y)=\Normal{y}{u_2}{\sigma_2}\\

\[\def\EXP{ e^x = 1 + x + \frac{1}{2!}x^2 + \frac{1}{3!}x^3 + \cdots } \EXP \]

\def\EXP{
e^x = 1 + x + \frac{1}{2!}x^2 + \frac{1}{3!}x^3  + \cdots
}
\EXP

参考资料

以上代码都可以在typora中运行,给出的图片链接语法是Ketax,可能有少数的不适用,但基本可以。

Katex语法总结图片

posted @ 2020-08-16 21:34  Wreng  阅读(23630)  评论(9编辑  收藏  举报