Tx · LaTeX & TikZ

How to Reduce Space Around a LaTeX wrapfigure

Published By the 9to5Science editorial team

At a glance

  1. 1. Check the spacing length

    Reduce \intextsep to control vertical space above and below wrapped figures.

  2. 2. Adjust text clearance

    Reduce \columnsep to bring the surrounding text closer horizontally.

  3. 3. Check paragraph layout

    Avoid unintended blank paragraphs and confirm the wrapfigure width and placement.

The space around a wrapfigure is usually controlled by LaTeX’s lengths for in-text figures. The main setting is \intextsep, which controls vertical space above and below the wrapped object. For the horizontal gap between the figure and text, use \columnsep.

Reduce the vertical gap

Set \intextsep to a smaller value in the preamble, before \begin{document}:

\setlength{\intextsep}{6pt}

The default can leave more space than you want in a compact layout. Try a modest reduction first; 4pt or 6pt is often a reasonable starting point. Setting it to 0pt removes the added separation, but can make the figure feel crowded against nearby text.

Here is a complete example. The framed rectangle stands in for an image, so the document compiles without an external image file.

\documentclass{article}
\usepackage{wrapfig}

\setlength{\intextsep}{6pt} % Vertical space around the wrapped object
\setlength{\columnsep}{10pt} % Horizontal space between object and text

\begin{document}

\begin{wrapfigure}{r}{0.32\textwidth}
  \centering
  \fbox{\parbox[c][2cm][c]{0.28\textwidth}{\centering Example figure}}
\end{wrapfigure}
This paragraph begins beside the figure and continues around it. Add enough
text for the paragraph to extend below the figure, so you can see how the
wrapped layout behaves. The text should flow alongside the object without
leaving an unnecessarily large vertical gap above or below it.

\end{document}

The wrapfig package provides the wrapfigure environment. The first argument, {r}, places the figure on the right; use {l} for the left. The second argument sets the overall width reserved for the figure. In this example, \intextsep reduces the vertical separation, while \columnsep controls the distance from the figure to the text.

Check paragraph breaks and figure width

A wrapfigure is intended to sit beside a paragraph. Put the environment where that paragraph begins, then continue the paragraph directly after \end{wrapfigure}. An empty line starts a new paragraph, which can disrupt the intended wrapping or make the layout appear to have extra space. Also make sure the reserved width is not much larger than the actual figure; unused width can look like excess padding.

If the text does not wrap for enough lines, wrapfigure also accepts an optional line-count argument, for example \begin{wrapfigure}[8]{r}{0.32\textwidth}. This tells the package approximately how many lines to reserve for the wrapped area. Adjust it only if the default estimate is visibly wrong; it controls the extent of the wrapping, not the basic vertical separation set by \intextsep.

Check the image itself

The gap may be part of the image file rather than LaTeX spacing. A PNG or PDF can contain white margins around its visible content. Lowering \intextsep will not remove those margins. If you use \includegraphics, inspect the image bounds and crop the file or use the trim and clip options from graphicx when appropriate:

\includegraphics[width=\linewidth,trim=8 5 8 5,clip]{figure}

The trim values are in the order left, bottom, right, top. Choose values that match the file’s whitespace; cropping can cut off labels or other important content.

Common mistakes

  • Changing \textfloatsep: that length controls separation around top and bottom floats, not the usual spacing for a wrapped figure. Start with \intextsep.
  • Changing \columnsep to fix vertical space: it affects the horizontal clearance only.
  • Using negative \vspace as the first fix: this can hide the symptom while causing collisions or inconsistent spacing elsewhere. Adjust the relevant length instead.
  • Assuming all blank space belongs to the environment: image margins and paragraph spacing can contribute too. Check the source image and the surrounding blank lines before applying more spacing changes.

References

  1. The wrapfig package documentation
  2. The LaTeX2e unofficial reference manual: Lengths

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