5.1.5 Changing context default settings

The context settings which are to be used by default in Score, Staff and Voice contexts may be specified in a \layout block, as illustrated in the following example. The \layout block should be placed within the \score block to which it is to apply, but outside any music.

Note that the \set command itself and the context must be omitted when the context default values are specified in this way:

\score {
  \relative c'' {
    a4^"Really small, thicker stems, no time signature" a a a
    a a a a
  }
  \layout {
    \context {
      \Staff
      fontSize = #-4
      \override Stem #'thickness = #4.0
      \remove "Time_signature_engraver"
    }
  }
}

[image of music]

In this example, the \Staff command specifies that the subsequent specifications are to be applied to all staves within this score block.

Modifications can be made to the Score context or all Voice contexts in a similar way.

Context changes can be placed in a variable and applied to a \context definition by prepending the modification with \with:

blubb = \with {
  fontSize = #-4
  \override Stem #'thickness = #4.0
  \remove "Time_signature_engraver"
}

bla = \with {
  fontSize = #3
  \override Stem #'thickness = #-2.0
}

melody = \relative c'' {
  a4 a a a |
  a4 a a a |
}

\score {
  <<
    \new Staff <<
      \melody
      s1*0^"Small, thicker stems, no time signature"
    >>
    \new Staff \bla <<
      \melody
      s1*0^"Different"
    >>
  >>
  \layout {
    \context {
      \Staff
      \blubb
    }
  }
}

[image of music]


Other languages: deutsch, español, français, italiano, 日本語.
About automatic language selection.

LilyPond — Notation Reference