[Tex/LaTex] Wrapfig – why is figure placed in margins

wrapfigure

I've created a wrapfig environment

\newenvironment{usefulterms}{
\begin{wrapfigure}{l}[0pt]{0.05\textwidth}
\vspace{-15pt}
\includegraphics[width = 0.05\textwidth]{abc.jpg}
\vspace{-25pt}
\end{wrapfigure}
\noindent{\textbf{Useful Terms}} \\
\newline}
{\newline}

The problem is that even thought I specify an overhang of 0pt, it is still placed in the margin;

enter image description here

Why is this command being "disobeyed"?

Thanks

Nick

Best Answer

This is caused by the fact that material inside an environment is placed inside a group, which confuses wrapfig. Page 1 of the package documentation, says

If you put a wrapfigure in a parbox or a minipage, or any other type of grouping, the text wrapping should end before the group does.