Misalignment with cutwin

Compiling the code below yields a misalignment of the text when the box is drawn.

\documentclass[fleqn,11pt]{book}
\usepackage{cutwin}
\begin{document}
\renewcommand\windowpagestuff{\flushright\rule{2cm}{2cm}}%
\opencutright%
text text text text text text text text text text text text text text text text text   text text text text text text text text text text text text
\begin{cutout}{1}{0.79\linewidth}{0pt}{5}%
text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text
\end{cutout}
\end{document}


Would you know nice tricks to avoid this behavior?

-
You can also use wrapfigure. –  Harish Kumar Feb 17 '13 at 12:22

It seems to be a small issue with the environment itself.

First of all you have to setup the environment as a single paragraph.(see documentation)

Next I redefined the environment itself by using the great package regexpatch:

\documentclass[fleqn,11pt]{book}

\usepackage{cutwin,kantlipsum,mwe}
\usepackage{regexpatch}
\opencutright
\renewcommand\windowpagestuff{\centering\includegraphics[width=2cm]{example-image-b}}%

\makeatletter
\xpretocmd{\cutout}{\leavevmode\hrule \@height\z@ \@width\linewidth\relax}
\makeatother

\begin{document}
\kant[3]

\begin{cutout}{2}{0.7\linewidth}{0pt}{5}%
\kant[1]
\end{cutout}
\end{document}


-
Should the package be corrected? Also, in your example, we can still notice a slight misalignment introduced by cutwin. Thanks –  pluton Feb 17 '13 at 15:49
@pluton: Indeed. I didn't notice this misalignment. In my opinion I would change some internals and especially the implementation of the environment itself. I prefer an environment based on list. –  Marco Daniel Feb 17 '13 at 16:03
which one? because I am trying to use a cutwin like environment in your mdframed environment and the only one working so far is cutwin –  pluton Feb 17 '13 at 16:15
@pluton: I like the possibility by parshape: tex.stackexchange.com/questions/23402/mdframed-and-wrapfig/… –  Marco Daniel Feb 17 '13 at 16:18
yes, this is probably the best. I could adapt to my case. –  pluton Feb 17 '13 at 18:09