美文网首页花间独酌
markdown 拓展 - MathJax 教程

markdown 拓展 - MathJax 教程

作者: acc8226 | 来源:发表于2020-05-03 14:17 被阅读0次

MathJax简介

MathJax 是一款运行在浏览器中的开源数学符号渲染引擎,使用MathJax可以方便的在浏览器中显示数学公式,不需要使用图片。目前,MathJax可以解析 LatexMathMLASCIIMathML 的标记语言。MathJax项目于2009年开始,发起人有American Mathematical Society, Design Science等,还有众多的支持者,个人感觉MathJax会成为今后数学符号渲染引擎中的主流,也许现在已经是了。本文接下来会讲述MathJax的基础用法,但不涉及MathJax的安装及配置。

LaTeX 数学公式

这个教程图文并茂, 强烈建议参考

You can render LaTeX mathematical expressions using KaTeX

实例

特殊字符

\pi

\pi

乘号, 除号, +或者-

\times \div \pm \mp

\times \div \pm \mp

上下标

x_i^2

x_i^2

x^2_i

x^2_i

x^{10}

x^{10}

括号

  1. 小括号与方括号:使用原始的(),[]即可
  2. 大括号:由于大括号{}被用来分组,因此需要使用{和}这种转义方法表示,也可以使用\lbrace和\rbrace来表示。如
\{a*b\}

\{a*b\}

\pi

\pi

\lbrace a*b \rbrace

\lbrace a*b \rbrace

求和与积分
\sum用来表示求和符号,其下标表示求和下限,上标表示上限。如

\sum_1^n

\sum_1^n

\int用来表示积分符号,同样地,其上下标表示积分的上下限。如

\int_1^\infty

\int_1^\infty

分式
第一种,使用\frac ab , \frac作用于其后的两个组a , b ,结果为𝑎𝑏。如果你的分子或分母不是单个字符,请使用{...}来分组。

\frac ab

\frac ab

\frac a{x+1}

\frac a{x+1}

第二种,使用\over来分隔一个组的前后两部分,如 {a+1 \over b+1}

{a+1 \over b+1}

{a+1 \over b+1}

根式
根式使用\sqrt表示

\sqrt 5

\sqrt 5

\sqrt[3] {x \over y}

\sqrt[3] {x \over y}

小于大于等号

\lt \gt \le \ge \neq

\lt \gt \le \ge \neq

\not\lt \not\gt \not\le \not\ge

\not\lt \not\gt \not\le \not\ge

排列

\binom{n+1}{2k}

\sqrt[3] {x \over y}

或者

{n+1 \choose 2k}

{n+1 \choose 2k}

x = {-b \pm \sqrt{b^2-4ac} \over 2a}

x = {-b \pm \sqrt{b^2-4ac} \over 2a}

数列
\ldots与\cdots,其区别是dots的位置不同,ldots位置稍低,cdots位置居中。

a_1 + a_2 + \cdots

a_1 + a_2 + \cdots

a_1,\,a_2, \ldots, a_n

a_1,\,a_2, \ldots, a_n

矩阵
使用‘三个点’

\begin{matrix}...\end{matrix}

\begin{matrix}...\end{matrix}来表示矩阵,在\begin与\end之间加入矩阵的元素即可。矩阵的行之间用\分隔,列之间用&分隔。

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

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

加括号
如果要对矩阵加括号,可以使用特殊的matrix,即替换\begin{matrix}...\end{matrix}中的matrix为pmatrix , bmatrix , Bmatrix , vmatrix , Vmatrix.

省略元素
可以使用\cdots ⋯ \ddots ⋱ \vdots ⋮ 来省略矩阵中的元素,如:

一些参考

\sum_{i=0}^n i^2 = \frac{(n^2+n)(2n+1)}{6}

\sum_{i=0}^n i^2 = \frac{(n^2+n)(2n+1)}{6}

\Gamma(z) = \int_0^\infty t^{z-1}e^{-t}dt\,.

\Gamma(z) = \int_0^\infty t^{z-1}e^{-t}dt\,.

支持 LaTeX 数学公式的markdown 工具

StackEdit 支持$$...$$写法
印象笔记 支持```math写法
有道云笔记 支持$$...$$写法 和 ```math写法
简书, 支持$...$行内式写法和 $$...$$独占整行写法

总结

不能记住所有的命令, 记得经常翻看
https://khan.github.io/KaTeX/docs/supported.html

空格的使用
\, 或者 \thinspace ³∕₁₈ em space, 最常用的一种空格形式
\enspace ½ em space
\quad 1 em space

参考

Mathjax与LaTex公式简介 - 林大勇 - 博客园
https://www.cnblogs.com/linxd/p/4955530.html

MathJax basic tutorial and quick reference - Mathematics Meta Stack Exchange
https://math.meta.stackexchange.com/questions/5020/mathjax-basic-tutorial-and-quick-reference/5044

https://khan.github.io/KaTeX/docs/supported.html

相关文章

网友评论

    本文标题:markdown 拓展 - MathJax 教程

    本文链接:https://www.haomeiwen.com/subject/osflghtx.html