思谋网已支持LaTeX数学公式,更好展示科研成果

思谋网的文章已经能支持Latex数学公式嵌入,该功能基于MathJax的JS脚本技术实现,可以在网页中实时显示数学公式,实现文字和公式符号的混合排版,便于展现高质量的科研成果。

表格

使用 \begin {array}{列样式}…\end{array}这样的形式来创建表格,列样式可以是clr表示居中,左,右对齐,还可以使用|表示一条竖线。表格中各行使用\\分隔,各列使用&分隔,使用\hline在本行前加入一条直线。例如

\begin {array}{c|lcr} n & \text{Left} & \text{Center} & \text{Right} \\ \hline 1 & 0.24 & 1 & 125 \\ 2 & -1 & 189 & -8 \\ 3 & -20 & 2000 & 1+10i \\ \end{array} 

结果:$$\begin{array}{c|lcr} n & \text{Left} & \text{Center} & \text{Right} \\ \hline 1 & 0.24 & 1 & 125 \\ 2 & -1 & 189 & -8 \\ 3 & -20 & 2000 & 1+10i \\ \end{array}$$

一个复杂的例子如下:

\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}

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

矩阵

基本用法
使用 \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}$$

加括号
如果要对矩阵加括号,可以像上文中提到的那样,使用\left与\right配合表示括号符号。也可以使用特殊的matrix,即替换\begin {matrix}…\end{matrix}中的matrix为pmatrix , bmatrix , Bmatrix , vmatrix , Vmatrix.

如 pmatrix: \(\begin{pmatrix} 1 &2 \\ 3 & 4 \\ \end{pmatrix}\) bmatrix: \(\begin{bmatrix} 1 &2 \\ 3 &4 \\ \end{bmatrix}\) Bmatrix: \(\begin{Bmatrix} 1 &2 \\ 3 & 4 \\ \end{Bmatrix}\) vmatrix: \(\begin{vmatrix} 1 & 2 \\ 3 &4 \\ \end{vmatrix}\) Vmatrix: \(\begin{Vmatrix} 1 &2 \\ 3 &4 \\ \end{Vmatrix}\)

pmatrix: [latex]\begin{pmatrix} 1 &2 \\ 3 & 4 \\ \end{pmatrix}[/latex] bmatrix: [latex]\begin{bmatrix} 1 &2 \\ 3 &4 \\ \end{bmatrix}[/latex] Bmatrix: [latex]\begin{Bmatrix} 1 &2 \\ 3 & 4 \\ \end{Bmatrix}[/latex] vmatrix: [latex]\begin{vmatrix} 1 & 2 \\ 3 &4 \\ \end{vmatrix}[/latex] Vmatrix: [latex]\begin{Vmatrix} 1 &2 \\ 3 &4 \\ \end{Vmatrix}[/latex]

省略元素
可以使用\cdots \(\cdots\) \ddots \(\ddots\) \vdots \(\vdots\) 来省略矩阵中的元素,如:$$\begin{pmatrix} 1 & a_1 & a_1^2 & \cdots & a_1^n \\ 1 & a_2 & a_2^2 & \cdots & a_2^n \\ \vdots & \vdots & \vdots & \ddots & \vdots \\ 1 & a_m & a_m^2 & \cdots & a_m^n \end{pmatrix}$$

\begin{pmatrix} 1 & a_1 & a_1^2 & \cdots & a_1^n \\ 1 & a_2 & a_2^2 & \cdots & a_2^n \\ \vdots & \vdots & \vdots & \ddots & \vdots \\ 1 & a_m & a_m^2 & \cdots & a_m^n \end{pmatrix}

增广矩阵
增广矩阵需要使用前面的array来实现,如

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

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

对齐的公式

有时候可能需要一系列的公式中等号对齐,如:$$ \begin{align} \sqrt{37} & = \sqrt{\frac{73^2-1}{12^2}} \tag{4} \\ & = \sqrt{\frac{73^2}{12^2} \cdot \frac{73^2-1}{73^2}} \tag{5} \\ & = \frac{73}{12} \sqrt{1 – \frac{1}{73^2}} \tag{6} \\ & \approx \frac{73}{12} \left( 1 – \frac{1}{2 \cdot 73^2} \right) \tag{7} \end{align} $$

\begin{align} \sqrt{37}  & = \sqrt{\frac{73^2-1}{12^2}} \tag{4} \\ & = \sqrt{\frac{73^2}{12^2} \cdot \frac{73^2-1}{73^2}} \tag{5} \\ & = \frac{73}{12} \sqrt{1 - \frac{1}{73^2}} \tag{6} \\ & \approx \frac{73}{12} \left( 1 - \frac{1}{2 \cdot 73^2} \right) \tag{7} \end{align}

这时候需要使用形如\begin{align}\end{align}的格式,其中需要使用&来指示需要对齐的位置,请使用右键查看上述公式的代码。

分类表达式

定义函数的时候经常需要分情况给出表达式,可使用\begin {cases}…\end{cases}。其中,使用\来分类,使用&指示需要对齐的位置。如:$$ f(n) = \begin{cases} n/2, & \text{if \(n\) is even} \\ 3n+1, & \text{if \(n\) is odd} \end{cases} $$

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

上述公式也可以移动到右侧,不过需要使用array来实现,如下:$$ \left. \begin{array}{l} \text{if \(n\) is even:} & n/2 \\ \text{if \(n\) is odd:} & 3n+1 \end{array} \right\} = f(n) $$

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

最后,如果需要让分类之间的垂直间隔变大,可以使用\[2ex]代替\来分隔不同情况。(3ex, 4ex也可以使用,1ex相当于原始距离)。

规范表达

不要在指数或者积分中使用\frac
在指数或者基本表达式中使用\frac会使表达式看起来不清晰,因此在专业的数学排版中很少被使用。应该使用一个水平的/来代替,效果如下:$$\begin{array}{cc} \mathrm{Bad} & \mathrm{Better} \\ \hline \\ e^{i\frac{\pi}{2}} \quad e^{\frac{i\pi}{2}} & e^{i\pi/2} \\ \int_{-\frac{\pi}{2}}^{\frac{\pi}{2}} \sin x \, dx & \int_{-\pi/2}^{\pi/2} \sin x \, dx \\ \end{array} $$

\begin{array}{cc} \mathrm{Bad} & \mathrm{Better} \\ \hline \\ e^{i\frac{\pi}{2}} \quad e^{\frac{i\pi}{2}} & e^{i\pi/2} \\ \int_{-\frac{\pi}{2}}^{\frac{\pi}{2}} \sin x \, dx & \int_{-\pi/2}^{\pi/2} \sin x \, dx \\ \end{array}

使用\mid代替|作为分隔符
符号|作为分隔符时有排版空间大小的问题,应该使用\mid代替,效果如下:$$\begin{array}{cc} \mathrm{Bad} & \mathrm{Better} \\ \hline \\ \{x | x^2 \in \Bbb Z\} & \{x \mid x^2 \in \Bbb Z \} \end{array}$$

\begin{array}{cc} \mathrm{Bad} & \mathrm{Better} \\ \hline \\ \{x | x^2 \in \Bbb Z\} & \{x \mid x^2 \in \Bbb Z \} \end{array}

多重积分
对于多重积分,不要使用\int\int此类的表达,应该使用\iint \iiint等特殊形式,效果如下:$$ \begin{array}{cc} \mathrm{Bad} & \mathrm{Better} \\ \hline \\ \int\int_S f(x) \, dy \, dx & \iint_S f(x) \, dy \, dx \\ \int\int\int_V f(x) \, dz \, dy \, dx & \iiint_V f(x) \, dz \, dy \, dx \end{array} $$

\begin{array}{cc} \mathrm{Bad}  & \mathrm{Better} \\ \hline \\ \int\int_S f(x) \, dy \, dx & \iint_S f(x) \, dy \, dx \\ \int\int\int_V f(x) \, dz \, dy \, dx & \iiint_V f(x) \, dz \, dy \, dx \end{array}

此外,在微分前应该使用\,来增加些许空间,否则\(\TeX\)会将微分紧凑地排列在一起,如下:$$ \begin{array}{cc} \mathrm{Bad} & \mathrm{Better} \\ \hline \\ \iiint_V f(x) dz dy dx & \iiint_V f(x) \, dz \, dy \, dx \end{array} $$

\begin{array}{cc} \mathrm{Bad} & \mathrm{Better} \\ \hline \\ \iiint_V f(x) dz dy dx & \iiint_V f(x) \, dz \, dy \, dx \end{array}

连分数
书写连分数表达式时,请使用\cfrac代替\frac或者\over:

$$x = a_0+\frac{1^2}{a_1+\frac{2^2}{a_2+\frac{3^2}{a_3+\frac{4^2}{a_4+\cdots}}}} $$

x = a_0+\frac{1^2}{a_1+\frac{2^2}{a_2+\frac{3^2}{a_3+\frac{4^2}{a_4+\cdots}}}}

方程组
使用\begin {array}…\end{array}与\left{…与\right.配合表示方程组,如:

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

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

同时,还可以使用\begin {cases}…\end{cases}表达同样的方程组,如:

\begin{cases} 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{cases}

$$ \begin{cases} 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{cases} $$

对齐方程组中的=号,可以使用\begin {aligned}…\end{aligned},如:

\left\{ \begin{aligned} a_1x+b_1y+c_1z & = d_1+e_1 \\ a_2x+b_2y & = d_2 \\ a_3x+b_3y+c_3z & = d_3 \end{aligned} \right. 

$$ \left\{ \begin{aligned} a_1x+b_1y+c_1z & = d_1+e_1 \\ a_2x+b_2y & = d_2 \\ a_3x+b_3y+c_3z & = d_3 \end{aligned} \right. $$

颜色
命名颜色是浏览器相关的,如果浏览器没有定义相关的颜色名称,则相关文本将被渲染为黑色。以下颜色是HTML4和CSS2标准中定义的一些颜色,其应该被大多数浏览器定义了。

$$ \begin{array}{|rc|} \hline \\ \verb+\color{black}{text}+ & \color{black}{text} \\ \verb+\color{gray}{text}+ & \color{gray}{text} \\ \verb+\color{silver}{text}+ & \color{silver}{text} \\ \verb+\color{white}{text}+ & \color{white}{text} \\ \hline \\ \verb+\color{maroon}{text}+ & \color{maroon}{text} \\ \verb+\color{red}{text}+ & \color{red}{text} \\ \verb+\color{yellow}{text}+ & \color{yellow}{text} \\ \verb+\color{lime}{text}+ & \color{lime}{text} \\ \verb+\color{olive}{text}+ & \color{olive}{text} \\ \verb+\color{green}{text}+ & \color{green}{text} \\ \verb+\color{teal}{text}+ & \color{teal}{text} \\ \verb+\color{aqua}{text}+ & \color{aqua}{text} \\ \verb+\color{blue}{text}+ & \color{blue}{text} \\ \verb+\color{navy}{text}+ & \color{navy}{text} \\ \verb+\color{purple}{text}+ & \color{purple}{text} \\ \verb+\color{fuchsia}{text}+ & \color{fuchsia}{text} \\ \verb+\color{magenta}{text}+ & \color{magenta}{text} \\ \hline \end{array} $$

同时,颜色也可以使用#rgb的形式来表示,如下:

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

公式标记和引用

如果想在之后引用该公式,则还需要加上\label{…}在\tag之后,如:

a:= x^2-y^3 \tag{A}\label{A1}

$$ a:= x^2-y^3 \tag{A}\label{A1} $$

为了引用公式,可以使用\eqref {A1},如:

a+y^3 \stackrel{\eqref{A1}}=x^2

$$ a+y^3 \stackrel{\eqref{A1}}=x^2 $$

可以看到,通过超链接可以跳转到被引用公式的位置。

【声明】本文由 思谋科普组 发布,所涉及言论仅代表作者观点,若有侵权或违规信息,请联系我们处理。除非另有说明,可自由分享(转载)本文内容,但必须保持署名、涉及商业用途应获得原作者授权。
网址引用: 思谋科普组. 思谋网已支持LaTeX数学公式,更好展示科研成果. 思谋网. https://www.scmor.com/view/6312.
(32)
思谋科普组的头像思谋科普组网站团队
上一篇 2021年4月10日 11:14
下一篇 2021年5月31日 07:09

相关阅读

发表回复

登录后才能评论