]> git.donarmstrong.com Git - lilypond.git/blobdiff - Documentation/user/tweaks.itely
Merge branch 'lilypond/translation' of ssh://jomand@git.sv.gnu.org/srv/git/lilypond...
[lilypond.git] / Documentation / user / tweaks.itely
index a30cbd6d1b2b055347d2e33e054c22162905ffcb..a68fd71359e45d46581d889cef45fc804ceb549c 100644 (file)
 This chapter discusses how to modify output.  LilyPond is extremely
 configurable; virtually every fragment of output may be changed.
 
-TODO: This chapter is still under development and this version is
-not yet complete.  Don't translate yet!
-
-
 
 @menu
 * Tweaking basics::             
@@ -24,7 +20,6 @@ not yet complete.  Don't translate yet!
 * Appearance of objects::       
 * Placement of objects::        
 * Collisions of objects::       
-* Page layout::                 
 * Further tweaking::            
 @end menu
 
@@ -50,7 +45,7 @@ permit almost any desired appearance of the printed music to be
 achieved.
 
 In this section we cover the basic concepts required to understand
-tweaking.  Later we give a variety of potted commands which can
+tweaking.  Later we give a variety of ready-made commands which can
 simply be copied to obtain the same effect in your own scores, and
 at the same time we show how these commands may be constructed so 
 that you may learn how to develop your own tweaks.
@@ -81,10 +76,12 @@ constructed.  That @code{Staff} object then holds all the
 properties associated with that particular staff, for example, its
 name and its key signature, together with details of the engravers
 which have been assigned to operate within that staff's context.
-Similarly, there are @code{Voice} objects, @code{Score} objects,
-@code{Lyric} objects, and objects to represent bar lines,
- note heads, ties, dynamics, etc, each with their own set of
-properties.
+Similarly, there are objects to hold the properties of all other
+contexts, such as @code{Voice} objects, @code{Score} objects,
+@code{Lyrics} objects, as well as objects to represent all
+notational elements such as bar lines,
+note heads, ties, dynamics, etc.  Every object has its own set of
+property values.
 
 Some types of object are given special names.  Objects which
 represent items of notation on the printed output such as
@@ -134,9 +131,12 @@ verbatim.
 @headitem Object/property type           
   @tab Naming convention
   @tab Example
-@item Contexts, Layout Objects     
+@item Contexts
   @tab Aaaa or AaaaAaaaAaaa
-  @tab Staff, GrandStaff, 
+  @tab Staff, GrandStaff
+@item Layout Objects
+  @tab Aaaa or AaaaAaaaAaaa
+  @tab Slur, NoteHead
 @item Engravers
   @tab Aaaa_aaa_engraver
   @tab Clef_engraver, Note_heads_engraver
@@ -160,11 +160,17 @@ properties.
 @node Tweaking methods
 @subsection Tweaking methods
 
+@strong{\override command}
+
+@cindex override command
+@funindex \override
+
 We have already met the commands @code{\set} and @code{\with},
 used to change the properties of @strong{contexts} and to remove
 and add @strong{engravers}, in
 @ref{Modifying context properties} and @ref{Adding
-and removing engravers}.  We now must meet one more command.
+and removing engravers}.  We now must meet one more important
+command.
 
 The command to change the properties of @strong{layout objects} is
 @code{\override}.  Because this command has to modify
@@ -182,7 +188,7 @@ The general syntax of this command is:
 
 @noindent
 This will set the property with the name @emph{layout_property}
-of the layout object with the name 
+of the layout object with the name
 @emph{layout_object}, which is a member of the @emph{context}
 context, to the value @emph{value}.
 
@@ -214,19 +220,91 @@ Again, just like @emph{context} in the @code{\override} command,
 @emph{context} is often not needed.  It will be omitted
 in many of the following examples.
 
-There is another form of the override command, 
+@strong{\overrideProperty command}
+
+@cindex overrideProperty command
+@funindex \overrideProperty
+
+There is another form of the override command,
 @code{\overrideProperty}, which is occasionally required.
-We mention it here for completeness, but for details see 
+We mention it here for completeness, but for details see
 @ruser{Difficult tweaks}.
 @c Maybe explain in a later iteration  -td
 
+@strong{\tweak command}
+
+@cindex tweak command
+@funindex \tweak
+
 The final tweaking command which is available is @code{\tweak}.
-It is not really a new command but a shorthand for an 
-@code{\override} command which must be used in a few special
-circumstances.  Again, we shall not discuss or use it here.  
-You may find the details in 
+This should be used to change the properties of objects which
+occur at the same musical moment, such as the notes within a
+chord.  Using @code{\override} would affect all the notes
+within a chord, whereas @code{\tweak} affects just the following
+item in the input stream.
+
+Here's an example.  Suppose we wish to change the size of the
+middle note (the E) in a C major chord.  Let's first see what
+@code{\once \override} would do:
+
+@lilypond[quote,fragment,ragged-right,verbatim,relative=1]
+  <c e g>4
+  \once \override NoteHead #'font-size = #-3
+  <c e g>4
+@end lilypond
+
+We see the override affects @emph{all} the notes in the chord.
+This is because all the notes of a chord occur at the same
+@emph{musical moment}, and the action of @code{\once} is to
+apply the override to all layout objects of the type specified
+which occur at the same musical moment as the @code{\override}
+command itself.
+
+The @code{\tweak} command operates in a different way.  It acts
+on the immediately following item in the input stream.  However,
+it is effective only on objects which are created directly from
+the input stream, essentially note heads and articulations.
+(Objects such as stems and accidentals are created later and
+cannot be tweaked in this way).  Furthermore, when it is applied
+to note heads these must be within a chord, i.e., within single
+angle brackets, so to tweak a single note the @code{\tweak}
+command must be placed inside single angle brackets with the
+note.
+
+So to return to our example, the size of the middle note of
+a chord would be changed in this way:
+
+@lilypond[quote,fragment,ragged-right,verbatim,relative=1]
+  <c e g>4
+  <c \tweak #'font-size #-3 e g>4
+@end lilypond
+
+Note that the syntax of @code{\tweak} is different from that
+of the @code{\override} command.  Neither the context nor the
+layout object should be specified; in fact, it would generate
+an error to do so.  These are both implied by the following
+item in the input stream.  So the general syntax of the
+@code{\tweak} command is simply:
+
+@example
+\tweak #'@emph{layout_property} = #@emph{value}
+@end example
+
+A @code{\tweak} command can also be used to modify just one in
+a series of articulations, as shown here:
+
+@lilypond[quote,fragment,ragged-right,verbatim,relative=2]
+a ^Black
+  -\tweak #'color #red ^Red
+  -\tweak #'color #green _Green
+@end lilypond
+
+Note that the @code{\tweak} command must be preceded by an
+articulation mark as if it were an articulation itself.
+
+You can find more details of the @code{\tweak} command in
 @ruser{Objects connected to the input}.
-@c Maybe explain in a later iteration  -td
+
 
 @node The Internals Reference manual
 @section The Internals Reference manual
@@ -234,9 +312,9 @@ You may find the details in
 @cindex Internals Reference
 
 @menu
-* Properties of layout objects::  
-* Properties found in interfaces::  
-* Types of properties::         
+* Properties of layout objects::
+* Properties found in interfaces::
+* Types of properties::
 @end menu
 
 @node Properties of layout objects
@@ -346,7 +424,7 @@ the context.  Let's use a very large value for the thickness
 at first, so we can be sure the command is working.  We get:
 
 @example
-  \override Slur #'thickness = #5.0
+\override Slur #'thickness = #5.0
 @end example 
 
 Don't forget the @code{#'} preceding the
@@ -584,7 +662,7 @@ Ok, so the @code{\override} command we need to print the lyrics
 in italics should be
 
 @example
-  \override LyricText #'font-shape = #'italic
+\override LyricText #'font-shape = #'italic
 @end example
 
 @noindent
@@ -625,7 +703,7 @@ object name, as otherwise the two names are run together and
 the interpreter cannot recognise them.  So the command should be:
 
 @example
-  \override Lyrics . LyricText #'font-shape = #'italic
+\override Lyrics . LyricText #'font-shape = #'italic
 @end example
 
 @warning{In lyrics always leave whitespace between the final
@@ -723,7 +801,21 @@ let us suppose the exercise is to supply the missing bar lines
 in a piece of music.  But the bar lines are normally inserted
 automatically.  How do we prevent them printing?
 
-As before, we go to the IR to find the layout object which prints
+Before we tackle this, let us remember that object properties
+are grouped in what are called @emph{interfaces} -- see
+@ref{Properties found in interfaces}.  This is simply to
+group together those properties that are commonly required
+together -- if one of them is required for an object, so are
+the others.  Some objects then need the properties in some
+interfaces, others need them from other interfaces.  The
+interfaces which contain the properties required by a 
+particular grob are listed in the IR at the bottom of the
+page describing that grob, and those properties may be
+viewed by looking at those interfaces.
+
+We explained how to find information about grobs in 
+@ref{Properties of layout objects}.  Using the same approach,
+we go to the IR to find the layout object which prints
 bar lines.  Going via @emph{Backend} and @emph{All layout objects}
 we find there
 is a layout object called @code{BarLine}.  Its properties include
@@ -1520,18 +1612,37 @@ and to a numerical value appropriate to each outside-staff object
 when the object is created.  The following table shows
 the default numerical values for some of the commonest
 outside-staff objects which are, by default, placed in the
-@code{Staff} Context.
-
-@multitable @columnfractions .3 .3
-@headitem Layout Object           @tab Priority
-@item @code{DynamicLineSpanner}   @tab @code{ 250}
-@item @code{DynamicText}          @tab @code{ 250}
-@item @code{OttavaBracket}        @tab @code{ 400}
-@item @code{TextScript}           @tab @code{ 450}
-@item @code{TextSpanner}          @tab @code{ 350}
+@code{Staff} or @code{Voice} contexts.
+
+@multitable @columnfractions .3 .3 .3
+@headitem Layout Object           
+  @tab Priority     
+  @tab Controls position of:
+@item @code{MultiMeasureRestText}
+  @tab @code{450}
+  @tab Text over full-bar rests
+@item @code{TextScript}
+  @tab @code{450}
+  @tab Markup text
+@item @code{OttavaBracket}
+  @tab @code{400}
+  @tab Ottava brackets
+@item @code{TextSpanner}
+  @tab @code{350}
+  @tab Text spanners
+@item @code{DynamicLineSpanner}
+  @tab @code{250}
+  @tab All dynamic markings
+@item @code{VoltaBracketSpanner}
+  @tab @code{100}
+  @tab Volta brackets
+@item @code{TrillSpanner}
+  @tab @code{50}
+  @tab Spanning trills
 @end multitable
 
-Here is an example showing the default placement of these.
+Here is an example showing the default placement of some of
+these.
 
 @cindex text spanner
 @funindex \startTextSpan
@@ -1585,18 +1696,19 @@ given the following default @code{outside-staff-priority} values:
 
 @multitable @columnfractions .3 .3
 @headitem Layout Object           @tab Priority
-@item @code{BarNumber}            @tab @code{ 100}
-@item @code{MetronomeMark}        @tab @code{1000}
 @item @code{RehearsalMark}        @tab @code{1500}
+@item @code{MetronomeMark}        @tab @code{1000}
+@item @code{BarNumber}            @tab @code{ 100}
 @end multitable
 
-If the default values of @code{outside-staff-priority} does not
+If the default values of @code{outside-staff-priority} do not
 give you the placing you want, the priority of any of the objects
 may be overridden.  Suppose we would
 like the ottava bracket to be placed below the text spanner in the
 example above.  All we need to do is to look up the priority of
 @code{OttavaBracket} in the IR or in the tables above, and reduce
-it to a value lower than that of a @code{TextSpanner}:
+it to a value lower than that of a @code{TextSpanner}, remembering
+that @code{OttavaBracket} is created in the @code{Staff} context:
 
 @lilypond[quote,fragment,ragged-right,verbatim,relative=1]
 % Set details for later Text Spanner
@@ -1605,7 +1717,7 @@ it to a value lower than that of a @code{TextSpanner}:
 % Place dynamics above staff
 \dynamicUp
 %Place following Ottava Bracket below Text Spanners
-\once \override OttavaBracket #'outside-staff-priority = #340
+\once \override Staff.OttavaBracket #'outside-staff-priority = #340
 % Start Ottava Bracket
 #(set-octavation 1)
 c' \startTextSpan
@@ -1908,16 +2020,19 @@ objects, this value is set by default to be around 1.0 or less
 @code{self-alignment-X}
 
 @cindex self-alignment-X property
-This property aligns the object to the left, to the right, or
-centers it with respect to the parent object's reference point.
-It may be used with all objects which support the
-@code{self-alignment-interface}.  In general these are objects
+This property can be used to align the object to the left, to 
+the right, or to center it with respect to the parent object's 
+reference point.  It may be used with all objects which support
+the @code{self-alignment-interface}.  In general these are objects
 that contain text.  The values are @code{LEFT}, @code{RIGHT}
-or @code{CENTER}.  The movement is limited by the length of the
-object.  Any numerical value between @code{-1} and @code{+1} may
-also be specified, where @code{-1} is left-aligned, @code{+1}
-is right-aligned, and numbers in between move the text
-progressively from left-aligned to right-aligned.
+or @code{CENTER}.  Alternatively, a numerical value between 
+@code{-1} and @code{+1} may be specified, where @code{-1} is 
+left-aligned, @code{+1} is right-aligned, and numbers in between 
+move the text progressively from left-aligned to right-aligned.
+Numerical values greater than @code{1} may be specified to move
+the text even further to the left, or less than @code{-1} to
+move the text even further to the right.  A change of @code{1}
+in the value corresponds to a movement of half the text's length.
 
 @item
 @code{extra-spacing-width}
@@ -2005,7 +2120,12 @@ This is most useful for manually adjusting the slope and height
 of beams, slurs, and tuplets.   It takes a pair of numbers
 giving the position of the left and right ends of the beam, slur,
 etc. relative to the center line of the staff.  Units are
-staff-spaces.
+staff-spaces.  Note, though, that slurs and phrasing slurs cannot
+be repositioned by arbitrarily large amounts.  LilyPond first
+generates a list of possible positions for the slur and by default
+finds the slur that @qq{looks best}.  If the @code{positions}
+property has been overridden the slur that is closest to the
+requested positions is selected from the list.
 @end table
 
 Objects do not all have all of these properties in general.
@@ -2065,16 +2185,63 @@ d1
 @end lilypond
 
 Note in the second example how important it is to figure out what
-context handles a certain object.  Since the @code{MetronomeMark} object
+context handles a certain object.  Since the @code{MetronomeMark}
+object
 is handled in the @code{Score} context, property changes in the
 @code{Voice} context will not be noticed.  For more details, see
 @ruser{Constructing a tweak}.
 
-@subheading left-padding and right-padding properties
+If the @code{padding} property of an object is increased when that
+object is in a stack of objects being positioned according to
+their @code{outside-staff-priority}, then that object and all
+objects outside it are moved.
+
+
+@subheading left-padding and right-padding
 @cindex left-padding property
 @cindex right-padding property
 
-TODO Example showing the utility of these properties  -td
+The @code{right-padding} property affects the spacing between the
+accidental and the note to which it applies.  It is not often
+required, but the following example shows one situation where it
+is needed.  Suppose we wish to show a chord containing both
+a B-natural and a B-flat.  To avoid ambiguity we would like to
+precede the notes with both a natural and a flat sign.  Here
+are a few attempts to do this:
+
+@lilypond[quote,fragment,ragged-right,verbatim,relative=2]
+<b bes>
+<b! bes>
+<b? bes>
+@end lilypond
+
+None work, with the second two showing bad collisions between
+the two signs.
+
+One way of achieving this is to override the accidental stencil
+with a markup containing the natural and flat symbols in the
+order we would like, like this:
+
+@lilypond[quote,ragged-right,verbatim]
+naturalplusflat = \markup { \natural \flat }
+\relative c'' {
+  \once \override Accidental
+    #'stencil = #ly:text-interface::print
+  \once \override Accidental #'text = #naturalplusflat
+  \once \override Score.AccidentalPlacement #'right-padding = #1.5
+  <b bes>
+}
+@end lilypond
+
+@noindent
+This necessarily uses an override for the accidental stencil which
+will not be covered until later.  The stencil type must be a
+procedure, here changed to print the contents of the @code{text}
+property of @code{Accidental}, which itself is set to be a natural 
+sign followed by a flat sign.  These are then moved further away 
+from the note head by overriding @code{right-padding}.
+
+@noindent
 
 @subheading staff-padding property
 @cindex staff-padding property
@@ -2166,59 +2333,6 @@ f-5
 @end lilypond
 
 
-@subheading force-hshift property
-@cindex force-hshift property
-@c FIXME: formatting stuff  (ie not important right now IMO)
-@c @a nchor Chopin finally corrected TODOgp
-
-We can now see how to apply the final corrections to the Chopin
-example introduced at the end of @ref{I'm hearing Voices}, which
-was left looking like this:
-
-@lilypond[quote,verbatim,fragment,ragged-right]
-\new Staff \relative c'' {
-  \key aes \major
-  <<
-    { c2 aes4. bes8 } \\
-    { aes2 f4 fes   } \\
-    { \voiceFour
-      <ees c>2
-      des2
-    }
-  >> |
-  <c ees aes c>1 |
-}
-@end lilypond
-
-@noindent
-The lower two notes of the first chord (i.e,
-those in the third voice) should not be shifted away from the
-note column of the higher two notes.  To correct this we set
-@code{force-hshift}, which is a property of
-@code{NoteColumn}, of these notes to zero.
-The lower note of the second chord is best placed just to the
-right of the higher notes.  We achieve this by setting
-@code{force-hshift} of this note to 0.5, ie half a note head's
-width to the right of the note column of the higher notes.
-
-Here's the final result:
-
-@lilypond[quote,verbatim,fragment,ragged-right]
-\new Staff \relative c'' {
-  \key aes \major
-  <<
-    { c2 aes4. bes8 } \\
-    { aes2 f4 fes   } \\
-    { \voiceFour
-      \once \override NoteColumn #'force-hshift = #0 <ees c>2
-      \once \override NoteColumn #'force-hshift = #0.5 des2
-    }
-  >> |
-  <c ees aes c>1 |
-}
-@end lilypond
-
-
 @subheading positions property
 @cindex positions property
 
@@ -2267,7 +2381,7 @@ collides with the upper notes:
 @end lilypond
 
 @noindent
-This can only be resolved by manually moving both ends of the beam
+This can be resolved by manually moving both ends of the beam
 up from their position at 2 staff-spaces above the center line to,
 say, 3:
 
@@ -2289,6 +2403,59 @@ Note that the override continues to apply in the first voice of
 the second block of quavers, but not to any of the beams in the
 second voice.
 
+@subheading force-hshift property
+@cindex force-hshift property
+@c FIXME: formatting stuff  (ie not important right now IMO)
+@c @a nchor Chopin finally corrected TODOgp
+
+We can now see how to apply the final corrections to the Chopin
+example introduced at the end of @ref{I'm hearing Voices}, which
+was left looking like this:
+
+@lilypond[quote,verbatim,fragment,ragged-right]
+\new Staff \relative c'' {
+  \key aes \major
+  <<
+    { c2 aes4. bes8 } \\
+    { aes2 f4 fes   } \\
+    { \voiceFour
+      <ees c>2
+      des2
+    }
+  >> |
+  <c ees aes c>1 |
+}
+@end lilypond
+
+@noindent
+The lower two notes of the first chord (i.e,
+those in the third voice) should not be shifted away from the
+note column of the higher two notes.  To correct this we set
+@code{force-hshift}, which is a property of
+@code{NoteColumn}, of these notes to zero.
+The lower note of the second chord is best placed just to the
+right of the higher notes.  We achieve this by setting
+@code{force-hshift} of this note to 0.5, ie half a note head's
+width to the right of the note column of the higher notes.
+
+Here's the final result:
+
+@lilypond[quote,verbatim,fragment,ragged-right]
+\new Staff \relative c'' {
+  \key aes \major
+  <<
+    { c2 aes4. bes8 } \\
+    { aes2 f4 fes   } \\
+    { \voiceFour
+      \once \override NoteColumn #'force-hshift = #0 <ees c>2
+      \once \override NoteColumn #'force-hshift = #0.5 des2
+    }
+  >> |
+  <c ees aes c>1 |
+}
+@end lilypond
+
+
 @node Real music example
 @subsection Real music example
 
@@ -2723,272 +2890,15 @@ lhMusic = \relative c' {
 @end lilypond
 
 
-@node Page layout
-@section Page layout
-
-@menu
-* Introduction to layout::      
-* Global sizes::                
-* Line breaks::                 
-* Page breaks::                 
-* Fitting music onto fewer pages::  
-@end menu
-
-@node Introduction to layout
-@subsection Introduction to layout
-
-The global paper layout is determined by three factors: 
-the page layout, the line breaks, and the spacing. These all 
-influence each other. The choice of spacing determines how 
-densely each system of music is set. This influences where line 
-breaks are chosen, and thus ultimately, how many pages a piece 
-of music takes.
-
-Settings which influence layout may be placed in two blocks.
-The @code{\paper @{...@}} block is placed outside any
-@code{\score @{...@}} blocks and contains settings that
-relate to the entire document.  The @code{\layout @{...@}}
-block is placed within a @code{\score @{...@}} block and
-contains settings for that particular score.  If you have
-only one @code{\score @{...@}} block the two have the same
-effect.  In general the commands shown in this section can
-be placed in either.
-
-Much more detail on the options for tweaking the laying out
-of music are contained in @ruser{Spacing issues}.
-
-@node Global sizes
-@subsection Global sizes
-
-TODO Check all these examples
-
-The default @strong{paper size} which LilyPond assumes in laying
-out the music is A4.  This may be changed in two ways:
-
-@example
-#(set-default-paper-size "a6")
-
-\paper @{
-#(set-paper-size "letter")
-@}
-@end example
-
-@noindent
-The first command sets the size of all pages. The second command
-sets the size of the pages to which the \paper block applies -- if
-the \paper block is at the top of the file, then it will apply
-to all pages.  Support for the following paper sizes is available:
-a6, a5, a4, a3, legal, letter, 11x17 (also known as tabloid).
-Setting the paper size automatically sets suitable margins and
-line length.
-
-If the symbol @code{landscape} is supplied as an argument to
-@code{set-default-paper-size}, the pages will be rotated by 90
-degrees, and wider line widths will be set correspondingly, e.g.
-
-@example
-#(set-default-paper-size "a6" 'landscape)
-@end example
-
-The default @strong{staff size} is set to 20 points.
-This may be changed in two ways:
-
-@example
-#(set-global-staff-size 14)
-
-\paper @{
-#(set-global-staff-size 16)
-@}
-@end example
-
-@noindent
-The first command sets the size in all pages. The second command
-sets the size in the pages to which the \paper block applies -\96 if
-the \paper block is at the top of the file, then it will apply
-to all pages.  All the fonts are automatically scaled to suit
-the new value of the staff size.
-
-@node Line breaks
-@subsection Line breaks
-
-Line breaks are normally determined automatically. They are chosen
-so that lines look neither cramped nor loose, and consecutive
-lines have similar density.  Occasionally you might want to
-override the automatic breaks; you can do this by specifying
-@code{\break}. This will force a line break at this point.  However,
-line breaks can only occur at the end of @q{complete} bars, i.e.,
-where there are no notes or tuplets left @q{hanging} over the bar
-line.  If you want to have a line break where there is no bar line,
-you can force an invisible bar line by entering @code{\bar ""},
-although again there must be no notes left hanging over in any of
-the staves at this point, or it will be ignored.
-
-The opposite command, @code{\noBreak}, forbids a line break at the
-bar line where it is inserted.
-
-The most basic settings influencing line spacing are @code{indent}
-and @code{line-width}. They are set in the @code{\layout} block.
-They control the indentation of the first line of music, and the
-lengths of the lines.
-
-If @code{ragged-right} is set to true in the @code{\layout} block,
-then systems end at their natural horizontal length, instead of
-being spread horizontally to fill the whole line. This is useful
-for short fragments, and for checking how tight the natural
-spacing is.
-
-The option @code{ragged-last} is similar to @code{ragged-right},
-but affects only the last line of the piece.
-
-@example
-\layout @{
-indent = #0
-line-width = #150
-ragged-last = ##t
-@}
-@end example
-
-@node Page breaks
-@subsection Page breaks
-
-The default page breaking may be overriden by inserting 
-@code{\pageBreak} or @code{\noPageBreak} commands.
-These commands are analogous to the @code{\break} and 
-@code{\noBreak} commands discused above and force or forbid 
-a page-break at the point where they are inserted.
-Of course, the @code{\pageBreak} command also forces a line break.
-Like @code{\break}, the @code{\pageBreak} command is effective only
-at the end of a @q{complete} bar as defined above.  For more
-details see @ruser{Page breaking} and following sections.
-
-There are also analogous settings to @code{ragged-right} and
-@code{ragged-last} which have the same effect on vertical spacing:
-@code{ragged-bottom} and @code{ragged-last-bottom}.  If set to
-@code{##t} the systems on all pages or just the last page
-respectively will not be justified vertically.
-
-For more details see @ruser{Vertical spacing}.
-
-@node Fitting music onto fewer pages
-@subsection Fitting music onto fewer pages
-
-Sometimes you can end up with one or two staves on a second
-(or third, or fourth...) page.  This is annoying, especially
-if you look at previous pages and it looks like there is plenty
-of room left on those.
-
-When investigating layout issues, @code{annotate-spacing} is
-an invaluable tool.  This command prints the values of various
-layout spacing commands; see @ruser{Displaying spacing}, for more
-details.  From the output of @code{annotate-spacing}, we can
-see which margins we may wish to alter.
-
-Other than margins, there are a few other options to save space:
-
-@itemize
-@item
-You may tell LilyPond to place systems as close together as
-possible (to fit as many systems as possible onto a page), but
-then to space those systems out so that there is no blank
-space at the bottom of the page.
-
-@example
-\paper @{
-  between-system-padding = #0.1
-  between-system-space = #0.1
-  ragged-last-bottom = ##f
-  ragged-bottom = ##f
-@}
-@end example
-
-@item
-You may force the number of systems (i.e., if LilyPond wants
-to typeset some music with 11 systems, you could force it to
-use 10).
-
-@example
-\paper @{
-  system-count = #10
-@}
-@end example
-
-@item
-Avoid (or reduce) objects which increase the vertical size of
-a system.  For example, volta repeats (or alternate repeats)
-require extra space.  If these repeats are spread over two
-systems, they will take up more space than one system with
-the volta repeats and another system without.
-
-Another example is moving dynamics which @q{stick out} of
-a system, as in the second bar here:
-
-@lilypond[verbatim,quote,fragment,ragged-right,relative=1]
-e4 c g\f c
-\override DynamicText #'extra-offset = #'( -2.2 . 2.0)
-e4 c g\f c
-@end lilypond
-
-@item
-Alter the horizontal spacing via @code{SpacingSpanner}.  See
-@ruser{Changing horizontal spacing}, for more details.  Here's
-an example first showing the default behaviour:
-
-@lilypond[verbatim,quote,ragged-right]
-\score {
-  \relative c'' {
-    g4 e e2 |
-    f4 d d2 |
-    c4 d e f |
-    g4 g g2 |
-    g4 e e2 |
-  }
-}
-@end lilypond
-
-@noindent
-and now with @code{common-shortest-duration} increased from the
-value of @code{1/4} (a quarter note is the most common in this
-example) to @code{1/2}:
-
-@lilypond[verbatim,quote,ragged-right]
-\score {
-  \relative c'' {
-    g4 e e2 |
-    f4 d d2 |
-    c4 d e f |
-    g4 g g2 |
-    g4 e e2 |
-  }
-  \layout {
-    \context {
-      \Score
-      \override SpacingSpanner
-                #'common-shortest-duration = #(ly:make-moment 1 2)
-    }
-  }
-}
-@end lilypond
-
-@noindent
-Note that this override cannot be modified dynamically, so it must
-always be placed in a @code{\context@{..@}} block so that it applies
-to the whole score.
-
-TODO Add description of using \context in this way earlier if it is
-not already anywhere  -td
-
-@end itemize
-
-
 @node Further tweaking
 @section Further tweaking
 
 @menu
-* Other uses for tweaks::       
-* Using variables for tweaks::  
-* Other sources of information::  
-* Advanced tweaks with Scheme::  
-* Avoiding tweaks with slower processing::  
+* Other uses for tweaks::
+* Using variables for tweaks::
+* Other sources of information::
+* Avoiding tweaks with slower processing::
+* Advanced tweaks with Scheme::
 @end menu
 
 @node Other uses for tweaks
@@ -2996,65 +2906,68 @@ not already anywhere  -td
 
 @itemize
 
-@cindex transparent property
+@cindex transparent property, use of
 @cindex objects, making invisible
 @cindex removing objects
 @cindex objects, removing
 @cindex hiding objects
 @cindex invisible objects
+@cindex tying notes across voices
 
 @item
-Setting the @code{transparent} property will cause an object 
-to be printed in @q{invisible ink}: the object is not printed, 
-but all its other behavior is retained.  The object still takes 
-up space, it takes part in collisions, and slurs, ties, and beams
-can be attached to it.
+@subheading Tying notes across voices
 
-The following example demonstrates how to connect different voices
-using ties.  Normally, ties only connect two notes in the same
-voice.  By introducing a tie in a different voice,
+The following example demonstrates how to connect notes in
+different voices using ties.  Normally, only two notes in the
+same voice can be connected with ties.  By using two voices,
+with the tied notes in one of them
 
 @lilypond[quote,fragment,relative=2]
-<< {
-  b8~ b8\noBeam
-} \\ {
-  b[ g8]
-} >>
+<< { b8~ b8\noBeam }
+\\ { b[ g8] }
+>>
 @end lilypond
 
 @noindent
-and blanking the first up-stem in that voice, the tie appears to cross
-voices:
+and blanking the first up-stem in that voice, the tie appears to
+cross voices:
 
 @lilypond[quote,fragment,relative=2,verbatim]
-<< {
-  \once \override Stem #'transparent = ##t
-  b8~ b8\noBeam
-} \\ {
-  b[ g8]
-} >>
+<<
+  {
+    \once \override Stem #'transparent = ##t
+    b8~ b8\noBeam
+  }
+\\
+  { b[ g8] }
+>>
 @end lilypond
 
-To make sure that the just-blanked stem doesn't squeeze the tie too much,
-we also lengthen the stem, by setting the @code{length} to
-@code{8},
+To make sure that the just-blanked stem doesn't squeeze the tie
+too much, we can lengthen the stem by setting the
+@code{length} to @code{8},
 
 @lilypond[quote,fragment,relative=2,verbatim]
-<< {
-  \once \override Stem #'transparent = ##t
-  \once \override Stem #'length = #8
-  b8~ b8\noBeam
-} \\ {
-  b[ g8]
-} >>
+<<
+  {
+    \once \override Stem #'transparent = ##t
+    \once \override Stem #'length = #8
+    b8~ b8\noBeam
+  }
+\\
+  { b[ g8] }
+>>
 @end lilypond
 
-@cindex stencil property
-
 @item
+@subheading Simulating a fermata
+
+@cindex stencil property, use of
+@cindex fermata, implementing in MIDI
+
 For outside-staff objects it is usually better to override the
 object's @code{stencil} property rather than its @code{transparent}
-property when you wish to remove it from the printed output.  
+property when you wish to remove it from the printed output.
 Setting the @code{stencil} property of an object to @code{#f} will
 remove that object entirely from the printed output.  This means it
 has no effect on the placement of other objects placed relative to
@@ -3062,13 +2975,13 @@ it.
 
 For example, if we wished to change the metronome setting in order
 to simulate a fermata in the MIDI output we would not want the
-metronome marking to appear in the printed output, and we would
+metronome markings to appear in the printed output, and we would
 not want it to influence the spacing between the two systems or
-the spacing of the notes on the staff.  So setting its 
+the spacing of the notes on the staff.  So setting its
 @code{stencil} property to @code{#f} would be the best way.
 We show here the effect of the two methods:
 
-@lilypond[quote,verbatim]
+@lilypond[quote,verbatim,ragged-right]
 \score {
   \relative c'' {
     % Visible tempo marking
@@ -3083,6 +2996,7 @@ We show here the effect of the two methods:
     \tempo 4=120
     a a a a
   }
+  \layout { }
   \midi { }
 }
 @end lilypond
@@ -3098,132 +3012,249 @@ while the second (with no stencil) does not.
 @node Using variables for tweaks
 @subsection Using variables for tweaks
 
-TODO Add section
+Override commands are often long and tedious to type, and they
+have to be absolutely correct.  If the same overrides are to be
+used many times it may be worth defining variables to hold them.
+Suppose we wish to emphasize certain words in lyrics by printing
+them in bold italics.  The @code{\italic} and @code{\bold}
+commands do not work within lyrics so we must instead use the
+following @code{\override} and @code{\revert} commands:
 
-@node Other sources of information
-@subsection Other sources of information
+@example
+@code{\override Lyrics . LyricText #'font-shape = #'italic}
+@code{\override Lyrics . LyricText #'font-series = #'bold}
 
-The Internals Reference documentation contains a lot of information
-about LilyPond, but even more information can be gathered from
-looking at the internal LilyPond files.
+@code{\revert Lyrics . LyricText #'font-shape}
+@code{\revert Lyrics . LyricText #'font-series}
+@end example
 
-TODO Show example, then explain where to find ly/propert-ly.
+These would be extremely tedious to enter if there were many words
+requiring emphasis.  So instead we define these as two variables,
+and use them as follows:
 
-Some default settings (such as the definitions for
-@code{\header@{@}}s) are stored as @code{.ly} files.  Other
-settings (such as the definitions of markup commands) are
-stored as @code{.scm} (Scheme) files.  Further explanation is
-outside the scope of this manual; users should be warned that
-a substantial amount of technical knowledge or time is required
-to understand these files.
+@lilypond[quote,verbatim]
+emph = {
+  \override Lyrics . LyricText #'font-shape = #'italic
+  \override Lyrics . LyricText #'font-series = #'bold
+}
+norm = {
+  \revert Lyrics . LyricText #'font-shape
+  \revert Lyrics . LyricText #'font-series
+}
 
-@itemize
+global = { \time 4/4 \partial 4 \key c \major}
+SopMusic   = \relative c' { c4 | e4. e8 g4  g  | a a g }
+AltoMusic  = \relative c' { c4 | c4. c8 e4  e  | f f e }
+TenorMusic = \relative c  { e4 | g4. g8 c4. b8 | a8 b c d e4 }
+BassMusic  = \relative c  { c4 | c4. c8 c4  c  | f8 g a b c4 }
+VerseOne   = \lyrics { E -- | ter -- nal \emph Fa -- ther, \norm | strong to save, }
+VerseTwo   = \lyricmode { O | \emph Christ, \norm whose voice the | wa -- ters heard, }
+VerseThree = \lyricmode { O | \emph Ho -- ly Spi -- rit, \norm | who didst brood }
+VerseFour  = \lyricmode { O | \emph Tri -- ni -- ty \norm of | love and pow'r }
 
-@item Linux: @file{@var{installdir}/lilypond/usr/share/lilypond/current/}
+\score {
+  \new ChoirStaff <<
+    \new Staff <<
+      \clef "treble"
+      \new Voice = "Sop"  { \voiceOne \global \SopMusic }
+      \new Voice = "Alto" { \voiceTwo \AltoMusic }
+      \new Lyrics \lyricsto "Sop" { \VerseOne   }
+      \new Lyrics \lyricsto "Sop" { \VerseTwo   }
+      \new Lyrics \lyricsto "Sop" { \VerseThree }
+      \new Lyrics \lyricsto "Sop" { \VerseFour  }
+    >>
+    \new Staff <<
+      \clef "bass"
+      \new Voice = "Tenor" { \voiceOne \TenorMusic }
+      \new Voice = "Bass"  { \voiceTwo \BassMusic  }
+    >>
+  >>
+}
+@end lilypond
 
-@item OSX:
-@file{@var{installdir}/LilyPond.app/Contents/Resources/share/lilypond/current/}.
-To access this, either @code{cd} into this directory from the
-Terminal, or control-click on the LilyPond application and select
-@q{Show Package Contents}.
 
-@item Windows: @file{@var{installdir}/LilyPond/usr/share/lilypond/current/}
 
-@end itemize
+@node Other sources of information
+@subsection Other sources of information
 
-The @file{ly/} and @file{scm/} directories will be of
-particular interest.  Files such as @file{ly/property-init.ly} and
-@file{ly/declarations-init.ly} define all the common tweaks.
+The Internals Reference documentation contains a lot of information
+about LilyPond, but even more information can be gathered by
+looking at the internal LilyPond files.  To explore these, first
+find the directory appropriate to your system, as follows:
 
+@strong{Linux}
 
-@node Advanced tweaks with Scheme
-@subsection Advanced tweaks with Scheme
+Navigate to
+@file{@var{installdir}/lilypond/usr/share/lilypond/current/}
 
-We have seen how LilyPond output can be heavily modified using
-commands like
-@code{\override TextScript #'extra-offset = ( 1 . -1)}.  But
-we have even more power if we use Scheme.  For a full explantion
-of this, see the @ref{Scheme tutorial}, and
-@ruser{Interfaces for programmers}.
+@strong{OSX}
 
-We can use Scheme to simply @code{\override} commands,
+Navigate to
+@file{@var{installdir}/LilyPond.app/Contents/Resources/share/lilypond/current/}
+by either @code{cd}-ing into this directory from the
+Terminal, or control-clicking on the LilyPond application and
+selecting @q{Show Package Contents}.
 
-TODO Check this is a valid example with skylining
+@strong{Windows}
 
-@lilypond[quote,verbatim,ragged-right]
-padText = #(define-music-function (parser location padding) (number?)
-#{
-  \once \override TextScript #'padding = #$padding
-#})
-
-\relative c''' {
-  c4^"piu mosso" b a b
-  \padText #1.8
-  c4^"piu mosso" d e f
-  \padText #2.6
-  c4^"piu mosso" fis a g
-}
-@end lilypond
+Using Windows Explorer, navigate to
+@file{@var{installdir}/LilyPond/usr/share/lilypond/current/}
 
-We can use it to create new commands,
+Within this directory the two interesting subdirectories are
 
-TODO Check this is a valid example with skylining
+@itemize
+@item @file{../ly/ } - contains files in LilyPond format
+@item @file{../scm/} - contains files in Scheme format
+@end itemize
 
-@lilypond[quote,verbatim,ragged-right]
-tempoMark = #(define-music-function (parser location padding marktext)
-                                    (number? string?)
-#{
-  \once \override Score . RehearsalMark #'padding = $padding
-  \once \override Score . RehearsalMark #'extra-spacing-width = #'(+inf.0 . -inf.0)
-  \mark \markup { \bold $marktext }
-#})
+Let's begin by looking at some files in @file{../ly/}.
+Open @file{../ly/property-init.ly} in a text editor.  The one
+you normally use for @code{.ly} files will be fine.  This file
+contains the definitions of all the standard LilyPond built-in
+commands, such as @code{\stemUp} and @code{\slurDotted}.  You will
+see that these are nothing more than definitions of variables
+containing one or a group of @code{\override} commands.  For
+example, @code{/tieDotted} is defined to be:
 
-\relative c'' {
-  c2 e
-  \tempoMark #3.0 #"Allegro"
-  g c
-}
-@end lilypond
+@example
+tieDotted = @{
+  \override Tie #'dash-period = #0.75
+  \override Tie #'dash-fraction = #0.1
+@}
+@end example
 
-Even music expressions can be passed in.
+If you do not like the default values these built-in commands can
+be redefined easily, just like any other variable, at the
+head of your input file.
+
+The following are the most useful files to be found in
+@file{../ly/}:
+
+@multitable @columnfractions .4 .6
+@headitem Filename
+  @tab Contents
+@item @file{../ly/engraver-init.ly}
+  @tab Definitions of engraver Contexts
+@item @file{../ly/paper-defaults.ly}
+  @tab Specifications of paper-related defaults
+@item @file{../ly/performer-init.ly}
+  @tab Definitions of performer Contexts
+@item @file{../ly/property-init.ly}
+  @tab Definitions of all common built-in commands
+@end multitable
+
+Other settings (such as the definitions of markup commands) are
+stored as @code{.scm} (Scheme) files.  The Scheme programming
+language is used to provide a programmable interface into
+LilyPond internal operation.  Further explanation of these files
+is currently outside the scope of this manual, as a knowledge of
+the Scheme language is required.  Users should be warned that
+a substantial amount of technical knowledge or time is required
+to understand Scheme and these files (see @ref{Scheme tutorial}).
+
+If you have this knowledge, the Scheme files which may be of
+interest are:
+
+@multitable @columnfractions .4 .6
+@headitem Filename
+  @tab Contents
+@item @file{../scm/auto-beam.scm}
+  @tab Sub-beaming defaults
+@item @file{../scm/define-grobs.scm}
+  @tab Default settings for grob properties
+@item @file{../scm/define-markup-commands.scm}
+  @tab Specify all markup commands
+@item @file{../scm/midi.scm}
+  @tab Default settings for MIDI output
+@item @file{../scm/output-lib.scm}
+  @tab Settings that affect appearance of frets, colors,
+       accidentals, bar lines, etc
+@item @file{../scm/parser-clef.scm}
+  @tab Definitions of supported clefs
+@item @file{../scm/script.scm}
+  @tab Default settings for articulations
+@end multitable
 
-@lilypond[quote,verbatim,ragged-right]
-pattern = #(define-music-function (parser location x y) (ly:music? ly:music?)
-#{
-  $x e8 a b $y b a e
-#})
-
-\relative c''{
-  \pattern c8 c8\f
-  \pattern {d16 dis} { ais16-> b\p }
-}
-@end lilypond
 
 
 @node Avoiding tweaks with slower processing
 @subsection Avoiding tweaks with slower processing
 
 LilyPond can perform extra checks while it processes files.  These
-commands will take extra time, but the result may require fewer
-manual tweaks.
+checks will take extra time to perform, but fewer manual tweaks
+may be required to obtain an acceptable result.  If a text script
+or part of the lyrics extends over the margins these checks will
+compress that line of the score just enough to fit within the
+margins.
+
+To be effective under all circumstances these checks must be enabled
+by placing the overrides in a Score @code{\with} block, rather than
+in-line in music, as follows:
 
 @example
-%%  makes sure text scripts and lyrics are within the paper margins
-\override Score.PaperColumn #'keep-inside-line = ##t 
-\override Score.NonMusicalPaperColumn #'keep-inside-line = ##t
+\new Score \with @{
+  % Makes sure text scripts and lyrics are within the paper margins
+  \override PaperColumn #'keep-inside-line = ##t
+  \override NonMusicalPaperColumn #'keep-inside-line = ##t
+@} @{
+   ..
+@}
 @end example
 
-In some cases (see issue 246), this must be done before
-@code{\override} commands can be processed.
+@node Advanced tweaks with Scheme
+@subsection Advanced tweaks with Scheme
 
-@verbatim
-\new Score \with {
-    \override PaperColumn #'keep-inside-line = ##t 
-    \override NonMusicalPaperColumn #'keep-inside-line = ##t
-  } {
-   ..
+Although many things are possible with the @code{\override} and
+@code{\tweak} commands, an even more powerful way of modifying
+the action of LilyPond is available through a programmable
+interface to the LilyPond internal operation.  Code written in
+the Scheme programming language can be incorporated directly in
+the internal operation of LilyPond.  Of course, at least a basic
+knowledge of programming in Scheme is required to do this, and an
+introduction is provided in the @ref{Scheme tutorial}.
+
+As an illustration of one of the many possibilities, instead of
+setting a property to a constant it can be set to a Scheme
+procedure which is then called whenever that property is accessed
+by LilyPond.  The property can then be set dynamically to a value
+determined by the procedure at the time it is called.  In this
+example we color the note head in accordance with its position on
+the staff.
+
+@lilypond[quote,verbatim,ragged-right]
+#(define (color-notehead grob)
+  "Color the notehead according to its position on the staff."
+  (let ((mod-position (modulo (ly:grob-property grob 'staff-position) 7)))
+    (case mod-position
+      ;;   Return rainbow colors
+      ((1) (x11-color 'red    ))  ; for C
+      ((2) (x11-color 'orange ))  ; for D
+      ((3) (x11-color 'yellow ))  ; for E
+      ((4) (x11-color 'green  ))  ; for F
+      ((5) (x11-color 'blue   ))  ; for G
+      ((6) (x11-color 'purple ))  ; for A
+      ((0) (x11-color 'violet ))  ; for B
+    )
+  )
+)
+
+\relative c' {
+  % Arrange to obtain color from color-notehead procedure
+  \override NoteHead #'color = #color-notehead
+  c2 c' | 
+  b4 g8 a b4 c | 
+  c,2 a' | 
+  g1 |
+}
+\addlyrics {
+  Some -- where o -- ver the Rain -- bow way up high,
 }
-@end verbatim
+@end lilypond
+
+Further examples showing the use of these programmable interfaces
+can be found in @ref{Tweaking with Scheme}.
+
+