4

I used to typeset verse with memoir package using some heavy \vspace trickery. The verse environment was too hard to control in terms of vertical space due to the immense amount of obscure glue. For instance, whenever I inserted a centered line (header, remark etc.) within a verse, the spacing was almost uncontrollable. The whole document started with \begin{verse}, contained verse with headers and ended with \end{verse}

To avoid hundreds of manual environment invocations, a prior answer was implemented in order to provide an environment detector (\Bverse to begin verse if not inside one already, \Everse to end one). I defined \ACT, \SCENE, \descr and \hero commands so as to check whether we are inside a verse environment, end if yes, typeset the ornate header and then resume the verse environment. However, the provided example fails to terminate the environments and goes on nesting them.

! LaTeX Error: Too deeply nested.
l.61 \herov{Альцест}
  1. Why are my environments being nested?
  2. Isn’t there a better solution to break a long verse with interwoven headers?

Please excuse the redundant working example, I did my best to minimize it in order to obtain the “too deeply nested” error. My example:

\documentclass{memoir}

\usepackage[utf8]{inputenc}
\usepackage[T2A]{fontenc}
\usepackage[russian]{babel}
\usepackage{soulutf8}

\sodef\sohe{}{.19em}{.6em plus.05em}{.5em plus.05em minus.05em}
\newcommand{\hero}[1]{\sohe{#1}}

\makeatletter
\newcommand{\Bverse}{%
  \ifx\@currenvir\@verse
  \else
  \begin{verse}
  \fi}
\newcommand\@verse{verse}
\newcommand{\Everse}{%
  \ifx\@currenvir\@verse
  \end{verse}
  \else
  \fi}
\makeatother

\newenvironment{center*}{\setlength\topsep{0pt}\setlength\parskip{0pt}\begin{center}}{\end{center}}

\newcommand{\SCENE}[1]{\Everse %
\begin{center*}\textsc{ #1}\end{center*}%
\Bverse %
}
\newcommand{\ACT}[1]{\Everse %
\newpage\begin{center*}\textsc{\textbf{\large #1}}\end{center*}%
\Bverse %
}
\newcommand{\descr}[1]{%
\Everse %
\begin{center*}\small #1\end{center*} %
\Bverse %
}
\newcommand{\herov}[1]{\Everse%
\begin{center*} \hero{#1} \end{center*}%
\Bverse%
}

\begin{document}

\begin{verse}

\ACT{Действие первое}

\SCENE{Явление первое}

\descr{\hero{Альцест} и \hero{Филинт}.}

\herov{Альцест}
Как шутки эти здесь некстати "--- просто срам!

\herov{Филинт}
Ну, шутки в сторону. Чего же нужно вам?

\herov{Альцест}
Чтоб люди искренни всегда и честны были \\
И только правду бы, от сердца, говорили.

\herov{Филинт}
Когда мы чьим-нибудь приветом польщены, \\
Платить мы тою же монетою должны: \\
Приветом за привет, услугой за услугу, \\
За клятву "--- клятвою, как преданному другу.
\end{verse}
\end{document}

UPDATE: Please see the picture of the version I had had before “optimizing” the code. Verse typeset with custom headers in between

closed as unclear what you're asking by Henri Menke, user13907, Mensch, Zarko, Mico Aug 6 '16 at 14:36

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Welcome to TeX.SX! I'm not sure if the output is what you need; but if I redefine \Bverse and \Everse to do nothing and \newenvironment{center*}{\par\centering}{\par}, I get the document compiled. – egreg Feb 19 '14 at 9:47
  • Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. – Martin Schröder Feb 19 '14 at 9:49
  • @egreg Thank you for the request of the desired output, please see the enclosed picture. The idea is: the blunt way to typeset it is to enclose each and every set of lines in its own verse environment, but what I want is to begin a verse environment and terminate it with custom designed centered lines, and start a new verse afterwards, since it is very hard to fine-tune penalties, glue and breaking rules between those different types of centered announcements inside verse environment. – Andreï Kostyrka Feb 19 '14 at 10:16