【博客工具】typora中的数学公式(字典型,用时查阅)

您所在的位置:网站首页 数学横纵坐标 【博客工具】typora中的数学公式(字典型,用时查阅)

【博客工具】typora中的数学公式(字典型,用时查阅)

#【博客工具】typora中的数学公式(字典型,用时查阅)| 来源: 网络整理| 查看: 265

文章目录 LaTeX编辑数学公式基本语法元素1. 各类希腊字母表2. 如何输入括号和分隔符3. 三角运算符4. 微积分运算符5. 逻辑运算符6. 上下标7. 根号8. 省略号9. 运算符10. 分数11. 矩阵和行列式12. 行列式13. 如何输入带分割符号的矩阵14. 如何输入向量15. 如何输入积分16. 如何进行字体转换17. 如何高亮一行公式18. 更改文字颜色19. 添加删除线20. 包围公式21. 箭头22. 方程式23. 分隔符24. 分段函数25. 如何输入一个左侧对齐的条件表达式26. 方程组27. 如何使条件表达式适配行高28. 数组与表格使用参考之如何输入一个数组或表格29. 数组与表格使用参考之如何输入一个嵌套的数组或表格 案例1. 线性模型2. 均方误差3. 批量梯度下降4. 推导过程 参考文档 注意:有一些公式在csdn中无法显示,但是在typora中可以显示出来,可以自己在本地上的typora上使用体验一下

LaTeX编辑数学公式基本语法元素

LaTeX中数学模式有两种形式:inline和display。前者是指正文插入行间数学公式,后者独立排列,可以有或没有编号。

行间公式(inline):用 $...$ 将公式括起来 块间公式(display):用 $$...$$ 将公式括起来,默认显示在行中间

1. 各类希腊字母表 希腊字母代号希腊字母代号希腊字母代号希腊字母代号α\alphaθ\thetaooτ\tauβ\betaϑ\varthetaπ\piυ\upsilonγ\gammaι\iotaϖ\varpiϕ\phiδ\deltaκ\kappaρ\rhoφ\varphiϵ\epsilonλ\lambdaϱ\varrhoχ\chiε\varepsilonμ\muσ\sigmaψ\psiζ\zetaν\nuς\varsigmaω\omegaη\etaξ\xiΣ\SigmaΨ\PsiΓ\GammaΛ\LambdaΥ\UpsilonΩ\OmegaΔ\DeltaΞ\XiΦ\PhiΘ\ThetaΠ\Pi 2. 如何输入括号和分隔符

()、[] 和 | 表示符号本身,使用 \{\} 来表示 {} 。当要显示大号的括号或分隔符时,要用 \left 和 \right 命令。

一些特殊的括号:

输入显示输入显示\langle ⟨ \langle ⟨\rangle ⟩ \rangle ⟩\lceil ⌈ \lceil ⌈\rceil ⌉ \rceil ⌉\lfloor ⌊ \lfloor ⌊\rfloor ⌋ \rfloor ⌋\lbrace { \lbrace {\rbrace } \rbrace }\lvert ∣ \lvert ∣\rvert ∣ \rvert ∣\lVert ∥ \lVert ∥\rVert ∥ \rVert ∥

有时,我们需要在行内使用两个竖杠表示向量间的某种空间距离,可以这样写 $\lVert \boldsymbol{X}_i - \boldsymbol{S}_j \rVert^2$ → ∥ X i − S j ∥ 2 \lVert \boldsymbol{X}_i - \boldsymbol{S}_j \rVert^2 ∥Xi​−Sj​∥2

示例

$$ f(x,y,z) = 3y^2z \left( 3+\frac{7x+5}{1+y^2} \right) $$

结果 f ( x , y , z ) = 3 y 2 z ( 3 + 7 x + 5 1 + y 2 ) f(x,y,z) = 3y^2z \left( 3+\frac{7x+5}{1+y^2} \right) f(x,y,z)=3y2z(3+1+y27x+5​)

有时要用 \left. 或 \right. 进行匹配而不显示本身。

示例

$$ \left. \frac{{\rm d}u}{{\rm d}x} \right| _{x=0} $$

结果 d u d x ∣ x = 0 \left. \frac{{\rm d}u}{{\rm d}x} \right| _{x=0} dxdu​∣∣∣∣​x=0​

3. 三角运算符 输入显示输入显示输入显示\backsim ∽ \backsim ∽\cong ≅ \cong ≅\angle A ∠ A \angle A ∠A\sin sin ⁡ \sin sin\cos cos ⁡ \cos cos\tan tan ⁡ \tan tan\csc csc ⁡ \csc csc\sec sec ⁡ \sec sec\cot cot ⁡ \cot cot 4. 微积分运算符 输入显示输入显示输入显示\int ∫ \int ∫\iint ∬ \iint ∬\iiint ∭ \iiint ∭\partial ∂ \partial ∂\oint ∮ \oint ∮\prime ′ \prime ′\lim lim ⁡ \lim lim\infty ∞ \infty ∞\nabla ∇ \nabla ∇ 5. 逻辑运算符 输入显示输入显示输入显示\because ∵ \because ∵\therefore ∴ \therefore ∴\neg ¬ \neg ¬\forall ∀ \forall ∀\exists ∃ \exists ∃\not\subset ⊄ \not\subset ​⊂\not ​>\not= ≠ \not= ​= 6. 上下标

下标:$x_i$ → x i x_i xi​

上标:$x^i$ → x i x^i xi

注意 :上下标如果多余一个字母或者符号,需要用一对{}括起来:

多个字母下标:$x_{i1}$ → x i 1 x_{i1} xi1​

多个字母上标:$x^{i1}$ → x i 1 x^{i1} xi1

另外,如果要在左右两边都有上下标,可以使用 \sideset 命令;也可以简单地在符号前面多打一个上下标,此时会以行内公式渲染。

示例:

$$ \sideset{^1_2}{^3_4}\bigotimes \quad or \quad {^1_2}\bigotimes {^3_4} $$

结果 KaTeX parse error: Undefined control sequence: \sideset at position 2: \̲s̲i̲d̲e̲s̲e̲t̲{^1_2}{^3_4} \b…

7. 根号

根号:$\sqrt[n]{5}$ → 5 n \sqrt[n]{5} n5 ​

8. 省略号

省略号:$\dots$ → … \dots … || $\cdots$ → ⋯ \cdots ⋯

9. 运算符

基本运算符:+ - * /等可以直接输入,其他特殊的有:

\pm\times\div\cdot\cap\cup\geq\leq\neq\approx\equix±×÷⋅∩∪≥≤ ≠ \neq ​=≈≡

求和:$\sum_1^n$ → ∑ 1 n \sum_1^n ∑1n​

累乘:$\prod_{n=1}^{99}x_n$ → ∏ n = 1 99 x n \prod_{n=1}^{99}x_n ∏n=199​xn​

积分:$\int_1^n$ → ∫ 1 n \int_1^n ∫1n​

极限:$\lim\limits _ {x \to \infty}$ → lim ⁡ x → ∞ \lim\limits _ {x \to \infty} x→∞lim​

10. 分数

分数的表示:$\frac{3}{8}$ → 3 8 \frac{3}{8} 83​

11. 矩阵和行列式

示例

$$ \begin{matrix} 1&x&x^2\\ 1&y&y^2\\ 1&z&z^2\\ \end{matrix} $$

结果 1 x x 2 1 y y 2 1 z z 2 \begin{matrix} 1&x&x^2\\ 1&y&y^2\\ 1&z&z^2\\ \end{matrix} 111​xyz​x2y2z2​

12. 行列式

使用 \cdots , \ddots , \vdots 来输入省略符号。

示例:

$$ X=\left| \begin{matrix} x_{11} & x_{12} & \cdots & x_{1d}\\ x_{21} & x_{22} & \cdots & x_{2d}\\ \vdots & \vdots & \ddots & \vdots\\ x_{m1} & x_{m2} & \cdots & x_{md} \\ \end{matrix} \right| $$

结果 X = ∣ x 11 x 12 ⋯ x 1 d x 21 x 22 ⋯ x 2 d ⋮ ⋮ ⋱ ⋮ x m 1 x m 2 ⋯ x m d ∣ X=\left| \begin{matrix} x_{11} & x_{12} & \cdots & x_{1d}\\ x_{21} & x_{22} & \cdots & x_{2d}\\ \vdots & \vdots & \ddots & \vdots\\ x_{m1} & x_{m2} & \cdots & x_{md} \\ \end{matrix} \right| X=∣∣∣∣∣∣∣∣∣​x11​x21​⋮xm1​​x12​x22​⋮xm2​​⋯⋯⋱⋯​x1d​x2d​⋮xmd​​∣∣∣∣∣∣∣∣∣​

在开头将 matrix 替换为 pmatrix bmatrix Bmatrix vmatrix Vmatrix 。

示例

$ \begin{matrix} 1 & 2 \\ 3 & 4 \\ \end{matrix} $ $ \begin{pmatrix} 1 & 2 \\ 3 & 4 \\ \end{pmatrix} $ $ \begin{bmatrix} 1 & 2 \\ 3 & 4 \\ \end{bmatrix} $ $ \begin{Bmatrix} 1 & 2 \\ 3 & 4 \\ \end{Bmatrix} $ $ \begin{vmatrix} 1 & 2 \\ 3 & 4 \\ \end{vmatrix} $ $ \begin{Vmatrix} 1 & 2 \\ 3 & 4 \\ \end{Vmatrix} $

结果

matrixpmatrixbmatrixBmatrixvmatrixVmatrix$ \begin{matrix} 1 & 2 \ 3 & 4 \ \end{matrix} $$ \begin{pmatrix} 1 & 2 \ 3 & 4 \ \end{pmatrix} $$ \begin{bmatrix} 1 & 2 \ 3 & 4 \ \end{bmatrix} $$ \begin{Bmatrix} 1 & 2 \ 3 & 4 \ \end{Bmatrix} $$ \begin{vmatrix} 1 & 2 \ 3 & 4 \ \end{vmatrix} $$ \begin{Vmatrix} 1 & 2 \ 3 & 4 \ \end{Vmatrix} $ 13. 如何输入带分割符号的矩阵

示例

$$ \left[ \begin{array}{cc|c} 1 & 2 & 3 \\ 4 & 5 & 6 \\ \end{array} \right] $$

结果 [ 1 2 3 4 5 6 ] \left[ \begin{array}{cc|c} 1 & 2 & 3 \\ 4 & 5 & 6 \\ \end{array}\right] [14​25​36​]

其中 cc|c 代表在一个三列矩阵中的第二和第三列之间插入分割线。

14. 如何输入向量

使用 \vec{向量} 来自动产生一个向量。也可以使用 \overrightarrow 等命令自定义字母上方的符号。

示例

$$ \vec{a} \cdot \vec{b}=0 $$

结果 a ⃗ ⋅ b ⃗ = 0 \vec{a} \cdot \vec{b}=0 a ⋅b =0 示例

$$ xy \text{ with arrows:} \quad \overleftarrow{xy} \; \mid \; \overleftrightarrow{xy} \; \mid \; \overrightarrow{xy} $$

结果 x y  with arrows: x y ←    ∣    x y ↔    ∣    x y → xy \text{ with arrows:} \quad \overleftarrow{xy} \; \mid \; \overleftrightarrow{xy} \; \mid \; \overrightarrow{xy} xy with arrows:xy ​∣xy ​∣xy ​

15. 如何输入积分

使用 \int_积分下限^积分上限 {被积表达式} 来输入一个积分。

示例

$$ \int_0^1 {x^2} \,{\rm d}x $$

结果 ∫ 0 1 x 2   d x \int_0^1 {x^2} \,{\rm d}x ∫01​x2dx

本例中 \, 和 {\rm d} 部分可省略,但加入能使式子更美观

16. 如何进行字体转换

若要对公式的某一部分字符进行字体转换,可以用 {\字体 {需转换的部分字符}} 命令,其中 \字体 部分可以参照下表选择合适的字体。一般情况下,公式默认为斜体字 。

示例中 全部大写 的字体仅大写可用。

输入全字母可用显示输入仅大写可用显示\rm罗马体 s a m p l e \rm {sample} sample\mathcal花体(数学符号等) s a m p l e \mathcal {sample} sample\it斜体 s a m p l e \it {sample} sample\mathbb黑板粗体(定义域等) s a m p l e \mathbb {sample} sample\bf粗体 s a m p l e \bf {sample} sample\mit数学斜体KaTeX parse error: Undefined control sequence: \mit at position 1: \̲m̲i̲t̲ ̲{sample}\sf等线体 s a m p l e \sf {sample} sample\scr手写体KaTeX parse error: Undefined control sequence: \scr at position 1: \̲s̲c̲r̲ ̲{sample}\tt打字机体 s a m p l e \tt {sample} sample\frak旧德式字体 s a m p l e \frak {sample} sample

@lymd \boldsymbol{\alpha} 用来表示向量或者矩阵的加粗斜体,如向量 。

转换字体十分常用,例如在积分中:

示例

\begin{array}{cc} \mathrm{Bad} & \mathrm{Better} \\ \hline \\ \int_0^1 x^2 dx & \int_0^1 x^2 \,{\rm d}x \end{array}

结果

B a d B e t t e r ∫ 0 1 x 2 d x ∫ 0 1 x 2   d x \begin{array}{cc} \mathrm{Bad} & \mathrm{Better} \\ \hline \\ \int_0^1 x^2 dx & \int_0^1 x^2 \,{\rm d}x\end{array} Bad∫01​x2dx​Better∫01​x2dx​​ 注意比较两个式子间 与 的不同。 使用 \operatorname 命令也可以达到相同的效果。

17. 如何高亮一行公式

使用 \bbox[底色, (可选)边距, (可选)边框 border: 框宽度 框类型 框颜色] 命令来高亮一行公式。 边距及框宽度支持 绝对像素 px 或 相对大小 em,框类型支持 实线 solid 或 虚线 dashed。

示例

$$ \bbox[yellow]{ e^x=\lim_{n\to\infty} \left( 1+\frac{x}{n} \right)^n \qquad (1)} $$

结果 KaTeX parse error: Undefined control sequence: \bbox at position 2: \̲b̲b̲o̲x̲[yellow]{ e^… 示例

$$ \bbox[#9ff, 5px]{ #此处向外添加 5 像素的边距 e^x=\lim_{n\to\infty} \left( 1+\frac{x}{n} \right)^n \qquad (1)} $$

结果 KaTeX parse error: Undefined control sequence: \bbox at position 2: \̲b̲b̲o̲x̲[#9ff, 5px]{e^x…

示例

$$ #此处使用 0.5 倍行高作为边距,附加 2 像素的实线边框(Ctrl+Alt+Y 可见) \bbox[#2f3542, 0.5em, border:2px solid #f1f2f6]{ \color{#f1f2f6}{e^x=\lim_{n\to\infty} \left( 1+\frac{x}{n} \right)^n \qquad (1)}} $$

结果 KaTeX parse error: Undefined control sequence: \bbox at position 2: \̲b̲b̲o̲x̲[#2f3542, 0.5em…

18. 更改文字颜色

使用 \color{颜色}{文字} 来更改特定的文字颜色。

更改文字颜色需要浏览器支持 ,如果浏览器不知道你所需的颜色,那么文字将被渲染为黑色。对于较旧的浏览器(HTML4 & CSS2),以下颜色是被支持的:

输入显示输入显示black s a m p l e \color{black}{sample} samplegrey s a m p l e \color{grey}{sample} samplesilver s a m p l e \color{silver}{sample} samplewhite s a m p l e \color{white}{sample} samplemaroon s a m p l e \color{maroon}{sample} samplered s a m p l e \color{red}{sample} sampleyellow s a m p l e \color{yellow}{sample} samplelime s a m p l e \color{lime}{sample} sampleolive s a m p l e \color{olive}{sample} samplegreen s a m p l e \color{green}{sample} sampleteal s a m p l e \color{teal}{sample} sampleauqa s a m p l e \color{auqa}{sample} sampleblue s a m p l e \color{blue}{sample} samplenavy s a m p l e \color{navy}{sample} samplepurple s a m p l e \color{purple}{sample} samplefuchsia s a m p l e \color{fuchsia}{sample} sample

对于较新的浏览器(HTML5 & CSS3),HEX 颜色将被支持:

输入 \color {#rgb} {text} 来自定义更多的颜色,其中 #rgb 或 #rrggbb 的 r g b 可输入 0-9 和 a-f 来表示红色、绿色和蓝色的纯度(饱和度)。

示例

\begin{array} {|rrrrrrrr|} \hline \verb+#000+ & \color{#000}{text} & & & \verb+#00F+ & \color{#00F}{text} & & \\ & & \verb+#0F0+ & \color{#0F0}{text} & & & \verb+#0FF+ & \color{#0FF}{text} \\ \verb+#F00+ & \color{#F00}{text} & & & \verb+#F0F+ & \color{#F0F}{text} & & \\ & & \verb+#FF0+ & \color{#FF0}{text} & & & \verb+#FFF+ & \color{#FFF}{text} \\ \hline \end{array}

结果 #000 t e x t #00F t e x t #0F0 t e x t #0FF t e x t #F00 t e x t #F0F t e x t #FF0 t e x t #FFF t e x t \begin{array}{|rrrrrrrr|}\hline \verb+#000+ & \color{#000}{text} & & & \verb+#00F+ & \color{#00F}{text} & & \\ & & \verb+#0F0+ & \color{#0F0}{text} & & & \verb+#0FF+ & \color{#0FF}{text} \\ \verb+#F00+ & \color{#F00}{text} & & & \verb+#F0F+ & \color{#F0F}{text} & & \\ & & \verb+#FF0+ & \color{#FF0}{text} & & & \verb+#FFF+ & \color{#FFF}{text} \\\hline\end{array} #000#F00​texttext​#0F0#FF0​texttext​#00F#F0F​texttext​#0FF#FFF​texttext​​

示例

\begin{array}{|rrrrrrrr|} \hline \verb+#000+ & \color{#000}{text} & \verb+#005+ & \color{#005}{text} & \verb+#00A+ & \color{#00A}{text} & \verb+#00F+ & \color{#00F}{text} \\ \verb+#500+ & \color{#500}{text} & \verb+#505+ & \color{#505}{text} & \verb+#50A+ & \color{#50A}{text} & \verb+#50F+ & \color{#50F}{text} \\ \verb+#A00+ & \color{#A00}{text} & \verb+#A05+ & \color{#A05}{text} & \verb+#A0A+ & \color{#A0A}{text} & \verb+#A0F+ & \color{#A0F}{text} \\ \verb+#F00+ & \color{#F00}{text} & \verb+#F05+ & \color{#F05}{text} & \verb+#F0A+ & \color{#F0A}{text} & \verb+#F0F+ & \color{#F0F}{text} \\ \hline \verb+#080+ & \color{#080}{text} & \verb+#085+ & \color{#085}{text} & \verb+#08A+ & \color{#08A}{text} & \verb+#08F+ & \color{#08F}{text} \\ \verb+#580+ & \color{#580}{text} & \verb+#585+ & \color{#585}{text} & \verb+#58A+ & \color{#58A}{text} & \verb+#58F+ & \color{#58F}{text} \\ \verb+#A80+ & \color{#A80}{text} & \verb+#A85+ & \color{#A85}{text} & \verb+#A8A+ & \color{#A8A}{text} & \verb+#A8F+ & \color{#A8F}{text} \\ \verb+#F80+ & \color{#F80}{text} & \verb+#F85+ & \color{#F85}{text} & \verb+#F8A+ & \color{#F8A}{text} & \verb+#F8F+ & \color{#F8F}{text} \\ \hline \verb+#0F0+ & \color{#0F0}{text} & \verb+#0F5+ & \color{#0F5}{text} & \verb+#0FA+ & \color{#0FA}{text} & \verb+#0FF+ & \color{#0FF}{text} \\ \verb+#5F0+ & \color{#5F0}{text} & \verb+#5F5+ & \color{#5F5}{text} & \verb+#5FA+ & \color{#5FA}{text} & \verb+#5FF+ & \color{#5FF}{text} \\ \verb+#AF0+ & \color{#AF0}{text} & \verb+#AF5+ & \color{#AF5}{text} & \verb+#AFA+ & \color{#AFA}{text} & \verb+#AFF+ & \color{#AFF}{text} \\ \verb+#FF0+ & \color{#FF0}{text} & \verb+#FF5+ & \color{#FF5}{text} & \verb+#FFA+ & \color{#FFA}{text} & \verb+#FFF+ & \color{#FFF}{text} \\ \hline \end{array}

结果

#000 t e x t #005 t e x t #00A t e x t #00F t e x t #500 t e x t #505 t e x t #50A t e x t #50F t e x t #A00 t e x t #A05 t e x t #A0A t e x t #A0F t e x t #F00 t e x t #F05 t e x t #F0A t e x t #F0F t e x t #080 t e x t #085 t e x t #08A t e x t #08F t e x t #580 t e x t #585 t e x t #58A t e x t #58F t e x t #A80 t e x t #A85 t e x t #A8A t e x t #A8F t e x t #F80 t e x t #F85 t e x t #F8A t e x t #F8F t e x t #0F0 t e x t #0F5 t e x t #0FA t e x t #0FF t e x t #5F0 t e x t #5F5 t e x t #5FA t e x t #5FF t e x t #AF0 t e x t #AF5 t e x t #AFA t e x t #AFF t e x t #FF0 t e x t #FF5 t e x t #FFA t e x t #FFF t e x t \begin{array}{|rrrrrrrr|}\hline \verb+#000+ & \color{#000}{text} & \verb+#005+ & \color{#005}{text} & \verb+#00A+ & \color{#00A}{text} & \verb+#00F+ & \color{#00F}{text} \\ \verb+#500+ & \color{#500}{text} & \verb+#505+ & \color{#505}{text} & \verb+#50A+ & \color{#50A}{text} & \verb+#50F+ & \color{#50F}{text} \\ \verb+#A00+ & \color{#A00}{text} & \verb+#A05+ & \color{#A05}{text} & \verb+#A0A+ & \color{#A0A}{text} & \verb+#A0F+ & \color{#A0F}{text} \\ \verb+#F00+ & \color{#F00}{text} & \verb+#F05+ & \color{#F05}{text} & \verb+#F0A+ & \color{#F0A}{text} & \verb+#F0F+ & \color{#F0F}{text} \\\hline \verb+#080+ & \color{#080}{text} & \verb+#085+ & \color{#085}{text} & \verb+#08A+ & \color{#08A}{text} & \verb+#08F+ & \color{#08F}{text} \\ \verb+#580+ & \color{#580}{text} & \verb+#585+ & \color{#585}{text} & \verb+#58A+ & \color{#58A}{text} & \verb+#58F+ & \color{#58F}{text} \\ \verb+#A80+ & \color{#A80}{text} & \verb+#A85+ & \color{#A85}{text} & \verb+#A8A+ & \color{#A8A}{text} & \verb+#A8F+ & \color{#A8F}{text} \\ \verb+#F80+ & \color{#F80}{text} & \verb+#F85+ & \color{#F85}{text} & \verb+#F8A+ & \color{#F8A}{text} & \verb+#F8F+ & \color{#F8F}{text} \\\hline \verb+#0F0+ & \color{#0F0}{text} & \verb+#0F5+ & \color{#0F5}{text} & \verb+#0FA+ & \color{#0FA}{text} & \verb+#0FF+ & \color{#0FF}{text} \\ \verb+#5F0+ & \color{#5F0}{text} & \verb+#5F5+ & \color{#5F5}{text} & \verb+#5FA+ & \color{#5FA}{text} & \verb+#5FF+ & \color{#5FF}{text} \\ \verb+#AF0+ & \color{#AF0}{text} & \verb+#AF5+ & \color{#AF5}{text} & \verb+#AFA+ & \color{#AFA}{text} & \verb+#AFF+ & \color{#AFF}{text} \\ \verb+#FF0+ & \color{#FF0}{text} & \verb+#FF5+ & \color{#FF5}{text} & \verb+#FFA+ & \color{#FFA}{text} & \verb+#FFF+ & \color{#FFF}{text} \\\hline\end{array} #000#500#A00#F00#080#580#A80#F80#0F0#5F0#AF0#FF0​texttexttexttexttexttexttexttexttexttexttexttext​#005#505#A05#F05#085#585#A85#F85#0F5#5F5#AF5#FF5​texttexttexttexttexttexttexttexttexttexttexttext​#00A#50A#A0A#F0A#08A#58A#A8A#F8A#0FA#5FA#AFA#FFA​texttexttexttexttexttexttexttexttexttexttexttext​#00F#50F#A0F#F0F#08F#58F#A8F#F8F#0FF#5FF#AFF#FFF​texttexttexttexttexttexttexttexttexttexttexttext​​

19. 添加删除线

使用删除线功能必须声明 $$ 符号。

在公式内使用 \require{cancel} 来允许片段删除线的显示。 声明片段删除线后,使用 \cancel{字符}、\bcancel{字符}、\xcancel{字符} 和 \cancelto{字符} 来实现各种片段删除线效果。

示例

$$ \require{cancel} \begin{array}{rl} \verb|y+\cancel{x}| & y+\cancel{x} \\ \verb|\cancel{y+x}| & \cancel{y+x} \\ \verb|y+\bcancel{x}| & y+\bcancel{x} \\ \verb|y+\xcancel{x}| & y+\xcancel{x} \\ \verb|y+\cancelto{0}{x}| & y+\cancelto{0}{x} \\ \verb+\frac{1\cancel9}{\cancel95} = \frac15+& \frac{1\cancel9}{\cancel95} = \frac15 \\ \end{array} $$

结果 KaTeX parse error: Undefined control sequence: \require at position 2: \̲r̲e̲q̲u̲i̲r̲e̲{cancel} \begin…

20. 包围公式

分别使用 circle 和 roundedbox 包围的公式

示例

$$ \require{enclose} \begin{array}{c} \enclose{circle}{f(\top),\, f^2(\top),\, f^3(\top) \,\cdots\, f^n(\top)} \\ \enclose{roundedbox}{f(\bot),\, f^2(\bot),\, f^3(\bot) \,\cdots\, f^n(\bot)} \\ \end{array} $$

结果 $$ $$ \require{enclose} \begin{array}{c} \enclose{circle}{f(\top),, f^2(\top),, f^3(\top) ,\cdots, f^n(\top)} \ \enclose{roundedbox}{f(\bot),, f^2(\bot),, f^3(\bot) ,\cdots, f^n(\bot)} \ \end{array} 使用 box 框住所有公式

示例

$$ \require{enclose} \enclose{box}{ \begin{array}{c} f(\top),\, f^2(\top),\, f^3(\top) \,\cdots\, f^n(\top) \\ f(\bot),\, f^2(\bot),\, f^3(\bot) \,\cdots\, f^n(\bot) \\ \end{array} } $$

结果 $$ $$ \require{enclose} \enclose{box}{ \begin{array}{c} f(\top),, f^2(\top),, f^3(\top) ,\cdots, f^n(\top) \ f(\bot),, f^2(\bot),, f^3(\bot) ,\cdots, f^n(\bot) \ \end{array} }

21. 箭头 符号表达式符号表达式←\lefrarrow⟵\longleftarrow→\rightarrow⟶\longrightarrow↔\leftrightarrow⟷\longleftrightarrow⇐\Leftarrow⟸\Longleftarrow⇒\Rightarrow⟹\Longrightarrow⇔\Leftrightarrow⟺\Longleftrightarrow 22. 方程式

示例

$$ \begin{equation} E=mc^2 \end{equation} $$

结果 KaTeX parse error: No such environment: equation at position 8: \begin{̲e̲q̲u̲a̲t̲i̲o̲n̲}̲ E=mc^2 \end{eq…

23. 分隔符

各种括号用 () [] { } \langle\rangle 等命令表示,注意花括号通常用来输入命令和环境的参数,所以在数学公式中它们前面要加 \。可以在上述分隔符前面加 \big \Big \bigg \Bigg 等命令来调整大小。

示例

$$ \max \limits_{af(x)}

24. 分段函数

示例

$$ f(n) = \begin{cases} n/2, & \text {if $n$ is even}\\ 3n+1, & \text {if $n$ is odd} \end{cases} $$

结果 f ( n ) = { n / 2 , if  n  is even 3 n + 1 , if  n  is odd f(n) = \begin{cases} n/2, & \text {if $n$ is even}\\ 3n+1, & \text {if $n$ is odd} \end{cases} f(n)={n/2,3n+1,​if n is evenif n is odd​

25. 如何输入一个左侧对齐的条件表达式

若想让文字在左侧对齐显示,则有如下方式:

示例

$$ \left. \begin{array}{l} \text{if $n$ is even:} & n/2 \\ \text{if $n$ is odd:} & 3n+1 \\ \end{array} \right\} =f(n) $$

结果

if  n  is even: n / 2 if  n  is odd: 3 n + 1 } = f ( n ) \left. \begin{array}{l} \text{if $n$ is even:} & n/2 \\ \text{if $n$ is odd:} & 3n+1 \\ \end{array} \right\} =f(n) if n is even:if n is odd:​n/23n+1​}=f(n)

26. 方程组

示例

$$ \left\{ \begin{array}{c} a_1x+b_1y+c_1z=d_1\\ a_2x+b_2y+c_2z=d_2\\ a_3x+b_3y+c_3z=d_3 \end{array} \right. # 注意right后面有个小数点 $$

结果 { a 1 x + b 1 y + c 1 z = d 1 a 2 x + b 2 y + c 2 z = d 2 a 3 x + b 3 y + c 3 z = d 3 \left\{ \begin{array}{c} a_1x+b_1y+c_1z=d_1\\ a_2x+b_2y+c_2z=d_2\\ a_3x+b_3y+c_3z=d_3 \end{array} \right. ⎩⎨⎧​a1​x+b1​y+c1​z=d1​a2​x+b2​y+c2​z=d2​a3​x+b3​y+c3​z=d3​​

27. 如何使条件表达式适配行高

在一些情况下,条件表达式中某些行的行高为非标准高度,此时使用 \\[2ex] 语句代替该行末尾的 \\ 来让编辑器适配。

例子:

不适配[2ex]

$$ f(n) = \begin{cases} \frac{n}{2}, & \text{if $n$ is even} \\ 3n+1, & \text{if $n$ is odd} \\ \end{cases} $$

适配[2ex]

$$ f(n) = \begin{cases} \frac{n}{2}, & \text{if $n$ is even} \\ 3n+1, & \text{if $n$ is odd} \\ \end{cases} $$ 显示: 不适配[2ex]适配[2ex]$f(n) = \begin{cases} \frac{n}{2}, & \text{if n n n is even} \ 3n+1, & \text{if n n n is odd} \ \end{cases}$$f(n) = \begin{cases} \frac{n}{2}, & \text{if n n n is even} \ 3n+1, & \text{if n n n is odd} \ \end{cases}$

一个 [ex] 指一个 “X-Height”,即 x 字母高度。可以根据情况指定多个 [ex],如 [3ex]、[4ex] 等。 其实可以在任意换行处使用 \\[2ex] 语句,只要你觉得合适。

28. 数组与表格使用参考之如何输入一个数组或表格

通常,一个格式化后的表格比单纯的文字或排版后的文字更具有可读性。 数组和表格均以 \begin{array} 开头,并在其后定义列数及每一列的文本对齐属性,c l r 分别代表居中、左对齐及右对齐。若需要插入垂直分割线,在定义式中插入 | ,若要插入水平分割线,在下一行输入前插入 \hline 。 与矩阵相似,每行元素间均须要插入 & ,每行元素以 \\ 结尾,最后以 \ end{array} 结束数组。 使用单个数组或表格时无需声明 $ 或 $$ 符号。

示例

\begin{array}{c|lcr} n & \text{左对齐} & \text{居中对齐} & \text{右对齐} \\ \hline 1 & 0.24 & 1 & 125 \\ 2 & -1 & 189 & -8 \\ 3 & -20 & 2000 & 1+10i \\ \end{array}

结果 n 左对齐 居中对齐 右对齐 1 0.24 1 125 2 − 1 189 − 8 3 − 20 2000 1 + 10 i \begin{array}{c|lcr} n & \text{左对齐} & \text{居中对齐} & \text{右对齐} \\ \hline 1 & 0.24 & 1 & 125 \\ 2 & -1 & 189 & -8 \\ 3 & -20 & 2000 & 1+10i \\ \end{array} n123​左对齐0.24−1−20​居中对齐11892000​右对齐125−81+10i​​

左对齐居中对齐右对齐

29. 数组与表格使用参考之如何输入一个嵌套的数组或表格

多个数组\表格可 互相嵌套 并组成一组数组或表格。 使用嵌套前必须声明 $$ 符号。

示例

$$ \begin{array}{c} % 总表格 \begin{array}{cc} % 第一行内分成两列 \begin{array}{c|cccc} % 第一列"最小值"数组 \text{min} & 0 & 1 & 2 & 3 \\ \hline 0 & 0 & 0 & 0 & 0 \\ 1 & 0 & 1 & 1 & 1 \\ 2 & 0 & 1 & 2 & 2 \\ 3 & 0 & 1 & 2 & 3 \\ \end{array} & \begin{array}{c|cccc} % 第二列"最大值"数组 \text{max} & 0 & 1 & 2 & 3 \\ \hline 0 & 0 & 1 & 2 & 3 \\ 1 & 1 & 1 & 2 & 3 \\ 2 & 2 & 2 & 2 & 3 \\ 3 & 3 & 3 & 3 & 3 \\ \end{array} \end{array} % 第一行表格组结束 \\ \begin{array}{c|cccc} % 第二行 Delta 值数组 \Delta & 0 & 1 & 2 & 3 \\ \hline 0 & 0 & 1 & 2 & 3 \\ 1 & 1 & 0 & 1 & 2 \\ 2 & 2 & 1 & 0 & 1 \\ 3 & 3 & 2 & 1 & 0 \\ \end{array} % 第二行表格结束 \end{array} % 总表格结束 $$

结果 min 0 1 2 3 0 0 0 0 0 1 0 1 1 1 2 0 1 2 2 3 0 1 2 3 max 0 1 2 3 0 0 1 2 3 1 1 1 2 3 2 2 2 2 3 3 3 3 3 3 Δ 0 1 2 3 0 0 1 2 3 1 1 0 1 2 2 2 1 0 1 3 3 2 1 0 \begin{array}{c} \begin{array}{cc} \begin{array}{c|cccc} \text{min} & 0 & 1 & 2 & 3 \\ \hline 0 & 0 & 0 & 0 & 0 \\ 1 & 0 & 1 & 1 & 1 \\ 2 & 0 & 1 & 2 & 2 \\ 3 & 0 & 1 & 2 & 3 \\ \end{array} & \begin{array}{c|cccc} \text{max} & 0 & 1 & 2 & 3 \\ \hline 0 & 0 & 1 & 2 & 3 \\ 1 & 1 & 1 & 2 & 3 \\ 2 & 2 & 2 & 2 & 3 \\ 3 & 3 & 3 & 3 & 3 \\ \end{array} \end{array} \\ \begin{array}{c|cccc} \Delta & 0 & 1 & 2 & 3 \\ \hline 0 & 0 & 1 & 2 & 3 \\ 1 & 1 & 0 & 1 & 2 \\ 2 & 2 & 1 & 0 & 1 \\ 3 & 3 & 2 & 1 & 0 \\ \end{array} \end{array} min0123​00000​10111​20122​30123​​​max0123​00123​11123​22223​33333​​​Δ0123​00123​11012​22101​33210​​​

案例 1. 线性模型

示例

$$ h(\theta)=\sum_{j=0}^n \theta_j x_j $$

结果 h ( θ ) = ∑ j = 0 n θ j x j h(\theta)=\sum_{j=0}^n \theta_j x_j h(θ)=j=0∑n​θj​xj​

2. 均方误差

示例

$$ J(\theta) = \frac{1}{2m} \sum_{i=0}^m (y^i-h_\theta (x^i))^2 $$

结果 J ( θ ) = 1 2 m ∑ i = 0 m ( y i − h θ ( x i ) ) 2 J(\theta) = \frac{1}{2m} \sum_{i=0}^m (y^i-h_\theta (x^i))^2 J(θ)=2m1​i=0∑m​(yi−hθ​(xi))2

3. 批量梯度下降

示例

$$ \frac{\partial J(\theta)}{\partial\theta_j} = -\frac{1}{m}\sum_{i=0}^m (y^i - h_\theta (x^i))x^i_j $$

结果 ∂ J ( θ ) ∂ θ j = − 1 m ∑ i = 0 m ( y i − h θ ( x i ) ) x j i \frac{\partial J(\theta)}{\partial\theta_j} = -\frac{1}{m}\sum_{i=0}^m (y^i - h_\theta (x^i))x^i_j ∂θj​∂J(θ)​=−m1​i=0∑m​(yi−hθ​(xi))xji​

4. 推导过程

示例:

$$ \begin{align} \frac{\partial J(\theta)}{\partial \theta_j} & = - \frac{1}{m} \sum_{i=0}^m (y^i-h_\theta(x^i))\frac{\partial}{\partial\theta_j}(y^i-h_\theta(x^i))\\ & = -\frac{1}{m}\sum_{i=0}^m(y^i-h_\theta(x^i))\frac{\partial}{\partial\theta_j}(\sum_{j=0}^n\theta_j x^i_j - y^i)\\ & = - \frac{1}{m}\sum_{i=0}^m(y^i-h_\theta (x^i))x^i_j \end{align} $$

结果 KaTeX parse error: No such environment: align at position 8: \begin{̲a̲l̲i̲g̲n̲}̲ \frac{\partial…

参考文档

Cmd Markdown 公式指导手册



【本文地址】


今日新闻


推荐新闻


    CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3