0

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

rendering with a verse

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?

fauve
  • 2,501
  • 1
    verse is a list and all latex lists work by using the same parshape mechanism so merging would be hard, simpler to just define a new verse environment that uses your specified parshape but with shape modiffied to increase teh left indent and decrease the text width in each line – David Carlisle Sep 01 '21 at 14:23
  • True, I was feeling the list environement it’s hard to merge with parshape. – fauve Sep 01 '21 at 14:37
  • Are you preparing a new edition of Apollinaire's Calligrammes, per chance? – Bernard Sep 01 '21 at 15:00
  • Haha, I was waiting someone ask this quesiton ^^ So, not realy, I make my own poems editions (including some calligrammes). – fauve Sep 01 '21 at 16:05

1 Answers1

1

The simplest is to define a verse enviornment that does not internally rely on the paragraph shape so you do not need to merge. Here I simply define it to add some vertical space and to locally define \\ to be end of paragraph. I force the extra indent here filled with dots to make the undulating margin clearer, you could not indent or indent with space just by omitting \dotfill

enter image description here

\documentclass[a4paper,12pt]{article}

\def\LINESPERPAGE{45} \usepackage[textheight=\LINESPERPAGE\baselineskip]{geometry}

\usepackage{lipsum} \usepackage{xinttools}% requires version 1.09m or later \renewenvironment{verse} {\par\parindent=0pt\smallskip\everypar{\makebox[25pt]{\dotfill}}\let\\par} {\par\smallskip}

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

David Carlisle
  • 757,742