我曾尝试使用wrapfigure
环境(来自wrapfig
)包,但是它的行为使得我无法使用它。
考虑以下 MWE:
\documentclass{article}
\usepackage{wrapfig,mwe}
\newenvironment{testenv}{%
\begin{wrapfigure}{r}{.5\linewidth}%
\vspace{.5\baselineskip}%
}{%
\end{wrapfigure}}
\begin{document}
\begin{wrapfigure}{r}{.5\textwidth}\vspace{.5\baselineskip}
This is some dummy text. This is some dummy text.
This is some dummy text. This is some dummy text.
\end{wrapfigure}
\lipsum[1]
\begin{testenv}
This is some dummy text. This is some dummy text.
This is some dummy text. This is some dummy text.
\end{testenv}
\lipsum[2]
\end{document}
这将产生以下输出。是什么原因导致了此错误?有什么方法可以修复它?
虽然修复这个问题wrapfigure
很酷,但如果针对我的特定用例存在更简单的修复方法,我会很高兴看到它:)
。
答案1
使用环境的命令形式wrapfigure
:
\documentclass{article}
\usepackage{wrapfig,lipsum}% http://ctan.org/pkg/{wrapfig,lipsum}
\newenvironment{testenv}{%
\wrapfigure{r}{.5\linewidth}%
\vspace{.5\baselineskip}%
}{%
\endwrapfigure}
\begin{document}
\begin{wrapfigure}{r}{.5\textwidth}\vspace{.5\baselineskip}
This is some dummy text. This is some dummy text.
This is some dummy text. This is some dummy text.
\end{wrapfigure}
\lipsum[1]
\begin{testenv}
This is some dummy text. This is some dummy text.
This is some dummy text. This is some dummy text.
\end{testenv}
\lipsum[2]
\end{document}