5

For some teaching examples I'm making, I'm looking to label slurs and ties. I'd like the label to be placed in the center of the slur automatically, much like LaTeX's midway stipulation. I can move the labels by brute force (as shown below), but is it possible to do it automatically?

\version "2.18.2"

\score {
  \relative c' {
    <c e g>1(_\markup \halign #-7 "X" | % I don't want to have to do that every time!
    <c f a>) |
  }
  \layout { }
}

enter image description here

2

Here is a starting point.

\version "2.20.0"
#(define ((myCallBack  string) grob)
   (grob-interpret-markup grob
     (if (= (ly:grob-property grob 'direction) 1)
         (markup #:translate '(1 . 3) #:center-column (
                                                        string
                                                        (#:stencil (ly:slur::print grob))))
         (markup  #:center-column (
                                    (#:stencil (ly:slur::print grob))
                                    ( string))))))


{
  \override Slur #'stencil = #(myCallBack "XX")
  c'2 (  c'' c d'' )
}

enter image description here

Adapted from https://lists.gnu.org/archive/html/lilypond-user/2009-06/msg00211.html

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.