20

Is there a (simple) way to adjust the white space to the left or right of a wrapfigure? I'd like to reduce the whitespace on the left side of a right-floated figure.

Adding \hspace moves the figure to the left, it doesn't move the caption:

\begin{wrapfigure}{r}[.25in]{.98in}
\vspace{-20pt}
\hspace{-.25in}
   \centering
        \includegraphics[width=.98in]{figure.pdf}
   \caption{Caption}
    \label{fig:looping}
 \vspace{-6pt}
 \end{wrapfigure}
1

1 Answer 1

17

The horizontal gap between the contents of the wrapfig environment and the surrounding paragraph text is \columnsep (from the wrapfig documentation, section 2 Sizing and optional overhang, p 3):

LaTeX will wrap surrounding text around the figure, leaving a gap of \intextsep at the top and bottom, and \columsep at the side, by producing a series of shortened text lines beside the figure. The indentation (shortening) of the text is the figure width plus \columnsep minus overhang (if any; see below).

Here's an example that shows the difference when setting \columnsep to 0pt, and leaving it as-is:

enter image description here

\documentclass{article}
\usepackage{wrapfig,graphicx,lipsum}% http://ctan.org/pkg/{wrapfig,graphicx,lipsum}
\begin{document}
\begingroup
\setlength{\columnsep}{0pt}%
\begin{wrapfigure}{r}{.98in}
  \centering\includegraphics[width=\linewidth]{example-image-a}
  \caption{Caption}\label{fig:looping1}
\end{wrapfigure}
\lipsum[1]
\endgroup

\begin{wrapfigure}{r}{.98in}
  \centering\includegraphics[width=\linewidth]{example-image-a}
  \caption{Caption}\label{fig:looping2}
\end{wrapfigure}
\lipsum[1]
\end{document}

Adjust this to your liking. Use scoping (\begingroup...\endgroup, or similar) to localize any changes.

Note that you can therefore also use \intextsep as your vertical adjustment, rather than fixed values.

4
  • 5
    Putting my wrapfigure inside the group (even without the setlength command) removes the margin entirely and the text just covers the image. Jan 20, 2014 at 17:48
  • 1
    @mangledorf: Don't leave a space between the wrapfigure environment and the subsequent paragraph. Check that you have the latest version of [wrapfig](ctan.org/pkg/wrapfig (3.6 according to CTAN). Also, it may be that your image has a faulty bounding box. It's not possible to guess what could cause that from what you mention.
    – Werner
    Jan 20, 2014 at 17:51
  • 1
    @mangledorf, solution was to make sure my wrapped paragraph of text was inside the group and there was a blank line before \endgroup, See tex.stackexchange.com/questions/82647/… Jan 20, 2014 at 17:52
  • @mangledorf: Ahhh, a blank line signifies a paragraph break in (La)TeX, which \lipsum does inherently (unless you \usepackge[nopar]{lipsum}).
    – Werner
    Jan 20, 2014 at 17:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .