I want to create a wrapper environment for wrapfigure in order to locally set \initextsep to 0. I know, it could be done differently, but this code is exhibiting strange behaviour. It moves the figure to a place after the paragraph it is defined in.
\documentclass{article}
\usepackage{lipsum}
\usepackage{wrapfig}
\begin{document}
\lipsum[1]
\newenvironment{mywrapfigure}[2]{
\begin{wrapfigure}{#1}{#2}
}
{
\end{wrapfigure}
}
\begin{mywrapfigure}{r}{.3\textwidth}
\rule{5cm}{5cm}
\end{mywrapfigure}
\lipsum[1]
\end{document}
Note that all I am doing is creating a dummy environment around wrapfigure.

How do I fix this?

\wrapfigureand\endwrapfigureinstead of\begin{wrapfigure}and\end{wrapfigure}wrapfigureis no real environment in the sense of\newenvironment. – Sep 08 '15 at 09:56\initexseplocally. I also find it annoying that that setting is not automatically zero inside wrapfigure – daleif Sep 08 '15 at 10:16\initextsepis completely unknown to me. Is it a TeX primitive? Do you mean\intextsep? – Sep 08 '15 at 10:19