> 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/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

这套由 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` 命令。要生成双横线，只需将该命令使用两次。这个表格的一个潜在问题是，如果我在最后一列的某个单元格中加入一长段文本，它会溢出页面。为了解决这个问题，在声明列规格时我们还可以使用另一个选项。那就是小写的 `页` 后面跟着一个以厘米为单位的宽度，并放在花括号中。所以如果我将最后一个 `l` 在声明中改成一个 `页` 与 `5 厘米` 你会看到文本已自动换行，使最后一列的宽度为 5 厘米。

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

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

最后，我们以一个更有趣的矩阵结束本视频。在这个例子中，我们所做的是在另一个矩阵中嵌套矩阵。因此，我们这里实际得到的是一个用 `pmatrix` 环境构建的 2×2 矩阵，其中左上角和右下角的条目本身也是矩阵，这次使用 `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://overleaf-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.
