qinglee / wrapstuff

Wrapping text around stuff
https://ctan.org/pkg/wrapstuff
LaTeX Project Public License v1.3c
11 stars 4 forks source link

Paragraph starting in a group following `wrapstuff` environment breaks #11

Open Skillmon opened 1 year ago

Skillmon commented 1 year ago

If the first a paragraph in the affected scope of a wrapstuff environment starts inside of a group but doesn't end in that group this breaks the package. A simple user-side workaround is placing \leavevmode in front of the group. Text following that group in the same paragraph doesn't change the behaviour, all that matters is that the group doesn't start before the paragraph starts or that it doesn't end before the paragraph ends.

See the following MWE for four wrapstuff usages, the first two failing because of the groups, the latter two working correctly (because of \leavevmode or the end of the paragraph in the same group -- FYI if another paragraph starts but doesn't end in that group it'll err as well):

\documentclass{article}

\usepackage{wrapstuff}

\begin{document}
\begin{wrapstuff}
  \rule{3cm}{3cm}
\end{wrapstuff}
{%
Some simple text inside a group without a trailing {\ttfamily\string\par}.
Perhaps it'll break \texttt{wrapstuff}, perhaps not. We'll see.
}%

\clearpage
\begin{wrapstuff}
  \rule{3cm}{3cm}
\end{wrapstuff}
\begingroup
Some simple text inside a group without a trailing {\ttfamily\string\par}.
Perhaps it'll break \texttt{wrapstuff}, perhaps not. We'll see.
\endgroup

\clearpage
\begin{wrapstuff}
  \rule{3cm}{3cm}
\end{wrapstuff}
\leavevmode
\begingroup
Some simple text inside a group without a trailing {\ttfamily\string\par}.
Perhaps it'll break \texttt{wrapstuff}, perhaps not. We'll see.
\endgroup

\clearpage
\begin{wrapstuff}
  \rule{3cm}{3cm}
\end{wrapstuff}
\begingroup
Some simple text inside a group with a trailing {\ttfamily\string\par}.
Perhaps it'll break \texttt{wrapstuff}, perhaps not. We'll see.
\par
\endgroup
\end{document}