Re: Prevent multiple similar text marks to appear in score?
Tina Petzel <[email protected]> Tue, 07 Jul 2026 22:46:24 +0200
| Newsgroups | gmane.comp.gnu.lilypond.general |
|---|---|
| Message-ID | <[email protected]> |
Hello Michael,
> my case consists of four instruments. Textmarks are repeated in the score -
> is that good practise? I wish they'd only appear once. I understand the
> conductor then cannot know what the players see... but still.
The whole reason why we have \textMark is that there can only be a single
rehearsal mark per timestep. So if you want no duplication the easiest thing
would be to simply use \mark "..." with potential changes to break-alignment,
self-alignment and break-visibility (of course "a tempo" is best suited as
metronome mark, since it is a tempo indication).
If you actually want to be able to have multiple marks at the same time but want
to avoid having multiple marks you can create an engraver that tracks all text
marks created an allowing each text to appear just once:
%% EXAMPLE BEGIN
#(define (collapse-marks-engraver context)
(let ((mark-map (make-hash-table)))
(make-engraver
(acknowledgers
((text-mark-interface engraver grob source)
(let ((text (ly:grob-property grob 'text)))
(if (hash-ref mark-map text)
(ly:grob-suicide! grob)
(hash-set! mark-map text #t)))))
((stop-translation-timestep engraver)
(hash-clear! mark-map)))))
\layout {
\context {
\Score
\consists #collapse-marks-engraver
}
}
\version "2.26.0"
\book {
\score {
<<
\new Staff { \textMark \markup \italic"a tempo" c'4 f \textMark \markup
\italic"a tempo" g a }
\new Staff { \textMark \markup \italic"a tempo" a4 c' \textMark \markup
\italic"a tempo" d' f' }
\new Staff { \textMark \markup \italic"a tempo" a2 \textMark \markup
\italic"a tempo" c'2 }
\new Staff { \textMark \markup \italic"a tempo" c'4. d'8 \textMark
\markup \italic"a tempo" f'2 }
>>
}
}
%% EXAMPLE END
Cheers,
Tina
signature.asc
(application/pgp-signature, 228 B)
-----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQS0sdUK2Lu8of48K2+FHhaCPe7BywUCak1loAAKCRCFHhaCPe7B yzC7AQC5rikKRjvPzRzb/AU6XyYGoivY4+j2ZFUj574iMaCZsAEA1FTvpq0FHsOT uk2WlE4SXt0tpN5V/O13OB6C8IdoVAw= =YSQr -----END PGP SIGNATURE-----