回忆录中的跨节行编号

回忆录中的跨节行编号

我正在排版一些需要编号但经常被评论打断的诗歌,比如戏剧。我希望编号从一节到另一节连续,但省略评论行,就像戏剧包一样。我还希望能够偶尔重新开始行号。我该怎么做?

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

答案1

这里我借用\notate一下我的回答在诗句环境中添加评论并将其合并到重新定义的 中,\\因为我也重新定义了。不幸的是,我无法以传统方式verse提供原始的可选参数。相反,可以设置与原始 的可选参数等效的参数。verse\renewcommand\verseposition{length}verse

\linenumberfrequency我现在已经实现了、\versenumbersleft和的替代方案\versenumbersright,并引入了一个\resetverselines用于重置行数的新宏。

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

在此处输入图片描述

在此处输入图片描述

相关内容