I use the solution suggested in “Non-rectangular body geometry” by the (deleted) user @user4686 but the render failed when it reached a verse environment in the body:
The MWE
As I need the non-rectangle shape for a document part only and not the wide document I remove the \cnta repetition commands:
\documentclass[a4paper,12pt]{article}
\def\LINESPERPAGE{45}
\usepackage[textheight=\LINESPERPAGE\baselineskip]{geometry}
\usepackage{lipsum}
\usepackage{xinttools}% requires version 1.09m or later
\usepackage{poemscol}
% let's divide by two the sizes of the undulation.
\edef\MOCKSINE {%
{1.5em \the\dimexpr\textwidth-1.5em}%
{2em \the\dimexpr\textwidth-2em}%
{2.5em \the\dimexpr\textwidth-2.5em}%
{2.875em \the\dimexpr\textwidth-2.875em}%
{3em \the\dimexpr\textwidth-3em}%
{2.875em \the\dimexpr\textwidth-2.875em}%
{2.5em \the\dimexpr\textwidth-2.5em}%
{2em \the\dimexpr\textwidth-2em}%
{1.5em \the\dimexpr\textwidth-1.5em}%
{1em \the\dimexpr\textwidth-1em}%
{.5em \the\dimexpr\textwidth-.5em}%
{0.125em \the\dimexpr\textwidth-0.125em}%
{0em \the\dimexpr\textwidth-0em}%
{0.125em \the\dimexpr\textwidth-0.125em}%
{.5em \the\dimexpr\textwidth-.5em}%
{1em \the\dimexpr\textwidth-1em}%
}
\makeatletter
\edef\MCK@LINESPERPAGE {\the\numexpr \LINESPERPAGE\relax }
\def\MCK@LINECOUNT {0}
\def\SETUPPARSHAPE {%
\xdef\MCK@tmpB {\the\numexpr \pagetotal/\baselineskip}%
\ifnum\MCK@tmpA>\MCK@tmpB
% assume we are on a new page. !!!Something more robust should be done here!!!
\xdef\MCK@LINECOUNT
{\the\numexpr\MCK@LINECOUNT+\MCK@tmpB-\MCK@tmpA+\MCK@LINESPERPAGE}%
\else
\xdef\MCK@LINECOUNT {\the\numexpr\MCK@LINECOUNT+\MCK@tmpB-\MCK@tmpA}%
\fi
\global\let\MCK@tmpA\MCK@tmpB
\edef\STARTINDEX {\the\numexpr\MCK@LINECOUNT+16-16*((\MCK@LINECOUNT+8)/16)}%
\parshape 16 \xintListWithSep { }{\xintTrim \STARTINDEX\MOCKSINE}
\xintListWithSep { }{\xintKeep \STARTINDEX\MOCKSINE} \relax
}
\def\STARTUNDULATIONS {\def\MCK@LINECOUNT {0}\def\MCK@tmpA {0}%
\def\par {\oldpar \SETUPPARSHAPE }\SETUPPARSHAPE }
\def\STOPUNDULATIONS {\let\par\oldpar }
\makeatother
\let\oldpar\par
\AtBeginDocument {\STARTUNDULATIONS }
\begin{document}
\section{This is a section}
\lipsum %[\cnta-\numexpr\cnta+3\relax]
\begin{verse}
This is a verse \
This is a verse \
This is a verse \
This is a verse \
This is a verse \
\end{verse}
\lipsum
\end{document}
The rendering

As I said the shape is correctly aplied in the whool document exepted when it reach the verse environement.
The goal
The goal is to force the shape to be applied in the full body included the verse environment and to keep going unless I use \STOPUNDULATIONS command.
So how can I patch the code to force verse environment to follow the shape?
