I have created a command that uses \startGroup and \stopGroup to print annotated horizontal brackets:

% Create a horizontal bracket with included text.
% If no text is desired an empty string has to be given.
% By default the bracket is above the staff, otherwise
% #DOWN has to be given as optional argument.

\layout {
  \context {
    \Voice
    \consists "Horizontal_bracket_engraver"
    \override HorizontalBracket.bracket-flare = #'(0 . 0)
    \override HorizontalBracket.staff-padding = 4.5
  }
}

startBracket =
#(define-event-function (direction text)((ly:dir? UP) markup?)
   #{
     -\tweak HorizontalBracketText.text #text
     -\tweak HorizontalBracketText.direction #(* -1 direction)
     -\tweak HorizontalBracketText.Y-offset #(if (= direction UP) -2.5 1)
     -\tweak direction #direction
     \startGroup
   #})

stopBracket = \stopGroup

\relative {
  g'4 g e d
  c \startBracket "Hello" d e f |
  g1 \stopBracket
}

(results attached as document.png).

However, in addition to that I need a way to align the start and end of that bracket not to the notes like in the example but to the enclosing measures, and optionally the whole staffline.

Is there any reasonable approach to doing that short of custom-printing a stencil by searching the current staff to find the neighbouring barlines (it is guaranteed that there are no line breaks)? The only advantage of going that way would be to have more control over how it actually looks like ...

Thanks for any pointers
Urs

_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to