2

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

output

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 Output of second code. Please see at the bottom part how it is showing at the left only.

2 Answers 2

3

I suggest using the plain TeX macro package insbox in the place of the wrapfigure environment. The \InsertBoxL and \InsertBoxR commands take two mandatory arguments: the number of unshortened lines at the beginning of the paragraph, and the inserted box, and an optional argument: the number of supplementary shortened lines, in cases (La)TeX calculates an incorrect number of shortened lines.

\documentclass{article}
\usepackage[latin]{babel} 
\usepackage{graphicx}
\usepackage{xcolor}
\usepackage{lipsum}
\usepackage{mdframed}
\input{insbox}

\begin{document}

\lipsum[2]
\InsertBoxR{0}{\enspace\includegraphics[width=0.48\textwidth]{AliceSteadman}}
\lipsum[1]
\lipsum[3]
\begin{mdframed}[backgroundcolor = gray!20]
\lipsum[3]
\end{mdframed}

\end{document} 

enter image description here

3
  • I used your suggestion, sometimes it works but sometimes it gives the text at the left only. Nov 5, 2020 at 13:35
  • Not sure to see exactly what happens. Could you post a small code reproducing the problem?
    – Bernard
    Nov 5, 2020 at 13:44
  • Please see my edited question. Nov 5, 2020 at 14:05
3

Just leave a blank line before mdframed (end the paragraph).

By the way, I can't reproduce the problem with an older version of lipsum.sty, but there is a newer version of lipsum.sty (what?!) that has problems with \par, and for which you should use the \LipsumPar{ } command (with curly braces).

3
  • I know \WFclear has to be used between paragraphs. Sep 28, 2020 at 3:09
  • @JohnKormylo if you use \WFclear, it will end the paragraph (the definition starts with \par). Is that what you meant? Sep 28, 2020 at 8:10
  • It also changes \everypar, which has to be done between paragraphs. Then there is \WF@finale. Sep 28, 2020 at 17:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .