+@cindex ambitus engraver
+
+Engravers can also be added to individual contexts.
+The command to do this is
+
+@code{\consists @emph{Engraver_name}},
+
+placed inside a @code{\with} block. Some vocal scores
+have an @rglos{ambitus} placed at the beginning of a
+staff to indicate the range of notes in that staff.
+The ambitus is produced by the @code{Ambitus_engraver},
+which is not normally included in any context. If
+we add it to the @code{Voice} context it calculates
+the range from that voice only:
+
+@lilypond[quote,verbatim,ragged-right]
+\new Staff <<
+ \new Voice \with {
+ \consists Ambitus_engraver
+ }
+ \relative c'' {
+ \voiceOne
+ c a b g
+ }
+ \new Voice
+ \relative c' {
+ \voiceTwo
+ c e d f
+ }
+>>
+@end lilypond
+
+@noindent
+but if we add the Ambitus engraver to the
+@code{Staff} context it calculates the range from all
+the notes in all the voices on that staff:
+
+@lilypond[quote,verbatim,ragged-right]
+\new Staff \with {
+ \consists Ambitus_engraver
+ }
+ <<
+ \new Voice
+ \relative c'' {
+ \voiceOne
+ c a b g
+ }
+ \new Voice
+ \relative c' {
+ \voiceTwo
+ c e d f
+ }
+>>
+@end lilypond
+
+@subsubheading Changing all contexts of the same type
+
+The examples above show how to remove or add engravers to
+individual contexts. It is also possible to remove or add
+engravers to every context of a specific type by placing the
+commands in the appropriate context in a @code{\layout}
+block. For example, If we wanted to show ambiti for every
+staff in a four-staff score we could write
+
+@lilypond[quote,verbatim,ragged-right]
+\score {
+ <<
+ \new Staff <<
+ \relative c'' { c a b g }
+ >>
+ \new Staff <<
+ \relative c' { c a b g }
+ >>
+ \new Staff <<
+ \clef "G_8"
+ \relative c' { c a b g }
+ >>
+ \new Staff <<
+ \clef "bass"
+ \relative c { c a b g }
+ >>
+ >>
+ \layout {
+ \context {
+ \Staff
+ \consists Ambitus_engraver
+ }
+ }
+}
+@end lilypond
+
+@noindent
+The default values of context properties may also be set
+for all contexts of a particular type by including the
+@code{\set} command in a @code{\context} block in the
+same way.
+
+@node Extending the templates
+@section Extending the templates
+
+You've read the tutorial, you know how to write music, you
+understand the fundamental concepts. But how can you
+get the staves that you want? Well, you can find lots of
+templates (see @ref{Templates}) which may give you a start.
+But what
+if you want something that isn't covered there? Read on.
+
+TODO Add links to templates after they have been moved to LSR
+
+@menu
+* Soprano and cello::
+* Four-part SATB vocal score::
+* Building a score from scratch::
+@end menu
+
+@node Soprano and cello
+@subsection Soprano and cello
+
+Start off with the template that seems closest to what you want to end
+up with. Let's say that you want to write something for soprano and
+cello. In this case, we would start with @q{Notes and lyrics} (for the
+soprano part).
+
+@example
+\version @w{"@version{}"}
+melody = \relative c' @{
+ \clef treble
+ \key c \major
+ \time 4/4
+ a4 b c d
+@}
+
+text = \lyricmode @{
+ Aaa Bee Cee Dee
+@}
+
+\score @{
+ <<
+ \new Voice = "one" @{
+ \autoBeamOff
+ \melody
+ @}
+ \new Lyrics \lyricsto "one" \text
+ >>
+ \layout @{ @}
+ \midi @{ @}
+@}
+@end example
+
+Now we want to add a cello part. Let's look at the @q{Notes only} example:
+
+@example
+\version @w{"@version{}"}
+melody = \relative c' @{
+ \clef treble
+ \key c \major
+ \time 4/4
+ a4 b c d
+@}
+
+\score @{
+ \new Staff \melody
+ \layout @{ @}
+ \midi @{ @}
+@}
+@end example
+
+We don't need two @code{\version} commands. We'll need the
+@code{melody} section. We don't want two @code{\score} sections
+-- if we had two @code{\score}s, we'd get the two parts separately.
+We want them together, as a duet. Within the @code{\score}
+section, we don't need two @code{\layout} or @code{\midi}.
+
+If we simply cut and paste the @code{melody} section, we would
+end up with two @code{melody} definitions. This would not generate
+an error, but the second one would be used for both melodies.
+So let's rename them to make them distinct. We'll call the
+section for the soprano @code{sopranoMusic} and the section for
+the cello @code{celloMusic}. While we're doing this, let's rename
+@code{text} to be @code{sopranoLyrics}. Remember to rename both
+instances of all these names -- both the initial definition (the
+@code{melody = \relative c' @{ } part) and the name's use (in the
+@code{\score} section).
+
+While we're doing this, let's change the cello part's staff --
+celli normally use bass clef. We'll also give the cello some
+different notes.
+
+@example
+\version @w{"@version{}"}
+sopranoMusic = \relative c' @{
+ \clef treble
+ \key c \major
+ \time 4/4
+ a4 b c d
+@}
+
+sopranoLyrics = \lyricmode @{
+ Aaa Bee Cee Dee
+@}
+
+celloMusic = \relative c @{
+ \clef bass
+ \key c \major
+ \time 4/4
+ d4 g fis8 e d4
+@}
+
+\score @{
+ <<
+ \new Voice = "one" @{
+ \autoBeamOff
+ \sopranoMusic
+ @}
+ \new Lyrics \lyricsto "one" \sopranoLyrics
+ >>
+ \layout @{ @}
+ \midi @{ @}
+@}
+@end example
+
+This is looking promising, but the cello part won't appear in the
+score -- we haven't used it in the @code{\score} section. If we
+want the cello part to appear under the soprano part, we need to add
+
+@example
+\new Staff \celloMusic
+@end example
+
+@noindent
+underneath the soprano stuff. We also need to add @code{<<} and
+@code{>>} around the music -- that tells LilyPond that there's
+more than one thing (in this case, two @code{Staves}) happening
+at once. The @code{\score} looks like this now
+
+@c Indentation in this example is deliberately poor
+@example
+\score @{
+ <<
+ <<
+ \new Voice = "one" @{
+ \autoBeamOff
+ \sopranoMusic
+ @}
+ \new Lyrics \lyricsto "one" \sopranoLyrics
+ >>
+ \new Staff \celloMusic
+ >>
+ \layout @{ @}
+ \midi @{ @}
+@}
+@end example
+
+@noindent
+This looks a bit messy; the indentation is messed up now. That is
+easily fixed. Here's the complete soprano and cello template.
+
+@lilypond[quote,verbatim,ragged-right]
+\version "2.11.38"
+sopranoMusic = \relative c' {
+ \clef treble
+ \key c \major
+ \time 4/4
+ a4 b c d
+}
+
+sopranoLyrics = \lyricmode {
+ Aaa Bee Cee Dee
+}
+
+celloMusic = \relative c {
+ \clef bass
+ \key c \major
+ \time 4/4
+ d4 g fis8 e d4
+}
+
+\score {
+ <<
+ <<
+ \new Voice = "one" {
+ \autoBeamOff
+ \sopranoMusic
+ }
+ \new Lyrics \lyricsto "one" \sopranoLyrics
+ >>
+ \new Staff \celloMusic
+ >>
+ \layout { }
+ \midi { }
+}
+@end lilypond
+
+
+@node Four-part SATB vocal score
+@subsection Four-part SATB vocal score
+
+Most vocal scores of music written for four-part mixed choir
+with orchestral accompaniment such as Mendelssohn's Elijah or
+Handel's Messiah have the choral music and words on four
+staves, one for each of SATB, with a piano reduction of the
+orchestral accompaniment underneath. Here's an example
+from Handel's Messiah:
+
+@c The following should appear as music without code
+@lilypond[quote,ragged-right]
+global = { \key d \major \time 4/4 }
+sopMusic = \relative c'' {
+ \clef "treble"
+ r4 d2 a4 | d4. d8 a2 | cis4 d cis2 |
+}
+sopWords = \lyricmode {
+ Wor -- thy is the lamb that was slain
+}
+altoMusic = \relative a' {
+ \clef "treble"
+ r4 a2 a4 | fis4. fis8 a2 | g4 fis e2 |
+}
+altoWords = \sopWords
+tenorMusic = \relative c' {
+ \clef "G_8"
+ r4 fis2 e4 | d4. d8 d2 | e4 a, cis2 |
+}
+tenorWords = \sopWords
+bassMusic = \relative c' {
+ \clef "bass"
+ r4 d2 cis4 | b4. b8 fis2 | e4 d a'2 |
+}
+bassWords = \sopWords
+upper = \relative a' {
+ \clef "treble"
+ \global
+ r4 <a d fis>2 <a e' a>4 |
+ <d fis d'>4. <d fis d'>8 <a d a'>2 |
+ <g cis g'>4 <a d fis> <a cis e>2 |
+}
+lower = \relative c, {
+ \clef "bass"
+ \global
+ <d d'>4 <d d'>2 <cis cis'>4 |
+ <b b'>4. <b' b'>8 <fis fis'>2 |
+ <e e'>4 <d d'> <a' a'>2 |
+}
+
+\score {
+ << % combine ChoirStaff and PianoStaff in parallel
+ \new ChoirStaff <<
+ \new Staff = "sopranos" <<
+ \set Staff.instrumentName = "Soprano"
+ \new Voice = "sopranos" { \global \sopMusic }
+ >>
+ \new Lyrics \lyricsto "sopranos" { \sopWords }
+ \new Staff = "altos" <<
+ \set Staff.instrumentName = "Alto"
+ \new Voice = "altos" { \global \altoMusic }
+ >>
+ \new Lyrics \lyricsto "altos" { \altoWords }
+ \new Staff = "tenors" <<
+ \set Staff.instrumentName = "Tenor"
+ \new Voice = "tenors" { \global \tenorMusic }
+ >>
+ \new Lyrics \lyricsto "tenors" { \tenorWords }
+ \new Staff = "basses" <<
+ \set Staff.instrumentName = "Bass"
+ \new Voice = "basses" { \global \bassMusic }
+ >>
+ \new Lyrics \lyricsto "basses" { \bassWords }
+ >> % end ChoirStaff
+
+ \new PianoStaff <<
+ \set PianoStaff.instrumentName = "Piano "
+ \new Staff = "upper" \upper
+ \new Staff = "lower" \lower
+ >>
+ >>
+}
+@end lilypond
+
+None of the templates provides this layout exactly. The
+nearest is @q{SATB vocal score and automatic piano reduction},
+but we need to change the layout and add a piano
+accompaniment which is not derived automatically from the
+vocal parts. The variables holding the music and words for
+the vocal parts are fine, but we shall need to add variables for
+the piano reduction.
+
+The order in which the contexts appear in the ChoirStaff of
+the template do not correspond with the order in the vocal
+score shown above. We need to rearrange them so there are
+four staves with the words written directly underneath the
+notes for each part.
+All the voices should be @code{\voiceOne}, which is
+the default, so the @code{\voiceXXX} commands should be removed.
+We also need to specify the tenor clef for the tenors.
+The way in which lyrics are specified in the template has not yet
+been encountered so we need to use the method with which we are
+familiar. We should also add the names of each staff.
+
+Doing this gives for our ChoirStaff:
+
+@example
+ \new ChoirStaff <<
+ \new Staff = "sopranos" <<
+ \set Staff.instrumentName = "Soprano"
+ \new Voice = "sopranos" @{ \global \sopMusic @}
+ >>
+ \new Lyrics \lyricsto "sopranos" @{ \sopWords @}
+ \new Staff = "altos" <<
+ \set Staff.instrumentName = "Alto"
+ \new Voice = "altos" @{ \global \altoMusic @}
+ >>
+ \new Lyrics \lyricsto "altos" @{ \altoWords @}
+ \new Staff = "tenors" <<
+ \set Staff.instrumentName = "Tenor"
+ \new Voice = "tenors" @{ \global \tenorMusic @}
+ >>
+ \new Lyrics \lyricsto "tenors" @{ \tenorWords @}
+ \new Staff = "basses" <<
+ \set Staff.instrumentName = "Bass"
+ \new Voice = "basses" @{ \global \bassMusic @}
+ >>
+ \new Lyrics \lyricsto "basses" @{ \bassWords @}
+ >> % end ChoirStaff
+@end example
+
+Next we must work out the piano part. This is
+easy - we just pull out the piano part from the
+@q{Solo piano} template:
+
+@example
+\new PianoStaff <<
+ \set PianoStaff.instrumentName = "Piano "
+ \new Staff = "upper" \upper
+ \new Staff = "lower" \lower
+>>
+@end example
+
+and add the variable definitions for @code{upper}
+and @code{lower}.
+
+The ChoirStaff and PianoStaff must be combined
+using angle brackets as we want them to be
+stacked one above the other:
+
+@example
+<< % combine ChoirStaff and PianoStaff one above the other
+ \new ChoirStaff <<
+ \new Staff = "sopranos" <<
+ \new Voice = "sopranos" @{ \global \sopMusic @}
+ >>
+ \new Lyrics \lyricsto "sopranos" @{ \sopWords @}
+ \new Staff = "altos" <<
+ \new Voice = "altos" @{ \global \altoMusic @}
+ >>
+ \new Lyrics \lyricsto "altos" @{ \altoWords @}
+ \new Staff = "tenors" <<
+ \clef "G_8" % tenor clef
+ \new Voice = "tenors" @{ \global \tenorMusic @}
+ >>
+ \new Lyrics \lyricsto "tenors" @{ \tenorWords @}
+ \new Staff = "basses" <<
+ \clef "bass"
+ \new Voice = "basses" @{ \global \bassMusic @}
+ >>
+ \new Lyrics \lyricsto "basses" @{ bassWords @}
+ >> % end ChoirStaff
+
+ \new PianoStaff <<
+ \set PianoStaff.instrumentName = "Piano "
+ \new Staff = "upper" \upper
+ \new Staff = "lower" \lower
+ >>
+>>
+@end example
+
+Combining all these together and adding the music
+for the three bars of the example above gives:
+
+@lilypond[quote,verbatim,ragged-right]
+\version "2.11.38"
+global = { \key d \major \time 4/4 }
+sopMusic = \relative c'' {
+ \clef "treble"
+ r4 d2 a4 | d4. d8 a2 | cis4 d cis2 |
+}
+sopWords = \lyricmode {
+ Wor -- thy is the lamb that was slain
+}
+altoMusic = \relative a' {
+ \clef "treble"
+ r4 a2 a4 | fis4. fis8 a2 | g4 fis fis2 |
+}
+altoWords = \sopWords
+tenorMusic = \relative c' {
+ \clef "G_8"
+ r4 fis2 e4 | d4. d8 d2 | e4 a, cis2 |
+}
+tenorWords = \sopWords
+bassMusic = \relative c' {
+ \clef "bass"
+ r4 d2 cis4 | b4. b8 fis2 | e4 d a'2 |
+}
+bassWords = \sopWords
+upper = \relative a' {
+ \clef "treble"
+ \global
+ r4 <a d fis>2 <a e' a>4 |
+ <d fis d'>4. <d fis d'>8 <a d a'>2 |
+ <g cis g'>4 <a d fis> <a cis e>2 |
+}
+lower = \relative c, {
+ \clef "bass"
+ \global
+ <d d'>4 <d d'>2 <cis cis'>4 |
+ <b b'>4. <b' b'>8 <fis fis'>2 |
+ <e e'>4 <d d'> <a' a'>2 |
+}
+
+\score {
+ << % combine ChoirStaff and PianoStaff in parallel
+ \new ChoirStaff <<
+ \new Staff = "sopranos" <<
+ \set Staff.instrumentName = "Soprano"
+ \new Voice = "sopranos" { \global \sopMusic }
+ >>
+ \new Lyrics \lyricsto "sopranos" { \sopWords }
+ \new Staff = "altos" <<
+ \set Staff.instrumentName = "Alto"
+ \new Voice = "altos" { \global \altoMusic }
+ >>
+ \new Lyrics \lyricsto "altos" { \altoWords }
+ \new Staff = "tenors" <<
+ \set Staff.instrumentName = "Tenor"
+ \new Voice = "tenors" { \global \tenorMusic }
+ >>
+ \new Lyrics \lyricsto "tenors" { \tenorWords }
+ \new Staff = "basses" <<
+ \set Staff.instrumentName = "Bass"
+ \new Voice = "basses" { \global \bassMusic }
+ >>
+ \new Lyrics \lyricsto "basses" { \bassWords }
+ >> % end ChoirStaff
+
+ \new PianoStaff <<
+ \set PianoStaff.instrumentName = "Piano "
+ \new Staff = "upper" \upper
+ \new Staff = "lower" \lower
+ >>
+ >>
+}
+@end lilypond
+
+
+@node Building a score from scratch
+@subsection Building a score from scratch
+
+After gaining some facility with writing LilyPond code you
+may find that it is easier to build a score from scratch
+rather than modifying one of the templates. You can also
+develop your own style this way to suit the sort of music you
+like. Let's see how to put together the score for an organ
+prelude as an example.
+
+We begin with a header section. Here go the title, name
+of composer, etc, then come any variable definitions, and
+finally the score block. Let's start with these in outline
+and fill in the details later.
+
+We'll use the first two bars of Bach's prelude
+based on @emph{Jesu, meine Freude} which is written for two
+manuals and pedal organ. You can see these two bars of music
+at the bottom of this section. The top manual part has two voices,
+the lower and pedal organ one each. So we need four
+music definitions and one to define the time signature
+and key:
+
+@example
+\version @w{"@version{}"}
+\header @{
+ title = "Jesu, meine Freude"
+ composer = "J S Bach"
+@}
+TimeKey = @{ \time 4/4 \key c \minor @}
+ManualOneVoiceOneMusic = @{s1@}
+ManualOneVoiceTwoMusic = @{s1@}
+ManualTwoMusic = @{s1@}
+PedalOrganMusic = @{s1@}
+
+\score @{
+@}
+@end example
+
+For now we've just used a spacer note, @code{s1},
+instead of the real music. We'll add that later.
+
+Next let's see what should go in the score block.
+We simply mirror the staff structure we want.
+Organ music is usually written on three staves,
+one for each manual and one for the pedals. The
+manual staves should be bracketed together so we
+need to use a PianoStaff for them. The first
+manual part needs two voices and the second manual
+part just one.
+
+@example
+ \new PianoStaff <<
+ \new Staff = "ManualOne" <<
+ \new Voice @{ \ManualOneVoiceOneMusic @}
+ \new Voice @{ \ManualOneVoiceTwoMusic @}
+ >> % end ManualOne Staff context
+ \new Staff = "ManualTwo" <<
+ \new Voice @{ \ManualTwoMusic @}
+ >> % end ManualTwo Staff context
+ >> % end PianoStaff context
+@end example
+
+Next we need to add a staff for the pedal organ.
+This goes underneath the PianoStaff, but it must
+be simultaneous with it, so we need angle brackets
+round the two. Missing these out would generate
+an error in the log file. It's a common mistake
+which you'll make sooner or later! Try copying
+the final example at the end of this section,
+remove these angle brackets, and compile it to
+see what errors it generates.
+
+@example
+<< % PianoStaff and Pedal Staff must be simultaneous
+ \new PianoStaff <<
+ \new Staff = "ManualOne" <<
+ \new Voice @{ \ManualOneVoiceOneMusic @}
+ \new Voice @{ \ManualOneVoiceTwoMusic @}
+ >> % end ManualOne Staff context
+ \new Staff = "ManualTwo" <<
+ \new Voice @{ \ManualTwoMusic @}
+ >> % end ManualTwo Staff context
+ >> % end PianoStaff context
+ \new Staff = "PedalOrgan" <<
+ \new Voice @{ \PedalOrganMusic @}
+ >>
+>>
+@end example
+
+It is not strictly necessary to use the simultaneous construct
+@code{<< >>} for the manual two staff and the pedal organ staff,
+since they contain only one music expression, but it does no harm
+and always using angle brackets after @code{\new Staff} is a good
+habit to cultivate in case there are multiple voices.
+
+Let's add this structure to the score block, and adjust the
+indenting. We also add the appropriate clefs, ensure the
+second voice stems point down with @code{\voiceTwo} and
+enter the time signature and key to each staff using our
+predefined variable, @code{\TimeKey}.
+
+@example
+\score @{
+ << % PianoStaff and Pedal Staff must be simultaneous
+ \new PianoStaff <<
+ \new Staff = "ManualOne" <<
+ \TimeKey % set time signature and key
+ \clef "treble"
+ \new Voice @{ \ManualOneVoiceOneMusic @}
+ \new Voice @{ \voiceTwo \ManualOneVoiceTwoMusic @}
+ >> % end ManualOne Staff context
+ \new Staff = "ManualTwo" <<
+ \TimeKey
+ \clef "bass"
+ \new Voice @{ \ManualTwoMusic @}
+ >> % end ManualTwo Staff context
+ >> % end PianoStaff context
+ \new Staff = "PedalOrgan" <<
+ \TimeKey
+ \clef "bass"
+ \new Voice @{ \PedalOrganMusic @}
+ >> % end PedalOrgan Staff
+ >>
+@} % end Score context
+@end example
+
+That completes the structure. Any three-staff organ music
+will have a similar structure, although the number of voices
+may vary. All that remains now
+is to add the music, and combine all the parts together.
+
+@lilypond[quote,verbatim,ragged-right]
+\version "2.11.38"
+\header {
+ title = "Jesu, meine Freude"
+ composer = "J S Bach"
+}
+TimeKey = { \time 4/4 \key c \minor }
+ManualOneVoiceOneMusic = \relative g' {
+ g4 g f ees | d2 c2 |
+}
+ManualOneVoiceTwoMusic = \relative c' {
+ ees16 d ees8~ ees16 f ees s c8 d~ d c~ |
+ c c4 b8 c8. g16 c b c d |
+}
+ManualTwoMusic = \relative c' {
+ c16 b c8~ c16 b c g a8 g~ g16 g aes ees |
+ f ees f d g aes g f ees d e8~ ees16 f ees d |
+}
+PedalOrganMusic = \relative c {
+ r8 c16 d ees d ees8~ ees16 a, b g c b c8 |
+ r16 g ees f g f g8 c,2 |
+ }
+
+\score {
+ << % PianoStaff and Pedal Staff must be simultaneous
+ \new PianoStaff <<
+ \new Staff = "ManualOne" <<
+ \TimeKey % set time signature and key
+ \clef "treble"
+ \new Voice { \ManualOneVoiceOneMusic }
+ \new Voice { \voiceTwo \ManualOneVoiceTwoMusic }
+ >> % end ManualOne Staff context
+ \new Staff = "ManualTwo" <<
+ \TimeKey
+ \clef "bass"
+ \new Voice { \ManualTwoMusic }
+ >> % end ManualTwo Staff context
+ >> % end PianoStaff context
+ \new Staff = "PedalOrgan" <<
+ \TimeKey
+ \clef "bass"
+ \new Voice { \PedalOrganMusic }
+ >> % end PedalOrgan Staff
+ >>
+} % end Score context
+@end lilypond
+