+@quotation
+@sourceimage{context-example,5cm,,}
+@end quotation
+
+Each context has the responsibility for enforcing some notation rules,
+creating some notation objects and maintaining the associated
+properties. For example, the @code{Voice} context may introduce an
+accidental and then the @code{Staff} context maintains the rule to
+show or suppress the accidental for the remainder of the measure.
+
+As another example, the synchronization of bar lines is, by default,
+handled in the @code{Score} context.
+However, in some music we may not want the bar lines to be
+synchronized -- consider a polymetric score in 4/4 and 3/4 time.
+In such cases, we must modify the default settings of the
+@code{Score} and @code{Staff} contexts.
+
+For very simple scores, contexts are created implicitly, and you need
+not be aware of them. For larger pieces, such as anything with more
+than one staff, they must be
+created explicitly to make sure that you get as many staves as you
+need, and that they are in the correct order. For typesetting pieces
+with specialized notation, it is usual to modify existing, or
+even to define totally new, contexts.
+
+In addition to the @code{Score,} @code{Staff} and
+@code{Voice} contexts there are contexts which fit between
+the score and staff levels to control staff groups, such as the
+@code{PianoStaff} and @code{ChoirStaff} contexts. There
+are also alternative staff and voice contexts, and contexts for
+lyrics, percussion, fret boards, figured bass, etc.
+
+The names of all context types are formed from one or more
+words, each word being capitalised and joined immediately to the
+preceding word with no hyphen or underscore, e.g.,
+@code{GregorianTranscriptionStaff}.
+
+@node Creating contexts
+@subsection Creating contexts
+
+There can be only one top level context: the
+@code{Score}
+context. This is created with the @code{\score} command,
+or, in simple scores, it is created automatically.
+
+For scores with only one voice and one staff, the
+@code{Voice} and @code{Staff} contexts may be left to be
+created automatically, but for more complex scores it is
+necessary to create them by hand.
+The simplest command that does this is @code{\new}.
+It is prepended to a music expression, for example
+
+@funindex \new
+@cindex new contexts
+@cindex Context, creating
+
+@example
+\new @var{type} @var{music-expression}
+@end example
+
+@noindent
+where @var{type} is a context name (like @code{Staff} or
+@code{Voice}). This command creates a new context, and starts
+interpreting the @var{music-expression} within that context.
+
+Note that there is no @code{\new Score} command;
+the single top-level @code{Score} context is introduced
+with @code{\score}.
+
+The @code{\new} command may also give a identifying name to the
+context to distinguish it from other contexts of the same type,
+
+@example
+\new @var{type} = @var{id} @var{music-expression}
+@end example
+
+Note the distinction between the name of the context type,
+@code{Staff}, @code{Voice}, etc, and
+the identifying name of a particular instance of that type,
+which can be any sequence of letters invented by the user.
+The identifying name is used to refer back to that particular
+instance of a context. We saw this in use in the section on
+lyrics in @ref{Voices and vocals}.
+
+
+@node Engravers explained
+@subsection Engravers explained
+
+@cindex engravers
+
+Every mark on the printed output of a score produced by LilyPond
+is produced by an @code{Engraver}. Thus there is an engraver
+to print staves, one to print note heads, one for stems, one for
+beams, etc, etc. In total there are over 120 such engravers!
+Fortunately, for most scores it is not necessary to know about
+more than a few, and for simple scores you do not need to know
+about any.
+
+Engravers live and operate in Contexts.
+Engravers such as the @code{Metronome_mark_engraver}, whose
+action and output applies to the score as a whole, operate in
+the highest level context -- the @code{Score} context.
+
+The @code{Clef_engraver} and @code{Key_engraver} are to be
+found in every Staff Context, as different staves may require
+different clefs and keys.
+
+The @code{Note_heads_engraver} and @code{Stem_engraver} live
+in every @code{Voice} context, the lowest level context of all.
+
+Each engraver processes the particular objects associated
+with its function, and maintains the properties that relate
+to that function. These properties, like the properties
+associated with contexts, may be modified to change the
+operation of the engraver or the appearance of those elements
+in the printed score.
+
+Engravers all have compound names formed from words which
+describe their function. Just the first word is capitalised,
+and the remainder are joined to it with underscores. Thus
+the @code{Staff_symbol_engraver} is responsible for creating the
+lines of the staff, the @code{Clef_engraver} determines and sets
+the pitch reference point on the staff by drawing a clef symbol.
+
+Here are some of the most common engravers together with their
+function. You will see it is easy to guess the function from
+the name, or vice versa.
+
+@multitable @columnfractions .3 .7
+@headitem Engraver
+ @tab Function
+@item Accidental_engraver
+ @tab Makes accidentals, cautionary and suggested accidentals
+@item Beam_engraver
+ @tab Engraves beams
+@item Clef_engraver
+ @tab Engraves clefs
+@item Dynamic_engraver
+ @tab Creates hairpins and dynamic texts
+@item Key_engraver
+ @tab Creates the key signature
+@item Metronome_mark_engraver
+ @tab Engraves metronome marking
+@item Note_heads_engraver
+ @tab Engraves note heads
+@item Rest_engraver
+ @tab Engraves rests
+@item Staff_symbol_engraver
+ @tab Engraves the five (by default) lines of the staff
+@item Stem_engraver
+ @tab Creates stems and single-stem tremulos
+@item Time_signature_engraver
+ @tab Creates time signatures
+@end multitable
+
+@smallspace
+
+We shall see later how the output of LilyPond can be changed
+by modifying the action of Engravers.
+
+
+@node Modifying context properties
+@subsection Modifying context properties
+
+@cindex context properties
+@funindex \set
+@funindex \unset
+
+Contexts are responsible for holding the values of a number of
+context @emph{properties}. Many of them can be changed to
+influence the interpretation of the input and so change the
+appearance of the output. They are changed by the
+@code{\set} command. This takes the form
+
+@example
+\set @emph{ContextName}.@emph{propertyName} = #@emph{value}
+@end example
+
+Where the @emph{ContextName} is usually @code{Score},
+@code{Staff} or @code{Voice}. It may be omitted,
+in which case @code{Voice} is assumed.
+
+The names of context properties consist of words joined
+together with no hyphens or underscores, all except the
+first having a capital letter. Here are a few examples
+of some commonly used ones. There are many more.
+
+@c attempt to force this onto a new page
+@need 50
+@multitable @columnfractions .25 .15 .45 .15
+@headitem propertyName
+ @tab Type
+ @tab Function
+ @tab Example Value
+@item extraNatural
+ @tab Boolean
+ @tab If true, set extra natural signs before accidentals
+ @tab @code{#t}, @code{#f}
+@item currentBarNumber
+ @tab Integer
+ @tab Set the current bar number
+ @tab @code{50}
+@item doubleSlurs
+ @tab Boolean
+ @tab If true, print slurs both above and below notes
+ @tab @code{#t}, @code{#f}
+@item instrumentName
+ @tab Text
+ @tab Set the name to be placed at the start of the staff
+ @tab @code{"Cello I"}
+@item fontSize
+ @tab Real
+ @tab Increase or decrease the font size
+ @tab @code{2.4}
+@item stanza
+ @tab Text
+ @tab Set the text to print before the start of a verse
+ @tab @code{"2"}
+@end multitable
+
+@noindent
+where a Boolean is either True (@code{#t}) or False (@code{#f}),
+an Integer is a positive whole number, a Real is a positive
+or negative decimal number, and text is enclosed in double
+apostrophes. Note the occurrence of hash signs,
+(@code{#}), in two different places -- as part of the Boolean
+value before the @code{t} or @code{f}, and before @emph{value}
+in the @code{\set} statement. So when a Boolean is being
+entered you need to code two hash signs, e.g., @code{##t}.
+
+Before we can set any of these properties we need to know
+in which context they operate. Sometimes this is obvious,
+but occasionally it can be tricky. If the wrong context
+is specified, no error message is produced, but the expected
+action will not take place. For example, the
+@code{instrumentName} clearly lives in the Staff context, since
+it is the staff that is to be named.
+In this example the first staff is labelled, but not the second,
+because we omitted the context name.
+
+@lilypond[quote,verbatim,ragged-right]
+<<
+ \new Staff \relative c'' {
+ \set Staff.instrumentName = #"Soprano"
+ c4 c
+ }
+ \new Staff \relative c' {
+ \set instrumentName = #"Alto" % Wrong!
+ d4 d
+ }
+>>
+@end lilypond
+
+Remember the default context name is Voice, so the second
+@code{\set} command set the property @code{instrumentName} in the
+Voice context to @qq{Alto}, but as LilyPond does not look
+for any such property in the @code{Voice} context, no
+further action took place. This is not an error, and no error
+message is logged in the log file.
+
+Similarly, if the property name is mis-spelt no error message
+is produced, and clearly the expected action cannot be performed.
+If fact, you can set any (fictitious) @q{property} using any
+name you like in any context that exists by using the
+@code{\set} command. But if the name is not
+known to LilyPond it will not cause any action to be taken.
+This is one of the reasons why it is highly recommended to
+use a context-sensitive editor with syntax highlighting for
+editing LilyPond files, such as Vim, Jedit, ConTEXT or Emacs,
+since unknown property names will be highlighted differently.
+
+The @code{instrumentName} property will take effect only
+if it is set in the @code{Staff} context, but
+some properties can be set in more than one context.
+For example, the property @code{extraNatural} is by
+default set to ##t (true) for all staves.
+If it is set to ##f (false) in one particular @code{Staff}
+context it applies just to the accidentals on that staff.
+If it is set to false in the @code{Score} context
+it applies to all staves.
+
+So this turns off extra naturals in one staff:
+
+@lilypond[quote,verbatim,ragged-right]
+<<
+ \new Staff \relative c'' {
+ ais4 aes
+ }
+ \new Staff \relative c'' {
+ \set Staff.extraNatural = ##f
+ ais4 aes
+ }
+>>
+@end lilypond
+
+@noindent
+and this turns them off in all staves:
+
+@lilypond[quote,verbatim,ragged-right]
+<<
+ \new Staff \relative c'' {
+ ais4 aes
+ }
+ \new Staff \relative c'' {
+ \set Score.extraNatural = ##f
+ ais4 aes
+ }
+>>
+@end lilypond
+
+The value of every property set in this way can be reset
+to its original value with the @code{\unset} command.
+
+The @code{\set} and @code{\unset} commands can appear anywhere
+in the input file and will take effect from the time they are
+encountered until the end of the score or until the property is
+@code{\set} or @code{\unset} again. Let's try changing the
+font size, which affects the size of the note heads (among
+other things) several times. The change is from the default
+value, not the current value.
+
+@lilypond[quote,verbatim,ragged-right,relative=1,fragment]
+c4
+% make note heads smaller
+\set fontSize = #-4
+d e
+% make note heads larger
+\set fontSize = #2.5
+f g
+% return to original size
+\unset fontSize
+a b
+@end lilypond
+
+We have now seen how to set the values of several different
+types of property. Note that integers and numbers are alway
+preceded by a hash sign, @code{#}, while a true or false value
+is specified by ##t and ##f, with two hash signs. A text
+property should be enclosed in double quotation signs, as above,
+although we shall see later that text can actually be specified
+in a much more general way by using the very powerful
+@code{markup} command.
+
+
+@funindex \with
+
+Context properties may also be set at the time the context is
+created. Sometimes this is a clearer way of specifying a
+property value if it is to remain fixed for the duration of
+the context. When a context is created with a @code{\new}
+command it may be followed immediately by a
+@code{\with @{ .. @}} block in which the property values are
+set. For example, if we wish to suppress the printing of
+extra naturals for the duration of a staff we would write:
+
+@example
+\new Staff \with @{ extraNatural = ##f @}
+@end example
+
+@noindent
+like this:
+
+@lilypond[quote,verbatim,ragged-right]
+<<
+ \new Staff
+ \relative c'' {
+ gis ges aes ais
+ }
+ \new Staff \with { extraNatural = ##f }
+ \relative c'' {
+ gis ges aes ais
+ }
+>>
+@end lilypond
+
+In effect this overrides the default value of the property. It
+may still be changed dynamically using @code{\set} and returned
+to its (new) default value with @code{\unset}.
+
+@node Adding and removing engravers
+@subsection Adding and removing engravers
+
+@cindex Engravers, adding
+@cindex Engravers, removing
+
+@funindex \consists
+@funindex \remove
+
+We have seen that contexts each contain several engravers, each
+of which is responsible for producing a particular part of the
+output, like bar lines, staves, note heads, stems, etc. If an
+engraver is removed from a context it can no longer produce its
+output. This is a crude way of modifying the output, but it
+can sometimes be useful.
+
+@subsubsection Changing a single context
+
+To remove an engraver from a single context we use the
+@code{\with} command placed immediately after the context creation
+command, as in the previous section.
+
+As an
+illustration let's repeat an example from the previous
+section with the staff lines removed. Remember that the
+staff lines are produced by the Staff_symbol_engraver.
+
+@lilypond[quote,verbatim,ragged-right]
+\new Staff \with {
+ \remove Staff_symbol_engraver
+}
+\relative c' {
+ c4
+ \set fontSize = #-4 % make note heads smaller
+ d e
+ \set fontSize = #2.5 % make note heads larger
+ f g
+ \unset fontSize % return to original size
+ a b