4

I'm typesetting some poetry that needs to be numbered but that is frequently interrupted by comments, something like a play. I want the numbering to be continuous from verse to verse but to omit the lines of comments, like the drama packages have. I also want to be able to restart the line number occasionally. How would I go about this?

\documentclass[ebook]{memoir}

\begin{document}

\linenumberfrequency{10}
\verselinenumbersleft

\begin{verse}
O'er every birth a star of fate presides,\\
And he that knows his orb of destiny,\\
May, by the changes of its radiance, tell\\
Whene'er his good or evil genius reigns.\\
This knowledge, earned by many a midnight vigil,\\
Has taught me that yon silver star is mine,\\
Which nightly, since I conn'd this wond'rous volume,\\
Hath dimm'd its fires, and warn'd me to forbear.\\
Yet have I still undaunted read, and now,\\
While pale and fitfully its beams shrink in,\\
The ingredients of a potent spell I mingle,\\
And but three drops of my own blood are wanting,\\
To give me proof that to my hests and bidding,\\
A spirit of dread ministry will come.\\
Why should the glorious planet fade at this?\\
Is there then peril to my better part\\
In this mysterious science? If I stop,\\
How shall I know the secrets written here\\
Are knowledge or phantasma? Can there be\\
Evil in truth? For to unfold the art\\
That summons spirits from their dark abode,\\
Is but to know what is -- and what the gods,\\
In their eternal mysteries have framed. -- \\
Shrink into darkness thou faint trembling light,\\
I will abide the issues of the spell.\\!
\end{verse}

Commentary Section 1

\begin{verse}   
The blood refuses. Why will it not come?\\
It was no groan! `Tis but the sighing wind,\\
That sweeps along the silent galleries.\\
What coward palsy am I smitten with?\\
I'll strike again. It flows -- so now `tis done.\\
What a horrible apocalypse is this?\\
``If thou on All Soul's Eve wilt be but mine,\\
To all thy wishes I will be thy slave.'' --\\
Who and what art thou? Show me first thy face, --\\
The strong condition of thy proffer'd service.\\!
\end{verse}

\end{document}
Jeremy
  • 943

1 Answers1

7

Here I borrow \notate from my answer at Add comments in a verse environment and incorporate that into a redefined \\ as I also redefine verse. I, unfortunately, could not provide for the original verse's optional argument in the traditional way. Instead, one can \renewcommand\verseposition{length} in order to set the parameter which is equivalent to the optional argument of the original verse.

I now have implemented a replacement for \linenumberfrequency, \versenumbersleft, and \versenumbersright, and introduced a new macro \resetverselines for resetting the line count.

\documentclass[ebook]{memoir}
\usepackage{lipsum}
\usepackage{tabto,xcolor}
\newcommand\notate[1]{%
  \tabto*{\versetabpos}%
  \smash{\llap{\textcolor{red}{\small#1}}}%
  \tabto*{\TabPrevPos}%
}
\newcounter{verseline}
\newcounter{versetagcount}

\let\svverse\verse
\let\endsvverse\endverse
\renewenvironment{verse}
{\svverse[\verseposition]\let\svlf\\%
  \def\\{%
    \stepcounter{verseline}%
    \stepcounter{versetagcount}%
    \ifnum\value{versetagcount}=\Linemodnum\relax%
      \notate{\theverseline}%
      \setcounter{versetagcount}{0}%
    \fi%
    \svlf
  }%
}
{\endsvverse}
\renewcommand\linenumberfrequency[1]{\def\Linemodnum{#1}}
\newcommand\resetverselines{%
  \setcounter{verseline}{0}%
  \setcounter{versetagcount}{0}%
}
\renewcommand\verselinenumbersleft{\def\versetabpos{-.28\textwidth}}
\renewcommand\verselinenumbersright{\def\versetabpos{.85\textwidth}}
\verselinenumbersright
\newcommand\verseposition{\textwidth}
\begin{document}
\linenumberfrequency{5}
\verselinenumbersleft

\begin{verse}
O'er every birth a star of fate presides,\\
And he that knows his orb of destiny,\\
May, by the changes of its radiance, tell\\
Whene'er his good or evil genius reigns.\\
This knowledge, earned by many a midnight vigil,\\
Has taught me that yon silver star is mine,\\
Which nightly, since I conn'd this wond'rous volume,\\
Hath dimm'd its fires, and warn'd me to forbear.\\
Yet have I still undaunted read, and now,\\
While pale and fitfully its beams shrink in,\\
The ingredients of a potent spell I mingle,\\
And but three drops of my own blood are wanting,\\
To give me proof that to my hests and bidding,\\
A spirit of dread ministry will come.\\
Why should the glorious planet fade at this?\\
Is there then peril to my better part\\
In this mysterious science? If I stop,\\
How shall I know the secrets written here\\
Are knowledge or phantasma? Can there be\\
Evil in truth? For to unfold the art\\
That summons spirits from their dark abode,\\
Is but to know what is -- and what the gods,\\
In their eternal mysteries have framed. -- \\
Shrink into darkness thou faint trembling light,\\
I will abide the issues of the spell.\\!
\end{verse}

Commentary Section 1 \lipsum[4]

\begin{verse}   
The blood refuses. Why will it not come?\\
It was no groan! `Tis but the sighing wind,\\
That sweeps along the silent galleries.\\
What coward palsy am I smitten with?\\
I'll strike again. It flows -- so now `tis done.\\
What a horrible apocalypse is this?\\
``If thou on All Soul's Eve wilt be but mine,\\
To all thy wishes I will be thy slave.'' --\\
Who and what art thou? Show me first thy face, --\\
The strong condition of thy proffer'd service.\\!
\end{verse}

Commentary Section 2: I will reset the verse lines,
change the verse position parameter,
and move the verse numbers to the right.
\resetverselines
\verselinenumbersright
\renewcommand\verseposition{.7\textwidth}

\begin{verse}   
The blood refuses. Why will it not come?\\
It was no groan! `Tis but the sighing wind,\\
That sweeps along the silent galleries.\\
What coward palsy am I smitten with?\\
I'll strike again. It flows -- so now `tis done.\\
What a horrible apocalypse is this?\\
``If thou on All Soul's Eve wilt be but mine,\\
To all thy wishes I will be thy slave.'' --\\
Who and what art thou? Show me first thy face, --\\
The strong condition of thy proffer'd service.\\!
\end{verse}

\end{document}

enter image description here

enter image description here

  • Yes, verse takes a length (for positioning purposes) as optional argument. +1, by the way. – Gonzalo Medina Mar 03 '15 at 19:43
  • @GonzaloMedina Thanks for the tip. I have expanded the capability, but will now tackle the optional argument issue. – Steven B. Segletes Mar 03 '15 at 19:47
  • This is incredibly helpful, thank you! But I have two questions -- one, how can I set this so that I have line numbers every 10 lines instead of every 5, and two, it doesn't appear to be counting lines correctly, e.g., I have a line numbered 235, then five more lines in that verse environment, but the final line isn't labeled 240; instead, it is the first line of the next verse environment that is labeled 240. What might be causing this? – Sara L. Uckelman Mar 03 '24 at 19:43
  • @SaraL.Uckelman As to the frequency of line numbering, you will find \linenumberfrequency{5} in which you can change the 5 to a 10. I cannot recreate the other issue. Perhaps try \linenumberfrequency{1} and see what the result looks like, in terms of the line count. – Steven B. Segletes Mar 03 '24 at 19:52
  • 1
    Thanks, Steven! setting it to {1} makes it clear that the final line of each verse is not being counted; I can fix this by putting \ at the end of the final lines.

    Success! Much appreciated.

    – Sara L. Uckelman Mar 04 '24 at 13:45