[ << Changing defaults ] | [Top][Contents][Index] | [ Notation manual tables >> ] |
[ < ] | [ Up : Interpretation contexts ] | [ Explaining the Internals Reference > ] |
5.1.7 Context layout order
Contexts are normally positioned in a system from top to bottom in the order in which they are encountered in the input file. When contexts are nested, the outer context will include inner nested contexts as specified in the input file, provided the inner contexts are included in the outer context’s “accepts” list. Nested contexts which are not included in the outer context’s “accepts” list will be repositioned below the outer context rather than nested within it.
The “accepts” list of a context can be changed with the
\accepts
or \denies
commands. \accepts
adds a
context to the “accepts” list and \denies
removes a context
from the list.
For example, a TabStaff
by default \accepts
TabVoice
contexts and \denies
Voice
contexts.
If a Voice
context is written within the TabStaff
,
it would be set on a separate staff.
\score { \new TabStaff << \new TabVoice { c'1 } \new Voice { d'1 } >> }
However, by using the \accepts
command, the Voice
context can be forced onto the TabStaff
\score { \new TabStaff << \new TabVoice { c'1 } \new Voice { d'1 } >> \layout { \context { \TabStaff \accepts Voice } } }
\denies
is mainly used when a new context is being based on
another, but the required nesting differs. For example, the
VaticanaStaff
context is based on the Staff
context, but
with the VaticanaVoice
context substituted for the Voice
context in the “accepts” list.
Note that a context will be silently created implicitly if a command is encountered when there is no suitable context available to contain it.
Within a context definition, the type of subcontext to be
implicitly created is specified using \defaultchild
. A
number of music events require a ‘Bottom’ context: when such
an event is encountered, subcontexts are created recursively until
reaching a context with no ‘defaultchild’ setting.
Implicit context creation can at times give rise to unexpected new
staves or scores. Using \new
to create contexts explicitly
avoids those problems.
Sometimes a context is required to exist for just a brief period, a good example being the staff context for an ossia. This is usually achieved by introducing the context definition at the appropriate place in parallel with corresponding section of the main music. By default, the temporary context will be placed below all the existing contexts. To reposition it above the context called “main”, it should be defined like this:
\new Staff \with { alignAboveContext = "main" }
A similar situation arises when positioning a temporary lyrics
context within a multi-staff layout such as a ChoirStaff
,
for example, when adding a second verse to a repeated section.
By default the temporary lyrics context will be placed beneath the
lower staves. By defining the temporary lyrics context with
alignBelowContext
it can be positioned correctly beneath
the (named) lyrics context containing the first verse.
Examples showing this repositioning of temporary contexts can be found elsewhere – see Nesting music expressions, Modifying single staves and Techniques specific to lyrics.
See also
Learning Manual: Nesting music expressions.
Notation Reference: Modifying single staves, Techniques specific to lyrics.
Application Usage: An extra staff appears.
Installed Files: ‘ly/engraver-init.ly’.
[ << Changing defaults ] | [Top][Contents][Index] | [ Notation manual tables >> ] |
[ < ] | [ Up : Interpretation contexts ] | [ Explaining the Internals Reference > ] |