Dear all,

A personal preference of mine: When slurs happen in my music, I want to
avoid within-slur widows and orphans
<https://en.wikipedia.org/wiki/Widows_and_orphans>. What I mean is this: I
think it looks bad when there is only one note (belonging to a slur) that
is printed before a system break (widow) or only one note within the slur
after a system break (orphan).

Inspired by Jean’s No_break_during_tie_engraver
<https://extending-lilypond.gitlab.io/en/extending/translation.html#example-for-end-acknowledgers-no-break-during-tie-engraver>,
Lukas and I have been working on something that we are calling the
Spanner_breaking_control_engraver.

It takes two arguments: type of spanner for LilyPond to watch and type of
grobs within the spanner to count. In the attached example, this engraver
monitors Slur spanners and counts NoteHead grobs.

Tracking multiple grob types is possible; in the file, try changing the
NoteHead argument to #'(NoteHead Rest).

Users can specify one or more of the following settings for this engraver:


   - widow-limit = p: Keep the first p notes under the spanner together
   (unbroken)
   - orphan-limit = q: Keep the last q notes under the spanner together
   (unbroken)
   - length-limit = n: only break spanners that contain more than n notes

User-specified \break and \allowBreak commands work as one would expect,
overriding any constraints that this engraver would have imposed on
breaking.

One known current limitation: In a very long spanner stretching across
three or more systems, this engraver will only control the output in the
first and last of those systems. But Lukas and I think this is not a big
issue, because rarely if ever in my real music would I be at risk of seeing
a widow or orphan (or maybe this would be called “runt” per Wikipedia) in a
middle system.

I would like to post this snippet to the Wiki, but first, I would like to
ask:


   1. Does anyone have questions or input?
   2. If you were to use this engraver, what other arguments would you be
   most likely to set for it? For example, other types of spanners within
   which you would find it especially useful to control breaking?

Cheers,

Gabriel (with Lukas, who, as usual, did the heavy lifting here)

Attachment: Spanner breaking control engraver - v2026-06-22.ly
Description: Binary data

Reply via email to