How to Put Two Pieces of Text Side by Side in LaTeX
At a glance
- 1. Choose a box
Put each text block in its own minipage so LaTeX can wrap the text within a set width.
- 2. Set the widths
Choose widths whose sum is less than the available line width, leaving room for a gap.
- 3. Add spacing
Place \hfill between the minipages to spread them across the line.
- 4. Check the result
Compile and adjust the widths or gap if the blocks wrap or run past the page margin.
For two separate blocks of text next to each other in a LaTeX document, put each block in a minipage. A minipage acts like a small text area: you set its width, and paragraphs wrap inside it. Put both minipages on the same line and use \hfill to leave flexible space between them.
A complete example
This example creates two side-by-side text blocks in a standard LaTeX document:
\documentclass{article}
\begin{document}
\noindent
\begin{minipage}[t]{0.48\textwidth}
\textbf{First block}
This paragraph is in the left-hand block. It wraps within the width of
this minipage, independently of the text in the other block.
\end{minipage}
\hfill
\begin{minipage}[t]{0.48\textwidth}
\textbf{Second block}
This paragraph is in the right-hand block. You can put several paragraphs
or other ordinary text here.
\end{minipage}
\end{document}
No additional package is needed. The article class and the minipage environment are built into LaTeX.
How the layout works
\noindentprevents LaTeX from adding a paragraph indent before the first block.\begin{minipage}[t]{0.48\textwidth}starts a text box whose width is 48% of the current text width. The[t]option aligns the boxes at the top.\hfillinserts stretchable horizontal space between the boxes. It expands to use the remaining room on the line.\end{minipage}closes each box. The two boxes stay side by side as long as their combined widths and the gap fit on the line.
The example uses 48% for each box, so together they take 96% of the text width, leaving room for the flexible gap. If you want a wider gap, make the boxes narrower, for example 0.45\textwidth each. If you need a fixed gap, use \hspace{1em} instead of \hfill.
Adjusting alignment and width
The optional alignment argument controls how the minipages align vertically when their contents have different heights. Use [t] for top alignment, [c] for vertical centering, or [b] for bottom alignment. Top alignment is usually the most natural choice for adjacent paragraphs.
The width is relative to the current text area. In a normal article, \textwidth is the width between the page margins. In a list or another nested layout, \linewidth can be more appropriate because it reflects the width available at that location.
For example, use narrower boxes to allow a larger gap:
\begin{minipage}[t]{0.44\linewidth}
Left text.
\end{minipage}
\hfill
\begin{minipage}[t]{0.44\linewidth}
Right text.
\end{minipage}
Common mistakes
Making the widths too large. Two boxes each set to 0.6\textwidth cannot fit on the same line. Their combined width already exceeds the available space, before any gap is added. Reduce the widths so their sum is less than the line width.
Putting a blank line between the boxes. A blank line starts a new paragraph, which can move the second minipage below the first. Keep the minipages in the same paragraph; a line break in the source code alone does not necessarily start a new paragraph.
Expecting ordinary paragraphs to form columns automatically. LaTeX normally typesets paragraphs one after another. To place only two particular blocks side by side, use minipages. The \twocolumn option is meant for a two-column page layout, not just two isolated text blocks.
If the blocks need table-like alignment or contain structured rows and columns, a tabular environment may be a better choice. For two independent pieces of prose, minipage is usually the simplest option.
Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.