zoukankan      html  css  js  c++  java
  • 编辑你的数学公式——markdown中latex的使用

    前言

    最近开始使用起markdown来记学习笔记,因为经常有公式要写,就需要用到latex,到网上查来查去又不太方便,而且也很少能查到写的比较全的,就准备写下这篇文章。

    插入数学公式

    在markdown中插入数学公式的语法有两种:

    1. 行内公式$数学公式$
    2. 行间公式$$数学公式$$

    如:

    函数$ L(Y,f(X))=(Y-f(X))^2 $
    函数
    $$ 
    L(Y,f(X))=(Y-f(X))^2 
    $$
    

    函数$ L(Y,f(X))=(Y-f(X))^2 ​$

    函数

    [L(Y,f(X))=(Y-f(X))^2 ]

    如果需要加编号,加上 ag{编号}即可,如:

    $$ 
    L(Y,f(X))=(Y-f(X))^2 
    	ag{1}
    $$
    

    [L(Y,f(X))=(Y-f(X))^2 ag{1} ]

    上下标

    上标可由^表示,下标可由_表示,若上下标不止一个字符则需用花括号{}括起

    如:

    n_x n^x
    

    (n_x) (n^x)

    分数

    分数输入格式为frac{分子}{分母}

    如:

    $frac{1}{N}$
    

    (frac{1}{N})

    括号

    () []|都表示自己,但是{}需加

    如:

    $() [] | {}$
    

    (() [] | {})

    上下划线

    $$
    egin{array}
    overline{a+b} \
    underline{a+b} \
    overleftarrow{a+b} \
    underleftarrow{a+b} \
    underleftrightarrow{a+b} \
    vec x = vec{AB} \
    overbrace {a+b}^	ext{a,b} \
    a+
    lap{overbrace{phantom{b+c+d}}^m}b+underbrace{c+d+e}_n+f
    end{array}
    $$
    

    [egin{array} overline{a+b} \ underline{a+b} \ overleftarrow{a+b} \ underleftarrow{a+b} \ underleftrightarrow{a+b} \ vec x = vec{AB} \ overbrace {a+b}^ ext{a,b} \ a+ lap{overbrace{phantom{b+c+d}}^m}b+underbrace{c+d+e}_n+f end{array} ]

    省略号

    $$
    egin{eqnarray*} \
    ldots \
    cdots \
    vdots \
    ddots \
    end{eqnarray*}
    $$
    

    [egin{eqnarray*} \ ldots \ cdots \ vdots \ ddots \ end{eqnarray*} ]

    线性方程组

    使用case环境将多个公式组合

    $$
    L(Y,f(X))=
    egin{cases}
    1,quad &Y
    eq f(X)\
    0,quad &Y=f(X)
    end{cases}
    $$
    

    [L(Y,f(X))= egin{cases} 1,quad &Y eq f(X)\ 0,quad &Y=f(X) end{cases} ]

    另还有gathered环境

    $$
    left. egin{gathered}
    S subseteq T \
    S supseteq T
    end{gathered} 
    ight}
    implies S = T  
    $$
    

    [left. egin{gathered} A subseteq B \ A supseteq B end{gathered} ight} implies A = B ]

    数学模式重音符

    $$
    hat{a} check{a} 	ilde{a} acute{a}
    grave{a} dot{a} ddot{a} reve{a}
    ar{a} vec{a} widehat{a} widetilde{a}
    $$
    

    [hat{a} check{a} ilde{a} acute{a}\ grave{a} dot{a} ddot{a} reve{a}\ ar{a} vec{a} widehat{a} widetilde{a} ]

    矩阵

    $$
    X = 
    left[
    egin{matrix}
     x^{(1)} & x^{(2)} & cdots & x^{(m)} \
     x^{(1)} & x^{(2)} & cdots & x^{(m)} \
     x^{(1)} & x^{(2)} & cdots & x^{(m)} \
    end{matrix}
    
    ight]
    $$
    

    [X = left[ egin{matrix} x^{(1)} & x^{(2)} & cdots & x^{(m)} \ x^{(1)} & x^{(2)} & cdots & x^{(m)} \ x^{(1)} & x^{(2)} & cdots & x^{(m)} \ end{matrix} ight] ]

    希腊字母

    见下表

    代码 大写 代码 小写
    A A alpha α
    B B eta β
    Gamma Γ gamma γ
    Delta Δ delta δ
    E E epsilon ϵ
    Z Z zeta ζ
    H H eta η
    Theta Θ heta θ
    I I iota ι
    K K kappa κ
    Lambda Λ lambda λ
    M M mu μ
    N N u ν
    Xi Ξ xi ξ
    O O omicron ο
    Pi Π pi π
    P P ho ρ
    Sigma Σ sigma σ
    T T au τ
    Upsilon Υ upsilon υ
    Phi Φ phi ϕ
    X X chi χ
    Psi Ψ psi ψ
    Omega Ω omega ω

    常用数学符号

    包括积分符号、集合符号、累乘累加符号等

    见下表:

    转义符号 效果
    log_{x}y = arccos z (log_{x}y = arccos z)
    frac{a} {b} (frac{a} {b})
    _{a}^{b} extrm{C} (_{a}^{b} extrm{C})
    frac{partial {z_x}}{partial x} (frac{partial {z_x}}{partial x})
    frac{partial^2 {x}}{partial x^2} (frac{partial^2 {x}}{partial x^2})
    frac{mathrm{d} y}{mathrm{d} x} (frac{mathrm{d} y}{mathrm{d} x})
    int x (int x)
    int_{a}^{b}x (int_{a}^{b}x)
    oint a (oint a)
    oint_{a}^{b}C (oint_{a}^{b}C)
    iint_{a}^{v}C (iint_{a}^{v}C)
    igcap A (igcap A)
    igcap_{a}^{b}C (igcap_{a}^{b}C)
    igcup c (igcup c)
    igcup_{a}^{b}C (igcup_{a}^{b}C)
    lim_{c}X (lim_{c}X)
    sum a (sum a)
    sum_{a}^{b}C (sum_{a}^{b}C)
    sqrt{X} (sqrt{X})
    sqrt[a]{X} (sqrt[a]{X})
    prod X (prod X)
    prod_{a}^{b} X (prod_{a}^{b} X)
    coprod X (coprod X)
    coprod_{a}^{b} X (coprod_{a}^{b} X)
    left [ a ight ] (left [ a ight ])
    left ( a ight ) (left ( a ight ))
    left { a ight } (left { a ight })
    left langle a ight angle (left langle a ight angle)
    left lfloor a ight floor (left lfloor a ight floor)
    left lceil a ight ceil (left lceil a ight ceil)
    supseteqq A (supseteqq A)

    二元关系符

    [egin{array} & < & exttt{"<"} & > & exttt{">"} &= & exttt{"="}\ leq & exttt{"leq or le"} & geq & exttt{"geq or ge"} &equiv & exttt{"equiv"}\ ll & exttt{"ll"} & gg & exttt{"gg"} &doteq & exttt{"doteq"}\ prec & exttt{"prec"} & succ & exttt{"succ"} &sim & exttt{"sim"}\ preceq & exttt{"preceq"} & succeq & exttt{"succeq"} &simeq & exttt{"simeq"}\ subset & exttt{"subset"} & supset & exttt{"supset"} &approx & exttt{"approx"}\ subseteq & exttt{"subseteq"} & supseteq & exttt{"supseteq"} &approxeq & exttt{"approxeq"}\ sqsubset & exttt{"sqsubset"} & sqsupset& exttt{"sqsupset"} &Join & exttt{"Join"}\ sqsubseteq & exttt{"sqsubseteq"} & sqsupseteq& exttt{"sqsupseteq"} &owtie & exttt{"owtie"}\ in & exttt{"in"} & i & exttt{" i or owns"} &propto & exttt{"propto"}\ vdash & exttt{"vdash"} & dashv & exttt{"dashv"} &models & exttt{"models"}\ mid & exttt{"mid"} & parallel & exttt{"parallel"} &perp & exttt{"perp"}\ smile & exttt{"smile"} & frown & exttt{"frown"} &asymp & exttt{"asymp"}\ : & exttt{":"} & otin & exttt{" otin"} & eq & exttt{" eq or e"}\ end{array} ]

    三角函数与逻辑数学字符

    数学字符 输入 数学字符 输入
    ± pm × imes
    ÷ div | mid
    ∤∤ mid cdot
    circ ast
    igodot igotimes
    igoplus emptyset
    igvee igwedge
    iguplus igsqcup
    angle 30^∘ 30 ^ circ
    sin sin cos cos
    tan an cot cot
    prime iiint
    iiiint infty
    abla ecause
    herefore forall
    exists ot>
    otsubset sec sec
    uparrow downarrow
    Uparrow Downarrow
    ightarrow leftarrow
    Rightarrow Leftarrow
    longrightarrow longleftarrow
    Longrightarrow Longleftarrow
    quad (空格) # #
    ot

    数学字体

    字体表

    [egin{array} exttt{"normal"} & exttt{} & ABCDEFGHIJKLMNOPQRSTUVWXYZ\ exttt{"blackboard"} & exttt{mathbb} &mathbb{ABCDEFGHIJKLMNOPQRSTUVWXYZ}\ exttt{"boldface"} & exttt{mathbf} &mathbf{ABCDEFGHIJKLMNOPQRSTUVWXYZ}\ exttt{"typewriter"} & exttt{mathtt} &mathtt{ABCDEFGHIJKLMNOPQRSTUVWXYZ}\ exttt{"roman"} & exttt{mathrm} &mathrm{ABCDEFGHIJKLMNOPQRSTUVWXYZ}\ exttt{"sans-serif"} & exttt{mathsf} &mathsf{ABCDEFGHIJKLMNOPQRSTUVWXYZ}\ exttt{"calligraphic"}& exttt{mathcal} &mathcal{ABCDEFGHIJKLMNOPQRSTUVWXYZ}\ exttt{"script"} & exttt{mathscr} &mathscr{ABCDEFGHIJKLMNOPQRSTUVWXYZ}\ exttt{"fraktur"} & exttt{mathfrak}&mathfrak{ABCDEFGHIJKLMNOPQRSTUVWXYZ}\ end{array} ]

    色彩表

    [egin{array} hline verb+color{black}{黑色}+ & color{black}{黑色} \ verb+color{darkgray}{深灰}+ & color{darkgray}{深灰}\ verb+color{gray}{灰色}+ & color{gray}{灰色} \ verb+color{silver}{银色}+ & color{silver}{银色} \ verb+color{lightgray}{浅灰}+&color{lightgray}{浅灰}\ verb+color{white}{白色}+ & color{white}{白色} \ hline verb+color{brown}{棕色}+ & color{brown}{棕色} \ verb+color{maroon}{栗色}+ & color{maroon}{栗色} \ verb+color{red}{红色}+ & color{red}{红色} \ verb+color{fuchsia}{桃红}+ & color{fuchsia}{桃红} \ verb+color{magenta}{品红}+ & color{magenta}{品红} \ verb+color{pink}{粉红}+ & color{pink}{粉红} \ verb+color{orange}{橙色}+ & color{orange}{橙色} \ verb+color{yellow}{黄色}+ & color{yellow}{黄色} \ verb+color{lime}{青柠}+ & color{lime}{青柠} \ verb+color{olive}{橄榄}+ & color{olive}{橄榄} \ verb+color{green}{绿色}+ & color{green}{绿色} \ verb+color{aqua}{水绿}+ & color{aqua}{水绿} \ verb+color{cyan}{青色}+ & color{cyan}{青色} \ verb+color{teal}{靛青}+ & color{teal}{靛青} \ verb+color{blue}{蓝色}+ & color{blue}{蓝色} \ verb+color{navy}{海蓝}+ & color{navy}{海蓝} \ verb+color{violet}{罗兰}+ & color{purple}{罗兰} \ verb+color{purple}{紫色}+ & color{purple}{紫色} \ hline end{array}参考 ]

    参考:

    https://www.cnblogs.com/nowgood/p/Latexstart.html

    http://jzqt.github.io/2015/06/30/Markdown中写数学公式/

    https://blog.csdn.net/u014630987/article/details/70156489

    https://blog.csdn.net/cclethe/article/details/79022216

  • 相关阅读:
    总结hashMap和hashtable
    Java抽象类
    JSP内置对象
    Java子父类间静态代码块、非静态代码块、构造方法的执行顺序
    struts1和struts2的区别
    Java Thread中,run方法和start方法的区别
    Java集合类: Set、List、Map
    输入一个整数n,输出契波那契数列的第n项
    numpy中的各种乘法总结
    矩阵按键的原理及代码实现
  • 原文地址:https://www.cnblogs.com/csu-lmw/p/10434854.html
Copyright © 2011-2022 走看看