%%%  SNIPPET BEGINS
\version "2.27.3"

% Text: Psalm 56:4
words = \lyricmode {
  I will praise God, be --
  cause of his word:
  
  I have put my trust in God,
  and will not fear what
  flesh can do un -- to me.
}

chant = \relative c'' {
  \time 11/4
  d1*1/4 % The beginning of the reciting note.
  % It needs to look like a whole note
  % but not actually function as one,
  % either in the duration sung by the performer
  % *or* in spacing by LilyPond.
  % The *1/4 gives the note the length of a quarter note,
  % but the spacing problem remains (see score 2).
  4 4 4 4 % end of reciting note
  f e d2 e2 |

  \time 21/4
  d1*1/4 % The beginning of the recitation.
  % Ditto the comment on d1*1/4 in previous measure.
  4 4 4 4 4 4
  4 4 4 4 4 % end of reciting note
  e d d c c b2( a2) |
}

staffCantor = \new Staff <<
  \new Voice = "cantor" \chant
  \new Lyrics \lyricsto "cantor" \words
>>

\layout {
  \context {
    \Score
    \omit TimeSignature
    forbidBreakBetweenBarLines = ##f
    % allows breaks to occur within measures/bars
  }
  \context {
    \Voice
    \consists Pitch_squash_engraver % for \vanish command
  }
  \context {
    \Lyrics
    % Force all lyric hyphens to display for clarity to singers:
    \override LyricHyphen.minimum-distance = #0.8
  }
}

\paper {
  indent = 0
  line-width = 140\mm
}

%%  SCORE 1
\markup \wordwrap {
  \circle 1 Plain score:
}
\score {
  \staffCantor
}
\markup \wordwrap {
  The problem: My singers find the repeated
  \typewriter d''4 note heads distracting.
  They clutter the page and make it hard to
  see where/when the pitch changes.
}
\markup \vspace #3

%%  SCORE 2
vanish = {
  \omit Score.NoteHead
  \omit Score.Dots
  \omit Score.Stem
  \omit Score.Beam
  \omit Score.Flag
  \omit Score.Tie
  \omit Score.Slur
  \omit Score.Rest
  \set Score.squashedPosition = 0
  \set Score.nullAccidentals = ##t
  \override Score.NoteHead.no-ledgers = ##t
  \override Score.NoteColumn.ignore-collision = ##t
}

unvanish = \undo \vanish

hider = \context Bottom {
  s1*1/4 \vanish s4*4 \unvanish s4*6 |
  
  s1*1/4 \vanish s4*11 \unvanish s4*9 |
}

\markup \wordwrap {
  \circle 2 With a \typewriter "\\hider" command
  applied; now, there is only one note head
  printed for each reciting note:
}
\score {
  <<
    \staffCantor
    \hider
  >>
}
\markup \wordwrap {
  My singers like score \circle 2 better than
  score \circle 1 because it is easier to see
  when the recitation (the reciting note) ends
  and the pitch changes.
  But the horizontal gaps in
  “I will” and “I have” look bad.
  In the next score, I will demonstrate a hack
  to fix the ugly spacing.
}
\markup \vspace #3

%%  SCORE 3
\markup \wordwrap {
  \circle 3 A hacked solution for now:
}
\score {
  <<
    \staffCantor
    \hider
  >>
  \layout {
    % Hack:
    line-width = 87\mm
    % (value found via brute-force
    % experimentation)
  }
}
\markup \wordwrap {
  The hack: I narrowed the \typewriter line-width
  until I got attractive word spacing. This score
  looks good, but this hack is not generalizable.
  In a real edition of a full psalm with many verses,
  the \typewriter line-width that would “fix”
  word spacing for *one* system might cause
  problems for word spacing in *other* systems.
}
%%%  SNIPPET ENDS