Why is text not wrapping around image?

\lipsum definition ends with a paragraph end, you need a blank line before the \endgroup as below, or safer if there is any possibility of the group ending before the text cutout is finished, do not put wrapfig in a group at all.

Note that changing \columnsep within the document will have odd effects if you have a two column document and a page break happens to fall within the scope of the change.

enter image description here

\documentclass{article}
\usepackage{graphicx,lipsum,wrapfig}% http://ctan.org/pkg/{graphicx,lipsum,wrapfig}
\begin{document}

\begingroup
\setlength{\intextsep}{0pt}
\setlength{\columnsep}{15pt}
\begin{wrapfigure}{r}{0.45\textwidth}
\centering
  \includegraphics[width=\linewidth]{example-image-a}
  \caption{Caption}\label{versusMABs}
\end{wrapfigure}
\lipsum[1]
\endgroup

\begingroup
\setlength{\intextsep}{0pt}
\setlength{\columnsep}{15pt}
\begin{wrapfigure}{r}{0.45\textwidth}
\centering
  \includegraphics[width=\linewidth]{example-image-a}
  \caption{Caption}\label{versusMABs}
\end{wrapfigure}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam ac urna at eros tristique imperdiet et ut mauris. Maecenas semper commodo purus id egestas. Praesent at nisi non magna molestie varius ac sed arcu. Proin aliquet dui eget sapien venenatis rutrum. In vel eleifend tortor, eu sodales nulla. Vivamus sit amet posuere sem. Aliquam scelerisque ac mauris eu feugiat. Donec faucibus est in justo ullamcorper tincidunt. In hac habitasse platea dictumst. Ut et odio a orci eleifend iaculis. Praesent rhoncus auctor arcu eget vulputate. Sed commodo mi id quam hendrerit porttitor. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.

\endgroup
\end{document}

The setting of \intextsep to zero is wrong (try it).

It's also better to define your own version of wrapfigure, rather than relying on code duplication in the document. It's necessary to use \wrapfloat and \endwrapfloat to build a new environment similar to the standard ones.

\documentclass{article}
\usepackage{graphicx,lipsum,wrapfig}

\newenvironment{lydiawrapfigure}
 {%
%  \setlength{\intextsep}{0pt}% <--- Wrong!
  \setlength{\columnsep}{15pt}%
  \wrapfloat{figure}%
 }
 {\endwrapfloat}

\begin{document}

\begin{lydiawrapfigure}{r}{0.45\textwidth}
\centering
  \includegraphics[width=\linewidth]{example-image-a}
  \caption{Caption}\label{versusMABs}
\end{lydiawrapfigure}

\lipsum[1]

\begin{lydiawrapfigure}{r}{0.45\textwidth}
\centering
  \includegraphics[width=\linewidth]{example-image-a}
  \caption{Caption}\label{versusMABs2}
\end{lydiawrapfigure}

Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
Nam ac urna at eros tristique imperdiet et ut mauris. 
Maecenas semper commodo purus id egestas. Praesent at 
nisi non magna molestie varius ac sed arcu. Proin aliquet 
dui eget sapien venenatis rutrum. In vel eleifend tortor, 
eu sodales nulla. Vivamus sit amet posuere sem. Aliquam 
scelerisque ac mauris eu feugiat. Donec faucibus est in 
justo ullamcorper tincidunt. In hac habitasse platea 
dictumst. Ut et odio a orci eleifend iaculis. Praesent 
rhoncus auctor arcu eget vulputate. Sed commodo mi id quam 
hendrerit porttitor. Class aptent taciti sociosqu ad litora 
torquent per conubia nostra, per inceptos himenaeos.

\end{document}

enter image description here

Tags:

Wrapfigure