| [ << Changing defaults ] | [Top][Contents][Index][ ? ] | [ Notation manual tables >> ] | ||
| [ < The override command ] | [ Up : Modifying properties ] | [ set versus override > ] | ||
5.3.4 The \tweak command
Changing grob properties
with \override causes the changes to apply to all of the
given grobs in the context at the moment the change applies.
Sometimes, however, it is desirable to have changes apply to just
one grob, rather than to all grobs in the affected context. This is
accomplished with the \tweak command, which has the following
syntax:
\tweak #'grob-property#value
The \tweak command applies to the object that immediately
follows value in the music stream.
For an introduction to the syntax and uses of the tweak command see Tweaking methods.
When several similar items are placed at the same musical moment,
the \override command cannot be used to modify just one of
them – this is where the \tweak command must be used.
Items which may appear more than once at the same musical moment
include the following:
- note heads of notes inside a chord
- articulation signs on a single note
- ties between notes in a chord
- tuplet brackets starting at the same time
In this example, the color of one note head and the type of another note head are modified within a single chord:
< c \tweak #'color #red d g \tweak #'duration-log #1 a > 4
\tweak can be used to modify slurs:
c-\tweak #'thickness #5 ( d e f)
For the \tweak command to work, it must
remain immediately adjacent to the object to which it is
to apply after the input file has been converted to a music stream.
At times, LilyPond may insert additional items into the music stream
during the parsing process. For example, when a note that is not
explicitly part of a chord will be placed in a chord by LilyPond,
so notes to be modified with \tweak must be placed inside
a chord construct:
\tweak #'color #red c4 <\tweak #'color #red c>4
The \tweak command cannot be used to modify any item
that does not appear explicitly in the input file. In particular
it cannot be used to modify stems,
beams or accidentals directly, since these are generated later by
note heads, rather than by music elements in the input stream.
Nor can \tweak be used to modify clefs or time
signatures, since these become separated from any preceding
\tweak command in the input stream by the automatic
insertion of extra elements required to specify the context.
Several \tweak commands may be placed before a
notational element – all affect it:
c -\tweak #'style #'dashed-line -\tweak #'dash-fraction #0.2 -\tweak #'thickness #3 -\tweak #'color #red \glissando f'
The music stream which is generated from a section of an input file,
including any automatically inserted elements, may be examined,
see
Displaying music expressions. This may be helpful in
determining what may be modified by a \tweak command, or
in determining how to adjust the input to make a \tweak
apply.
See also
Learning Manual: Tweaking methods.
Extending: Displaying music expressions.
Known issues and warnings
The \tweak command cannot be used inside a variable.
The \tweak commands cannot be used in \lyricmode.
The \tweak command will apply to only the first of several
generated ties in a chord.
| [ << Changing defaults ] | [Top][Contents][Index][ ? ] | [ Notation manual tables >> ] | ||
| [ < The override command ] | [ Up : Modifying properties ] | [ set versus override > ] | ||