2

I am using the verse package to typeset some poetry. Consider the following MWE:

\documentclass{article}
\usepackage{verse}
\begin{document}

% count the verses
\poemlines{5}

\begin{verse}
First,\\
second,\\
third,\\
fourth,\\
fifth\\>
and sixth.\\!
\end{verse}

\end{document}

The \poemlines{5} command counts the verses (every fifth verse). However, if a verse where the numbering occurs is broken in-line (by the \\> macro), the numbering gets duplicated, as seen in this screen:

enter image description here

Is there a way to avoid this behaviour? In particular, I would like for the number to appear only next to the first sub-verse (i.e. fifth in the MWE).

2 Answers 2

1

I looked at the verse package and found the routine that output the verse lines: \getmodulo@vs. I then modified it so that when a verse line was printed out (i.e., when the modulo verse condition was met), the immediate next line could not also be numbered. I use a macro \dupskip to store the current status.

EDITED to address OP comment regarding \!.

\documentclass{article}
\usepackage{verse}
\makeatletter
\renewcommand{\getmodulo@vs}{\bgroup
  \ifnum\c@modulo@vs<\@ne   % no line numbers
  \else
    \ifnum\c@modulo@vs<\tw@ % every line numbered
      \vlnumfont\thepoemline
    \else
      \@tempcnta\c@poemline
      \advance\@tempcnta -\c@fvsline
      \divide\@tempcnta\c@modulo@vs
      \multiply\@tempcnta\c@modulo@vs
      \advance\@tempcnta\c@fvsline
      \ifnum\@tempcnta=\c@poemline\vlnumfont
        \if F\dupskip
          \thepoemline\gdef\dupskip{T}%
        \else
          \gdef\dupskip{F}%
        \fi
      \else
        \gdef\dupskip{F}%
      \fi
    \fi
  \fi
\egroup}
\newcommand\dupskip{F}

\makeatother
\begin{document}

% count the verses
\poemlines{5}

\begin{verse}
First,\\
second,\\
third,\\
fourth,\\
fifth\\>
and sixth.\\
First,\\
second,\\
third,\\
fourth,\\
fifth\\>
and sixth.\\
First,\\
second,\\
third,\\
fourth,\\
fifth\\>
and sixth.\\!
\end{verse}

\end{document}

enter image description here

2
  • I have just noticed, after using this for a while, that if the 5-th verse is followed by a stanza break (\\!), then the counter does not show!
    – olinarr
    Dec 22, 2021 at 20:50
  • @olinarr Please see my revision. Dec 22, 2021 at 21:47
1

You also can use the \verselinebreak command:

\documentclass{article}
\usepackage{verse}
\begin{document}

\begin{verse}
\poemlines{5}
   There was an Old Man with a beard, \\
               Who said, "It is just as I feared!--\\
               Two Owls and a Hen,\\
               Four Larks and a Wren,\\
               Have all built their nests\verselinebreak[1.1in] in my beard!"\\

\end{verse}

\end{document} 

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .