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

# 多栏排版

## 引言

通过传递参数，可以轻松创建双栏文档 `\twocolumn` 给文档类声明。如果你需要更灵活的栏布局，或者创建包含多栏的文档，宏包 `multicol` 提供了一组用于此目的的命令。本文将解释如何使用 `multicol` 该宏包，从这个基本示例开始：

```latex
\documentclass{article}
\usepackage{blindtext}
\usepackage{multicol}
\title{Multicols Demo}
\author{Overleaf}
\date{April 2021}

\begin{document}
\maketitle

\begin{multicols}{3}
[
\section{First Section}
万物皆有衰败之时。命运一旦召唤，君王也必须服从。
]
\blindtext\blindtext
\end{multicols}

\end{document}
```

[打开此 `multicols` Overleaf 中的示例](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/d5825890a827d4e519af379a005ffd69deb2a89b)

要导入该宏包，需将以下行

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

添加到导言区。宏包导入后，环境 `multicols` 即可使用。该环境接受两个参数：

* 栏数。此参数必须放在花括号中，在示例中其值为 3。
* “标题文本”，它被插入在方括号中。这是可选项，会显示在多栏文本顶部。这里可以使用任何 LaTeX 命令，但浮动元素（如图和表）除外。在示例中，这里设置了节标题和一小段文字。

被标签包围的文本 `\begin{multicols}` 和 `\end{multicols}` 会以多栏格式排版。

## 栏间距

栏间距由 `\columnsep`决定。请看下面的示例：

```latex
\documentclass{article}
\usepackage{blindtext}
\usepackage{multicol}
\setlength{\columnsep}{1cm}
\title{Second multicols Demo}
\author{Overleaf}
\date{April 2021}

\begin{document}
\maketitle

\begin{multicols}{2}
[
\section{First Section}
万物皆有衰败之时。命运一旦召唤，君王也必须服从。
]
\blindtext\blindtext
\end{multicols}

\end{document}
```

[打开此 `multicols` Overleaf 中的示例](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/dae0e0c2c89e935f4591c2fa563f74e2b67bafb0)

这里，命令 `\setlength{\columnsep}{1cm}` 将栏间距设置为 1cm。请参见 [LaTeX 中的长度](/latex/zh-cn/ge-shi-hua/01-lengths-in-latex.md) 以获取可用单位列表。

## 不平衡的栏

在默认的 `multicols` 环境中，各栏是平衡的，因此每一栏包含相同数量的文本。这个默认格式可以通过带星号的环境 `multicols*`:

```latex
\documentclass{article}
\usepackage{blindtext}
\usepackage{multicol}
\setlength{\columnsep}{1cm}
\title{Second multicols Demo}
\author{Overleaf}
\date{April 2021}
\begin{document}
\maketitle
\begin{multicols*}{3}
[
\section{First Section}
万物皆有衰败之时。命运一旦召唤，君王也必须服从。
]
\blindtext\blindtext
\end{multicols*}

\end{document}
```

[打开此 `multicols` Overleaf 中的示例](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/d27361b4783294e0c44042d91f88672556532bd2)

如果你在 Overleaf 上打开这个示例，你会看到文本会在一栏中排版，直到到达页面末尾，然后继续在下一栏中排版，依此类推。

## 插入浮动元素

可以使用以下宏包在多栏文档中插入浮动元素（表格和图片） `wrapfig` 和 `wraptable`。下面的 LaTeX 代码片段并不是一个完整的 LaTeX 文档，它展示了如何使用浮动元素。请使用代码下方的链接打开一个完整的 LaTeX 文档，你可以在 Overleaf 上编译它。

```latex
\begin{multicols}{2}
[
\section{First Section}
万物皆有衰败之时。命运一旦召唤，君王也必须服从。
]

你好，这里有一些没有意义的文本。这段文本应当展示
此处的排版文本会是什么样子。
如果你读这段文字，你不会得到任何信息。真的？这里有
没有信息吗？有吗。

\vfill

\begin{wrapfigure}{l}{0.7\linewidth}
\includegraphics[width=\linewidth]{overleaf-logo}
\caption{This is the Overleaf logo}
\end{wrapfigure}

像这样的占位文本会告诉你所选字体、如何
字母的书写方式和外观印象。这段文本应当
包含所有……

\begin{wraptable}{l}{0.7\linewidth}
\centering
\begin{tabular}{|c|c|}
\hline
Name & ISO \\
\hline
Afghanistan & AF \\
Aland Islands & AX \\
Albania    &AL  \\
Algeria   &DZ \\
American Samoa & AS \\
Andorra & AD   \\
Angola & AO \\
\hline
\end{tabular}
\caption{Table, floating element}
\label{table:ta}
\end{wraptable}

\end{multicols}
```

![MulticolumnsEx4OverleafV2.png](/files/1167ea55f8f106fdd95cd48125b72c828970fc9c)

[打开此 `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-cn/tu-xing-he-biao-ge/02-positioning-images-and-tables.md).
* 环境 `wraptable` 相当于 *wrapfigure* ，但用于表格。请参见 [图片和表格的定位](/latex/zh-cn/tu-xing-he-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{First Section}
万物皆有衰败之时。命运一旦召唤，君王也必须服从。
]
你好，这里有一些没有意义的文本。这段文本应当展示
此处的排版文本会是什么样子。

如果你读这段文字，你不会得到任何信息。真的？这里有
没有信息吗？有吗。

\columnbreak
\blindtext
这将位于新的一栏中，这里有一些没有意义的文字。这段文字
应该展示此处的排版效果。

如果你读这段文字，你不会得到任何信息。真的？这里有
没有信息吗？有吗……
\end{multicols}

\blindtext

\end{document}
```

[打开此 `multicols` Overleaf 中的示例](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/f8a7ccbeccc6e1425d667d8d7adb1bf91b7f4e38)

如果你在 Overleaf 上打开这个示例，你会看到栏分隔符也可以设置为特定颜色。下面是每个命令的说明：

**\usepackage{color}.**

这行插入到导言区，以启用在文档中使用多种颜色。

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

这决定了用作栏分隔符的竖线宽度，默认设为 0。示例中打印出了一条宽度为 1pt 的竖线。

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

分隔竖线的颜色设置为蓝色。有关 LaTeX 中颜色使用和颜色操作的更多信息，请参阅相关文章。

**\columnbreak**

该命令插入一个栏断点。在这种情况下，文本的行为与您预期的不同。插入栏分隔后，断点之前的段落会被均匀分布以填满所有可用空间。在示例中，第二段位于栏底部，并在第二段和第一段之间插入了空白。

## 进一步阅读

更多信息请参见：

* [段落和新行](/latex/zh-cn/latex-ji-chu/02-paragraphs-and-new-lines.md)
* [粗体、斜体和下划线](/latex/zh-cn/latex-ji-chu/03-bold-italics-and-underlining.md)
* [列表](/latex/zh-cn/latex-ji-chu/04-lists.md)
* [插入图片](/latex/zh-cn/geng-duo-zhu-ti/27-inserting-images.md)
* [表格](/latex/zh-cn/tu-xing-he-biao-ge/01-tables.md)
* [图片和表格的定位](/latex/zh-cn/tu-xing-he-biao-ge/02-positioning-images-and-tables.md)
* [LaTeX 中的长度](/latex/zh-cn/ge-shi-hua/01-lengths-in-latex.md)
* [段落格式](/latex/zh-cn/ge-shi-hua/04-articles-how-to-change-paragraph-spacing-in-latex.md)
* [页面大小和页边距](/latex/zh-cn/ge-shi-hua/07-page-size-and-margins.md)
* [单面和双面文档](/latex/zh-cn/ge-shi-hua/08-single-sided-and-double-sided-documents.md)
* [在 LaTeX 中使用颜色](/latex/zh-cn/ge-shi-hua/13-using-colors-in-latex.md)
* [脚注](/latex/zh-cn/ge-shi-hua/14-footnotes.md)
* [页边注释](/latex/zh-cn/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://ayakaleaf-pro.ayaka.space/latex/zh-cn/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.
