Markdown公式
1.公式块
方法一:左上角点击“段落”,再点击“公式块”
方法二:在文中输入$$,再按下回车
2.行内公式
方法一: 在$$的中间加入需要的公式
简便的方法一:先按 $ ,再按 “esc”(键盘左上角)
(行内公式是需要先设置一下)
基本格式
1.上下标
$$ A_1^2 \\ B_{12} \\ 2^{x^2+y} $$
|
A12B122x2+y
2.分数
$$ \frac{x}{1+x^2} \\ \frac{\frac{1}{2}+x}{y} \\ \tfrac{a}{b} \frac{a}{b} $$
|
fracx1+x2fracfrac12+xytfracabfracab
3.开根号,取模
$$ \sqrt{x} \sqrt[3]{x} \\ x \pmod a \\ 2\mod{x} $$
|
\\sqrt{x} \\sqrt\[3\]{x} \\ x \\pmod a \\ 2\\mod{x}
4**.组合数**
$$ \binom{n}{k} \tbinom{n}{k} $$
|
binomnktbinomnk
5.导数、偏微分、积分、累加/累乘/极限
a′a′′aprimenablaint12intop21ointsmallintiintoiintiiintoiiint
7.积分
$$ \int_0^1 {x^2} \,{\rm d}x $$
|
int_01x2,rmdx
8.求导
(1)求导
fracdf(theta)dtheta
$$ \frac{df(\theta)}{d\theta} $$
|
(2) 求偏导
fracpartialLosspartialC
$$ \frac {\partial Loss } {\partial C } $$
|
矩阵
1.简单矩阵
使用\begin{matrix}…\end{matrix}生成, 每一行以\\结尾表示换行,元素间以&间隔,式子的表示序号\tag{1}(右边的序号)。
![[公式]](https://www.zhihu.com/equation?tex=%5Cbegin%7Bmatrix%7D++1+%26+2+%26+3+%5C++4+%26+5+%26+6+%5C++7+%26+8+%26+9++%5Cend%7Bmatrix%7D+%5Ctag%7B1%7D)
$$ \begin{matrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \end{matrix} \tag{1} $$
|
2.带左右括号的矩阵(大中小括号)
方法一:在\begin{}之前和\end{}之后添加左右括号的代码。
大括号:
![[公式]](https://www.zhihu.com/equation?tex=%5Cleft%7B++%5Cbegin%7Bmatrix%7D++++1+%26+2+%26+3+%5C++++4+%26+5+%26+6+%5C++++7+%26+8+%26+9+++%5Cend%7Bmatrix%7D+++%5Cright%7D+%5Ctag%7B2%7D)
$$ \left\{ \begin{matrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \end{matrix} \right\} \tag{2} $$
|
中括号:
![[公式]](https://www.zhihu.com/equation?tex=%5Cleft%5B++%5Cbegin%7Bmatrix%7D++++1+%26+2+%26+3+%5C++++4+%26+5+%26+6+%5C++++7+%26+8+%26+9+++%5Cend%7Bmatrix%7D+++%5Cright%5D+%5Ctag%7B3%7D)
$$ \left[ \begin{matrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \end{matrix} \right] \tag{3} $$
|
小括号:
![[公式]](https://www.zhihu.com/equation?tex=%5Cleft(++%5Cbegin%7Bmatrix%7D++++1+%26+2+%26+3+%5C++++4+%26+5+%26+6+%5C++++7+%26+8+%26+9+++%5Cend%7Bmatrix%7D+++%5Cright)+%5Ctag%7B4%7D)
$$ \left( \begin{matrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \end{matrix} \right) \tag{4} $$
|
方法二:改变\begin{matrix}和\end{matrix}中{matrix}
大括号:
![[公式]](https://www.zhihu.com/equation?tex=%5Cbegin%7BBmatrix%7D++++1+%26+2+%26+3+%5C++++4+%26+5+%26+6+%5C++++7+%26+8+%26+9+++%5Cend%7BBmatrix%7D+%5Ctag%7B5%7D)
$$ \begin{Bmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \end{Bmatrix} \tag{6} $$
|
中括号:
![[公式]](https://www.zhihu.com/equation?tex=%5Cbegin%7Bbmatrix%7D++++1+%26+2+%26+3+%5C++++4+%26+5+%26+6+%5C++++7+%26+8+%26+9+++%5Cend%7Bbmatrix%7D+%5Ctag%7B6%7D)
$$ \begin{bmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \end{bmatrix} \tag{6} $$
|
3.包含希腊字母与省略号
行省略号\cdots,列省略号\vdots,斜向省略号(左上至右下)\ddots。
![[公式]](https://www.zhihu.com/equation?tex=%5Cleft%7B++%5Cbegin%7Bmatrix%7D++1++++++%26+2++++++++%26+%5Ccdots+%26+5++++++++%5C++6++++++%26+7++++++++%26+%5Ccdots+%26+10+++++++%5C++%5Cvdots+%26+%5Cvdots+++%26+%5Cddots+%26+%5Cvdots+++%5C++%5Calpha+%26+%5Calpha%2B1+%26+%5Ccdots+%26+%5Calpha%2B4+++%5Cend%7Bmatrix%7D++%5Cright%7D)
$$ \left\{ \begin{matrix} 1 & 2 & \cdots & 5 \\ 6 & 7 & \cdots & 10 \\ \vdots & \vdots & \ddots & \vdots \\ \alpha & \alpha+1 & \cdots & \alpha+4 \end{matrix} \right\} $$
|
公式序号
见“矩阵”小节,代码最后的一行即表示右端序号
行列式
行列式相关语法与矩阵类似 $$ \begin{vmatrix} 1 & 2 & 3 \ 4 & 5 & 6 \ 7 & 8 & 9 \end{vmatrix} \tag{7} $$
$$ \begin{vmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \end{vmatrix} \tag{7} $$
|
表格
1.简易表格
![[公式]](https://www.zhihu.com/equation?tex=%5Cbegin%7Barray%7D%7B%7Cc%7Cc%7Cc%7C%7D+%09%5Chline+2%269%264%5C%5C+%09%5Chline+7%265%263%5C%5C+%09%5Chline+6%261%268%5C%5C+%09%5Chline+%5Cend%7Barray%7D)
$$ \begin{array}{ccc} \hline 2&9&4\\ \hline 7&5&3\\ \hline 6&1&8\\ \hline \end{array} $$
|
开头结尾: \begin{array} , \end{array}
定义式:例:{ccc},其中c l r 分别代表居中、左对齐及右对齐。
分割线:①竖直分割线:在定义式中插入 , (表示两条竖直分割线)。
②水平分割线:在下一行输入前插入 \hline,以下图真值表为例。
其他:每行元素间均须要插入 & ,每行元素以 \\ 结尾。
2…真值表
![[公式]](https://www.zhihu.com/equation?tex=%5Cbegin%7Barray%7D%7Bcc%7Cc%7D+%09+++++++A%26B%26F%5C%5C+%09%5Chline+0%260%260%5C%5C+%09+++++++0%261%261%5C%5C+%09+++++++1%260%261%5C%5C+%09+++++++1%261%261%5C%5C+%5Cend%7Barray%7D)
$$ \begin{array}{ccc} A&B&F\\ \hline 0&0&0\\ 0&1&1\\ 1&0&1\\ 1&1&1\\ \end{array} $$
|
多行等式对齐
![[公式]](https://www.zhihu.com/equation?tex=%5Cbegin%7Baligned%7D+a+%26%3D+b+%2B+c+%5C+++%26%3D+d+%2B+e+%2B+f+%5Cend%7Baligned%7D)
$$ \begin{aligned} a &= b + c \\ &= d + e + f \end{aligned} $$
|
方程组、条件表达式
方程组:
![[公式]](https://www.zhihu.com/equation?tex=%5Cbegin%7Bcases%7D+3x+%2B+5y+%2B++z+%5C+7x+-+2y+%2B+4z+%5C+-6x+%2B+3y+%2B+2z+%5Cend%7Bcases%7D)
$$ \begin{cases} 3x + 5y + z \\ 7x - 2y + 4z \\ -6x + 3y + 2z \end{cases} $$
|
同理,条件表达式:
![[公式]](https://www.zhihu.com/equation?tex=f(n)+%3D+%5Cbegin%7Bcases%7D++n%2F2%2C++%26+%5Ctext%7Bif+%7Dn%5Ctext%7B+is+even%7D+%5C+3n%2B1%2C+%26+%5Ctext%7Bif+%7Dn%5Ctext%7B+is+odd%7D+%5Cend%7Bcases%7D)
$$ f(n) = \begin{cases} n/2, & \text{if }n\text{ is even} \\ 3n+1, & \text{if }n\text{ is odd} \end{cases} $$
|
间隔 (大小空格、紧贴)
紧贴 + 无空格 + 小空格 + 中空格 + 大空格 + 真空格 + 双真空格
$$ a\!b + ab + a\,b + a\;b + a\ b + a\quad b + a\qquad b $$
|
紧贴\!
无空格 小空格\, 中空格\; 大空格\
真空格\quad 双真空格\qquad
通过Python生成LaTeX表达式
step1:安装latexify-py模块
step2:编写代码
import math //引入数学模块(有些运算的函数需要) import latexify //引入latexify模块
@latexify.with_latex //特定语法,表示之后定义的函数可以转化为LaTeX代码 def f(x,y,z): //包含的参数 pass //此处填写可能需要的数学表达式 return result //也可以直接体现数学关系
print(f) //直接print(函数名)
|
step3:在输出区得到需要的LaTeX数学表达式
特别说明,生成的表达式为定义式,即 ,如果只需要等式 ,可以把生成表达式中的\triangleq改成= !