使用 reledmac 时,如何在标题中打印诗句编号而不是行号?

使用 reledmac 时,如何在标题中打印诗句编号而不是行号?

我正在排版圣经文本,想在页眉中打印每页上的经文范围。我已经能够复制在常规文本中。但是,我在 reledmac 的编号环境中使用它时遇到了问题,因为会产生额外的垂直空间(参见下面第二段,第 5-8 节)。请注意,它在该环境之外工作正常。

在此处输入图片描述

以下是最小的工作示例:

\documentclass{memoir}

\usepackage{reledmac}

%% Page style for READER SECTION %%
\makepagestyle{myps}
%\makepsmarks{myps}{}

% Headers
\makeevenhead{myps}{\firstmarks1:\botmarks1}{\leftmark}{\thepage}
\makeoddhead{myps}{\thepage}{\leftmark}{\firstmarks1-\botmarks1}
\markboth{Chapter 1}{Chapter 1}


% Set verse counter (for printing in header)
\newcounter{verseno}
\newcommand{\vnum}{\refstepcounter{verseno}%
    \textbf{\theverseno}. %
    \marks1{\theverseno}}


\begin{document}

    \pagestyle{myps}
    
    \vnum Lorem ipsum dolor sit amet, consectetur adipiscing elit. \vnum  Etiam in semper dolor, ut imperdiet lectus. \vnum  Praesent ut consequat enim, et pretium ligula. \vnum  Sed aliquam purus neque, nec laoreet arcu porta non. Nullam ut finibus lacus. Duis sit amet magna a\linenumannotation{23} metus bibendum vehicula.  Aliquam mollis facilisis tellus quis semper. Curabitur at mi tempus, fringilla odio aliquam, ultrices tellus. Quisque finibus varius dolor at dapibus. Sed vel justo eu odio mollis finibus vel eu nisl.\\
    
    
    %% START NUMBERED LINES %%
    \beginnumbering
    \pstart
    
    \vnum Lorem ipsum dolor sit amet, consectetur adipiscing elit. \vnum  Etiam in semper dolor, ut imperdiet lectus. \vnum  Praesent ut consequat enim, et pretium ligula. \vnum  Sed aliquam purus neque, nec laoreet arcu porta non. Nullam ut finibus lacus. Duis sit amet magna a metus bibendum vehicula.  Aliquam mollis facilisis tellus quis semper. Curabitur at mi tempus, fringilla odio aliquam, ultrices tellus. Quisque finibus varius dolor at dapibus. Sed vel justo eu odio mollis finibus vel eu nisl.
    
    %% END NUMBERED LINES %%
    \pend
    \endnumbering
    
\end{document}

有办法解决这个问题吗?

*** 编辑 ***

我发现该问题与\marks1{\theverseno}命令有关,显然是因为 reledmac 以不同的方式使用标记。

我尝试使用 atbegshi 包来更新每页开头的计数器(范围内的第一节),并使用 verseno 计数器来更新范围内的最后一节。但是,我遇到了另一个问题,即使用 reledmac 时,它\AtBeginShipout似乎适用于每个段落(作为一个块),而不是适用于每个页面。

答案1

正如 的维护者@Maïeul 所说reledmac解释,由于编号段落的特殊结构,你应该

用于\doinsidethislinehook包含敏感命令,如\marking

特别是,Maïeul 指出了发行版中包含的一个(精心构建且非常有用的)示例文件reledmac标题中的细分编号。该文档基本上涵盖了您的需求;这里我根据您的 MWE 写了一个具体的解决方案。

方案一:手动切换

我已经根据\autoversenumber您的风格要求调整了 Maïeul 的命令:它根据您的计数器构建verseno并相应地排版数字。这意味着当您在它和之间切换时,编号保持连续\vnum

\newcommand{\autoversenumber}{%
  \refstepcounter{verseno}%Add 1 to the counter
  \edef\tmp{\noexpand\marks1{\theverseno}}%\tmp will be expanded to \markboth{<verse-value>}{<verse-value}>
  \expandafter\doinsidethislinehook\expandafter{\tmp}%First, we expand \tmp to  the value, and then, pass the result as argument to \doinsidelinehook
  \textbf{\theverseno}.\space%Typeset the verse counter value in bold, followed by a dot and then a space.
}

请注意,此命令仅在编号文本中起作用,反之亦然\vnum。因此,您需要根据上下文选择适当的命令。

应用于 MWE 的结果

变体 2:不可知命令为您选择

为了简化操作,您可以定义一个命令来检测它是否在编号部分 ( ) 内被调用,并在您的原始命令和我的命令\ifnumbering之间进行选择。无需自己做出决定。\vnum\autoversenumber

我已经在 MWE 的第二部分使用了这个命令,即第 9-16 节(请删除第一次出现的\end{document}以激活该部分。)

\newcommand{\myautovnum}{\ifnumbering\autoversenumber\else\vnum\fi}

使用自动命令的 MWE 结果

平均能量损失

\documentclass{memoir}

\usepackage{reledmac}

\makepagestyle{myps}

% Headers
\makeevenhead{myps}{\firstmarks1:\botmarks1}{\leftmark}{\thepage}
\makeoddhead{myps}{\thepage}{\leftmark}{\firstmarks1-\botmarks1}
\markboth{Chapter 1}{Chapter 1}

%%% 1 - \vnum - This block in the original MWE:
%   
% Set verse counter (for printing in header)
\newcounter{verseno}
\newcommand{\vnum}{\refstepcounter{verseno}%
    \textbf{\theverseno}. %
    \marks1{\theverseno}}

%%% 2 - \autoversenumber - This block adapted from the reledmac examples: 2-subdivision-number-in-header.tex:
%
\newcommand{\autoversenumber}{%
  \refstepcounter{verseno}%Add 1 to the counter
  \edef\tmp{\noexpand\marks1{\theverseno}}%\tmp will be expanded to \markboth{<verse-value>}{<verse-value}>
  \expandafter\doinsidethislinehook\expandafter{\tmp}%First, we expand \tmp to  the value, and then, pass the result as argument to \doinsidelinehook
  \textbf{\theverseno}.\space%Typeset the verse counter value in bold, followed by a dot and then a space.
}


%%% Agnostic command detects whether to use \vnum or \autoversenumber
%
\newcommand{\myautovnum}{\ifnumbering\autoversenumber\else\vnum\fi}



\begin{document}
\pagestyle{myps}
%%% VARIANT 1: Manual selection of appropriate verse command
%
    \vnum Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
    \vnum  Etiam in semper dolor, ut imperdiet lectus. 
    \vnum  Praesent ut consequat enim, et pretium ligula. 
    \vnum  Sed aliquam purus neque, nec laoreet arcu porta non. Nullam ut finibus lacus. Duis sit amet magna a\linenumannotation{23} metus bibendum vehicula.  Aliquam mollis facilisis tellus quis semper. Curabitur at mi tempus, fringilla odio aliquam, ultrices tellus. Quisque finibus varius dolor at dapibus. Sed vel justo eu odio mollis finibus vel eu nisl.    
   
    %% START NUMBERED LINES %%
    \beginnumbering
    \pstart
    \autoversenumber Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
    \autoversenumber  Etiam in semper dolor, ut imperdiet lectus. 
    \autoversenumber  Praesent ut consequat enim, et pretium ligula. 
    \autoversenumber  Sed aliquam purus neque, nec laoreet arcu porta non. Nullam ut finibus lacus. Duis sit amet magna a metus bibendum vehicula.  Aliquam mollis facilisis tellus quis semper. Curabitur at mi tempus, fringilla odio aliquam, ultrices tellus. Quisque finibus varius dolor at dapibus. Sed vel justo eu odio mollis finibus vel eu nisl.
    %% END NUMBERED LINES %%
    \pend
    \endnumbering
\end{document}    % Comment to try out the agnostic command, \myautovnum

%%% VARIANT 2: Agnostic verse command
%
    \myautovnum Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
    \myautovnum  Etiam in semper dolor, ut imperdiet lectus. 
    \myautovnum  Praesent ut consequat enim, et pretium ligula. 
    \myautovnum  Sed aliquam purus neque, nec laoreet arcu porta non. Nullam ut finibus lacus. Duis sit amet magna a\linenumannotation{23} metus bibendum vehicula.  Aliquam mollis facilisis tellus quis semper. Curabitur at mi tempus, fringilla odio aliquam, ultrices tellus. Quisque finibus varius dolor at dapibus. Sed vel justo eu odio mollis finibus vel eu nisl.    
   
    %% START NUMBERED LINES %%
    \beginnumbering
    \pstart
    \myautovnum Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
    \myautovnum  Etiam in semper dolor, ut imperdiet lectus. 
    \myautovnum  Praesent ut consequat enim, et pretium ligula. 
    \myautovnum  Sed aliquam purus neque, nec laoreet arcu porta non. Nullam ut finibus lacus. Duis sit amet magna a metus bibendum vehicula.  Aliquam mollis facilisis tellus quis semper. Curabitur at mi tempus, fringilla odio aliquam, ultrices tellus. Quisque finibus varius dolor at dapibus. Sed vel justo eu odio mollis finibus vel eu nisl.
    %% END NUMBERED LINES %%
    \pend
    \endnumbering
\end{document}

PS:为了减少不必要的空白,我建议避免在文档的编号部分(即 内\pstart...\pend)出现空行。空行通常会开始一个新段落,这往往会在 中产生不愉快的意外reledmac

相关内容