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.
\intextsep
certainly matters. Try setting it to100pt
!\fbox
es around theminipage
s to see what I mean. (Not sure about this, though.)wrapfig
inserts a\par
with 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\par
doesn't add any vertical space, but I think it changes the location oft
relative to theminipage
. However, I don't see why this should affect anything outside the box ....wrapfig
is possibly not the best idea.