1

I am typesetting a biblical text and would like to print the range of verses on each page in the header. I have been able to replicate this in a regular text. However, I run into problems when using it within reledmac's numbering environment, as extra vertical space is created (see the second paragraph below, verses 5-8). Notice that it works fine outside of that environment.

enter image description here

Here is the minimal working example:

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

Is there a way around this problem?

*** EDIT ***

I have discovered that the issue is related to the \marks1{\theverseno} command, apparently because reledmac makes use of marks in a different way.

I attempted a solution using the atbegshi package to update a counter at the beginning of each page (first verse in range) and using the verseno counter for the last verse in range. However, I encountered another problem in that, with reledmac, \AtBeginShipout appears to be applied for every paragraph as a block, and not for each page.

1 Answer 1

2

As @Maïeul, the maintainer of reledmac, explains, because of the peculiar structure of numbered paragraphs you should

use \doinsidethislinehook to include a sensitive command like \marking.

In particular, Maïeul points to a (carefully constructed and very useful) sample file that is included in the reledmac distribution: Subdivision number in header. That document basically covers your needs; here I wrote a concrete solution based on your MWE.

Variant 1: Manual switching

I have adapted Maïeul's command \autoversenumber to your style requirements: it builds off your counter verseno and typesets the numbers accordingly. This means that the numbering stays continuous as you switch between it and \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.
}

Note that this command will function only within numbered text, and vice versa for your \vnum. So you need to choose the appropriate command based on the context.

The result when applied to your MWE

Variant 2: Agnostic command chooses for you

To simplify things, you can define a command that detects whether it is invoked within a numbered section (\ifnumbering) and chooses accordingly between your original \vnumand my \autoversenumber. No need to make that determination yourself.

I have used this command in the second part of my MWE, that is verse 9--16 (please remove the first occurrence of \end{document} to activate that part.)

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

result of MWE with automatic command

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: In the interest of reducing unnecessary whitespace, I suggest to avoid empty lines in the numbered portions of your document (that is, inside a \pstart...\pend). An empty line usually starts a new paragraph and this tends to produce unpleasant surprises in reledmac.

2
  • Thanks very much for this thoughtful and detailed solution. It seems to work just as desired.
    – jejb
    Commented Feb 15 at 16:54
  • @jejb With pleasure!
    – marquinho
    Commented Feb 15 at 18:55

You must log in to answer this question.

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