在 mdframed 环境中,Wrap Figure 无法正常工作

在 mdframed 环境中,Wrap Figure 无法正常工作

我正在使用wrapfigure环境,但得到了一些不需要的输出。我的代码是

\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}

输出为

输出

您可以在底部看到框架仅显示在左侧。如何使其恢复正常?请帮忙。

谢谢

[编辑]@Bernard 回答后的观察。

请考虑另一个例子:

\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}

输出是 输出第二个代码。 请查看底部如何仅在左侧显示。

答案1

我建议使用纯 TeX 宏包insbox代替环境 wrapfigure\InsertBoxL\InsertBoxR命令有两个强制参数:段落开头和插入框的未缩短行数,以及一个可选参数:补充缩短行数,以防 (La)TeX 计算的缩短行数不正确。

\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} 

在此处输入图片描述

答案2

mdframed(结束段落)前留一行空白。

顺便说一句,我无法使用旧版本的 lipsum.sty 重现该问题,但新版本的 lipsum.sty(什么?!)存在问题\par,因此您应该使用命令\LipsumPar{ }(带花括号)。

相关内容