LilyPond snippets: Staff notation

# Staff notation

Staff notation

## Ambitus pro Stimme hinzufügen

Ambitus können pro Stimme gesetzt werden. In diesem Fall müssen sie manuell verschoben werden, um Zusammenstöße zu verhindern.

    \new Staff <<
      \new Voice \with {
        \consists "Ambitus_engraver"
      } \relative c'' {
        \override Ambitus.X-offset = #2.0
        \voiceOne
        c4 a d e
        f1
      }
      \new Voice \with {
        \consists "Ambitus_engraver"
      } \relative c' {
        \voiceTwo
        es4 f g as
        b1
      }
    >>

## Adding an extra staff at a line break

When adding a new staff at a line break, some extra space is unfortunately added at the end of the line before the break (to fit in a key signature change, which will never be printed anyway). The workaround is to add a setting of `Staff.explicitKeySignatureVisibility` as is shown in the example.

    \score {
      \new StaffGroup \relative c'' {
        \new Staff
        \key f \major
        c1 c^"Unwanted extra space" \break
        << { c1 | c }
           \new Staff {
             \key f \major
             \once \omit Staff.TimeSignature
             c1 | c
           }
        >>
        c1 | c^"Fixed here" \break
        << { c1 | c }
           \new Staff {
             \once \set Staff.explicitKeySignatureVisibility = #end-of-line-invisible
             \key f \major
             \once \omit Staff.TimeSignature
             c1 | c
           }
        >>
      }
    }

## Adding an extra staff

An extra staff can be added (possibly temporarily) after the start of a piece.

    \score {
      <<
        \new Staff \relative c'' {
          c1 | c | c | c | c
        }
        \new StaffGroup \relative c'' {
          \new Staff {
            c1 | c
            <<
              {
                c1 | d
              }
              \new Staff {
                \once \omit Staff.TimeSignature
                c1 | b
              }
            >>
            c1
          }
        }
      >>
    }

## Adding indicators to staves which get split after a break

This snippet defines the `\splitStaffBarLine`, `convUpStaffBarLine` and `convDownStaffBarLine` commands. These add arrows at a bar line, to denote that several voices sharing a staff will each continue on a staff of their own in the next system, or that voices split in this way recombine.

    #(define-markup-command (arrow-at-angle layout props angle-deg length fill)
       (number? number? boolean?)
       (let* (
               (PI-OVER-180 (/ (atan 1 1) 34))
               (degrees->radians (lambda (degrees) (* degrees PI-OVER-180)))
               (angle-rad (degrees->radians angle-deg))
               (target-x (* length (cos angle-rad)))
               (target-y (* length (sin angle-rad))))
         (interpret-markup layout props
           (markup
            #:translate (cons (/ target-x 2) (/ target-y 2))
            #:rotate angle-deg
            #:translate (cons (/ length -2) 0)
            #:concat (#:draw-line (cons length 0)
                       #:arrow-head X RIGHT fill)))))

    splitStaffBarLineMarkup = \markup \with-dimensions #'(0 . 0) #'(0 . 0) {
      \combine
      \arrow-at-angle #45 #(sqrt 8) ##t
      \arrow-at-angle #-45 #(sqrt 8) ##t
    }

    splitStaffBarLine = {
      \once \override Staff.BarLine.stencil =
      #(lambda (grob)
         (ly:stencil-combine-at-edge
          (ly:bar-line::print grob)
          X RIGHT
          (grob-interpret-markup grob splitStaffBarLineMarkup)
          0))
      \break
    }

    convDownStaffBarLine = {
      \once \override Staff.BarLine.stencil =
      #(lambda (grob)
         (ly:stencil-combine-at-edge
          (ly:bar-line::print grob)
          X RIGHT
          (grob-interpret-markup grob #{
            \markup\with-dimensions #'(0 . 0) #'(0 . 0) {
              \translate #'(0 . -.13)\arrow-at-angle #-45 #(sqrt 8) ##t
            }#})
          0))
      \break
    }

    convUpStaffBarLine = {
      \once \override Staff.BarLine.stencil =
      #(lambda (grob)
         (ly:stencil-combine-at-edge
          (ly:bar-line::print grob)
          X RIGHT
          (grob-interpret-markup grob #{
            \markup\with-dimensions #'(0 . 0) #'(0 . 0) {
              \translate #'(0 . .14)\arrow-at-angle #45 #(sqrt 8) ##t
            }#})
          0))
      \break
    }

    \paper {
      ragged-right = ##t
      short-indent = 10\mm
    }

    separateSopranos = {
      \set Staff.instrumentName = "AI AII"
      \set Staff.shortInstrumentName = "AI AII"
      \splitStaffBarLine
      \change Staff = "up"
    }
    convSopranos = {
      \convDownStaffBarLine
      \change Staff = "shared"
      \set Staff.instrumentName = "S A"
      \set Staff.shortInstrumentName = "S A"
    }

    sI = {
      \voiceOne
      \repeat unfold 4 f''2
      \separateSopranos
      \repeat unfold 4 g''2
      \convSopranos
      \repeat unfold 4 c''2
    }
    sII = {
      s1*2
      \voiceTwo
      \change Staff = "up"
      \repeat unfold 4 d''2
    }
    aI = {
      \voiceTwo
      \repeat unfold 4 a'2
      \voiceOne
      \repeat unfold 4 b'2
      \convUpStaffBarLine
      \voiceTwo
      \repeat unfold 4 g'2
    }
    aII = {
      s1*2
      \voiceTwo
      \repeat unfold 4 g'2
    }
    ten = {
      \voiceOne
      \repeat unfold 4 c'2
      \repeat unfold 4 d'2
      \repeat unfold 4 c'2
    }
    bas = {
      \voiceTwo
      \repeat unfold 4 f2
      \repeat unfold 4 g2
      \repeat unfold 4 c2
    }

    \score {
      <<
        \new ChoirStaff <<
          \new Staff = up \with {
            instrumentName = "SI SII"
            shortInstrumentName = "SI SII"
          } {
            s1*4
          }

          \new Staff = shared \with {
            instrumentName = "S A"
            shortInstrumentName = "S A"
          } <<
            \new Voice = sopI \sI
            \new Voice = sopII \sII
            \new Voice = altI \aI
            \new Voice = altII \aII
          >>
          \new Lyrics \with {
            alignBelowContext = up
          }
          \lyricsto sopII { e f g h }
          \new Lyrics \lyricsto altI { a b c d e f g h i j k l }

          \new Staff = men \with {
            instrumentName = "T B"
            shortInstrumentName = "T B"
          } <<
            \clef F
            \new Voice = ten \ten
            \new Voice = bas \bas
          >>
          \new Lyrics \lyricsto bas { a b c d e f g h i j k l }
        >>
      >>
      \layout {
        \context {
          \Staff \RemoveEmptyStaves
          \override VerticalAxisGroup.remove-first = ##t
        }
      }
    }

## Orchesterstichnoten zu einem Klavierauszug hinzufügen

Hier wird gezeigt, wie man das Hinzufügen von vielen Orchsterstichnoten zu einem Klavierauszug hinzufügen kann. Die musikalische Funktion `\cueWhile` braucht vier Argumente: Die Noten, von denen die Stichnoten formatiert werden sollen, definiert durch `\addQuote`, die Bezeichnung, die mit den Noten angegeben werden soll, dann entweder `#UP` (hoch) oder `#DOWN` (runter) zur Angabe von entweder `\voiceOne` mit der Bezeichnung über dem System oder `\voiceTwo` mit der Bezeichnung unter dem System, und schließlich die Klaviermusik, die parallel zu den Stichnoten gespielt werden soll. Die Bezeichnung des Stichnoteninstruments wird links der Stichnoten positioniert. Viele Abschnitte können zitiert werden, aber sie dürfen sich nicht überlappen.

    cueWhile =
    #(define-music-function
       (instrument name dir music)
       (string? string? ly:dir? ly:music?)
       #{
         \cueDuring $instrument #dir {
           \once \override TextScript.self-alignment-X = #RIGHT
           \once \override TextScript.direction = $dir
           <>-\markup { \tiny #name }
           $music
         }
       #})

    flute = \relative c'' {
      \transposition c'
      s4 s4 e g
    }
    \addQuote "flute" { \flute }

    clarinet = \relative c' {
      \transposition bes
      fis4 d d c
    }
    \addQuote "clarinet" { \clarinet }

    singer = \relative c'' { c4. g8 g4 bes4 }
    words = \lyricmode { here's the lyr -- ics }

    pianoRH = \relative c'' {
      \transposition c'
      \cueWhile "clarinet" "Clar." #DOWN { c4. g8 }
      \cueWhile "flute" "Flute" #UP { g4 bes4 }
    }
    pianoLH = \relative c { c4 <c' e> e, <g c> }

    \score {
      <<
        \new Staff {
          \new Voice = "singer" {
            \singer
          }
        }
        \new Lyrics {
          \lyricsto "singer"
          \words
        }
        \new PianoStaff <<
          \new Staff {
            \new Voice {
              \pianoRH
            }
          }
          \new Staff {
            \clef "bass"
            \pianoLH
          }
        >>
      >>
    }

## Adding timing marks to long glissandi

Skipped beats in very long glissandi are sometimes indicated by timing marks, often consisting of stems without noteheads. Such stems can also be used to carry intermediate expression markings.

If the stems do not align well with the glissando, they may need to be repositioned slightly.

    glissandoSkipOn = {
      \override NoteColumn.glissando-skip = ##t
      \hide NoteHead
      \override NoteHead.no-ledgers = ##t
    }

    glissandoSkipOff = {
      \revert NoteColumn.glissando-skip
      \undo \hide NoteHead
      \revert NoteHead.no-ledgers
    }

    \relative c'' {
      r8 f8\glissando
      \glissandoSkipOn
      f4 g a a8\noBeam
      \glissandoSkipOff
      a8

      r8 f8\glissando
      \glissandoSkipOn
      g4 a8
      \glissandoSkipOff
      a8 |

      r4 f\glissando \<
      \glissandoSkipOn
      a4\f \>
      \glissandoSkipOff
      b8\! r |
    }

## Alternative Taktnummerierung

Zwei alternative Methoden können eingestellt werden, die die Taktnummerierung beeinflussen, insbesondere bei Wiederholungen.

    \relative c'{
      \set Score.alternativeNumberingStyle = #'numbers
      \repeat volta 3 { c4 d e f | }
        \alternative {
          { c4 d e f | c2 d \break }
          { f4 g a b | f4 g a b | f2 a | \break }
          { c4 d e f | c2 d }
        }
      c1 \break
      \set Score.alternativeNumberingStyle = #'numbers-with-letters
      \repeat volta 3 { c,4 d e f | }
        \alternative {
          { c4 d e f | c2 d \break }
          { f4 g a b | f4 g a b | f2 a | \break }
          { c4 d e f | c2 d }
        }
      c1
    }

## Ambitus after key signature

By default, ambitus are positioned at the left of the clef. The `\ambitusAfter` function allows for changing this placement. Syntax is `\ambitusAfter grob-interface` (see Interfaces Graphical Object Interfaces for a list of possible values for `grob-interface`). A common use case is printing the ambitus between key signature and time signature.

    \new Staff \with {
      \consists Ambitus_engraver
    } \relative {
      \ambitusAfter key-signature
      \key d \major
      es'8 g bes cis d2
    }

## Centered measure numbers

Scores of large ensemble works often have bar numbers placed beneath the system, centered horizontally on the measure’s extent. This snippet shows how the `Measure_counter_engraver` may be used to simulate this notational practice. Here, the engraver has been added to a `Dynamics` context.

    \layout {
      \context {
        \Dynamics
        \consists #Measure_counter_engraver
        \override MeasureCounter.direction = #DOWN
        \override MeasureCounter.font-encoding = #'latin1
        \override MeasureCounter.font-shape = #'italic
        % to control the distance of the Dynamics context from the staff:
        \override VerticalAxisGroup.nonstaff-relatedstaff-spacing.padding = #2
      }
      \context {
        \Score
        \remove "Bar_number_engraver"
      }
    }

    pattern = \repeat unfold 7 { c'4 d' e' f' }

    \new StaffGroup <<
      \new Staff {
        \pattern
      }
      \new Staff {
        \pattern
      }
      \new Dynamics {
        \startMeasureCount
        s1*7
        \stopMeasureCount
      }
    >>

## Changing the default bar lines

Default bar lines can be changed when re-defined in a score context.

    % http://lsr.di.unimi.it/LSR/Item?id=964
    %%=> http://lists.gnu.org/archive/html/lilypond-user/2014-03/msg00126.html
    %%=> http://lilypond.1069038.n5.nabble.com/Changing-the-default-end-repeat-bracket-tc169357.html

    \layout {
      \context {
        \Score
        %% Changing the defaults from engraver-init.ly
        defaultBarType = #"!"
        startRepeatType = #"[|:"
        endRepeatType = #":|]"
        doubleRepeatType = #":|][|:"
      }
    }

    %% example:
    {
      c'1
      \repeat volta 2 { \repeat unfold 2 c' }
      \repeat volta 2 { \repeat unfold 2 c' }
      \alternative {
        { c' }
        {
          %% v2.18 workaround
          \once\override Score.VoltaBracket.shorten-pair = #'(1 . -1)
          c'
        }
      }
      \bar "|."
    }

## Changing the number of lines in a staff

The number of lines in a staff may changed by overriding the `StaffSymbol` property `line-count`.

    upper = \relative c'' {
      c4 d e f
    }

    lower = \relative c {
      \clef bass
      c4 b a g
    }

    \score {
      \context PianoStaff <<
        \new Staff {
          \upper
        }
        \new Staff {
          \override Staff.StaffSymbol.line-count = #4
          \lower
        }
      >>
    }

## Changing the staff size

Though the simplest way to resize staves is to use `#(set-global-staff-size xx)`, an individual staff’s size can be changed by scaling the properties `'staff-space` and `fontSize`.

    <<
      \new Staff {
        \relative c'' {
          \dynamicDown
          c8\ff c c c c c c c
        }
      }
      \new Staff \with {
        fontSize = #-3
        \override StaffSymbol.staff-space = #(magstep -3)
      } {
        \clef bass
        c8 c c c c\f c c c
      }
    >>

## Creating blank staves

To create blank staves, generate empty measures then remove the `Bar_number_engraver` from the `Score` context, and the `Time_signature_engraver`, `Clef_engraver` and `Bar_engraver` from the `Staff` context.

    #(set-global-staff-size 20)

    \score {
      {
        \repeat unfold 12 { s1 \break }
      }
      \layout {
        indent = 0\in
        \context {
          \Staff
          \remove "Time_signature_engraver"
          \remove "Clef_engraver"
          \remove "Bar_engraver"
        }
        \context {
          \Score
          \remove "Bar_number_engraver"
        }
      }
    }

    % uncomment these lines for "letter" size
    %{
    \paper {
      #(set-paper-size "letter")
      ragged-last-bottom = ##f
      line-width = 7.5\in
      left-margin = 0.5\in
      bottom-margin = 0.25\in
      top-margin = 0.25\in
    }
    %}

    % uncomment these lines for "A4" size
    %{
    \paper {
      #(set-paper-size "a4")
      ragged-last-bottom = ##f
      line-width = 180
      left-margin = 15
      bottom-margin = 10
      top-margin = 10
    }
    %}

## Creating custom key signatures

LilyPond supports custom key signatures. In this example, print for D minor with an extended range of printed flats.

    \new Staff \with {
      \override StaffSymbol.line-count = #8
      \override KeySignature.flat-positions = #'((-7 . 6))
      \override KeyCancellation.flat-positions = #'((-7 . 6))
      % presumably sharps are also printed in both octaves
      \override KeySignature.sharp-positions = #'((-6 . 7))
      \override KeyCancellation.sharp-positions = #'((-6 . 7))

      \override Clef.stencil = #
      (lambda (grob)(grob-interpret-markup grob
      #{ \markup\combine
        \musicglyph "clefs.C"
        \translate #'(-3 . -2)
        \musicglyph "clefs.F"
       #}))
        clefPosition = #3
        middleCPosition = #3
        middleCClefPosition = #3
    }

    {
      \key d\minor
      f bes, f bes,
    }

## Creating double-digit fingerings

Creating fingerings larger than 5 is possible.

    \relative c' {
      c1-10
      c1-50
      c1-36
      c1-29
    }

## Hälse über beide Systeme

Dieses Schnipsel zeigt den Einsatz von `Span_stem_engraver` und `\crossStaff`, um Hälse über Systeme hinweg automatisch zu verbinden. Die Länge des Halses muss definiert werden, da der variable Abstand zwischen Notenköpfen und Notensystemen automatisch errechnet wird.

    \layout {
      \context {
        \PianoStaff
        \consists #Span_stem_engraver
      }
    }

    {
      \new PianoStaff <<
        \new Staff {
          <b d'>4 r d'16\> e'8. g8 r\!
          e'8 f' g'4 e'2
        }
        \new Staff {
          \clef bass
          \voiceOne
          \autoBeamOff
          \crossStaff { <e g>4 e, g16 a8. c8} d
          \autoBeamOn
          g8 f g4 c2
        }
      >>
    }

## Klammer anzeigen, wenn nur ein System gesetzt wird

Wenn nur ein System einer Systemgruppe vom Typ `ChoirStaff` oder `StaffGroup` angezeigt wird, wird die Klammer zu Beginn normalerweise nicht gesetzt. Das kann verändert werden, indem man die entsprechende Eigenschaft verändert.

Bei Systemen wie `PianoStaff` und `GrandStaff`, die mit einer geschweiften Klammer beginne, muss eine andere Eigenschaft verändert werden, wie das zweite Beispiel zeigt.

    \score {
      \new StaffGroup <<
        % Must be lower than the actual number of staff lines
        \override StaffGroup.SystemStartBracket.collapse-height = #4
        \override Score.SystemStartBar.collapse-height = #4
        \new Staff {
          c'1
        }
      >>
    }
    \score {
      \new PianoStaff <<
        \override PianoStaff.SystemStartBrace.collapse-height = #4
        \override Score.SystemStartBar.collapse-height = #4
        \new Staff {
          c'1
        }
      >>
    }

## Extending a TrillSpanner

For `TrillSpanner`, the `minimum-length` property becomes effective only if the `set-spacing-rods` procedure is called explicitly.

To do this, the `springs-and-rods` property should be set to `ly:spanner::set-spacing-rods`.

    \relative c' {
    \key c\minor
      \time 2/4
      c16( as') c,-. des-.
      \once\override TrillSpanner.minimum-length = #15
      \once\override TrillSpanner.springs-and-rods = #ly:spanner::set-spacing-rods
      \afterGrace es4
      \startTrillSpan { d16[( \stopTrillSpan es)] }
      c( c' g es c g' es d
      \hideNotes
      c8)
    }

## Extending glissandi across repeats

A glissando which extends into several `\alternative` blocks can be simulated by adding a hidden grace note with a glissando at the start of each `\alternative` block. The grace note should be at the same pitch as the note which starts the initial glissando. This is implemented here with a music function which takes the pitch of the grace note as its argument.

Note that in polyphonic music the grace note must be matched with corresponding grace notes in all other voices.

    repeatGliss = #(define-music-function (grace)
      (ly:pitch?)
      #{
        % the next two lines ensure the glissando is long enough
        % to be visible
        \once \override Glissando.springs-and-rods
          = #ly:spanner::set-spacing-rods
        \once \override Glissando.minimum-length = #3.5
        \once \hideNotes
        \grace $grace \glissando
      #})

    \score {
      \relative c'' {
        \repeat volta 3 { c4 d e f\glissando }
        \alternative {
          { g2 d }
          { \repeatGliss f g2 e }
          { \repeatGliss f e2 d }
        }
      }
    }

    music =  \relative c' {
      \voiceOne
      \repeat volta 2 {
        g a b c\glissando
      }
      \alternative {
        { d1 }
        { \repeatGliss c \once \omit StringNumber e1\2 }
      }
    }

    \score {
      \new StaffGroup <<
        \new Staff <<
          \new Voice { \clef "G_8" \music }
        >>
        \new TabStaff  <<
          \new TabVoice { \clef "moderntab" \music }
        >>
      >>
    }

## Flat Ties

The function takes the default `Tie.stencil` as an argument, calculating the result relying on the extents of this default.

Further tweaking is possible by overriding `Tie.details.height-limit` or with `\shape`. It’s also possible to change the custom-definition on the fly.

    %% http://lsr.di.unimi.it/LSR/Item?id=1031

    #(define ((flared-tie coords) grob)

      (define (pair-to-list pair)
         (list (car pair) (cdr pair)))

      (define (normalize-coords goods x y dir)
        (map
          (lambda (coord)
            ;(coord-scale coord (cons x (* y dir)))
            (cons (* x (car coord)) (* y dir (cdr coord))))
          goods))

      (define (my-c-p-s points thick)
        (make-connected-path-stencil
          points
          thick
          1.0
          1.0
          #f
          #f))

      ;; outer let to trigger suicide
      (let ((sten (ly:tie::print grob)))
        (if (grob::is-live? grob)
            (let* ((layout (ly:grob-layout grob))
                   (line-thickness (ly:output-def-lookup layout 'line-thickness))
                   (thickness (ly:grob-property grob 'thickness 0.1))
                   (used-thick (* line-thickness thickness))
                   (dir (ly:grob-property grob 'direction))
                   (xex (ly:stencil-extent sten X))
                   (yex (ly:stencil-extent sten Y))
                   (lenx (interval-length xex))
                   (leny (interval-length yex))
                   (xtrans (car xex))
                   (ytrans (if (> dir 0)(car yex) (cdr yex)))
                   (uplist
                     (map pair-to-list
                          (normalize-coords coords lenx (* leny 2) dir))))

       (ly:stencil-translate
           (my-c-p-s uplist used-thick)
         (cons xtrans ytrans)))
       '())))

    #(define flare-tie
      (flared-tie '((0 . 0)(0.1 . 0.2) (0.9 . 0.2) (1.0 . 0.0))))

    \layout {
      \context {
        \Voice
        \override Tie.stencil = #flare-tie
      }
    }

    \paper { ragged-right = ##f }

    \relative c' {
      a4~a
      \override Tie.height-limit = 4
      a'4~a
      a'4~a
      <a,, c e a c e a c e>~ q

      \break

      a'4~a
      \once \override Tie.details.height-limit = 14
      a4~a

      \break

      a4~a
      \once \override Tie.details.height-limit = 0.5
      a4~a

      \break

      a4~a
      \shape #'((0 . 0) (0 . 0.4) (0 . 0.4) (0 . 0)) Tie
      a4~a

      \break

      a4~a
      \once \override Tie.stencil =
        #(flared-tie '((0 . 0)(0.1 . 0.4) (0.9 . 0.4) (1.0 . 0.0)))
      a4~a

      a4~a
      \once \override Tie.stencil =
        #(flared-tie '((0 . 0)(0.06 . 0.1) (0.94 . 0.1) (1.0 . 0.0)))
      a4~a
    }

## Forcing measure width to adapt to MetronomeMark’s width

By default, metronome marks do not influence horizontal spacing. This can be solved through a simple override, as shown in the second half of the example.

    example = {
      \tempo "Allegro"
      R1*6
      \tempo "Rall."
      R1*2
      \tempo "A tempo"
      R1*8
    }

    {
      \compressMMRests {
        \example
        R1
        R1
        \override Score.MetronomeMark.extra-spacing-width = #'(-3 . 0)
        \example
      }
    }

## Glissando kann Grobs überspringen

`NoteColumn`-Grobs können bei Glissandos übersprungen werden.

    \relative c' {
      a2 \glissando
      \once \override NoteColumn.glissando-skip = ##t
      f''4 d,
    }

## How to print two rehearsal marks above and below the same barline (method 1)

This method prints two ’rehearsal marks’, one on top of the other. It shifts the lower rehearsal mark below the staff and then adds padding above it in order to place the upper rehearsal mark above the staff.

By adjusting the extra-offset and baseline-skip values you can increase or decrease the overall space between the rehearsal mark and the staff.

Because nearly every type of glyph or string can be made to behave like a rehearsal mark it is possible to centre those above and below a bar line.

Adding the appropriate ’break visibility’ as shown in snippet 1 will allow you to position two marks at the end of a line as well.

Note: Method 1 is less complex than Method 2 but does not really allow for fine tuning of placement of one of the rehearsal marks without affecting the other. It may also give some problems with vertical spacing, since using `extra-offset` does not change the bounding box of the mark from its original value.

    \relative c'{
      c d e f |
      \once \override Score.RehearsalMark.extra-offset = #'(0 . -8.5)
      \once \override Score.RehearsalMark.baseline-skip = #9
      \mark \markup \center-column { \circle 1 \box A }
      g f e d |
      \once \override Score.RehearsalMark.extra-offset = #'(0 . -8.5)
      \once \override Score.RehearsalMark.baseline-skip = #9
      \mark \markup \center-column { \flat { \bold \small \italic Fine. } }
      g f e d |
      \once \override Score.RehearsalMark.extra-offset = #'(0 . -8.5)
      \once \override Score.RehearsalMark.baseline-skip = #9
      \override Score.RehearsalMark.break-visibility = #begin-of-line-invisible
      \mark \markup \center-column { \fermata \box z }
    }

## How to print two rehearsal marks above and below the same barline (method 2)

This method prints two ’rehearsal marks’ - one above the stave and one below, by creating two voices, adding the Rehearsal Mark engraver to each voice - without this no rehearsal mark is printed - and then placing each rehearsal mark UP and DOWN in each voice respectively.

This method (as opposed to method 1) is more complex, but allows for more flexibility, should it be needed to tweak each rehearsal mark independently of the other.

    \score {
      \relative c'
      <<
        \new Staff {
          <<
            \new Voice \with {
              \consists Mark_engraver
              \consists "Staff_collecting_engraver"
            }
            { c4 d e f
              \mark \markup { \box A }
              c4 d e f
            }
            \new Voice \with {
              \consists Mark_engraver
              \consists "Staff_collecting_engraver"
              \override RehearsalMark.direction = #DOWN
            }
            { s4 s s s
              \mark \markup { \circle 1 }
              s4 s s s
            }
          >>
        }
      >>
      \layout {
        \context {
          \Score
          \remove "Mark_engraver"
          \remove "Staff_collecting_engraver"
        }
      }
    }

## Incipit

When transcribing mensural music, an incipit at the beginning of the piece is useful to indicate the original key and tempo. Musicians today are used to bar lines, but these were not known during the period of mensural music. As a compromise, bar lines are often printed between the staves, a layout style called mensurstriche layout.

    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    % A short excerpt from the Jubilate Deo by Orlande de Lassus
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    global = {
      \set Score.skipBars = ##t
      \key g \major
      \time 4/4

      % the actual music
      \skip 1*8

      % let finis bar go through all staves
      \override Staff.BarLine.transparent = ##f

      % finis bar
      \bar "|."
    }

    discantusIncipit = {
      \clef "neomensural-c1"
      \key f \major
      \time 2/2
      c''1.
    }

    discantusNotes = {
      \transpose c' c'' {
        \clef "treble"
        d'2. d'4 |
        b e' d'2 |
        c'4 e'4.( d'8 c' b |
        a4) b a2 |
        b4.( c'8 d'4) c'4 |
        \once \hide NoteHead
        c'1 |
        b\breve |
      }
    }

    discantusLyrics = \lyricmode {
      Ju -- bi -- la -- te De -- o,
      om -- nis ter -- ra, __ om-
      "..."
      -us.
    }

    altusIncipit = {
      \clef "neomensural-c3"
      \key f \major
      \time 2/2
      r1 f'1.
    }

    altusNotes = {
      \transpose c' c'' {
        \clef "treble"
        r2 g2. e4 fis g |
        a2 g4 e |
        fis g4.( fis16 e fis4) |
        g1 |
        \once \hide NoteHead
        g1 |
        g\breve |
      }
    }

    altusLyrics = \lyricmode {
      Ju -- bi -- la -- te
      De -- o, om -- nis ter -- ra,
      "..."
      -us.
    }

    tenorIncipit = {
      \clef "neomensural-c4"
      \key f \major
      \time 2/2
      r\longa
      r\breve
      r1 c'1.
    }

    tenorNotes = {
      \transpose c' c' {
        \clef "treble_8"
        R1 |
        R1 |
        R1 |
        % two measures
        r2 d'2. d'4 b e' |
        \once \hide NoteHead
        e'1 |
        d'\breve |
      }
    }

    tenorLyrics = \lyricmode {
      Ju -- bi -- la -- te
      "..."
      -us.
    }

    bassusIncipit = {
      \clef "mensural-f"
      \key f \major
      \time 2/2
      r\maxima
      f1.
    }

    bassusNotes = {
      \transpose c' c' {
        \clef "bass"
        R1 |
        R1 |
        R1 |
        R1 |
        g2. e4 |
        \once \hide NoteHead
        e1 |
        g\breve |
      }
    }

    bassusLyrics = \lyricmode {
      Ju -- bi-
      "..."
      -us.
    }

    \score {
      <<
        \new StaffGroup = choirStaff <<
          \new Voice = "discantusNotes" <<
            \set Staff.instrumentName = "Discantus"
            \incipit \discantusIncipit
            \global
            \discantusNotes
          >>
          \new Lyrics \lyricsto discantusNotes { \discantusLyrics }
          \new Voice = "altusNotes" <<
            \set Staff.instrumentName = "Altus"
            \global
            \incipit \altusIncipit
            \altusNotes
          >>
          \new Lyrics \lyricsto altusNotes { \altusLyrics }
          \new Voice = "tenorNotes" <<
            \set Staff.instrumentName = "Tenor"
            \global
            \incipit \tenorIncipit
            \tenorNotes
          >>
          \new Lyrics \lyricsto tenorNotes { \tenorLyrics }
          \new Voice = "bassusNotes" <<
            \set Staff.instrumentName = "Bassus"
            \global
            \incipit \bassusIncipit
            \bassusNotes
          >>
          \new Lyrics \lyricsto bassusNotes { \bassusLyrics }
        >>
      >>
      \layout {
        \context {
          \Score
          %% no bar lines in staves or lyrics
          \hide BarLine
        }
        %% the next two instructions keep the lyrics between the bar lines
        \context {
          \Lyrics
          \consists "Bar_engraver"
          \consists "Separating_line_group_engraver"
        }
        \context {
          \Voice
          %% no slurs
          \hide Slur
          %% Comment in the below "\remove" command to allow line
          %% breaking also at those bar lines where a note overlaps
          %% into the next measure.  The command is commented out in this
          %% short example score, but especially for large scores, you
          %% will typically yield better line breaking and thus improve
          %% overall spacing if you comment in the following command.
          %%\remove "Forbid_line_break_engraver"
        }
        indent = 6\cm
        incipit-width = 4\cm
      }
    }

## Inserting score fragments above a staff, as markups

The `\markup` command is quite versatile. In this snippet, it contains a `\score` block instead of texts or marks.

    tuning = \markup {
      \score {
        \new Staff \with { \remove "Time_signature_engraver" }
        {
          \clef bass
          <c, g, d g>1
        }
        \layout { ragged-right = ##t  indent = 0\cm }
      }
    }

    \header {
      title = "Solo Cello Suites"
      subtitle = "Suite IV"
      subsubtitle = \markup { Originalstimmung: \raise #0.5 \tuning }
    }

    \layout { ragged-right = ##f }

    \relative c'' {
      \time 4/8
      \tuplet 3/2 { c8 d e } \tuplet 3/2 { c d e }
      \tuplet 3/2 { c8 d e } \tuplet 3/2 { c d e }
      g8 a g a
      g8 a g a
    }

## Let TabStaff print the topmost string at bottom

In tablatures usually the first string is printed topmost. If you want to have it at the bottom change the `stringOneTopmost`-context-property. For a context-wide setting this could be done in `layout` as well.

    %
    %\layout {
    %  \context {
    %    \Score
    %    stringOneTopmost = ##f
    %  }
    %  \context {
    %    \TabStaff
    %    tablatureFormat = #fret-letter-tablature-format
    %  }
    %}

    m = {
      \cadenzaOn
      e, b, e gis! b e'
      \bar "||"
    }

    <<
      \new Staff { \clef "G_8" <>_"default" \m <>_"italian (historic)"\m }
      \new TabStaff
      {
        \m
        \set Score.stringOneTopmost = ##f
        \set TabStaff.tablatureFormat = #fret-letter-tablature-format
        \m
      }
    >>

## Letter tablature formatting

Tablature can be formatted using letters instead of numbers.

    music = \relative c {
      c4 d e f
      g4 a b c
      d4 e f g
    }

    <<
      \new Staff {
        \clef "G_8"
        \music
      }
      \new TabStaff \with {
        tablatureFormat = #fret-letter-tablature-format
      }
      {
        \music
      }
    >>

## Making glissandi breakable

Setting the `breakable` property to `#t` in combination with `after-line-breaking` allows a glissando to break if it occurs at a line break:

    glissandoSkipOn = {
      \override NoteColumn.glissando-skip = ##t
      \hide NoteHead
      \override NoteHead.no-ledgers = ##t
    }

    \relative c'' {
      \override Glissando.breakable = ##t
      \override Glissando.after-line-breaking = ##t
      f1\glissando |
      \break
      a4 r2. |
      f1\glissando
      \once \glissandoSkipOn
      \break
      a2 a4 r4 |
    }

## Eine Linie des Notensystems dicker als die anderen machen

Für den pädagogischen Einsatz kann eine Linie des Notensystems dicker gezeichnet werden (z. B. die Mittellinie, oder um den Schlüssel hervorzuheben). Das ist möglich, indem man zusätzliche Linien sehr nahe an der Linie, die dicker erscheinen soll, einfügt. Dazu wird die `line-positions`-Eigenschaft herangezogen.

    {
      \override Staff.StaffSymbol.line-positions =
        #'(-4 -2 -0.2 0 0.2 2 4)
      d'4 e' f' g'
    }

## Measure counter

This snippet provides a workaround for emitting measure counters using transparent percent repeats.

    <<
      \context Voice = "foo" {
        \clef bass
        c4 r g r
        c4 r g r
        c4 r g r
        c4 r g r
      }
      \context Voice = "foo" {
        \set countPercentRepeats = ##t
        \hide PercentRepeat
        \override PercentRepeatCounter.staff-padding = #1
        \repeat percent 4 { s1 }
      }
    >>

## Mensurstriche-Layout (Taktstriche zwischen den Systemen

Das Mensurstiche-Layout, in welchem die Taktlinien nicht auf den Systemen, sondern zwischen den Systemen gesetzt werden, kann mit einer `StaffGroup` anstelle von `ChoirStaff` erreicht werden. Die Taktlinien auf den Systemen werden mit der `transparent`-Eigenschaft ausgelöscht.

    global = {
      \hide Staff.BarLine
      s1 s
      % the final bar line is not interrupted
      \undo \hide Staff.BarLine
      \bar "|."
    }

    \new StaffGroup \relative c'' {
      <<
        \new Staff { << \global { c1 c } >> }
        \new Staff { << \global { c c } >> }
      >>
    }

## Modifying the Ottava spanner slope

It is possible to change the slope of the Ottava spanner.

    \relative c'' {
      \override Staff.OttavaBracket.stencil = #ly:line-spanner::print
      \override Staff.OttavaBracket.bound-details =
        #`((left . ((Y . 0) ; Change the integer here
                    (attach-dir . ,LEFT)
                    (padding . 0)
                    (stencil-align-dir-y . ,CENTER)))
           (right . ((Y . 5) ; Change the integer here
                     (padding . 0)
                     (attach-dir . ,RIGHT)
                     (text . ,(make-draw-dashed-line-markup
                               (cons 0 -1.2))))))
      \override Staff.OttavaBracket.left-bound-info =
         #ly:line-spanner::calc-left-bound-info-and-text
      \override Staff.OttavaBracket.right-bound-info =
         #ly:line-spanner::calc-right-bound-info
      \ottava #1
      c1
      c'''1
    }

## Systeme schachteln

Die Eigenschaft `systemStartDelimiterHierarchy` kann eingesetzt werden, um komplizierte geschachtelte Systemklammern zu erstellen. Der Befehl `\set StaffGroup.systemStartDelimiterHierarchy` nimmt eine Liste mit der Anzahl der Systeme, die ausgegeben werden, auf. Vor jedem System kann eine Systemanfangsklammer angegeben werden. Sie muss in Klammern eingefügt werden und umfasst so viele Systeme, wie die Klammer einschließt. Elemente in der Liste können ausgelassen werden, aber die erste Klammer umfasst immer die gesamte Gruppe. Die Möglichkeiten der Anfangsklammer sind: `SystemStartBar`, `SystemStartBracket`, `SystemStartBrace` und `SystemStartSquare`.

    \new StaffGroup
    \relative c'' <<
      \override StaffGroup.SystemStartSquare.collapse-height = #4
      \set StaffGroup.systemStartDelimiterHierarchy
        = #'(SystemStartSquare (SystemStartBrace (SystemStartBracket a
                                 (SystemStartSquare b)  ) c ) d)
      \new Staff { c1 }
      \new Staff { c1 }
      \new Staff { c1 }
      \new Staff { c1 }
      \new Staff { c1 }
    >>

## Untypische Tonarten

Der üblicherweise benutzte `\key`-Befehl setzt die `keySignature`-Eigenschaft im `Staff`-Kontext.

Um untypische Tonartenvorzeichen zu erstellen, muss man diese Eigenschaft direkt setzen. Das Format für den Befehl ist eine Liste: `\set Staff.keySignature = #`(((Oktave . Schritt) . Alteration) ((Oktave . Schritt) . Alteration) ...)` wobei für jedes Element in der Liste `Oktave` die Oktave angibt (0 ist die Oktave vom eingestrichenen C bis zum eingestrichenen H), `Schritt` gibt die Note innerhalb der Oktave an (0 heißt C und 6 heißt H), und `Alteration` ist `,SHARP ,FLAT ,DOUBLE-SHARP` usw. (Beachte das beginnende Komma.)

Alternativ kann auch jedes Element der Liste mit dem allgemeineren Format `(Schritt . Alteration)` gesetzt werden, wobei dann die Einstellungen für alle Oktaven gelten.

Hier ein Beispiel einer möglichen Tonart für eine Ganztonleiter:

    \include "arabic.ly"
    \relative do' {
      \set Staff.keyAlterations = #`((0 . ,SEMI-FLAT)
                                     (1 . ,SEMI-FLAT)
                                     (2 . ,FLAT)
                                     (5 . ,FLAT)
                                     (6 . ,SEMI-FLAT))
    %\set Staff.extraNatural = ##f
      re reb \dwn reb resd
      dod dob dosd \dwn dob |
      dobsb dodsd do do |
    }

## Numbering groups of measures

This snippet demonstrates the use of the `Measure_counter_engraver` to number groups of successive measures. Any stretch of measures may be numbered, whether consisting of repetitions or not.

The engraver must be added to the appropriate context. Here, a `Staff` context is used; another possibility is a `Dynamics` context.

The counter is begun with `\startMeasureCount` and ended with `\stopMeasureCount`. Numbering will start by default with `1`, but this behavior may be modified by overriding the `count-from` property.

When a measure extends across a line break, the number will appear twice, the second time in parentheses.

    \layout {
      \context {
        \Staff
        \consists #Measure_counter_engraver
      }
    }

    \new Staff {
      \startMeasureCount
      \repeat unfold 7 {
        c'4 d' e' f'
      }
      \stopMeasureCount
      \bar "||"
      g'4 f' e' d'
      \override Staff.MeasureCounter.count-from = #2
      \startMeasureCount
      \repeat unfold 5 {
        g'4 f' e' d'
      }
      g'4 f'
      \bar ""
      \break
      e'4 d'
      \repeat unfold 7 {
        g'4 f' e' d'
      }
      \stopMeasureCount
    }

## Orchester, Chor und Klavier

Diese Vorlage zeigt die Benutzung von geschachtelten `StaffGroup`- und `GrandStaff`-Kontexte, um Instrumente in Untergruppen zu unterteilen, und die Benutzung von `\transpose` für transponierende Instrumente. Alle Noten werden in C geschrieben. Noten können in C eingegeben werden, oder auch in der Tonart des Instrumentes: dann müssen sie zuerst nach C transponiert werden, bevor sie einer Variable zugewiesen werden.

    #(set-global-staff-size 17)
    \paper {
      indent = 3.0\cm  % add space for instrumentName
      short-indent = 1.5\cm  % add less space for shortInstrumentName
    }

    fluteMusic = \relative c' { \key g \major g'1 b }

    % Pitches as written on a manuscript for Clarinet in A
    % are transposed to concert pitch.

    clarinetMusic = \transpose c' a
      \relative c'' { \key bes \major bes1 d }

    trumpetMusic = \relative c { \key g \major g''1 b }

    % Key signature is often omitted for horns

    hornMusic = \transpose c' f
      \relative c { d'1 fis }

    percussionMusic = \relative c { \key g \major g1 b }

    sopranoMusic = \relative c'' { \key g \major g'1 b }

    sopranoLyrics = \lyricmode { Lyr -- ics }

    altoIMusic = \relative c' { \key g \major g'1 b }

    altoIIMusic = \relative c' { \key g \major g'1 b }

    altoILyrics =  \sopranoLyrics

    altoIILyrics = \lyricmode { Ah -- ah }

    tenorMusic = \relative c' { \clef "treble_8" \key g \major g1 b }

    tenorLyrics = \sopranoLyrics

    pianoRHMusic = \relative c { \key g \major g''1 b }

    pianoLHMusic = \relative c { \clef bass \key g \major g1 b }

    violinIMusic = \relative c' { \key g \major g'1 b }

    violinIIMusic = \relative c' { \key g \major g'1 b }

    violaMusic = \relative c { \clef alto \key g \major g'1 b }

    celloMusic = \relative c { \clef bass \key g \major g1 b }

    bassMusic = \relative c { \clef "bass_8" \key g \major g,1 b }

    \score {
      <<
        \new StaffGroup = "StaffGroup_woodwinds" <<
          \new Staff = "Staff_flute" \with { instrumentName = "Flute" }
          \fluteMusic

          \new Staff = "Staff_clarinet" \with {
            instrumentName = \markup { \concat { "Clarinet in B" \flat } }
          }

          % Declare that written Middle C in the music
          % to follow sounds a concert B flat, for
          % output using sounded pitches such as MIDI.
          %\transposition bes

          % Print music for a B-flat clarinet
          \transpose bes c' \clarinetMusic
        >>

        \new StaffGroup = "StaffGroup_brass" <<
          \new Staff = "Staff_hornI" \with { instrumentName = "Horn in F" }
           % \transposition f
            \transpose f c' \hornMusic

          \new Staff = "Staff_trumpet" \with { instrumentName = "Trumpet in  C" }
          \trumpetMusic

        >>
        \new RhythmicStaff = "RhythmicStaff_percussion"
        \with { instrumentName = "Percussion" }
        <<
          \percussionMusic
        >>
        \new PianoStaff \with { instrumentName = "Piano" }
        <<
          \new Staff { \pianoRHMusic }
          \new Staff { \pianoLHMusic }
        >>
        \new ChoirStaff = "ChoirStaff_choir" <<
          \new Staff = "Staff_soprano" \with { instrumentName = "Soprano" }
          \new Voice = "soprano"
          \sopranoMusic

          \new Lyrics \lyricsto "soprano" { \sopranoLyrics }
          \new GrandStaff = "GrandStaff_altos"
          \with { \accepts Lyrics } <<
            \new Staff = "Staff_altoI"  \with { instrumentName = "Alto I" }
            \new Voice = "altoI"
            \altoIMusic

            \new Lyrics \lyricsto "altoI" { \altoILyrics }
            \new Staff = "Staff_altoII" \with { instrumentName = "Alto II" }
            \new Voice = "altoII"
            \altoIIMusic

            \new Lyrics \lyricsto "altoII" { \altoIILyrics }
          >>

          \new Staff = "Staff_tenor" \with { instrumentName = "Tenor" }
            \new Voice = "tenor"
            \tenorMusic

          \new Lyrics \lyricsto "tenor" { \tenorLyrics }
        >>
        \new StaffGroup = "StaffGroup_strings" <<
          \new GrandStaff = "GrandStaff_violins" <<
            \new Staff = "Staff_violinI" \with { instrumentName = "Violin I" }
            \violinIMusic

            \new Staff = "Staff_violinII" \with { instrumentName = "Violin II" }
            \violinIIMusic
          >>

          \new Staff = "Staff_viola" \with { instrumentName = "Viola" }
          \violaMusic

          \new Staff = "Staff_cello" \with { instrumentName = "Cello" }
          \celloMusic

          \new Staff = "Staff_bass" \with { instrumentName = "Double Bass" }
          \bassMusic
        >>
      >>
      \layout { }
    }

## Putting lyrics inside the staff

Lyrics can be moved vertically to place them inside the staff. The lyrics are moved with `\override LyricText.extra-offset = #'(0 . dy)` and there are similar commands to move the extenders and hyphens. The offset needed is established with trial and error.

    <<
      \new Staff <<
        \new Voice = "voc" \relative c' { \stemDown a bes c8 b c4 }
      >>
      \new Lyrics \with {
        \override LyricText.extra-offset = #'(0 . 8.6)
        \override LyricExtender.extra-offset = #'(0 . 8.6)
        \override LyricHyphen.extra-offset = #'(0 . 8.6)
      } \lyricsto "voc" { La la -- la __ _ la }
    >>

## Eine Stimme mit Transposition zitieren

Zitate berücksichtigen sowohl die Transposition der Quelle als auch des Zielinstruments. In diesem Beispiel spielen alle Instrumente klingendes C, das Zielinstrument ist in F. Die Noten für das Zielinstrument können mit `\transpose` transponiert werden, in diesem Fall werden alle Noten (auch die zitierten) transponiert.

    \addQuote clarinet {
      \transposition bes
      \repeat unfold 8 { d'16 d' d'8 }
    }

    \addQuote sax {
      \transposition es'
      \repeat unfold 16 { a8 }
    }

    quoteTest = {
      % french horn
      \transposition f
      g'4
      << \quoteDuring "clarinet" { \skip 4 } s4^"clar." >>
      << \quoteDuring "sax" { \skip 4 } s4^"sax." >>
      g'4
    }

    {
      \new Staff \with {
        instrumentName = \markup { \column { Horn "in F" } }
      }
      \quoteTest
      \transpose c' d' << \quoteTest s4_"up a tone" >>
    }

## Eine andere Stimme zitieren

Die `quotedEventTypes`-Eigenschaft bestimmt die Typen an Musikereignissen, die zitiert werden. Die Standardeinstellung ist `(note-event rest-event)`, womit nur Noten und Pausen der zitierten Stimme für den `\quoteDuring`-Ausdruck übernommen werden. Im Beispiel hier wird die 16-Pause nicht übernommen, weil sich `rest-event` nicht in `quotedEventTypes` befindet.

    quoteMe = \relative c' {
      fis4 r16 a8.-> b4\ff c
    }
    \addQuote quoteMe \quoteMe

    original = \relative c'' {
      c8 d s2
      \once \override NoteColumn.ignore-collision = ##t
      es8 gis8
    }

    <<
      \new Staff \with { instrumentName = "quoteMe" }
      \quoteMe

      \new Staff \with { instrumentName = "orig" }
      \original

      \new Staff \with {
        instrumentName = "orig+quote"
        quotedEventTypes = #'(note-event articulation-event)
      }
      \relative c''
      <<
        \original
        \new Voice {
          s4
          \set fontSize = #-4
          \override Stem.length-fraction = #(magstep -4)
          \quoteDuring "quoteMe" { \skip 2. }
        }
      >>
    >>

## Removing brace on first line of piano score

This snippet removes the first brace from a `PianoStaff` or a `GrandStaff`.

It may be useful when cutting and pasting the engraved image into existing music.

It uses `\alterBroken`.

    someMusic =  {
      \once \override Staff.Clef.stencil = ##f
      \once \override Staff.TimeSignature.stencil = ##f
      \repeat unfold 3 c1 \break
      \repeat unfold 5 c1 \break
      \repeat unfold 5 c1
    }

    \score {
      \new PianoStaff
      <<
        \new Staff = "right" \relative c'' \someMusic
        \new Staff = "left" \relative c' { \clef F \someMusic }
      >>
      \layout {
        indent=75
        \context {
          \PianoStaff
          \alterBroken transparent #'(#t) SystemStartBrace
        }
      }
    }

## Die erste leere Notenzeile auch entfernen

Ein leeres Notensystem kann auch aus der ersten Zeile einer Partitur entfernt werden, indem die Eigenschaft `remove-first` der `VerticalAxisGroup`-Eigenschaft eingesetzt wird. Das kann man global in einer `\layout`-Umgebung oder lokal in dem bestimmten Notensystem machen, das entfernt werden soll. In letzterem Fall muss man den Kontext angeben.

Das untere Notensystem der zweiten Systemgruppe wird nicht entfernt, weil in die Einstellungen in dem Schnipsel nur für das eine Notensystem gültig sind.

    \layout {
      \context {
        \Staff \RemoveEmptyStaves
        % To use the setting globally, uncomment the following line:
        % \override VerticalAxisGroup.remove-first = ##t
      }
    }
    \new StaffGroup <<
      \new Staff \relative c' {
        e4 f g a \break
        c1
      }
      \new Staff {
        % To use the setting globally, comment this line,
        % uncomment the line in the \layout block above
        \override Staff.VerticalAxisGroup.remove-first = ##t
        R1 \break
        R
      }
    >>
    \new StaffGroup <<
      \new Staff \relative c' {
        e4 f g a \break
        c1
      }
      \new Staff {
        R1 \break
        R
      }
    >>

## Setting system separators

System separators can be inserted between systems. Any markup can be used, but `\slashSeparator` has been provided as a sensible default.

    \paper {
      system-separator-markup = \slashSeparator
      line-width = 120
    }

    notes = \relative c' {
      c1 | c \break
      c1 | c \break
      c1 | c
    }

    \book {
      \score {
        \new GrandStaff <<
          \new Staff \notes
          \new Staff \notes
        >>
      }
    }

## Tick bar lines

’Tick’ bar lines are often used in music where the bar line is used only for coordination and is not meant to imply any rhythmic stress.

    \relative c' {
      \set Score.defaultBarType = #"'"
      c4 d e f
      g4 f e d
      c4 d e f
      g4 f e d
      \bar "|."
    }

## Time signature in parentheses - method 3

Another way to put the time signature in parenthesis

    \relative c'' {
      \override Staff.TimeSignature.stencil = #(lambda (grob)
        (parenthesize-stencil (ly:time-signature::print grob) 0.1 0.4 0.4 0.1 ))
      \time 2/4
      a4 b8 c
    }

## Time signature in parentheses

The time signature can be enclosed within parentheses.

    \relative c'' {
      \override Staff.TimeSignature.stencil = #(lambda (grob)
        (bracketify-stencil (ly:time-signature::print grob) Y 0.1 0.2 0.1))
      \time 2/4
      a4 b8 c
    }

## Eigenschaften des Schlüssels optimieren

Der Befehl `\clef "treble_8"` ist gleichbedeutend mit einem expliziten Setzen der Eigenschaften von `clefGlyph`, `clefPosition` (welche die vertikale Position des Schlüssels bestimmt), `middleCPosition` und `clefTransposition`. Ein Schlüssel wird ausgegeben, wenn eine der Eigenschaften außer `middleCPosition` sich ändert.

Eine Änderung des Schriftzeichens (Glyph), der Schlüsselposition oder der Oktavierung selber ändert noch nicht die Position der darauf folgenden Noten auf dem System: das geschieht nur, wenn auch die Position des eingestrichenen C (middleCPosition) angegeben wird. Die Positionsparameter sind relativ zur Mittellinie des Systems, dabei versetzen positive Zahlen die Position nach oben, jeweils eine Zahl für jede Linie plus Zwischenraum. Der `clefTransposition`-Wert ist normalerweise auf 7, -7, 15 oder -15 gesetzt, aber auch andere Werte sind gültig.

Wenn ein Schlüsselwechsel an einem Zeilenwechsel geschieht, wird das neue Symbol sowohl am Ende der alten Zeilen als auch am Anfang der neuen Zeile ausgegeben. Wenn der Warnungs-Schlüssel am Ende der alten Zeile nicht erforderlich ist, kann er unterdrückt werden, indem die `explicitClefVisibility`-Eigenschaft des `Staff`-Kontextes auf den Wert `end-of-line-invisible` gesetzt wird. Das Standardverhalten kann mit `\unset Staff.explicitClefVisibility` wieder hergestellt werden.

Die folgenden Beispiele zeigen die Möglichkeiten, wenn man diese Eigenschaften manuell setzt. Auf der ersten Zeile erhalten die manuellen Änderungen die ursprüngliche relative Positionierung von Schlüssel und Noten, auf der zweiten Zeile nicht.

    {
      % The default treble clef
      \key f \major
      c'1
      % The standard bass clef
      \set Staff.clefGlyph = #"clefs.F"
      \set Staff.clefPosition = #2
      \set Staff.middleCPosition = #6
      \set Staff.middleCClefPosition = #6
      \key g \major
      c'1
      % The baritone clef
      \set Staff.clefGlyph = #"clefs.C"
      \set Staff.clefPosition = #4
      \set Staff.middleCPosition = #4
      \set Staff.middleCClefPosition = #4
      \key f \major
      c'1
      % The standard choral tenor clef
      \set Staff.clefGlyph = #"clefs.G"
      \set Staff.clefPosition = #-2
      \set Staff.clefTransposition = #-7
      \set Staff.middleCPosition = #1
      \set Staff.middleCClefPosition = #1
      \key f \major
      c'1
      % A non-standard clef
      \set Staff.clefPosition = #0
      \set Staff.clefTransposition = #0
      \set Staff.middleCPosition = #-4
      \set Staff.middleCClefPosition = #-4
      \key g \major
      c'1 \break

      % The following clef changes do not preserve
      % the normal relationship between notes, key signatures
      % and clefs:

      \set Staff.clefGlyph = #"clefs.F"
      \set Staff.clefPosition = #2
      c'1
      \set Staff.clefGlyph = #"clefs.G"
      c'1
      \set Staff.clefGlyph = #"clefs.C"
      c'1
      \set Staff.clefTransposition = #7
      c'1
      \set Staff.clefTransposition = #0
      \set Staff.clefPosition = #0
      c'1

      % Return to the normal clef:

      \set Staff.middleCPosition = #0
      c'1
    }

## Two \partCombine pairs on one staff

The `\partCombine` function takes two music expressions each containing a part, and distributes them among four `Voice`s named „two“ „one“ „solo“ and „chords“ depending on when and how the parts merged into a common voice. The voices output from `\partCombine` can have their layout properties adjusted in the usual way. Here we define extensions of `\partCombine` to make it easier to put four voices on a staff.

    soprano = { d'4 | cis'  b  e'  d'8 cis' | cis'2 b }
    alto = { fis4 | e8 fis gis ais b4 b | b ais fis2 }
    tenor = { a8 b | cis' dis' e'4 b8 cis' d'4 | gis cis' dis'2 }
    bass = { fis8 gis | a4 gis g fis | eis fis b,2 }

    \new Staff <<
      \key b\minor
      \clef alto
      \partial 4
      \transpose b b'
      \partCombineUp \soprano \alto
      \partCombineDown \tenor \bass
    >>

    \layout {
      \context {
        \Staff
        \accepts "VoiceBox"
      }
      \context {
        \name "VoiceBox"
        \type "Engraver_group"
        \defaultchild "Voice"
        \accepts "Voice"
        \accepts "NullVoice"
      }
    }

    customPartCombineUp =
    #(define-music-function (partOne partTwo)
      (ly:music? ly:music?)
    "Take the music in @var{partOne} and @var{partTwo} and return
    a @code{VoiceBox} named @q{Up} containing @code{Voice}s
    that contain @var{partOne} and @var{partTwo} merged into one
    voice where feasible.  This variant sets the default voicing
    in the output to use upward stems."
    #{
      \new VoiceBox = "Up" <<
        \context Voice = "one" { \voiceOne }
        \context Voice = "two" { \voiceThree }
        \context Voice = "shared" { \voiceOne }
        \context Voice = "solo" { \voiceOne }
        \context NullVoice = "null" {}
        \partCombine #partOne #partTwo
      >>
    #})

    customPartCombineDown = #
    (define-music-function (partOne partTwo)
      (ly:music? ly:music?)
    "Take the music in @var{partOne} and @var{partTwo} and return
    a @code{VoiceBox} named @q{Down} containing @code{Voice}s
    that contain @var{partOne} and @var{partTwo} merged into one
    voice where feasible.  This variant sets the default voicing
    in the output to use downward stems."
    #{
      \new VoiceBox = "Down" <<
        \set VoiceBox.soloText = #"Solo III"
        \set VoiceBox.soloIIText = #"Solo IV"
        \context Voice ="one" { \voiceFour }
        \context Voice ="two" { \voiceTwo }
        \context Voice ="shared" { \voiceFour }
        \context Voice ="solo" { \voiceFour }
        \context NullVoice = "null" {}
        \partCombine #partOne #partTwo
      >>
    #})

    soprano = { d'4 | cis'  b  e'  d'8 cis' | cis'2 b }
    alto = { fis4 | e8 fis gis ais b4 b | b ais fis2 }
    tenor = { a8 b | cis' dis' e'4 b8 cis' d'4 | gis cis' dis'2 }
    bass = { fis8 gis | a4 gis g fis | eis fis b,2 }

    \new Staff <<
      \key b\minor
      \clef alto
      \partial 4
      \transpose b b'
      \customPartCombineUp \soprano \alto
      \customPartCombineDown \tenor \bass
    >>

## Eine eckige Klammer zu Beginn von Systemgruppen benutzen

Die Klammer zu Beginn von Systemgruppen kann auch in eine eckige Klammer (`SystemStartSquare`) umgewandelt werden, wenn man sie explizit im `StaffGroup`- oder `ChoirStaffGroup`-Kontext setzt.

    \score {
      \new StaffGroup { <<
      \set StaffGroup.systemStartDelimiter = #'SystemStartSquare
        \new Staff { c'4 d' e' f' }
        \new Staff { c'4 d' e' f' }
      >> }
    }

## Using autochange with more than one voice

Using `autochange` with more than one voice.

    \score
    {
      \new PianoStaff
      <<
        \new Staff = "up" {
          <<
            \set Timing.beamExceptions = #'()
            \set Timing.beatStructure = #'(4)
            \new Voice {
              \voiceOne
              \autoChange
              \relative c' {
                g8 a b c d e f g
                g,8 a b c d e f g
              }
            }

            \new Voice {
              \voiceTwo
              \autoChange
              \relative c' {
                g8 a b c d e f g
                g,,8 a b c d e f g
              }
            }
          >>
        }

        \new Staff = "down" {
          \clef bass
        }
      >>
    }

## Using marklines in a Frenched score

Using `MarkLine` contexts (such as in LSR1010) in a Frenched score can be problematic if all the staves between two `MarkLine`s are removed in one system. The `Keep_alive_together_engraver` can be used within each `StaffGroup` to keep the `MarkLine` alive only as long as the other staves in the group stay alive.

    bars = {
      \tempo "Allegro" 4=120
      s1*2
      \repeat unfold 5 { \mark \default s1*2 }
      \bar "||"
      \tempo "Adagio" 4=40
      s1*2
      \repeat unfold 8 { \mark \default s1*2 }
      \bar "|."
    }
    winds = \repeat unfold 120 { c''4 }
    trumpet = { \repeat unfold 8 g'2 R1*16 \repeat unfold 4 g'2 R1*8 }
    trombone = { \repeat unfold 4 c'1 R1*8 d'1 R1*17 }
    strings = \repeat unfold 240 { c''8 }

    #(set-global-staff-size 16)
    \paper {
      systems-per-page = 5
      ragged-last-bottom = ##f
    }

    \layout {
      indent = 15\mm
      short-indent = 5\mm
      \context {
        \name MarkLine
        \type Engraver_group
        \consists Output_property_engraver
        \consists Axis_group_engraver
        \consists Mark_engraver
        \consists Metronome_mark_engraver
        \override VerticalAxisGroup.remove-empty = ##t
        \override VerticalAxisGroup.remove-layer = #'any
        \override VerticalAxisGroup.staff-affinity = #DOWN
        \override VerticalAxisGroup.nonstaff-relatedstaff-spacing.basic-distance = 1
        keepAliveInterfaces = #'()
      }
      \context {
        \Staff
        \override VerticalAxisGroup.remove-empty = ##t
        \override VerticalAxisGroup.remove-layer = ##f
      }
      \context {
        \StaffGroup
        \accepts MarkLine
        \consists Keep_alive_together_engraver
      }
      \context {
        \Score
        \remove Mark_engraver
        \remove Metronome_mark_engraver
      }
    }

    \score {
      <<
        \new StaffGroup = "winds" \with {
          instrumentName = "Winds"
          shortInstrumentName = "Winds"
        } <<
          \new MarkLine \bars
          \new Staff \winds
        >>
        \new StaffGroup = "brass" <<
          \new MarkLine \bars
          \new Staff = "trumpet" \with {
            instrumentName = "Trumpet"
            shortInstrumentName = "Tpt"
          } \trumpet
          \new Staff = "trombone" \with {
            instrumentName = "Trombone"
            shortInstrumentName = "Tbn"
          } \trombone
        >>
        \new StaffGroup = "strings" \with {
          instrumentName = "Strings"
          shortInstrumentName = "Strings"
        } <<
          \new MarkLine \bars
          \new Staff = "strings" { \strings }
        >>
      >>
    }

## Vertical aligned StaffGroups without connecting SystemStartBar

This snippet shows how to achieve vertically aligned StaffGroups with a SystemStartBar for each StaffGroup, but without connecting them.

    % by Thomas Morley

    #(set-global-staff-size 18)

    \paper {
      indent = 0
      ragged-right = ##f
      print-all-headers = ##t
    }

    \layout {
      \context {
        \Staff
        \consists "Mark_engraver"
        \override RehearsalMark.self-alignment-X = #LEFT
      }
      \context {
        \StaffGroup
        systemStartDelimiterHierarchy =
          #'(SystemStartBrace (SystemStartBracket a b))
      }
      \context {
        \Score
        \override SystemStartBrace.style = #'bar-line
        \omit SystemStartBar
        \override SystemStartBrace.padding = #-0.1
        \override SystemStartBrace.thickness = #1.6
        \remove "Mark_engraver"
        \override StaffGrouper.staffgroup-staff-spacing.basic-distance = #15
      }
    }

    %%%% EXAMPLE

    txt =
    \lyricmode {
      Wer4 nur den lie -- ben Gott läßt wal2 -- ten4
      und4 hof -- fet auf ihn al -- le Zeit2.
    }

    % First StaffGroup "exercise"

    eI =
    \relative c' {
            \mark \markup {
                    \bold Teacher:
                    This is a simple setting of the choral. Please improve it.
                    }
            \key a \minor
            \time 4/4
            \voiceOne

            \partial 4
            e4
            a b c b
            a b gis2
            e4\fermata g! g f
            e a a gis
            a2.\fermata
            \bar ":|."
    }

    eII =
    \relative c' {
            \key a \minor
            \time 4/4
            \voiceTwo
            \partial 4
            c4
            e e e gis
            a f e2
            b4 b d d
            c c d d
            c2.
            \bar ":|."
    }

    eIII =
    \relative c' {
            \key a \minor
            \time 4/4
            \clef bass
            \voiceOne

            \partial 4
            a4
            c b a b
            c d b2
            gis4 g g b
            c a f e
            e2.
    }

    eIV =
    \relative c' {
            \key a \minor
            \time 4/4
            \clef bass
            \voiceTwo

            \partial 4
            a,4
            a' gis a e
            a, d e2
            e,4\fermata e' b g
            c f d e
            a,2.\fermata
            \bar ":|."
    }

    exercise =
    \new StaffGroup = "exercise"
    <<

      \new Staff
        <<
          \new Voice \eI
          \new Voice \eII
        >>

      \new Lyrics \txt

      \new Staff
        <<
          \new Voice \eIII
          \new Voice \eIV
        >>
    >>

    % Second StaffGRoup "simple Bach"

    sbI =
    \relative c' {
            \mark \markup { \bold" Pupil:" Here's my version! }
            \key a \minor
            \time 4/4
            \voiceOne

            \partial 4
            e4
            a b c b
            a b gis2
            e4\fermata g! g f
            e a a gis
            a2.\fermata
            \bar ":|."
    }

    sbII =
    \relative c' {
            \key a \minor
            \time 4/4
            \voiceTwo
            \partial 4
            c8 d
            e4 e e8 f g4
            f f e2
            b4 b8 c d4 d
            e8 d c4 b8 c d4
            c2.
            \bar ":|."
    }

    sbIII =
    \relative c' {
            \key a \minor
            \time 4/4
            \clef bass
            \voiceOne

            \partial 4
            a8 b
            c4 b a b8 c
            d4 d8 c b2
            gis4 g g8 a b4
            b a8 g f4 e
            e2.
    }

    sbIV =
    \relative c' {
            \key a \minor
            \time 4/4
            \clef bass
            \voiceTwo

            \partial 4
            a,4
            a' gis a e
            f8 e d4 e2
            e,4\fermata e' b a8 g
            c4 f8 e d4 e
            a,2.\fermata
            \bar ":|."
    }

    simpleBach =
    \new StaffGroup = "simple Bach"
    <<

      \new Staff
        <<
          \new Voice \sbI
          \new Voice \sbII
        >>

      \new Lyrics \txt

      \new Staff
        <<
          \new Voice \sbIII
          \new Voice \sbIV
        >>
    >>

    % Third StaffGroup "chromatic Bach"

    cbI =
    \relative c' {
            \mark \markup {
              \bold "Teacher:"
              \column {
                "Well, you simply copied and transposed a version of J.S.Bach."
                "Do you know this one?"
              }
            }
            \key a \minor
            \time 4/4
            \voiceOne

            \partial 4
            e4
            a b c b
            a b gis4. fis8
            e4\fermata g! g f
            e a a8 b gis4
            a2.\fermata
            \bar ":|."
    }

    cbII =
    \relative c' {
            \key a \minor
            \time 4/4
            \voiceTwo
            \partial 4
            c8 d
            e4 e e8 fis gis4
            a8 g! f!4 e2
            b4 e e d
            d8[ cis] d dis e fis e4
            e2.
            \bar ":|."
    }

    cbIII =
    \relative c' {
            \key a \minor
            \time 4/4
            \clef bass
            \voiceOne

            \partial 4
            a8 b
            c[ b] a gis8 a4 d,
            e8[ e'] d c b4. a8
            gis4 b c d8 c
            b[ a] a b c b b c16 d
            c2.
    }

    cbIV =
    \relative c' {
            \key a \minor
            \time 4/4
            \clef bass
            \voiceTwo

            \partial 4
            a4
            c, e a, b
            c d e2
            e4\fermata e a b8 c
            gis[ g] fis f e dis e4
            a,2.\fermata
            \bar ":|."
    }

    chromaticBach =
    \new StaffGroup = "chromatic Bach"
    <<

      \new Staff
        <<
          \new Voice \cbI
          \new Voice \cbII
        >>

      \new Lyrics \txt

      \new Staff
        <<
          \new Voice \cbIII
          \new Voice \cbIV
        >>
    >>

    % Score

    \score {
            <<
            \exercise
            \simpleBach
            \chromaticBach
            >>
            \header {
                    title = \markup
                               \column {
                                 \combine \null \vspace #1
                                 "Exercise: Improve the given choral"
                                 " "
                                }
            }
            \layout {
                    \context {
                            \Lyrics
                            \override LyricText.X-offset = #-1
                    }
            }
    }

## Wiederholungs-(Volta-)Klammern unterhalb der Akkordsymbole

Indem man den `Volta_engraver` zu dem entsprechenden Notensystem hinzufügt, können Wiederholungsklammern unterhalb der Akkorde gesetzt werden.

    \score {
      <<
        \chords {
          c1
          c1
        }
        \new Staff \with {
          \consists "Volta_engraver"
        }
        {
          \repeat volta 2 { c'1 }
          \alternative { c' }
        }
      >>
      \layout {
        \context {
          \Score
          \remove "Volta_engraver"
        }
      }
    }

## Volta multi staff

By adding the `Volta_engraver` to the relevant staff, volte can be put over staves other than the topmost one in a score.

    voltaMusic = \relative c'' {
      \repeat volta 2 {
        c1
      }
      \alternative {
        d1
        e1
      }
    }

    <<
      \new StaffGroup <<
        \new Staff \voltaMusic
        \new Staff \voltaMusic
      >>
      \new StaffGroup <<
        \new Staff \with { \consists "Volta_engraver" }
          \voltaMusic
        \new Staff \voltaMusic
      >>
    >>

#### LilyPond – Snippets v2.22.2 (stabiler Zweig).