Figures and Images

How to Wrap Text Around an Image in LaTeX

Wrap text around an image in LaTeX with the wrapfigure environment: choose the side, set the width, avoid common list and heading problems, and tune spacing.

On this page
  1. Load wrapfig and graphicx
  2. A basic wrapped figure
  3. Syntax: line count, side and width
  4. Size the image to fit the wrap box
  5. Where to place the wrapfigure
  6. Problems with lists, headings and display math
  7. Use minipage when wrapping isn’t needed
  8. Summary

To wrap text around an image in LaTeX, load the wrapfig package and use the wrapfigure environment. Put it at the start of the paragraph where the wrap should begin. The environment takes a side (r for right, l for left) and a width, and the text flows around a box of that size.

Load wrapfig and graphicx

\usepackage{graphicx}
\usepackage{wrapfig}

A basic wrapped figure

\begin{wrapfigure}{r}{0.4\textwidth}
  \centering
  \includegraphics[width=0.38\textwidth]{photo}
  \caption{A sample photograph.}
  \label{fig:photo}
\end{wrapfigure}

This paragraph starts the wrap. The text runs down the left side of the image until the image and its caption end. After that, the lines return to the full text width.

The image sits on the right, and the paragraph’s text fills the space on the left until the box ends.

Syntax: line count, side and width

The full form is \begin{wrapfigure}[lines]{position}{width}:

  • [lines] (optional) sets how many lines the figure spans. Use it when LaTeX’s estimate of the height is off.
  • {position} is r or l. These place the figure on the right or left and keep it there. The uppercase R and L let the figure float to a better spot, such as the top of the next page.
  • {width} is the width of the space the text can’t use. It isn’t the image’s own size.

Size the image to fit the wrap box

Make the image a little narrower than the wrap width. In the example, the image is 0.38 of the text width and the box is 0.4, which leaves a small gap between the image and the text.

Use \centering inside the environment, not the center environment. The center environment adds extra vertical space above and below the image. Keep the caption short too, because every line of caption also takes up space beside the text.

Where to place the wrapfigure

Put the environment at the start of a paragraph, on its own lines, and not in the middle of a sentence. The wrap then begins at the paragraph’s first line. Keep each wrapped figure in its own paragraph so that two wraps don’t compete for the same space.

If the figure should sit at the top or bottom of a page rather than beside the text, a regular float is the better choice. The guide to controlling figure placement explains the options for that.

Problems with lists, headings and display math

Wrapped figures don’t always work well next to other structures. Lists (itemize and enumerate), section headings and display equations can produce odd spacing, or lines that don’t wrap where you expect.

Some fixes:

  • Move the wrapfigure into an ordinary paragraph, before the list or heading.
  • Adjust the optional [lines] argument if the spacing looks wrong.
  • Add a small vertical space with \vspace to nudge the layout.
  • If the layout still doesn’t behave, switch to a regular floating figure.

wrapfig is designed for single-column text. In multi-column layouts, test the result before you rely on it.

Use minipage when wrapping isn’t needed

If you want the image and the text side by side, with the text staying in its own column, a minipage text box gives you more predictable results. Keep the two widths below the text width:

\begin{minipage}[c]{0.45\textwidth}
  \centering
  \includegraphics[width=\linewidth]{photo}
\end{minipage}\hfill
\begin{minipage}[c]{0.5\textwidth}
  The text sits beside the photo and stays in its own column rather than
  flowing around the image.
\end{minipage}

A minipage doesn’t wrap, so you give up the flowing text. If you need several images under one caption instead, the subfigures guide shows that layout. For the basics of including images, see the guide to inserting images in LaTeX.

Summary

Load wrapfig, place a wrapfigure at the start of a paragraph, choose r or l for the side, and set a width a little larger than the image. Keep the image narrower than the box, use \centering, and keep lists and headings away from the wrap. For a side-by-side layout without wrapping, use a minipage instead.

The complete guide to figures and images

Inserting Images in LaTeX: PDF, PNG and More
Read the guide

Keep exploring

Guides from other topics

All topics →