> 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/ge-shi-hua/09-multiple-columns.md).

# 多欄排版

## 簡介

透過傳入參數即可輕鬆建立雙欄文件 `\twocolumn` 給文檔類別宣告。若您需要更彈性的欄位版面，或要建立多欄文件，則可使用套件 `multicol` 提供了一組相關指令。本文將說明如何使用 `multicol` 套件，先從這個基本範例開始：

```latex
\documentclass{article}
\usepackage{blindtext}
\usepackage{multicol}
\title{多欄示範}
\author{Overleaf}
\date{April 2021}

\begin{document}
\maketitle

\begin{multicols}{3}
[
\section{第一節}
凡人之事皆難逃衰敗。而當命運召喚時，君王也必須服從。
]
\blindtext\blindtext
\end{multicols}

\end{document}
```

[在 Overleaf 中開啟這個 `multicols` 範例](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=multicols+package+demo\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Bblindtext%7D%0A%5Cusepackage%7Bmulticol%7D%0A%5Ctitle%7BMulticols+Demo%7D%0A%5Cauthor%7BOverleaf%7D%0A%5Cdate%7BApril+2021%7D%0A%0A%5Cbegin%7Bdocument%7D%0A%5Cmaketitle%0A%0A%5Cbegin%7Bmulticols%7D%7B3%7D%0A%5B%0A%5Csection%7BFirst+Section%7D%0AAll+human+things+are+subject+to+decay.+And+when+fate+summons%2C+Monarchs+must+obey.%0A%5D%0A%5Cblindtext%5Cblindtext%0A%5Cend%7Bmulticols%7D%0A%0A%5Cend%7Bdocument%7D)

![三欄範例](/files/235609ff4506dc85af47ba149c99e3ab6f4bf026)

若要匯入套件，請加入下列這一行

```latex
\usepackage{multicol}
```

到導言區中。套件匯入後，即可使用環境 `multicols` 。此環境需要兩個參數：

* 欄數。此參數必須以大括號傳入，在此範例中的值為 3。
* 「標頭文字」，會插入在方括號之間。這是可選的，並會顯示在多欄文字上方。這裡可以使用任何 LaTeX 指令，但浮動元素如圖形與表格除外。在此範例中，這裡放入了章節標題與一小段文字。

標籤內包住的文字 `\begin{multicols}` 和 `\end{multicols}` 會以多欄格式輸出。

## 欄間距

欄間距由以下指令決定 `\columnsep`。請見下方範例：

```latex
\documentclass{article}
\usepackage{blindtext}
\usepackage{multicol}
\setlength{\columnsep}{1cm}
\title{第二個多欄示範}
\author{Overleaf}
\date{April 2021}

\begin{document}
\maketitle

\begin{multicols}{2}
[
\section{第一節}
凡人之事皆難逃衰敗。而當命運召喚時，君王也必須服從。
]
\blindtext\blindtext
\end{multicols}

\end{document}
```

[在 Overleaf 中開啟這個 `multicols` 範例](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=multicols+package+demo\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Bblindtext%7D%0A%5Cusepackage%7Bmulticol%7D%0A%5Csetlength%7B%5Ccolumnsep%7D%7B1cm%7D%0A%5Ctitle%7BSecond+multicols+Demo%7D%0A%5Cauthor%7BOverleaf%7D%0A%5Cdate%7BApril+2021%7D%0A%0A%5Cbegin%7Bdocument%7D%0A%5Cmaketitle%0A%0A%5Cbegin%7Bmulticols%7D%7B2%7D%0A%5B%0A%5Csection%7BFirst+Section%7D%0AAll+human+things+are+subject+to+decay.+And+when+fate+summons%2C+Monarchs+must+obey.%0A%5D%0A%5Cblindtext%5Cblindtext%0A%5Cend%7Bmulticols%7D%0A%0A%5Cend%7Bdocument%7D)

![雙欄範例](/files/72a8bca2562ab3d8f025de666ee6a1bbc2a89670)

這裡，指令 `\setlength{\columnsep}{1cm}` 將欄間距設為 1cm。請見 [LaTeX 中的長度](/latex/zh-tw/ge-shi-hua/01-lengths-in-latex.md) 文件以取得可用單位的列表。

## 不平衡欄位

在預設的 `multicols` 環境中，欄位會自動平衡，因此每一欄都包含相同數量的文字。此預設格式可透過加星號的環境 `multicols*`:

```latex
\documentclass{article}
\usepackage{blindtext}
\usepackage{multicol}
\setlength{\columnsep}{1cm}
\title{第二個多欄示範}
\author{Overleaf}
\date{April 2021}
\begin{document}
\maketitle
\begin{multicols*}{3}
[
\section{第一節}
凡人之事皆難逃衰敗。而當命運召喚時，君王也必須服從。
]
\blindtext\blindtext
\end{multicols*}

\end{document}
```

[在 Overleaf 中開啟這個 `multicols` 範例](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=multicols+package+demo\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Bblindtext%7D%0A%5Cusepackage%7Bmulticol%7D%0A%5Csetlength%7B%5Ccolumnsep%7D%7B1cm%7D%0A%5Ctitle%7BSecond+multicols+Demo%7D%0A%5Cauthor%7BOverleaf%7D%0A%5Cdate%7BApril+2021%7D%0A%5Cbegin%7Bdocument%7D%0A%5Cmaketitle%0A%5Cbegin%7Bmulticols%2A%7D%7B3%7D%0A%5B%0A%5Csection%7BFirst+Section%7D%0AAll+human+things+are+subject+to+decay.+And+when+fate+summons%2C+Monarchs+must+obey.%0A%5D%0A%5Cblindtext%5Cblindtext%0A%5Cend%7Bmulticols%2A%7D%0A%0A%5Cend%7Bdocument%7D)

![三欄示範](/files/56a9c58134cc45a5e45063f29f962a0f8b38404b)

如果你在 Overleaf 中開啟此範例，你會看到文字會先列印在一欄中，直到到達頁面底端，接著會在下一欄繼續，依此類推。

## 插入浮動元素

可在多欄文件中使用以下套件插入浮動元素（表格與圖形）： `wrapfig` 和 `wraptable`以下的 LaTeX 程式碼片段並不是完整的 LaTeX 文件，它示範了如何使用浮動元素。請使用程式碼下方的連結開啟一份可在 Overleaf 上編譯的完整 LaTeX 文件。

```latex
\begin{multicols}{2}
[
\section{第一節}
凡人之事皆難逃衰敗。而當命運召喚時，君王也必須服從。
]

你好，這裡有一些沒有意義的文字。這段文字應該展示出
在這個位置列印出的文字會是這個樣子。
如果你讀到這段文字，你不會得到任何資訊。真的嗎？有
沒有資訊嗎？有。

\vfill

\begin{wrapfigure}{l}{0.7\linewidth}
\includegraphics[width=\linewidth]{overleaf-logo}
\caption{這是 Overleaf 標誌}
\end{wrapfigure}

像這樣的無意義文字可讓你了解所選字型、如何
書寫，以及整體外觀的印象。這段文字應該
容納所有……

\begin{wraptable}{l}{0.7\linewidth}
\centering
\begin{tabular}{|c|c|}
\hline
名稱 & ISO \\
\hline
阿富汗 & AF \\
亞蘭群島 & AX \\
阿爾巴尼亞    &AL  \\
阿爾及利亞   &DZ \\
美屬薩摩亞 & AS \\
安道爾 & AD   \\
安哥拉 & AO \\
\hline
\end{tabular}
\caption{表格，浮動元素}
\label{table:ta}
\end{wraptable}

\end{multicols}
```

![MulticolumnsEx4OverleafV2.png](/files/a5c431b958ca429d6e8528e31451d7e38da6b684)

[在 Overleaf 中開啟這個 `multicols` Overleaf LaTeX 專案中的範例](https://www.overleaf.com/project/new/template/19510?id=65969509\&templateName=A+multicols+demo\&latexEngine=pdflatex\&texImage=texlive-full%3A2020.1\&mainFile=)

在……中的浮動元素 **multicol** 套件在目前版本中的支援不佳。以傳統的 `figure*` 和 `table*` 環境插入後，只會在下一頁的頂端或底端出現，並且會破壞版面配置。此處提供的範例是一種變通方法，但你可能會遇到一些粗糙之處。例如，如果浮動區塊的寬度設為 `\linewidth` 就會造成奇怪的文字重疊。話雖如此，以下是各指令的簡要說明：

* `\usepackage{wrapfig}`。將這一行放在導言區中以匯入套件 **wrapfig**
* 環境 `wrapfigure` 會插入一個被文字環繞的圖形。關於此環境的更多資訊與其他範例，請參見 [圖片與表格的定位](/latex/zh-tw/tu-biao-yu-biao-ge/02-positioning-images-and-tables.md).
* 環境 `wraptable` 相當於 *wrapfigure* ，但適用於表格。請參見 [圖片與表格的定位](/latex/zh-tw/tu-biao-yu-biao-ge/02-positioning-images-and-tables.md) 以了解更多資訊。

## 插入垂直分隔線

可插入一條垂直分隔線作為欄間分隔，在某些文件中或許能提升可讀性：

```latex
\documentclass{article}
\usepackage{blindtext}
\usepackage{multicol}
\usepackage{color}
\setlength{\columnseprule}{1pt}
\def\columnseprulecolor{\color{blue}}

\begin{document}

\begin{multicols}{3}
[
\section{第一節}
凡人之事皆難逃衰敗。而當命運召喚時，君王也必須服從。
]
你好，這裡有一些沒有意義的文字。這段文字應該展示出
在這個位置列印出的文字會是這個樣子。

如果你讀到這段文字，你不會得到任何資訊。真的嗎？有
沒有資訊嗎？有。

\columnbreak
\blindtext
這將會出現在新的一欄，這裡有一些沒有意義的文字。這段文字
應該顯示出在這個位置列印出的文字會是什麼樣子。

如果你讀到這段文字，你不會得到任何資訊。真的嗎？有
沒有資訊嗎？有……
\end{multicols}

\blindtext

\end{document}
```

[在 Overleaf 中開啟這個 `multicols` 範例](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=multicols+package+demo\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Bblindtext%7D%0A%5Cusepackage%7Bmulticol%7D%0A%5Cusepackage%7Bcolor%7D%0A%5Csetlength%7B%5Ccolumnseprule%7D%7B1pt%7D%0A%5Cdef%5Ccolumnseprulecolor%7B%5Ccolor%7Bblue%7D%7D%0A%0A%5Cbegin%7Bdocument%7D%0A%0A%5Cbegin%7Bmulticols%7D%7B3%7D%0A%5B%0A%5Csection%7BFirst+Section%7D%0AAll+human+things+are+subject+to+decay.+And+when+fate+summons%2C+Monarchs+must+obey.%0A%5D%0AHello%2C+here+is+some+text+without+a+meaning.++This+text+should+show+what+%0Aa+printed+text+will+look+like+at+this+place.%0A%0AIf+you+read+this+text%2C+you+will+get+no+information.++Really%3F++Is+there+%0Ano+information%3F++Is+there.%0A%0A%5Ccolumnbreak%0A%5Cblindtext%0AThis+will+be+in+a+new+column%2C+here+is+some+text+without+a+meaning.++This+text+%0Ashould+show+what+a+printed+text+will+look+like+at+this+place.%0A%0AIf+you+read+this+text%2C+you+will+get+no+information.++Really%3F++Is+there+%0Ano+information%3F++Is+there...%0A%5Cend%7Bmulticols%7D%0A%0A%5Cblindtext%0A%0A%5Cend%7Bdocument%7D)

![欄間分隔線範例](/files/c2e7bdb8166c04ae0f3ad7c6db5932016d2ddf1f)

如果你在 Overleaf 上開啟此範例，你會看到欄間分隔線也可以設為特定顏色。以下是各指令的說明：

**\usepackage{color}。**

將這一行插入導言區，以啟用文件中使用多種顏色。

**\setlength{\columnseprule}{1pt}**

這決定了作為欄間分隔線的線寬，預設為 0。在此範例中，會列印出一條寬度為 1pt 的欄線。

**\def\columnseprulecolor{\color{blue}}**

分隔線的顏色設為藍色。關於顏色操作的更多資訊，請參見關於在 LaTeX 中使用顏色的文章。

**\columnbreak**

此指令會插入欄位斷點。在這種情況下，文字的行為與你可能預期的不同。插入欄位分隔後，斷點之前的段落會平均分配以填滿所有可用空間。在此範例中，第二段位於欄底，而第二段與第一段之間插入了空白。

## 延伸閱讀

詳情請見：

* [段落與換行](/latex/zh-tw/latex-ji-chu/02-paragraphs-and-new-lines.md)
* [粗體、斜體與底線](/latex/zh-tw/latex-ji-chu/03-bold-italics-and-underlining.md)
* [清單](/latex/zh-tw/latex-ji-chu/04-lists.md)
* [插入圖片](/latex/zh-tw/geng-duo-zhu-ti/27-inserting-images.md)
* [表格](/latex/zh-tw/tu-biao-yu-biao-ge/01-tables.md)
* [圖片與表格的定位](/latex/zh-tw/tu-biao-yu-biao-ge/02-positioning-images-and-tables.md)
* [LaTeX 中的長度](/latex/zh-tw/ge-shi-hua/01-lengths-in-latex.md)
* [段落格式設定](/latex/zh-tw/ge-shi-hua/04-articles-how-to-change-paragraph-spacing-in-latex.md)
* [頁面大小與邊界](/latex/zh-tw/ge-shi-hua/07-page-size-and-margins.md)
* [單面與雙面文件](/latex/zh-tw/ge-shi-hua/08-single-sided-and-double-sided-documents.md)
* [在 LaTeX 中使用顏色](/latex/zh-tw/ge-shi-hua/13-using-colors-in-latex.md)
* [腳註](/latex/zh-tw/ge-shi-hua/14-footnotes.md)
* [邊界註記](/latex/zh-tw/ge-shi-hua/15-margin-notes.md)
* [**multicols** 套件說明文件](http://mirrors.ctan.org/macros/latex/required/tools/multicol.pdf).


---

# 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/ge-shi-hua/09-multiple-columns.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.
