Multiple columns
Two-column documents can be easily created by passing the parameter \twocolumn
to the document class statement. If you need more flexibility in the column layout, or to create a document with multiple columns, the package multicol provides a set of commands for that. This article explains how to import and use that package.
Introduction
A flexible tool to handle multicolumn documents in LaTeX is multicol, as used in the following example:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{multicol}
\begin{document}
\begin{multicols}{3}
[
\section{First Section}
All human things are subject to decay. And when fate summons, Monarchs must obey.
]
Hello, here is some text without a meaning. This text should show what
a printed text will look like at this place.
If you read this text, you will get no information. Really? Is there
no information? Is there...
\end{multicols}
\end{document}
To import the package, the line
\usepackage{multicol}
is added to the preamble. Once the package is imported, the environment multicols
can be used. The environment takes two parameters:
- Number of columns. This parameter must be passed inside braces, and its value is 3 in the example.
- "Header text", which is inserted in between square brackets. This is optional and will be displayed on top of the multicolumn text. Any LaTeX command can be used here, except for floating elements such as figures and tables. In the example, the section title and a small paragraph are set here.
The text enclosed inside the tags \begin{multicols}
and \end{multicols}
is printed in multicolumn format.
Open an example of the multicols package in Overleaf
Column separation
The column separation is determined by \columnsep
. See the example below:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{multicol}
\setlength{\columnsep}{1cm}
\begin{document}
\begin{multicols}{2}
[
\section{First Section}
All human things are subject to decay. And when fate summons, Monarchs must obey.
]
Hello, here is some text without a meaning. This text should show what
a printed text will look like at this place.
If you read this text, you will get no information. Really? Is there
no information? Is there...
\end{multicols}
\end{document}
Here, the command \setlength{\columnsep}{1cm}
sets the column separation to 1cm. See Lengths in LaTeX for a list of available units.
Open an example of the multicols package in Overleaf
Unbalanced columns
In the default multicols
environment the columns are balanced so each one contains the same amount of text. This default format can be changed by the stared environment multicols*
:
\begin{multicols*}{3}
[
\section{First Section}
All human things are subject to decay. And when fate summons, Monarchs must obey.
]
Hello, here is some text without a meaning. This text should show what
a printed text will look like at this place.
If you read this text, you will get no information. Really? Is there
no information? Is there...
\end{multicols*}
\end{document}
In this case the text is printed in a column till the end of the page is reached, then the in continues in the next column and so on.
Open an example of the multicols package in Overleaf
Inserting floating elements
Floating elements (tables and figures) can be inserted in a multicolumn document with wrapfig
and wraptable
.
\begin{multicols}{2}
[
\section{First Section}
All human things are subject to decay. And when fate summons, Monarchs must obey.
]
Hello, here is some text without a meaning. This text should show what
a printed text will look like at this place.
If you read this text, you will get no information. Really? Is there
no information? Is there.
\vfill
\begin{wrapfigure}{l}{0.7\linewidth}
\includegraphics[width=\linewidth]{./lion-logo.jpg}
\caption{This is the former Share\LaTeX{} logo}
\end{wrapfigure}
A blind text like this gives you information about the selected font, how
the letters are written and an impression of the look. This text should
contain all...
\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}
\end{document}
Floats in the multicol package are poorly supported in the current version. Elements inserted with the conventional figure*
and table*
environments will show up only at the top or bottom of the next page after they are inserted, and will break the layout. The example presented here is a workaround, but you may expect some rough edges. For instance, if the float width is set to \linewidth
it causes a weird text overlapping. This said, below is a brief description of the commands:
\usepackage{wrapfig}
. Put this line in the preamble to import the package wrapfig- The environment
wrapfigure
will insert a figure wrapped in the text. For more information and further examples about this environment see Positioning images and tables. - The environment
wraptible
is the equivalent to wrapfigure but for tables. See Positioning images and tables for more information.
Open an example of the multicols package in Overleaf
Inserting vertical rulers
A vertical ruler can be inserted as column separator to may improve readability in some documents:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{multicol}
\usepackage{color}
\usepackage{comment}
\setlength{\columnseprule}{1pt}
\def\columnseprulecolor{\color{blue}}
\begin{document}
\begin{multicols}{3}
[
\section{First Section}
All human things are subject to decay. And when fate summons, Monarchs must obey.
]
Hello, here is some text without a meaning. This text should show what
a printed text will look like at this place.
If you read this text, you will get no information. Really? Is there
no information? Is there.
\columnbreak
This will be in a new column, here is some text without a meaning. This text
should show what a printed text will look like at this place.
If you read this text, you will get no information. Really? Is there
no information? Is there...
\end{multicols}
Something else here. The text should not be multicolumned in this part
\end{document}
As you see, the column separator can be set to a specific colour also. Below a description of each command:
\usepackage{color}
.- This line is inserted in the preamble to enable the use of several colours within the document.
\setlength{\columnseprule}{1pt}
- This determines the width of the ruler to be used as column separator, it's set to 0 by default. In the example a column whose width is 1pt is printed.
\def\columnseprulecolor{\color{blue}}
- The colour of the separator ruler is set to blue. See the article about using colours in LaTeX for more information on colour manipulation.
\columnbreak
- This command inserts a column breakpoint. In this case, the behaviour of the text is different from what you may expect. The column break is inserted, then the paragraphs before the breakpoint are evenly distributed to fill all available space. In the example, the second paragraph is at the bottom of the column and a blank space is inserted in between the second and the first paragraphs.
Open an example of the multicols package in Overleaf
Further reading
For more information see:
Overleaf guides
- Creating a document in Overleaf
- Uploading a project
- Copying a project
- Creating a project from a template
- Including images in Overleaf
- Exporting your work from Overleaf
- Working offline in Overleaf
- Using Track Changes in Overleaf
- Using bibliographies in Overleaf
- Sharing your work with others
- Debugging Compilation timeout errors
- How-to guides
LaTeX Basics
- Creating your first LaTeX document
- Choosing a LaTeX Compiler
- Paragraphs and new lines
- Bold, italics and underlining
- Lists
- Errors
Mathematics
- Mathematical expressions
- Subscripts and superscripts
- Brackets and Parentheses
- Fractions and Binomials
- Aligning Equations
- Operators
- Spacing in math mode
- Integrals, sums and limits
- Display style in math mode
- List of Greek letters and math symbols
- Mathematical fonts
Figures and tables
- Inserting Images
- Tables
- Positioning Images and Tables
- Lists of Tables and Figures
- Drawing Diagrams Directly in LaTeX
- TikZ package
References and Citations
- Bibliography management in LaTeX
- Bibliography management with biblatex
- Biblatex bibliography styles
- Biblatex citation styles
- Bibliography management with natbib
- Natbib bibliography styles
- Natbib citation styles
- Bibliography management with bibtex
- Bibtex bibliography styles
Languages
- Multilingual typesetting on Overleaf using polyglossia and fontspec
- International language support
- Quotations and quotation marks
- Arabic
- Chinese
- French
- German
- Greek
- Italian
- Japanese
- Korean
- Portuguese
- Russian
- Spanish
Document structure
- Sections and chapters
- Table of contents
- Cross referencing sections and equations
- Indices
- Glossaries
- Nomenclatures
- Management in a large project
- Multi-file LaTeX projects
- Hyperlinks
Formatting
- Lengths in LaTeX
- Headers and footers
- Page numbering
- Paragraph formatting
- Line breaks and blank spaces
- Text alignment
- Page size and margins
- Single sided and double sided documents
- Multiple columns
- Counters
- Code listing
- Code Highlighting with minted
- Using colours in LaTeX
- Footnotes
- Margin notes
Fonts
Presentations
Commands
Field specific
- Theorems and proofs
- Chemistry formulae
- Feynman diagrams
- Molecular orbital diagrams
- Chess notation
- Knitting patterns
- CircuiTikz package
- Pgfplots package
- Typing exams in LaTeX
- Knitr
- Attribute Value Matrices
Class files
- Understanding packages and class files
- List of packages and class files
- Writing your own package
- Writing your own class
- Tips