Prevent wrapfigure from wrapping the next section

With the text and image as they are, wrapfig needs a bit of help.

You could tell it to stop wrapping after 29 lines:

\begin{wrapfigure}[29]{l}{0.5\textwidth}

But the result is rather squeezed:

enter image description here

A much better result in this case is to simply add \clearpage before the \section and move it to the next page.


You could simply include the wrapfig and the wrapped text in brackets as follows:

{
\begin{wrapfigure}{l}{0.5\textwidth}
  \rule{4cm}{12cm}
\end{wrapfigure}
\lipsum[1]
}
\section{Hello}

This stops the wrapping at the line where the wrapped text stops. As pointed out by Andrew Swann, this doesn't work if the figure is longer than the text; in that case, the following section heading will be overwritten by the figure.


If the text wrapping the figure ends in some actual text and not just included text like \lipsum, then it works to just add empty lines to the end of the text.

\documentclass{article}
\usepackage[a5paper]{geometry}
\usepackage{wrapfig}
\usepackage{lipsum}
\begin{document}
\begin{wrapfigure}{l}{0.5\textwidth}
  \rule{4cm}{11cm}
\end{wrapfigure}
\lipsum[2] 
text\\ \\ \\ \\ \\ \\ \\ \\

\section{Hello}

Hello section text
\end{document}

enter image description here

Tags:

Wrapfigure