5.1.5 Changing context default settings

Context and grob properties can be changed with \set and \override commands, as described in Modifying properties. These commands create music events, making the changes take effect at the point in time the music is being processed.

In contrast, this section explains how to change the default values of context and grob properties at the time the context is created. There are two ways of doing this. One modifies the default values in all contexts of a particular type, the other modifies the default values in just one particular instance of a context.


Changing all contexts of the same type

The default context settings which are to be used for typesetting in Score, Staff, Voice and other contexts may be specified in a \context block within any \layout block.

Settings for Midi output as opposed to typesetting will have to be separately specified in \midi blocks (see Output definitions - blueprints for contexts).

The \layout block should be placed within the \score block to which it is to apply, after the music.

\layout {
  \context {
    \Voice
    [context settings for all Voice contexts]
  }
  \context {
    \Staff
    [context settings for all Staff contexts]
  }
}

The following types of settings may be specified:

Property-setting commands can be placed in a \layout block without being enclosed in a \context block. Such settings are equivalent to including the same property-setting commands at the start of every context of the type specified. If no context is specified every bottom-level context is affected, see Bottom-level contexts - voices. The syntax of a property-setting command in a \layout block is the same as the same command written in the music stream.

\score {
  \new Staff {
    \relative {
      a'4^"Smaller font" a a a
      a4 a a a
    }
  }
  \layout {
    \accidentalStyle dodecaphonic
    \set fontSize = #-4
    \override Voice.Stem.thickness = #4.0
  }
}

[image of music]


Changing just one specific context

The context properties of just one specific context instance can be changed in a \with block. All other context instances of the same type retain the default settings built into LilyPond and modified by any \layout block within scope. The \with block must be placed immediately after the \new context-type command:

\new Staff \with { [context settings for this context instance only] }
{
  …
}

Alternatively, if the music is being entered using the short form of the input mode-specifying commands, e.g. \chords rather than \chordmode, the \with command must be placed immediately after the mode-specifying command:

\chords \with { [context settings for this (implicit) context instance only] }
{
  …
}

as it is the implicit context created by these short forms which should be modified. The same consideration applies to the other input mode-specifying short forms (\drums, \figures), see Input modes.

Since context modifications specified in \with blocks are inside music, they will affect all outputs (typesetting and Midi) as opposed to changes within an output definition.

The following types of settings may be specified:

See also

Notation Reference: Input modes


Order of precedence

The value of a property which applies at a particular time is determined as follows:

See also

Learning Manual: Modifying context properties.

Notation Reference: Contexts explained, Bottom-level contexts - voices, The \set command, The \override command, The \layout block.


Jiné jazyky: català, deutsch, español, français, italiano, 日本語.
About automatic language selection.

LilyPond — Notation Reference v2.21.0 (Vývojářská větev).