I used the code from here to get text to wrap around images, but whenever I have a long image near the end of the page, it runs off the page and gets cut off. How do I fix this?

2 Answers 2


When positioning the wrapped float, you can specify uppercase L or R for the position, instead of lowercase l, r. This allows the wrapfigure environment to float and LaTeX can move it to avoid page overflow.

  • Hmm, It does, but in my case it moved the figure to the end of the document, which I consider a bit excessive...
    – JHBonarius
    May 8, 2018 at 9:55

You could add the following to your document preamble:

  \par \penalty-100\begingroup%
  \dimen@ii\pagegoal \advance\dimen@ii-\pagetotal
  \ifdim \dimen@>\dimen@ii

and then use


to check whether the image will fit on the page or not. If it does/will fit, nothing will happen. If it does/will not fit, a break (page or column) is issued, so the next paragraph will start on a new page.

The above code was taken from the minimal needspace package.

  • 1
    I don't want to be tough, but it does mean that one has to include the graphics twice, first to check its siye and then to include it?
    – yo'
    Jan 27, 2012 at 19:13
  • @tohecz: That's correct. I'm not sure whether this requirement is an isolated instance, and therefore a separate commands seems viable. If not, and this check has to be included with each, it would be possible to include such a check as part of the wrapfigure environment.
    – Werner
    Jan 27, 2012 at 19:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.