17

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}
8
  • Is there a page break near the problematic figure? Sep 20, 2012 at 3:25
  • Not an explicitly forced one. e.g. \newpage Sep 20, 2012 at 3:31
  • Please try to remove the \vspace. It might be that the total of the \vspace is more than the height of the figure.
    – Guido
    Sep 20, 2012 at 3:37
  • THanks for the suggestion but unfortunately that doesn't help. I took out all of the vspace and it shifted the figure but just behind the text. Sep 20, 2012 at 3:46
  • @LaurenLEmberson pagebreaks (even non explicit ones) can be problematic if they occur in the place where the wrapfigure is supposed to appear. Try changing the wrapfigure to another location and see if that solves the problem; also, remove the \vspace commands. Sep 20, 2012 at 3:46

4 Answers 4

9

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.

1

I have found there is also a problem if the text next to wrapfigure starts a new paragraph. You can fix this if, at that paragraph break, you change

end of new paragraph.

Start of new paragraph ...

to

end of new paragraph.\hfill\break\indent Start of new paragraph ...

It will look exactly like a new paragraph, but latex won't think it has started another paragraph, and wrapfigure magically works again.

You can put the Start on a new line, just don't include a blank line in between. Or to make it easier to see where your pseudo-paragraphs are, put a line starting with % in between, latex won't see that as a blank line.

1

I had the same problem, but the cause was different. I had

{\hskip \parindent}

at the beginning of one of my paragraphs, removing it fixed the problem.

I tried replacing it with

\hspace{\parindent}

but that also caused the wrapfigure to be misplaced and overlap the text.

0

I have found that defining the spacing for that area of text to cause the text to properly wrap, especially for figures that have a transparent background. Use \begin{spacing}{1.0} ending with \end{spacing}, for example. You will need the setspace package: \usepackage{setspace}.

1
  • 1
    Thanks for your answer and welcome! I'm not quite sure that this is the problem the author of the original question had. It would be great if you could expand on your answer to show an example (as minimal as possible) where this trick helped you!
    – wrtlprnft
    May 6, 2016 at 9:51

You must log in to answer this question.

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