Tx · LaTeX & TikZ

How to Position a LaTeX Minipage

Published By the 9to5Science editorial team

At a glance

  1. 1. Choose vertical alignment

    Use the first optional argument: c centers the minipage, t aligns it at the top, and b aligns it at the bottom.

  2. 2. Set its width

    Give the required width in braces, such as 0.47\textwidth, to control how much horizontal space the minipage occupies.

  3. 3. Place it horizontally

    Use ordinary text spacing, \hfill, or a centering command; minipage itself is not a floating environment.

  4. 4. Adjust inner content

    Use the third optional argument for vertical placement of content inside a minipage with a specified height.

A minipage is a fixed-width box that can contain paragraphs, lists, and other material. Its optional position argument controls how the box aligns vertically with nearby material; it does not specify a page location such as “top of page.” This distinction matters when placing minipages side by side or alongside text.

The minipage syntax

The basic form is:

\begin{minipage}[position][height][inner-position]{width}
  ...
\end{minipage}

Only the width is required. The first optional argument controls how the minipage aligns with surrounding material:

OptionAlignment
cCenter vertically; this is the default.
tAlign at the top.
bAlign at the bottom.

For example, \begin{minipage}[t]{0.45\textwidth} creates a minipage whose width is 45% of \textwidth (the document’s text-block width). In a nested layout, use \linewidth if you want 45% of the current line width.

The optional height sets the minipage’s height. The third argument, inner-position, controls where the contents sit vertically within that specified height. It accepts c, t, b, or s (stretch vertical space between paragraphs). These inner-position choices do not replace the first argument: one concerns the box’s alignment with its surroundings, and the other concerns content inside the box.

Align two minipages side by side

Use [t] on both boxes to top-align them, and use \hfill to distribute the horizontal space between them. This complete example compiles with the standard article class and needs no additional packages:

\documentclass{article}
\begin{document}

\noindent
\begin{minipage}[t]{0.47\textwidth}
  \vspace{0pt}
  \textbf{First column}

  This column has a short paragraph.
\end{minipage}\hfill
\begin{minipage}[t]{0.47\textwidth}
  \vspace{0pt}
  \textbf{Second column}

  This column has a longer paragraph, so it extends farther down the page.
\end{minipage}

\end{document}

The widths total 94% of \textwidth, leaving room for \hfill to insert flexible horizontal space. \noindent prevents paragraph indentation before the first box. The \vspace{0pt} at the start of each minipage is a useful alignment aid when the first items in the boxes differ: it gives each box a consistent top reference. If the minipages still do not fit on one line, reduce their widths or remove intervening spaces that add width.

To center a single minipage horizontally, put it in a center environment or use \centering in the surrounding context. To push it toward the right, put \hfill before it. These are horizontal layout choices; [t], [c], and [b] are vertical alignment choices.

A minipage does not float

Unlike a figure or table environment, a minipage stays where it appears in the source and does not accept float-placement options such as [htbp]. It can be placed inside a figure or table if you want the containing float to move, or you can adjust its position within the text using ordinary box and spacing commands. Use \raisebox only when you need a deliberate small vertical shift; changing the minipage alignment option is usually clearer.

Common mistakes

  • Using [h] or [!ht] as the position argument. These are not minipage alignment options. Use c, t, or b there; float placement belongs to figure and table.
  • Expecting [t] to move a box to the top of the page. It aligns the box with nearby material, not with a page edge.
  • Confusing box alignment and content alignment. The first optional argument positions the minipage as a whole. The third optional argument positions its contents when a height is given.
  • Forgetting horizontal spacing. Two minipages placed consecutively may touch or wrap. Set suitable widths and add \hfill or another separator.
  • Using a blank line between adjacent boxes. A blank line starts a new paragraph, so the boxes may no longer sit on the same line. Keep them together in the source when you want a side-by-side layout.

References

  1. LaTeX2e unofficial reference manual: minipage

Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.