Hi Vlado,

> Hello everyone, example:
> 
> 
> 
> \version "2.24.1"
> 
> 
> 
> 
> upper = {
> 
> \key as \minor
> 
> c'1
> 
> \stopStaff
> 
> s1*4
> 
> \startStaff
> 
> \section
> 
> \sectionLabel "Coda"
> 
> c'1
> 
> \bar ".|"
> 
> }
> 
> 
> 
> 
> lower = {
> 
> \key as \minor
> 
> c'1
> 
> \stopStaff
> 
> s1*4
> 
> \startStaff
> 
> \section
> 
> \sectionLabel "Coda"
> 
> c'1
> 
> \bar "|."
> 
> }
> 
> 
> 
> 
> \score {
> 
>   \new PianoStaff
> 
>   <<
> 
>     \new Staff = "upper" \upper
> 
>     \new Staff = "lower" \lower
> 
>   >>
> 
> }
> 
> 
> 
> 
> How can I force lilypond to print pianostaff brace, clef and key signature at 
> the beginning of Coda that is not on line break?
> 
> 

There is a way that was devised by Jean About Samoa earlier this year and it 
works brilliantly, I think, by copying the brace at the start of the system. It 
will need a bit of `cosmetic adjustment’ if you change the key signature or 
force a time signature, but you can get the effect that you require:


\version "2.24.1"


#(define replicate-stil
   (grob-transformer
    'stencil
    (lambda (grob original)
      (let* ((replicate (ly:grob-array->list (ly:grob-object grob 
'replicate-on-cols)))
             (left (ly:spanner-bound grob LEFT))
             (own (interval-start (ly:paper-column::break-align-width left 
'clef)))
             (sts (map (lambda (col)
                         (let ((tr (interval-start 
(ly:paper-column::break-align-width col 'clef))))
                           (ly:stencil-outline
                            (ly:stencil-translate-axis original (- tr own) X)
                            empty-stencil)))
                       replicate)))
        (apply ly:stencil-add (cons original sts))))))


\layout {
  \context {
    \PianoStaff
    \consists
    #(lambda (context)
       (let ((delims '())
             (cols '()))
         (make-engraver
          (acknowledgers
           ((system-start-delimiter-interface engraver grob source-engraver)
            (set! delims (cons grob delims))))
          ((stop-translation-timestep engraver)
           (let ((col (ly:context-property context 'currentCommandColumn)))
             (when (assoc-get 'replicate-delims (ly:grob-property col 'details))
               (set! cols (cons col cols)))))
          ((finalize engraver)
           (for-each (lambda (delim)
                       (ly:grob-set-object! delim 'replicate-on-cols 
(ly:grob-list->grob-array cols)))
                     delims)))))
    \override SystemStartBar.stencil = #replicate-stil
    \override SystemStartBracket.stencil = #replicate-stil
    \override SystemStartBrace.stencil = #replicate-stil
    \override SystemStartSquare.stencil = #replicate-stil
  }
}


replicateDelims = {
  \once \override Score.NonMusicalPaperColumn.details.replicate-delims = ##t
  \once \set Staff.forceClef = ##t
  \once \override Staff.Clef.full-size-change = ##t
  \once \set Score.measureBarType = ##f
  \once \override Score.BreakAlignment.X-extent =
  #(lambda (grob)
     (match-let (((a . b) (ly:axis-group-interface::width grob)))
                (cons (- a 0.8) b)))
}


%%%%%%%%%%%%%%


upper = {
  \key as \minor
  c'1
  \stopStaff
  s1*4
  \once \omit Staff.BarLine
  \once \omit PianoStaff.SpanBar
  \replicateDelims
  \startStaff
  \override PianoStaff.KeySignature.extra-offset = #'(-1 . 0)
  \key as \minor
  \override TextScript.X-offset = #-15.6
  \override TextScript.Y-offset = #1.945
  \section
  \sectionLabel "Coda"
  c'1^\markup {
    \override #'(line-cap-style . square)
    \with-dimensions #'(0 . 0) #'(0 . 0)
    \override #'(thickness . 2)
    \draw-line #'(0 . -12.875)
  }
  \bar ".|"
}


lower = {
  \key as \minor
  c'1
  \stopStaff
  s1*4
  \once \omit Staff.BarLine
  \replicateDelims
  \startStaff
  \key as \minor
  \section
  \sectionLabel "Coda"
  c'1
  \bar "|."
}


\score {
  \new PianoStaff
  <<
    \new Staff = "upper" \upper
    \new Staff = "lower" \lower
  >>
}



Jean’s original code is at 
https://music.stackexchange.com/questions/127631/how-can-i-insert-an-additional-systemstartbrace-into-a-pianostaff-in-lilypond,
 along with an equally successful alternative from Valentin Petzel.


The code above should lead to this:






I hope that this is helpful. Do let me know if you discover a more 
straightforward method!


Alex Voice


Reply via email to