lilypond-learning: The override command
The ‘\override’ command
.......................
We have already met the commands ‘\set’ and ‘\with’, used to change the
DONTPRINTYET properties of *contexts* and to remove and add *engravers*, in
Modifying context properties, and *noteAdding and removing
DONTPRINTYET properties of *contexts* and to remove and add *engravers*, in
Modifying context properties, and Adding and removing
engravers. We must now introduce some more important commands.
The command to change the properties of *layout objects* is
‘\override’. Because this command has to modify internal properties
deep within LilyPond its syntax is not as simple as the commands you
have used so far. It needs to know precisely which property of which
object in which context has to be modified, and what its new value is to
be. Let’s see how this is done.
The general syntax of this command is:
\override CONTEXT.LAYOUTOBJECT.LAYOUT-PROPERTY = #VALUE
This will set the property with the name LAYOUT-PROPERTY of the layout
object with the name LAYOUTOBJECT, which is a member of the CONTEXT
context, to the value VALUE.
The CONTEXT may be omitted (and usually is) when the required context
is unambiguously implied and is one of lowest level contexts, i.e.,
‘Voice’, ‘ChordNames’ or ‘Lyrics’, and we shall omit it in many of the
following examples. We shall see later when it must be specified.
Later sections deal comprehensively with properties and their values,
see Types of properties. But in this section we shall use just
a few simple properties and values which are easily understood in order
to illustrate the format and use of these commands.
LilyPond’s primary expressions are musical items like notes,
durations, and markups. More basic expressions like numbers, strings,
and lists are processed in ‘Scheme mode’, which is invoked by prefixing
the value with ‘#’. Although the values may sometimes have a valid
representation in LilyPond’s musical mode, this manual will always use
‘#’ for their entry for the sake of consistency. For more information
about Scheme mode, see (lilypond-extending)LilyPond Scheme
syntax.
‘\override’ is the most common command used in tweaking, and most of
the rest of this chapter will be directed to presenting examples of how
it is used. Here is a simple example to change the color of the note
head:
c4 d
\override NoteHead.color = #red
e4 f |
\override NoteHead.color = #green
g4 a b c |
[image src="" alt="[image of music]" text="image of music" ]