# wrapfig with {R} remains left and keeps white space to the right

I am using wrapfig inside normal text (no lists or anything), with the {R} option to make it float right. However, some of the figures end up being aligned left, with all the space to their right being empty (i.e. the text does not wrap around). I have tried reproducing this with the lipsum package (the document is sensitive, unfortunately), but could not reproduce the error. It is definitely not due to the images (like bounding box issues etc.), as they work fine for the lipsumexample.

The figures are of the form

\begin{wrapfigure}{R}{.47\textwidth}
\centering
\includegraphics[width=.45\textwidth]{file.pdf}
\caption{{\bf Description.} Rest of the caption.}
\label{fig:figlabel}
\end{wrapfigure}


I've put up an example on Google Drive. Has anyone experienced something similar?

• You'll probably need to post an example. Probably you are catching the page breaker at exactly the wrong time and hard to debug without a test case. Don't use lipsum as hard to control the text length which is likely to be critical. Start from a copy of your document. Replace the image by \vspace{} whatever space it needs. Then just change the wordsuse a text editor to change every letter to x it doesn't really matter. Then discard any packages and text you can while still showing the problem. (ps \bf has been deprecated since latex2e came out in 1993) – David Carlisle Jun 26 '13 at 22:49
• Thanks. I've uploaded an example following your suggestions: Google Drive – user32849 Jun 27 '13 at 15:28
• You seem to be violating some of rules specified in the wrapfig documentation (p 2): "The environment should be placed so as to not run over a page break." Also, "When ﬂoating, LaTeX tries to apply these rules. More specifically, a floated wrapping environment will only begin: when there is enough room on the page, or it is possible to go on the next page; if the paragraph is not wrapping around another figure." – Werner Jun 27 '13 at 23:16
• The first sentence obviously only refers to manual placement. Also, there is clearly enough paragraph text to wrap around in my example. None of this explains why the figures end up on the left side. – user32849 Jun 27 '13 at 23:27

In spite that you have found some problem with lipsum, this package is useful to showing the problem at least with a MWE with no extra packages.

As you can see in this code, the first section show the problem of page break cited in the Werner's comment. The second section, with the same text and figures, reproduce the problem not due to a page break. Here the problem is that wrapfig would take space from the following paragraph, but you have another figure there. You can see a similar problem in Typesetting errors with two wrapfigures on one page?

For the same reason, you also must be careful when a wrapfig figure is followed with another objects as a section or a newenvironment instead of a simple paragraph.

The solution is manually move the source code of the figures to avoid both problems, as showed in the third section.

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{wrapfig}
\usepackage{lipsum}
\newcommand\FIG{\begin{wrapfigure}{R}{.47\textwidth}
\centering
\includegraphics[width=.45\textwidth]{file.pdf}
\caption{{\bf Description.} Rest of the caption.}
\label{fig:figlabel}
\end{wrapfigure}}

\begin{document}
\section{Bad float due to page break}
\FIG\lipsum[1] % ok
\FIG\lipsum[1] % ok
\FIG\lipsum[1] % go to the left due to page break
\FIG\lipsum[1]
\lipsum[1] % ok
\newpage
\section{Misplacement due to too close figures}
\FIG\lipsum[1] % ok
\FIG\FIG \lipsum[1] % Too close figures
\lipsum[1]
\FIG\lipsum[1] % ok
\lipsum[1]
\newpage
\section{Good float}
\FIG\lipsum[1] % ok
\FIG\lipsum[1] % ok
\lipsum[1]
\FIG\lipsum[1] % ok
\FIG\lipsum[1] % ok
\end {document}