> For the complete documentation index, see [llms.txt](https://ayakaleaf-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://ayakaleaf-pro.ayaka.space/latex/zh-cn/geng-duo-zhu-ti/36-latex-video-tutorial-for-beginners-video-6.md).

# LaTeX 新手视频教程（视频 6）

[视频 1](/latex/zh-cn/geng-duo-zhu-ti/31-latex-video-tutorial-for-beginners-video-1.md) | [视频 2](/latex/zh-cn/geng-duo-zhu-ti/32-latex-video-tutorial-for-beginners-video-2.md) | [视频 3](/latex/zh-cn/geng-duo-zhu-ti/33-latex-video-tutorial-for-beginners-video-3.md) | [视频 4](/latex/zh-cn/geng-duo-zhu-ti/34-latex-video-tutorial-for-beginners-video-4.md) | [视频 5](/latex/zh-cn/geng-duo-zhu-ti/35-latex-video-tutorial-for-beginners-video-5.md) | 视频 6 | 视频 7

这套由七部分组成的 LaTeX 教程视频最初发布于 2013 年；因此，由于 ShareLaTeX 的发展以及随后 ShareLaTeX 与 Overleaf 的合并，如今的编辑器界面已经发生了相当大的变化。不过，这些视频内容仍然相关，并且会教你 LaTeX 的基础知识——这些技能和经验适用于所有平台。你不需要任何先前的背景知识，在这些 LaTeX 指南结束时，你将能够创建并编写基本的 LaTeX 文档，并具备开始学习如何创建更复杂文档的知识。每个视频都配有一份文字稿（列在视频下方）——这些就地文字稿取代了每个教程开头显示的 URL。

### LaTeX 中的表格和矩阵

**注意：** 你可以通过以下方式打开视频中使用的项目 [点击此链接](https://www.sharelatex.com/project/51f1324bc00460011608ea5c).

{% embed url="<https://www.youtube.com/embed/1cEdqTMtHZQ>" %}

### 视频文字稿

在 [上一个视频](/latex/zh-cn/geng-duo-zhu-ti/35-latex-video-tutorial-for-beginners-video-5.md) 我们已经看过如何使用 BibTeX 将参考文献添加到文档中。在本视频中，我们将看看如何插入表格和矩阵。

在 LaTeX 中插入表格，我们使用 `tabular` 环境。所以让我们添加 begin 和 end 命令。紧接着 `\begin{tabular}` 命令后，我们需要告诉 LaTeX 列的规格。为此我们使用几个关键字符。首先，小写的 `l` 表示左对齐列，小写的 `r` 表示右对齐列，而小写的 `c` 表示居中列。在我的示例中，我将指定六列，第一列和最后一列左对齐，其余列居中。要在列之间添加竖线，我们可以使用竖线符号，并把它放在需要出现线条的字母之间。输入表格内容时，我们每行从新的一行开始，使用与号分隔各列条目，并且每一行都以双反斜杠结束，最后一行除外。

现在要添加水平线，我们使用 `\hline` 命令。要制作双水平线，只需将该命令使用两次。这个表格的一个潜在问题是，如果我在最后一列的某个单元格中加入一长段文字，它会溢出页面。为了解决这个问题，在声明列规格时我们还可以使用另一个选项。它是小写的 `p` 后面跟着一个以厘米为单位的宽度，放在花括号中。所以如果我把声明中的最后一个 `l` 在声明中改成一个 `p` 与 `5cm` 你会看到文本已经自动换行，因此最后一列的宽度是 5cm。

这就是编写表格的基础。不过，就像图片一样，我们通常希望对位置有更多控制，并且可能想添加标题和标签。为此我们使用一个名为 `table` 它类似于我们用于图片的 `figure` 环境。要把我们现有的表格放入 `table` 环境中，我们只需将代码包裹在 `\begin{table}` 和 `\end{table}` 命令中。然后我们可以使用以下组合来设置位置参数： `h`, `t`, `b`, `p` 和感叹号（`!`）。我还可以添加标题和标签。

现在我们简要看看矩阵，因为它们使用与表格类似的语法。此时请确保你已经加载了 `amsmath` 宏包。在添加矩阵之前，我们需要通过打开一个环境来告诉 LaTeX 我们即将添加一些数学内容。我们可以像前几期视频那样使用 equation 环境，不过这里我们将使用 `displaymath` 环境，因为它有很好的 LaTeX 简写形式。这意味着我们不必使用 `\begin` 命令，而可以使用反斜杠加左方括号；同样，也不必使用结束命令，而可以使用反斜杠加右方括号。矩阵可以使用 `matrix` 环境插入。对于矩阵，我们不需要声明使用多少列，只需直接开始添加条目即可。同样，我们每行从新的一行开始，使用与号分隔条目，并用双反斜杠分隔各行。要更改矩阵周围的括号，我们只需更改环境。 `pmatrix` 环境使用圆括号， `bmatrix` 使用方括号， `Bmatrix` （其中大写的 `B`）使用花括号， `vmatrix` 使用竖线，而 `Vmatrix` （其中大写的 `V`）使用双竖线。

最后，我们用一个更有趣的矩阵来结束本视频。在这个例子中，我们是在一个矩阵中嵌套矩阵。实际上这里我们得到的是一个由 `pmatrix` 环境构建的二乘二矩阵，其中左上角和右下角的条目本身也是矩阵，这次是由 `matrix` 环境构建，以避免出现多个括号。

这就结束了我们对表格和矩阵的讨论。在本系列的最后一个视频中，我们将看看如何编排更大的文档。

[视频 1](/latex/zh-cn/geng-duo-zhu-ti/31-latex-video-tutorial-for-beginners-video-1.md) | [视频 2](/latex/zh-cn/geng-duo-zhu-ti/32-latex-video-tutorial-for-beginners-video-2.md) | [视频 3](/latex/zh-cn/geng-duo-zhu-ti/33-latex-video-tutorial-for-beginners-video-3.md) | [视频 4](/latex/zh-cn/geng-duo-zhu-ti/34-latex-video-tutorial-for-beginners-video-4.md) | [视频 5](/latex/zh-cn/geng-duo-zhu-ti/35-latex-video-tutorial-for-beginners-video-5.md) | 视频 6 | 视频 7


---

# 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://ayakaleaf-pro.ayaka.space/latex/zh-cn/geng-duo-zhu-ti/36-latex-video-tutorial-for-beginners-video-6.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.
