The following MWE's code (taken from here and slightly modified: added minipages around) should demonstrate the details:
\documentclass{article}
\usepackage{lipsum,tikz,wrapfig}
\setlength\intextsep{0pt}%<- doesn't seem to matter
\begin{document}
%
\fbox{%
\begin{minipage}[t]{0.45\textwidth}%
\begin{wrapfigure}{r}{4cm}%
\begin{tikzpicture}%
\fill (0, 0) rectangle (4, 4);%
\end{tikzpicture}%
\end{wrapfigure}%
\lipsum[1]%
\end{minipage}%
}%
%
\fbox{%
\begin{minipage}[t]{0.45\textwidth}%
% \begin{wrapfigure}{r}{4cm}%
% \begin{tikzpicture}%
% \fill (0, 0) rectangle (4, 4);%
% \end{tikzpicture}%
% \end{wrapfigure}%
\lipsum[1]%
\end{minipage}%
}%
\end{document}
Screenshot:
Question: How can the gap (see the red questionmark within the screenshot) be eliminated? (My build-environment: Win7-64, Texstudio, TexLive2017, LuaLatex)
Update 1:
According cfr's comments I've added fboxes around the minipages. This shows that there is no space added - instead the minipage environment seems to be influenced by wrapfig: Please see the following screenshot.




\intextsepcertainly matters. Try setting it to100pt! – cfr Jun 17 '17 at 00:26\fboxes around theminipages to see what I mean. (Not sure about this, though.)wrapfiginserts a\parwith an\hrule, I think, to set the width of the box to the required value. If you put a letter before thewrapfig, it is possibly a little clearer. The\pardoesn't add any vertical space, but I think it changes the location oftrelative to theminipage. However, I don't see why this should affect anything outside the box .... – cfr Jun 17 '17 at 00:36wrapfigis possibly not the best idea. – cfr Jun 17 '17 at 00:57wrapfigwould be affecting stuff outside theminipagewhich contains it :(. – cfr Jun 17 '17 at 12:42