maieul / ledmac

package reledmac for latex
http://www.ctan.org/tex-archive/macros/latex/contrib/reledmac
54 stars 28 forks source link

Line numbering in long headings #976

Open lueck opened 1 month ago

lueck commented 1 month ago

Version

Master branch as of Tue Jul 23 21:09:35 2024 +0200, commit 80d4779d4bdcc75f0f2570f303ebfe4b789c00f5.

TeX Engine

Both from texlive 2023.

Regression

Description

In my edition, there are some longer section titles that exceed multiple lines. When the length of a heading exceeds a certain limit, not all of its lines are counted, so that apparatus entries in them may have wrong line numbers and lines from following paragraphs also do not have the right number.

In the minimal working example, the first chapter heading spans five lines. But only two of them are counted. I would expect the following paragraph to start with line number 6, not 3.

I can not figure out, if the limit, above which the problem occurs, is bound to lines printed out or count of words.

The problem occurs with all of the section levels reledmac provides.

Minimal Working Example

\documentclass{book}

% for bigger font sizes
%\usepackage[fontsize=14pt]{scrextend}

\usepackage{ifluatex}
\ifluatex
  %% for luatex
  \usepackage[utf8]{luainputenc}
  \usepackage{luabidi}
\else
  %% for pdftex
  \usepackage[utf8]{inputenc}%
  \usepackage[T1]{fontenc}%
\fi

\usepackage[ngerman,english]{babel}

\usepackage{reledmac}

% number every line beginning from the first
\firstlinenum{1}
\linenumincrement{1}

\begin{document}

\beginnumbering

\pstart
\eledchapter{There is a Problem with Headings when they Exceed a Certain Length: Lines Above a Limit are not Assigned a Number.}
\pend

\pstart
Sorry, for stating something obvious \ldots
\pend

\pstart
Sorry, for stating something obvious \ldots
\pend

\pstart
\eledchapter{This Chapter Title Spans Two Lines}
\pend

\pstart
Two-liners are broken, too. \ldots
\pend

\pstart
\eledchapter{1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21}
\pend

\pstart
Is it count of printed-out lines or count of words, what
causes the problem?
\pend

\pstart
\eledsection{1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30}
\pend

\pstart
Is this limit fixed? Or does it alter with the font size?
\pend

\pstart
\eledsection{1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40}
\pend

\pstart
Is this limit fixed? Or does it alter with the font size?
\pend

\endnumbering

\end{document}

Workaround

None that I know of.

maieul commented 1 month ago

yes, that is a knew issued with edledsection. But unfortunatly, I have no time anymore for reledmac

Le 30/09/2024 à 09:53, Christian Lück a écrit :

Version

Master branch as of Tue Jul 23 21:09:35 2024 +0200, commit 80d4779 <https://github.com/maieul/ledmac/ commit/80d4779d4bdcc75f0f2570f303ebfe4b789c00f5>.

TeX Engine

  • pdflatex
  • lualatex

Both from texlive 2023.

Regression

Description

In my edition, there are some longer section titles that exceed multiple lines. When the length of a heading exceeds a certain limit, not all of its lines are counted, so that apparatus entries in them may have wrong line numbers and lines from following paragraphs also do not have the right number.

In the minimal working example, the first chapter heading spans five lines. But only two of them are counted. I would expect the following paragraph to start with line number 6, not 3.

I can not figure out, if the limit, above which the problem occurs, is bound to lines printed out or count of words.

The problem occurs with all of the section levels reledmac provides.

Minimal Working Example

\documentclass{book}

% for bigger font sizes %\usepackage[fontsize=14pt]{scrextend}

\usepackage{ifluatex} \ifluatex %% for luatex \usepackage[utf8]{luainputenc} \usepackage{luabidi} \else %% for pdftex \usepackage[utf8]{inputenc}% \usepackage[T1]{fontenc}% \fi

\usepackage[ngerman,english]{babel}

\usepackage{reledmac}

% number every line beginning from the first \firstlinenum{1} \linenumincrement{1}

\begin{document}

\beginnumbering

\pstart \eledchapter{There is a Problem with Headings when they Exceed a Certain Length: Lines Above a Limit are not Assigned a Number.} \pend

\pstart Sorry, for stating something obvious\ldots \pend

\pstart Sorry, for stating something obvious\ldots \pend

\pstart \eledchapter{This Chapter Title Spans Two Lines} \pend

\pstart Two-liners are broken, too.\ldots \pend

\pstart \eledchapter{1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21} \pend

\pstart Is it count of printed-out lines or count of words, what causes the problem? \pend

\pstart \eledsection{1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30} \pend

\pstart Is this limit fixed? Or does it alter with the font size? \pend

\pstart \eledsection{1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40} \pend

\pstart Is this limit fixed? Or does it alter with the font size? \pend

\endnumbering

\end{document}

Workaround

None that I know of.

— Reply to this email directly, view it on GitHub <https://github.com/ maieul/ledmac/issues/976>, or unsubscribe <https://github.com/ notifications/unsubscribe-auth/ AAE3NYGCUMJV6QBS7ZUKQHDZZD7ORAVCNFSM6AAAAABPCVWDIGVHI2DSMVQWIX3LMV43ASLTON2WKOZSGU2TKOBWGAZTENQ>. You are receiving this because you are subscribed to this thread.Message ID: @.***>

lueck commented 1 month ago

Oh, what a pitty! However, thanks for your great work on this irreplacable package!

If you have an idea about this issue, even the slightest idea, or if you can point me to a range in the dtx file, please let me know.

lueck commented 1 month ago

I'm using a simple workaround: redefining the \eledxxxx section commands like so:

\usepackage{ifthen}

\newcommand*{\mysectionfont}[1]{\Large #1}

\renewcommand{\eledsection}[2][]{%
  \mysectionfont{#2}%
  \ifthenelse{\equal{#1}{}}{%
    \addcontentsline{toc}{section}{#2}}{%
    \addcontentsline{toc}{section}{#1}}%
}

Turned out, that putting vertical skips into this macro, results in the similar errors: broken line numbers and echos like described in #977. I put vertical spacing outside of \pstart ... \pend and everything is fine.

maieul commented 1 month ago

A workaround is not a solution, I reopen

maieul commented 1 month ago

Instead of redefining, you should use a \patchmd method

lueck commented 1 month ago

I've found the code where the \eledxxxx sectioning commands hand over to well-known \section etc. However, I did not yet understand how this handing over is exactly done.

I also investigated on \@startsection from ltsect.dtx (find it via kpsewhere ltsect.dtx) which is the "mother of all user level sectioning commands". But my efforts to patch it to get rid of vertical spacing failed. So, I ended up with a re-definition of \eledxxxx.

maieul commented 1 month ago

My point is that in general, you should not redefine command, but only patching them using etooblbox tools.