I am using wrapfigure
environment but I am getting some unwanted output. My code is
\usepackage{wrapfig}
\usepackage{lipsum}
\usepackage{mdframed}
\lipsum[2]
\begin{wrapfigure}{r}{0.5\textwidth}
\centering
\includegraphics[width=0.48\textwidth]{Fig59.pdf}
\end{wrapfigure}
\lipsum[1]
\lipsum[2]
\lipsum[2]
\begin{mdframed}[backgroundcolor = gray!20]
\lipsum[3]
\end{mdframed}
and the output is
You can see at the bottom the frame is showing at the left only. How to get it normal? Please help.
Thanks
[Edit] Observation after the answer of @Bernard.
Please consider another example:
\begin{proof}
Consider a unit circle centered at (0,0).
\InsertBoxR{1}{\enspace\includegraphics[width=0.48\textwidth]{TrigFig11.pdf}}
\noindent
Take a point $P(x_0,y_0)$ on circle and let $\angle AOP=\theta$ then we have
\[
\cos\theta=x_0,\ \sin\theta=y_0.
\]
Since a point $P(x_0,y_0)$ lies on a unit circle so
\[
x_0\in[-1,1],\ y_0\in[-1,1].
\]
Conversely, if take any number from $-1$ to $1$ then we can find a point on unit circle whose $x$ coordinate equals that number and also we can find a point whose $y$ coordinate equals that number.
Thus, we have
\begin{align*}
\cos\theta&\in [-1,1]\\
\sin\theta&\in[-1,1].
\end{align*}
\begin{figure}[H]
\centering
\includegraphics[scale=1.5]{TrigFig12.pdf}
\end{figure}
\noindent
%[Some details are skipped.]
Hence we get,
\begin{equation*}
\tan\theta\in(-\infty,\infty).\qedhere
\end{equation*}
\end{proof}
And the output is Please see at the bottom part how it is showing at the left only.