> For the complete documentation index, see [llms.txt](https://overleaf-pro.ayaka.space/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://overleaf-pro.ayaka.space/latex/zh-cn/shu-xue/04-matrices.md).

# 矩阵

## amsmath 矩阵环境

该 `amsmath` 该宏包提供用于使用不同定界符排版矩阵的命令。一旦你加载了 `\usepackage{amsmath}` 在导言区中，你就可以在数学环境中使用以下环境：

| 类型                 | LaTeX 标记                                              | 显示为                                                 |
| ------------------ | ----------------------------------------------------- | --------------------------------------------------- |
| 普通                 | `\begin{matrix} 1 & 2 & 3\\ a & b & c \end{matrix}`   | $$\begin{matrix}1 & 2 & 3\a & b & c\end{matrix}$$   |
| <p>圆括号；<br>圆括号</p> | `\begin{pmatrix} 1 & 2 & 3\\ a & b & c \end{pmatrix}` | $$\begin{pmatrix}1 & 2 & 3\a & b & c\end{pmatrix}$$ |
| <p>方括号；<br>方括号</p> | `\begin{bmatrix} 1 & 2 & 3\\ a & b & c \end{bmatrix}` | $$\begin{bmatrix}1 & 2 & 3\a & b & c\end{bmatrix}$$ |
| <p>花括号；<br>花括号</p> | `\begin{Bmatrix} 1 & 2 & 3\\ a & b & c \end{Bmatrix}` | $$\begin{Bmatrix}1 & 2 & 3\a & b & c\end{Bmatrix}$$ |
| 竖线                 | `\begin{vmatrix} 1 & 2 & 3\\ a & b & c \end{vmatrix}` | $$\begin{vmatrix}1 & 2 & 3\a & b & c\end{vmatrix}$$ |
| 双竖线                | `\begin{Vmatrix} 1 & 2 & 3\\ a & b & c \end{Vmatrix}` | $$\begin{Vmatrix}1 & 2 & 3\a & b & c\end{Vmatrix}$$ |

如果你需要创建带有不同 [定界符](/latex/zh-cn/shu-xue/03-brackets-and-parentheses.md)，你可以手动将它们添加到普通 `矩阵`.

| LaTeX 标记                                                                       | 显示为                                                                        |
| ------------------------------------------------------------------------------ | -------------------------------------------------------------------------- |
| `\left\lceil \begin{matrix} 1 & 2 & 3\\ a & b & c \end{matrix} \right\rceil`   | $$\left\lceil\begin{matrix}1 & 2 & 3\a & b & c\end{matrix}\right\rceil$$   |
| `\left\langle \begin{matrix} 1 & 2 & 3\\ a & b & c \end{matrix} \right\rvert`  | $$\left\langle\begin{matrix}1 & 2 & 3\a & b & c\end{matrix}\right\rvert$$  |
| `\left\langle \begin{matrix} 1 & 2 & 3\\ a & b & c \end{matrix} \right\rangle` | $$\left\langle\begin{matrix}1 & 2 & 3\a & b & c\end{matrix}\right\rangle$$ |

## 行内矩阵

在排版行内数学时，通常 `矩阵` 上面的环境可能显得过大。此时最好使用 `smallmatrix` 在这种情况下，尽管你需要自己提供 [定界符](/latex/zh-cn/shu-xue/03-brackets-and-parentheses.md).

```latex
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\noindent 试着在这里排版一个行内矩阵：
 $\begin{pmatrix}
  a & b\\
  c & d
\end{pmatrix}$,
但它看起来太大了，所以我们试试
$\big(\begin{smallmatrix}
  a & b\\
  c & d
\end{smallmatrix}\big)$
。
\end{document}
```

[在 Overleaf 中打开此 `smallmatrix` Overleaf 中的示例](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=amsmath+matrix+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Bamsmath%7D%0A%5Cbegin%7Bdocument%7D%0A%5Cnoindent+Trying+to+typeset+an+inline+matrix+here%3A%0A+%24%5Cbegin%7Bpmatrix%7D%0A++a+%26+b%5C%5C+%0A++c+%26+d%0A%5Cend%7Bpmatrix%7D%24%2C++%0Abut+it+looks+too+big%2C+so+let%27s+try+%0A%24%5Cbig%28%5Cbegin%7Bsmallmatrix%7D%0A++a+%26+b%5C%5C%0A++c+%26+d%0A%5Cend%7Bsmallmatrix%7D%5Cbig%29%24+%0Ainstead.%0A%5Cend%7Bdocument%7D)

下图显示了上述示例生成的输出：

![Amsmatrix.png](/files/1e0f473d1b61f8e253b04c6a6af625a55d08db4f)

该 `mathtools` 宏包提供 `psmallmatrix`, `bsmallmatrix` 等环境，方便使用。

## 进一步阅读

* [数学表达式](/latex/zh-cn/shu-xue/01-mathematical-expressions.md)
* [括号](/latex/zh-cn/shu-xue/03-brackets-and-parentheses.md)
* [使用 amsmath 对齐方程](/latex/zh-cn/shu-xue/06-aligning-equations-with-amsmath.md)
* [数学模式中的显示样式](/latex/zh-cn/shu-xue/10-display-style-in-math-mode.md)
* [LaTeX2ε 不那么简短的介绍](http://www.ctan.org/tex-archive/info/lshort/)
* [amsmath 宏包文档](http://texdoc.net/pkg/amsmath)
* [mathtools 宏包文档](http://texdoc.net/pkg/mathtools)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://overleaf-pro.ayaka.space/latex/zh-cn/shu-xue/04-matrices.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
