Hi Marc,
2017-07-05 8:13 GMT+02:00 Marc Hohl <address@hidden>:
Hi list,
I have the following MWE:
[...]
It causes the string number "5" to appear twice, strangely overlapping.
I tried to move the New_fingering_engraver to Staff, but then I got
side-axis not set for grob StringNumber.
Not sure what you expected, I didn't explore the programming error, though.
I assume that I have to create an engraver similar to the
Merge_rests_engraver that does this job? Or is there another way apart from
\once\hide StringNumber
all the way across the file?
You could do:
#(define (suicide-duplicate-text-grobs grob-lst)
"Walks through the sorted @var{grob-lst}, suiciding grobs with duplicate text"
(if (null? (cdr grob-lst))
#f
(suicide-duplicate-text-grobs
(if (string=? (ly:grob-property (car grob-lst) 'text)
(ly:grob-property (cadr grob-lst) 'text))
(begin
(ly:grob-suicide! (car grob-lst))
(cdr grob-lst))
(cdr grob-lst)))))
#(define reduce-string-numbers
(lambda (grob)
"Gets the PaperColumn-grob, filters for StringNumber-grobs, sorts this grobs
with @code{string<?} looking at their 'text-property.
Finally suicides grobs with already present text."
(let* ((paper-column (ly:item-get-column grob))
(strgs
(filter
(lambda (g)
(grob::has-interface g 'string-number-interface))
(ly:grob-array->list (ly:grob-object paper-column 'elements))))
(sorted-strgs
(sort
strgs
(lambda (p q)
(string<? (ly:grob-property p 'text)
(ly:grob-property q 'text))))))
(suicide-duplicate-text-grobs sorted-strgs))))
deleteDuplicateStrings =
\override StringNumber.after-line-breaking = #reduce-string-numbers
up = { <c'\5 g'\4 e''>8 ~ e''2. }
down = { <c'\5 g'\4> ~ c'2. }
\score {
<<
\new Staff
<<
\new Voice \with { \deleteDuplicateStrings } { \voiceOne \up }
\new Voice { \voiceTwo \down }
>>
\new TabStaff
<<
\new TabVoice { \voiceOne \up }
\new TabVoice { \voiceTwo \down }
>>
>>
}
Though, I think an engraver would probably do the job cheaper. (Not tested)