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

# 多栏

## 引言

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

```latex
\documentclass{article}
\usepackage{blindtext}
\usepackage{multicol}
\title{多栏演示}
\author{Overleaf}
\date{2021 年 4 月}

\begin{document}
\maketitle

\begin{multicols}{3}
[
\section{第一节}
凡人之事皆终将衰败。而当命运召唤时，君王也必须服从。
]
\blindtext\blindtext
\end{multicols}

\end{document}
```

[在 Overleaf 中打开此 `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{第二个多栏演示}
\author{Overleaf}
\date{2021 年 4 月}

\begin{document}
\maketitle

\begin{multicols}{2}
[
\section{第一节}
凡人之事皆终将衰败。而当命运召唤时，君王也必须服从。
]
\blindtext\blindtext
\end{multicols}

\end{document}
```

[在 Overleaf 中打开此 `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{第二个多栏演示}
\author{Overleaf}
\date{2021 年 4 月}
\begin{document}
\maketitle
\begin{multicols*}{3}
[
\section{第一节}
凡人之事皆终将衰败。而当命运召唤时，君王也必须服从。
]
\blindtext\blindtext
\end{multicols*}

\end{document}
```

[在 Overleaf 中打开此 `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{第一节}
凡人之事皆终将衰败。而当命运召唤时，君王也必须服从。
]

你好，这里有一段没有意义的文字。这段文字应该展示出
此处的排版效果将会是这样的。
如果你读到这段文字，你不会得到任何信息。真的？难道这里有
没有信息吗？有吗。

\\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
Name & ISO \\
\hline
Afghanistan & AF \\
Aland Islands & AX \\
Albania    &AL  \\
Algeria   &DZ \\
American Samoa & AS \\
Andorra & AD   \\
Angola & AO \\
\hline
\end{tabular}
\caption{表格，浮动元素}
\label{table:ta}
\end{wraptable}

\end{multicols}
```

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

[在 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-cn/tu-biao-he-biao-ge/02-positioning-images-and-tables.md).
* 环境 `wraptable` 相当于 *wrapfigure* ，但用于表格。请参见 [图片和表格的位置](/latex/zh-cn/tu-biao-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{第一节}
凡人之事皆终将衰败。而当命运召唤时，君王也必须服从。
]
你好，这里有一段没有意义的文字。这段文字应该展示出
此处的排版效果将会是这样的。

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

\columnbreak
\blindtext
这将出现在新的一栏中，这里是一段没有意义的文字。此文本
应显示此处的排版效果。

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

\blindtext

\end{document}
```

[在 Overleaf 中打开此 `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-biao-he-biao-ge/01-tables.md)
* [图片和表格的位置](/latex/zh-cn/tu-biao-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://overleaf-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.
