# Wrapfigure placing image on the wrong side of page

I'm using wrapfigure to place images on the outside (o) edge of my document. Mostly it seems to work fine but sometimes an image gets placed on the wrong side.

You can see the problem on page 3. The space for the first image is on the left rather than the right and the image doesn't seem to place correctly.

I think it has to do with a command someone helped me write once that forces the end of a wrapfigure environment:

\documentclass[10pt]{report}
\usepackage{graphicx}
\usepackage{wrapfig}
\usepackage[latin]{babel}
\usepackage{blindtext}
\usepackage{forloop}
\usepackage[twoside,a4paper,portrait,lmargin=10mm,rmargin=10mm,tmargin=14mm,bmargin=9mm]{geometry}
\begin{document}
% make a command, wrapfill, that forces the end of a wrapfigure
\makeatletter
\def\wrapfill{\par
\ifx\parshape\WF@fudgeparshape
\nobreak
\ifnum\c@WF@wrappedlines>\@ne
\vskip\c@WF@wrappedlines\baselineskip
\global\c@WF@wrappedlines\z@
\fi
\allowbreak
\WF@finale
\fi
}
\makeatother
\newcounter{ct}
\forloop{ct}{1}{\value{ct} < 12 }%
{
\begin{wrapfigure}{o}{0pt}
\includegraphics[width=12cm,height=25mm,keepaspectratio=true]{test.jpg}
\end{wrapfigure}
\blindtext
\blindtext
\wrapfill
}
\end{document}


I'll post a link to the PDF later. I can only include 2 links due to reputation being < 10.

Any idea how I might track down what's going on or how I could fix it?

• Welcome to TeX.SX! I am sorry, but I won't download an archive file. I think most users here won't. You really have to prepare an MWE. In best case, you will find your error doing it. If you want to learn something here, it makes no sense to give a big pile of code for review but you should ask a specific question. For a beginning, you could check if your image is too big. Just set width=0.1\linewidth and see if it does place correctly then. Oct 2, 2014 at 7:14
• Oct 3, 2014 at 2:08

one of the related articles had what appears to be the answer.

Wrapfigure apparently creating dummy space on a following page

I needed to add \leavevmode to the end of my wrapfill macro:

\makeatletter
\def\wrapfill{\par
\ifx\parshape\WF@fudgeparshape
\nobreak
\ifnum\c@WF@wrappedlines>\@ne