使用LaTeX写矩阵

时间:2022-02-09 06:10:18

简介

LaTeX 的公式功能非常强大,一次性讲全不是件容易的事情。将LaTeX 的这些功能分成较小的相互独立的部分来讲,一方面方便大家单独查阅;另一方面,所有[CSDN_Markdown]相关的文章都放到了同一个专栏下: CSDN Markdown在线编辑,方便大家查阅。

本文主要介绍,如何在CSDN的Markdown编辑器中利用LaTeX 公式命令获得矩阵。


简单Matrix

使用$$\begin{matrix}…\end{matrix}$$来生成矩阵,其中... 表示的是LaTeX 的矩阵命令,矩阵命令中每一行以 \\ 结束,矩阵的元素之间用&来分隔开。

例如:


$$
  \begin{matrix}
   1 & 2 & 3 \\
   4 & 5 & 6 \\
   7 & 8 & 9
  \end{matrix} \tag{1}
$$
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

得到如下结果:

 

(1)123456789" role="presentation" style="box-sizing: border-box; outline: 0px; line-height: normal; word-spacing: normal; word-wrap: normal; white-space: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; padding: 0px; margin: 0px; word-break: break-all; position: relative; user-select: text !important; display: table-cell !important; width: 10000em !important;">147258369(1)(1)123456789

 


带括号的Matrix

感觉(1)中的矩阵不是很美观,可以给矩阵加上括号,加括号的方式有很多,大致可分为两种:使用\left ... \right 或者把公式命令中的matrix 改成 pmatrixbmatrixBmatrixvmatrixVmatrix等。


使用\left ... \right


1. {…}

实例:


$$
 \left\{
 \begin{matrix}
   1 & 2 & 3 \\
   4 & 5 & 6 \\
   7 & 8 & 9
  \end{matrix}
  \right\} \tag{2}
$$
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

得到如下结果:

 

(2){123456789}" role="presentation" style="box-sizing: border-box; outline: 0px; line-height: normal; word-spacing: normal; word-wrap: normal; white-space: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; padding: 0px; margin: 0px; word-break: break-all; position: relative; user-select: text !important; display: table-cell !important; width: 10000em !important;">147258369(2)(2){123456789}

 


2. […]

实例:


$$
 \left[
 \begin{matrix}
   1 & 2 & 3 \\
   4 & 5 & 6 \\
   7 & 8 & 9
  \end{matrix}
  \right] \tag{3}
$$
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

得到如下结果:

 

(3)[123456789]" role="presentation" style="box-sizing: border-box; outline: 0px; line-height: normal; word-spacing: normal; word-wrap: normal; white-space: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; padding: 0px; margin: 0px; word-break: break-all; position: relative; user-select: text !important; display: table-cell !important; width: 10000em !important;">147258369(3)(3)[123456789]

 


替换matrix


1. […]

实例:


$$
 \begin{bmatrix}
   1 & 2 & 3 \\
   4 & 5 & 6 \\
   7 & 8 & 9
  \end{bmatrix} \tag{4}
$$
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

得到如下结果:

 

(4)[123456789]" role="presentation" style="box-sizing: border-box; outline: 0px; line-height: normal; word-spacing: normal; word-wrap: normal; white-space: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; padding: 0px; margin: 0px; word-break: break-all; position: relative; user-select: text !important; display: table-cell !important; width: 10000em !important;">147258369(4)(4)[123456789]

 


2. {…}

实例:


$$
 \begin{Bmatrix}
   1 & 2 & 3 \\
   4 & 5 & 6 \\
   7 & 8 & 9
  \end{Bmatrix} \tag{5}
$$
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

得到如下结果:

 

(5){123456789}" role="presentation" style="box-sizing: border-box; outline: 0px; line-height: normal; word-spacing: normal; word-wrap: normal; white-space: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; padding: 0px; margin: 0px; word-break: break-all; position: relative; user-select: text !important; display: table-cell !important; width: 10000em !important;">147258369(5)(5){123456789}

 


带省略符号的Matrix

如果矩阵元素太多,可以使用\cdots " role="presentation" style="box-sizing: border-box; outline: 0px; display: inline; line-height: normal; text-align: left; word-spacing: normal; word-wrap: normal; white-space: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; padding: 0px; margin: 0px; word-break: break-all; position: relative; user-select: text !important;"> \ddots " role="presentation" style="box-sizing: border-box; outline: 0px; display: inline; line-height: normal; text-align: left; word-spacing: normal; word-wrap: normal; white-space: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; padding: 0px; margin: 0px; word-break: break-all; position: relative; user-select: text !important;"> \vdots " role="presentation" style="box-sizing: border-box; outline: 0px; display: inline; line-height: normal; text-align: left; word-spacing: normal; word-wrap: normal; white-space: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; padding: 0px; margin: 0px; word-break: break-all; position: relative; user-select: text !important;"> 等省略符号来定义矩阵。

例如:


$$
\left[
\begin{matrix}
 1      & 2      & \cdots & 4      \\
 7      & 6      & \cdots & 5      \\
 \vdots & \vdots & \ddots & \vdots \\
 8      & 9      & \cdots & 0      \\
\end{matrix}
\right]
$$
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

得到如下结果:

 

(6)[124765890]" role="presentation" style="box-sizing: border-box; outline: 0px; line-height: normal; word-spacing: normal; word-wrap: normal; white-space: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; padding: 0px; margin: 0px; word-break: break-all; position: relative; user-select: text !important; display: table-cell !important; width: 10000em !important;">178269450(6)(6)[124765890]

 


带参数的Matrix

比如写增广矩阵,可能需要最右边一列单独考虑。可以用array命令来处理:


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

得到如下结果:

 

(7)[123456]" role="presentation" style="box-sizing: border-box; outline: 0px; line-height: normal; word-spacing: normal; word-wrap: normal; white-space: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; padding: 0px; margin: 0px; word-break: break-all; position: relative; user-select: text !important; display: table-cell !important; width: 10000em !important;">[142536](7)(7)[123456]

 

其中\begin{array}{cc|c}中的c表示居中对齐元素,|用来作为分割列的符号。


行间矩阵

可以使用\bigl(\begin{smallmatrix} ... \end{smallmatrix}\bigr)

例如:


我们使用矩阵 $\bigl( \begin{smallmatrix} a & b \\ c & d \end{smallmatrix} \bigr)$ 作为因子矩阵,将其...
  • 1

得到:

我们使用矩阵 (abcd)" role="presentation" style="box-sizing: border-box; outline: 0px; display: inline; line-height: normal; text-align: left; word-spacing: normal; word-wrap: normal; white-space: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; padding: 0px; margin: 0px; word-break: break-all; position: relative; user-select: text !important;">(acbd)(abcd) 作为因子矩阵,将其…


总结

本文主要介绍了如何使用LaTeX 的命令在Markdown编辑器中生成矩阵。主要使用 \begin{matrix}...\end{matrix} \left\right 等命令来定义矩阵。了解更多,请参考:http://www.ctan.org/pkg/lshort