typora中插入LaTeX数学公式

typora中插入LaTeX数学公式

本文内容参考https://blog.youkuaiyun.com/baidu_38060633/article/details/79183905 在Typora上进行了实验。

typora公式语法

数学公式有两种形式: inline 和 display

  • **inline(行间公式)?*在正文插入数学公式,用$...$ 将公式括起来
  • display(快间公式) :独立排列的公式,用 $$...$$将公式括起来,默认显示在行中间

equation是用户给当前公式自定义的名字(随便写)

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

  • 各类希腊字母表:

    eg: $\alpha$:α\alphaα

    在这里插入图片描述

常用语法

所有字符后面都可以跟个空格,避免与表达式中的字母符号混淆

特殊字符说 明实例
$数学公式前后加$是行内公式数学公式: a = x + y a=x+y a=x+y
$$数学公式加$$就是读占一行的公式独占一行: a = x + y a=x+y a=x+y
\转义字符,特殊字符要显示原意,就在前面加\$$$
\\在数学公式中是换行 a = x + y b = y a=x+y\\b=y a=x+yb=y
_后跟内容为下标 a i a_i ai
^后跟内容为上标 a i a^i ai
{}被括号起来的公式是一组内容 x 22 y ( x ) x y z x_{22} y^{(x)} x^{y^z} x22y(x)xyz
\frac分数 1 a \frac{1}{a} a1
\sqrt根号 x y + x a \sqrt{xy}+\sqrt[a]{x} xy +ax
\ldots跟文本底线对齐的省略号 a i … n a_{i\ldots{n}} ain
\cdots跟文本中线对齐的省略号 i ⋯ n i\cdots n in
\sum求和$\sum_{k=1}^nkx $
\int积分 ∫ a b \int_a^b ab
\limits强制上下限在上下侧$\sum\limits_{k=1}^nkx $
\nolimits强制上下限在右侧 ∑ k = 1 n k x \sum\nolimits_{k=1}^nkx k=1nkx
\overline上划线 a + b ‾ \overline{a+b} a+b
\underline下划线 a + b ‾ \underline{a+b} a+b
\overbrace上花括号 a + b + ⋯ + n ⏞ m 个 \overbrace{a+b+\dots+n}^{m个} a+b++n m
\underbrace下花括号 a + b + ⋯ + n ⏟ m 个 \underbrace{a+b+\dots+n}_{m个} m a+b++n
\vec向量 a ⃗ \vec{a} a
\lim极限 lim ⁡ x → ∞ \lim_{x \to \infty} limx
\left \right用于自适应匹配分隔符如{,(,详情见方程组
\approx约等于 ≈ \approx
\cdot点乘 A ⋅ B A\cdot B AB
\times叉乘 5 × 7 5\times7 5×7
\sim波浪号 ∼ \sim

Latex的各种帽子

\hat{A}

img

\widehat{A}

img

\tilde{A}

img

\widetilde{A}

img

\overline{A}

img

\underline{A}

img

\overbrace{A}

img

\underbrace{A}

img

\overset{a}{b}

img

\underset{a}{b}

img

\overleftarrow{A}

img

\overrightarrow{A}

img

其他常见例子

注意使用\begin{equation}…\end{equation},equation对应每种表达式,但是单行的情况下可以不用

  • 基本预算符: ± \pm ± ÷ \div ÷

  • 矩阵与行列式

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

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} 111xyzx2y2z2

行列式:

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

X = ∣ x 11 x 12 ⋯ x 1 d x 21 x 22 ⋯ x 2 d ⋮ ⋮ ⋱ ⋮ x 11 x 12 ⋯ x 1 d ∣ X=\left| \begin{matrix} x_{11} & x_{12} & \cdots & x_{1d}\\ x_{21} & x_{22} & \cdots & x_{2d}\\ \vdots & \vdots & \ddots & \vdots \\ x_{11} & x_{12} & \cdots & x_{1d}\\ \end{matrix} \right| X=x11x21x11x12x22x12x1dx2dx1d

  • 分隔符

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

  • 箭头
$\leftarrow$

← \leftarrow

在这里插入图片描述

  • 方程式

    E=mc^2
    

    E = m c 2 E=mc^2 E=mc2

  • 分段函数

    $$
    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

  • 方程组

    $$
    \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.
    $$
    
    

    { 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. a1x+b1y+c1z=d1a2x+b2y+c2z=d2a3x+b3y+c3z=d3

常用公式

  • 线性模型

    $$
    	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=0nθjxj

  • 均方误差

    $$
    	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(θ)=2m1i=0m(yihθ(xi))2

    求积公式

    $$
    	H_c=\sum_{l_1+\dots +l_p}\prod^p_{i=1} \binom{n_i}{l_i}
    $$
    

H c = ∑ l 1 + ⋯ + l p ∏ i = 1 p ( n i l i ) H_c=\sum_{l_1+\dots +l_p}\prod^p_{i=1} \binom{n_i}{l_i} Hc=l1++lpi=1p(lini)

  • 批量梯度下降

    $$
    	\frac{\partial J(\theta)}{\partial\theta_j} = -\frac1m\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} = -\frac1m\sum_{i=0}^m(y^i - h_\theta(x^i))x^i_j θjJ(θ)=m1i=0m(yihθ(xi))xji

  • 推导过程

    $$
    \begin{align}
    	\frac{\partial J(\theta)}{\partial\theta_j}
    	& = -\frac1m\sum_{i=0}^m(y^i - h_\theta(x^i)) \frac{\partial}{\partial\theta_j}(y^i-h_\theta(x^i))\\
    	& = -\frac1m\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)\\
    	&=-\frac1m\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{\partia…

  • 字符下标

    $$
    \max \limits_{a<x<b}\{f(x)\}	
    $$
    

max ⁡ a < x < b { f ( x ) } \max \limits_{a<x<b}\{f(x)\} a<x<bmax{f(x)}

参考

  1. https://blog.youkuaiyun.com/baidu_38060633/article/details/79183905
  2. https://www.latex-project.org/help/

注:如有问题,请指正,谢谢

^n\theta_j xi_j-yi)\
&=-\frac1m\sum_{i=0}m(yi -h_\theta(x^i)) x^i_j
\end{align}
$$

  • 字符下标

    $$
    \max \limits_{a<x<b}\{f(x)\}	
    $$
    

max ⁡ a < x < b { f ( x ) } \max \limits_{a<x<b}\{f(x)\} a<x<bmax{f(x)}

参考

  1. https://blog.youkuaiyun.com/baidu_38060633/article/details/79183905
  2. https://www.latex-project.org/help/

注:如有问题,请指正,谢谢

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值