[ << Changing defaults ] | [Top][Contents][Index][ ? ] | [ Interfaces for programmers >> ] | ||
[ < The override command ] | [ Up : Modifying properties ] | [ set versus override > ] |
5.3.4 The \tweak
command
In some cases, it is possible to take a short-cut for tuning
graphical objects. For objects that are created directly from
an item in the input file, you can use the \tweak
command.
For example:
< c \tweak #'color #red d g \tweak #'duration-log #1 a > 4 -\tweak #'padding #8 -^
But the main use of the \tweak
command is to modify just
one of a number of notation elements which start at the same musical
moment, like the notes of a chord, or tuplet brackets which start
at the same time.
For an introduction to the syntax and uses of the tweak command see Tweaking methods.
The \tweak
command sets a property in the following object
directly, without requiring the grob name or context to be
specified. For this to work, it is necessary for the \tweak
command to remain immediately adjacent to the object to which it is
to apply after the input file has been converted to a music stream.
This is often not the case, as many additional elements are inserted
into the music stream implicitly. For example, when a note which is
not part of a chord is processed, Lilypond implicitly inserts a
ChordEvent
event before the note, so separating the tweak
from the note. However, if chord symbols are placed round the
tweak and the note, the \tweak
command comes after the
ChordEvent
in the music stream, so remaining adjacent to the
note, and able to modify it.
So, this works:
<\tweak #'color #red c>4
but this does not:
\tweak #'color #red c4
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
and \tweak
may be used to modify any single occurrence of
these items.
Notably the \tweak
command cannot be used to modify stems,
beams or accidentals, since these are generated later by note heads,
rather than by music elements in the input stream. Nor can a
\tweak
command 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.
But the \tweak
command can be used as an alternative to
the \override
command to modify those notational elements
that do not cause any additional implicit elements to be added
before them in the music stream. For example, slurs may be
modified in this way:
c-\tweak #'thickness #5 ( d e f)
Also 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.
See also
Learning Manual: Tweaking methods.
Notation Reference: 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 cannot be used to modify the control
points of just one of several ties in a chord, other than the first
one encountered in the input file.
[ << Changing defaults ] | [Top][Contents][Index][ ? ] | [ Interfaces for programmers >> ] | ||
[ < The override command ] | [ Up : Modifying properties ] | [ set versus override > ] |