[Tex/LaTex] wrapfigure problem: text over figure

errorsfloatswrapfigure

I am a relatively new LaTeX user, so bear with me. I am using wrapfigure to present figures in a grant application (read: space is at a premium). All of a sudden, one of my figures is being presented under the text. I have done a lot of debugging including replacing the file from another figure file (still has the problem) but putting the original figure into other analogous code reproduces the problem with different code. Changing the file to a JPG from a PDF doesn't help.

Anyways, I've spent several hours on this and any help would be greatly appreciated! I've posted the relevant code.

image

\begin{wrapfigure}{r}{0.3\textwidth}

\begin{center}

\vspace{-38pt}

\includegraphics[width=0.3\textwidth]{infantpilotresults-cropped.pdf}

\vspace{-27pt}

\caption{\emph{Six month-olds' looking to unexpected visual omissions.}}

\vspace{-15pt}

\label{figure:prelim1results} 

\end{center}

\end{wrapfigure}

Best Answer

After the comments to the original question it is clear that the problem was caused by a page break. Pagebreaks (even non explicit ones) can be problematic if they occur in the place where the wrapfigure is supposed to appear. The wrapfig package documenatation mentions this explicitly:

The environment should be placed so as to not run over a page break.

Moving the wrapfigure environment to another location fixes the problem.

As a side note, instead of using the center environment it could be better to use the \centering command; also, perhaps you might want to reconsider the use of the \vspace commands.