> 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-tw/geng-duo-zhu-ti/36-latex-video-tutorial-for-beginners-video-6.md).

# 初學者 LaTeX 影片教學（影片 6）

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

這套七集的 LaTeX 教學影片系列最初於 2013 年發布；因此，由於 ShareLaTeX 的發展以及後來 ShareLaTeX 與 Overleaf 的合併，今日的編輯器介面已經有相當大的變化。不過，影片內容仍然相關，並會教你 LaTeX 的基礎——這些技能與專業知識可適用於所有平台。你不需要任何先前背景知識，而在這些 LaTeX 指南結束時，你將能夠建立並撰寫基本的 LaTeX 文件，並具備開始學習如何建立更複雜文件的知識。每支影片都附有逐字稿（列於影片下方）——這些內嵌逐字稿取代了每個教學開頭顯示的網址。

### LaTeX 中的表格與矩陣

**注意：** 你可以透過以下方式開啟影片中使用的專案 [這個連結](https://www.sharelatex.com/project/51f1324bc00460011608ea5c).

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

### 影片逐字稿

在 [上一個影片](/latex/zh-tw/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，你就會看到文字已自動換行，因此最後一欄的寬度是 5 公分。

這就是撰寫表格的基本概念。不過，就像圖像一樣，我們通常希望對位置有更多控制，而且可能還想加上標題與標籤。為了做到這一點，我們使用一個稱為 `table` 的環境，它類似於我們用在圖像上的 `figure` 環境。要把現有的表格放進 `table` 環境中，我們只要把程式碼包在 `\begin{table}` 和 `\end{table}` 指令之間。接著我們可以使用以下組合來設定位置指定符： `h`, `的區域變數中`, `b`, `p` 和驚嘆號（`!`）。我也可以加入標題與標籤。

我們現在簡單看看矩陣，因為它們使用與表格相似的語法。此時請確認你已載入 `amsmath` 套件。在加入矩陣之前，我們需要先開啟一個環境，告訴 LaTeX 我們即將加入數學式。我們可以像幾部影片前那樣使用 equation 環境，不過這裡我們將使用 `displaymath` 環境，因為它有方便的 LaTeX 簡寫。這表示我們不用使用 `\begin` 指令，而可以使用反斜線加上左中括號；同樣地，不用 end 指令，而可以使用反斜線加上右中括號。矩陣可以使用 `matrix` 環境來插入。使用矩陣時，我們不需要宣告使用多少欄，只要直接開始加入項目即可。同樣地，我們在新的一行輸入每一列，使用與號分隔各項，並使用雙反斜線分隔各列。若要變更包圍矩陣的括號，我們就更換環境。 `pmatrix` 環境使用圓括號， `bmatrix` 使用方括號， `Bmatrix` （大寫 `B`）使用大括號， `vmatrix` 使用垂直線，而 `Vmatrix` （大寫 `V`）使用雙垂直線。

最後，我們將用一個更有趣的矩陣來結束這部影片。在這個範例中，我們所做的是把矩陣巢狀放入另一個矩陣中。因此，這裡實際上是一個用 `pmatrix` 環境建立的二乘二矩陣，其中左上與右下的項目本身也是矩陣，這次則是用 `matrix` 環境建立，以避免出現多層括號。

這就結束了我們對表格與矩陣的討論。在本系列的最後一部影片中，我們將看看如何撰寫更大的文件。

[影片 1](/latex/zh-tw/geng-duo-zhu-ti/31-latex-video-tutorial-for-beginners-video-1.md) | [影片 2](/latex/zh-tw/geng-duo-zhu-ti/32-latex-video-tutorial-for-beginners-video-2.md) | [影片 3](/latex/zh-tw/geng-duo-zhu-ti/33-latex-video-tutorial-for-beginners-video-3.md) | [影片 4](/latex/zh-tw/geng-duo-zhu-ti/34-latex-video-tutorial-for-beginners-video-4.md) | [影片 5](/latex/zh-tw/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-tw/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.
