latex-notes/multiple_columns.md

74 lines
1.5 KiB
Markdown

# Multiple Columns
To make an *entire* document render in two columns, just pass the `twocolumn` parameter to the document class:
```
\documentclass[twocolumn]{article}
```
To achieve finer control over multiple columns, use the `multicol` package. (Extended documentation is [here](https://ctan.org/pkg/multicol?lang=en).) Just add the following to the document's preamble:
```
\usepackage{multicol}
```
The basic use is:
```
\begin{multicols}{3}
Lorem ipsum
\end{multicols}
```
To include a section which is *not* multiple columns, enclose that text in square brackets:
```
\begin{multicols}{3}
[
This line will not be in multiple columns
]
This line and all remaining text will be in three columns.
\end{multicols}
```
## Column Separation
The distance between the columns is controlled by `\columnsep` in the `\setlength` parameter in the document's preamble:
```
\setlength{\columnsep}{0.5in}
```
## Unbalanced Columns
By default, the `multicol` package will do its best to balance all the columns. If you want *unbalanced* columns, then use `multicols*` instead:
```
\begin{multicols*}{3}
This text will have unbalanced columns.
Lorem ipsum.
\end{multicols}
```
## Column Rules
To insert a vertical line between columns, pass `\columnseprule` to the `\setlength` parameter in the document's preamble:
```
\setlength{columnseprule}{1pt}
\def\columnseprulecolr{\color{blue}}
```
In order to add colors, be sure to use the `color` package by adding the following to the document's preamble:
```
\usepackage{color}
```