]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/changing-defaults.itely
* tex/GNUmakefile (TEX_FILES): add texinfo.cnf
[lilypond.git] / Documentation / user / changing-defaults.itely
1 @c -*- coding: latin-1; mode: texinfo; -*-
2 @node Changing defaults
3 @chapter Changing defaults
4
5
6 The purpose of LilyPond's design is to provide the finest output
7 quality as a default. Nevertheless, it may happen that you need to
8 change this default layout.  The layout is controlled through a large
9 number of proverbial ``knobs and switches.''  This chapter does not
10 list each and every knob. Rather, it outlines what groups of controls
11 are available and explains how to lookup which knob to use for a
12 certain effect.
13
14
15 @cindex Program reference
16
17 The controls available for tuning are described in a separate
18 document, the @internalsref{Program reference} manual. That manual
19 lists all different variables, functions and options available in
20 LilyPond. It is written as a HTML document, which is available
21 @uref{http://lilypond.org/doc/Documentation/user/out-www/lilypond-internals/,on-line},
22 but is also included with the LilyPond documentation package.
23
24 There are three areas where the default settings may be changed:
25
26 @itemize @bullet
27 @item Output: changing the appearance of individual
28   objects. For example, changing stem directions, or the location of
29   subscripts.
30   
31 @item Context: changing aspects of the translation from music events to
32   notation. For example, giving each staff a separate time signature. 
33   
34 @item Global layout: changing the appearance of the spacing, line
35   breaks and page dimensions.
36 @end itemize
37
38 Then, there are separate systems for typesetting text (like
39 @emph{ritardando}) and selecting different fonts. This chapter also
40 discusses these.
41
42 Internally, LilyPond uses Scheme (a LISP dialect) to provide
43 infrastructure.  Overriding layout decisions in effect accesses the
44 program internals, which requires Scheme input.  Scheme elements are
45 introduced in a @code{.ly} file with the hash mark
46 @code{#}.@footnote{@ref{Scheme tutorial} contains a a short tutorial
47 on entering numbers, lists, strings and symbols in Scheme.}
48
49
50 @menu
51 * Interpretation contexts::     
52 * The \override command::       
53 * Fonts::                       
54 * Text markup::                 
55 * Global layout::               
56 * File structure::              
57 @end menu
58
59  
60 @node Interpretation contexts
61 @section Interpretation contexts
62
63 When music is printed, a lot of notation elements must be added to the
64 input, which is often bare bones.  For example, compare the input and
65 output of the following example:
66
67 @lilypond[verbatim,relative=2,fragment]
68   cis4 cis2. g4
69 @end lilypond
70
71 The input is rather sparse, but in the output, bar lines, accidentals,
72 clef, and time signature are added. LilyPond @emph{interprets} the
73 input. During this step, the musical information is inspected in time
74 order, similar to reading a score from left to right. While reading,
75 the program remembers where measure boundaries are, and what pitches
76 need explicit accidentals.  This information can be presented on
77 several levels.  For example, the effect of an accidental is limited
78 to a single stave, while a bar line must be synchronized across the
79 entire score.
80
81 Within LilyPond, these rules and bits of information are grouped in
82 so-called Contexts. Examples of context are @context{Voice},
83 @context{Staff}, and @context{Score}.  They are hierarchical, for
84 example, a @context{Staff} can contain many @context{Voice}s, and a
85 @context{Score} can contain many @context{Staff} contexts.
86
87 Each context has the responsibility for enforcing some notation rules,
88 creating some notation objects and maintaining the associated
89 properties.  So, the synchronization of bar lines is handled at
90 @context{Score} context.  The @context{Voice} may introduce an
91 accidentals and then the @context{Staff} context maintains the rule to
92 show or suppress the accidental for the remainder of the measure.
93
94 For simple scores, contexts are created implicitly, and you need not
95 be aware of them. For larger pieces, such as piano music, they must be
96 created explicitly to make sure that you get as many staves as you
97 need, and that they are in the correct order.  For typesetting pieces
98 with specialized notation, it can be useful to modify existing or
99 define new contexts.
100
101
102 Full description of all available contexts is in the program
103 reference, see
104 @ifhtml
105 @internalsref{Contexts}.
106 @end ifhtml
107 @ifnothtml 
108 Translation @arrow{} Context.
109 @end ifnothtml
110
111 @c [TODO: describe propagation]
112
113
114 @menu
115 * Creating contexts::           
116 * Changing context properties on the fly::  
117 * Modifying context plug-ins::  
118 * Layout tunings within contexts::  
119 * Changing context default settings::  
120 * Defining new contexts::      
121 @end menu
122
123 @node Creating contexts
124 @subsection Creating contexts
125
126 For scores with only one voice and one staff, correct contexts are
127 created automatically. For more complex scores, it is necessary to
128 create them by hand.  There are three commands which do this.
129
130 The easiest command is @code{\new}, and it also the quickest to type.
131 It is prepended to a music expression, for example
132
133 @cindex @code{\new}
134 @cindex new contexts
135 @cindex Context, creating
136
137 @example
138   \new @var{type} @var{music expression}
139 @end example
140
141 @noindent
142 where @var{type} is a context name (like @code{Staff} or
143 @code{Voice}).  This command creates a new context, and starts
144 interpreting @var{music expression} with that.
145
146 A practical application of @code{\new} is a score with many
147 staves. Each part that should be on its own staff, is preceded with 
148 @code{\new Staff}.
149
150 @lilypond[verbatim,relative=2,raggedright,fragment]
151   << \new Staff { c4 c }
152      \new Staff { d4 d }
153   >>
154 @end lilypond
155
156 @cindex @code{\context}
157
158 Like @code{\new}, the @code{\context} command also directs a music
159 expression to a context object, but gives the context an extra name. The
160 syntax is
161
162 @example
163   \context @var{type} = @var{id} @var{music}
164 @end example
165
166 This form will search for an existing context of type @var{type}
167 called @var{id}. If that context does not exist yet, it is created.
168 This is useful if the context is referred to later on. For example, when
169 setting lyrics the melody is in a named context
170
171 @example
172  \context Voice = "@b{tenor}" @var{music}
173 @end example
174
175 @noindent
176 so the texts can be properly aligned to its notes,
177
178 @example
179 \new Lyrics \lyricsto "@b{tenor}" @var{lyrics} 
180 @end example
181
182 @noindent
183
184 Another possibility is funneling two different music expressions into
185 one context. In the following example, articulations and notes are
186 entered separately,
187
188 @verbatim
189 music =  { c4 c4 }
190 arts =  { s4-. s4-> }
191 @end verbatim
192
193 They are combined by sending both to the same @context{Voice} context,
194
195 @verbatim
196   << \new Staff \context Voice = "A" \music
197      \context Voice = "A" \arts
198   >>
199 @end verbatim
200 @lilypond[raggedright]
201 music =  { c4   c4 }
202 arts =   { s4-. s4-> }
203    \relative c''  << \new Staff \context Voice = "A" \music
204      \context Voice = "A" \arts
205   >>
206 @end lilypond
207
208 With this mechanism, it is possible to define an Urtext (original
209 edition), with the option put several distinct articulations on the
210 same notes.
211
212 @cindex @code{\context}
213 @cindex creating contexts
214
215 The third command for creating contexts is
216 @example
217   \context @var{type} @var{music}
218 @end example
219
220
221 @noindent
222 This is similar to @code{\context} with @code{= @var{id}}, but matches
223 any context of type @var{type}, regardless of its given name.
224
225 This variant is used with music expressions that can be interpreted at
226 several levels. For example, the @code{\applyoutput} command (see
227 @ref{Running a function on all layout objects}). Without an explicit
228 @code{\context}, it is usually is applied to @context{Voice}
229
230 @example
231   \applyoutput #@var{function}   % apply to Voice
232 @end example
233
234 To have it interpreted at the @context{Score} or @context{Staff} level use
235 these forms
236
237 @example
238   \context Score \applyoutput #@var{function}
239   \context Staff \applyoutput #@var{function}
240 @end example
241
242
243 @node Changing context properties on the fly
244 @subsection Changing context properties on the fly
245
246 @cindex properties
247 @cindex @code{\set}
248 @cindex changing properties
249
250 Each context can have different @emph{properties}, variables contained
251 in that context. They can be changed during the interpretation step.
252 This is achieved by inserting the @code{\set} command in the music,
253
254 @quotation
255   @code{\set } @var{context}@code{.}@var{prop}@code{ = #}@var{value} 
256 @end quotation
257
258 For example,
259 @lilypond[verbatim,relative=2,fragment]
260   R1*2 
261   \set Score.skipBars = ##t
262   R1*2
263 @end lilypond
264
265 This command skips measures that have no notes. The result is that
266 multi rests are condensed.  The value assigned is a Scheme object. In
267 this case, it is @code{#t}, the boolean True value.
268
269 If the @var{context} argument is left out, then the current bottom-most
270 context (typically @context{ChordNames}, @context{Voice}, or
271 @context{Lyrics}) is used.  In this example,
272
273 @lilypond[verbatim,relative=2,fragment]
274   c8 c c c
275   \set autoBeaming = ##f
276   c8 c c c
277 @end lilypond
278
279 @noindent
280 the @var{context} argument to @code{\set} is left out, so automatic
281 beaming is switched off in the current @internalsref{Voice}.
282
283 Contexts are hierarchical, so if a bigger context was specified, for
284 example @context{Staff}, then the change would also apply to all
285 @context{Voice}s in the current stave. The change is applied
286 `on-the-fly', during the music, so that the setting only affects the
287 second group of eighth notes.
288
289 @cindex @code{\unset} 
290
291 There is also an @code{\unset} command,
292 @quotation
293   @code{\unset }@var{context}@code{.}@var{prop}
294 @end quotation
295
296 @noindent
297 which removes the definition of @var{prop}. This command removes
298 the definition only if it is set in @var{context}, so
299
300 @example
301  \set Staff.autoBeaming = ##f
302 @end example
303
304 @noindent
305 introduces a property setting at @code{Staff} level. The setting also
306 applies to the current @code{Voice}. However,
307
308 @example
309  \unset Voice.autoBeaming
310 @end example
311
312 @noindent
313 does not have any effect. To cancel this setting, the @code{\unset}
314 must be specified on the same level as the original @code{\set}. In
315 other words, undoing the effect of @code{Staff.autoBeaming = ##f}
316 requires
317 @example
318  \unset Staff.autoBeaming
319 @end example
320
321 Like @code{\set}, the @var{context} argument does not have to be
322 specified for a bottom context, so the two statements
323
324 @example
325   \set Voice.autoBeaming = ##t 
326   \set autoBeaming = ##t 
327 @end example 
328
329 @noindent
330 are equivalent.
331
332
333 @cindex \once
334 Settings that should only apply to a single time-step can be entered
335 with @code{\once}, for example in
336
337 @lilypond[verbatim,relative=2,fragment]
338   c4
339   \once \set fontSize = #4.7
340   c4
341   c4
342 @end lilypond
343
344 the property @code{fontSize} is unset automatically after the second
345 note.
346
347 A full description of all available context properties is in the
348 program reference, see
349 @ifhtml
350 @internalsref{Tunable-context-properties}.
351 @end ifhtml
352 @ifnothtml
353 Translation @arrow{} Tunable context properties.
354 @end ifnothtml
355
356
357 @node Modifying context plug-ins
358 @subsection Modifying context plug-ins
359
360 Notation contexts (like Score and Staff) not only store properties,
361 they also contain plug-ins, called ``engravers'' that create notation
362 elements. For example, the Voice context contains a
363 @code{Note_head_engraver} and the Staff context contains a
364 @code{Key_signature_engraver}.
365
366 For a full a description of each plug-in, see 
367 @ifhtml
368 @internalsref{Engravers}.
369 @end ifhtml
370 @ifnothtml
371 Program reference @arrow Translation @arrow{} Engravers.
372 @end ifnothtml
373 Every context described in
374 @ifhtml
375 @internalsref{Contexts}
376 @end ifhtml
377 @ifnothtml 
378 Program reference @arrow Translation @arrow{} Context.
379 @end ifnothtml
380 lists the engravers used for that context.
381
382
383 It can be useful to shuffle around these plug-ins. This is done by
384 starting a new context, with @code{\new} or @code{\context}, and
385 modifying it like this, 
386
387 @example
388  \new @var{context} \with @{
389    \consists @dots{}
390    \consists @dots{}
391    \remove  @dots{}
392    \remove @dots{}
393    @emph{etc.}
394  @}
395  @var{..music..}
396 @end example
397
398 where the @dots{} should be the name of an engraver. Here is a simple
399 example which removes @code{Time_signature_engraver} and
400 @code{Clef_engraver} from a @code{Staff} context,
401
402 @lilypond[relative=1, verbatim,fragment]
403 << \new Staff {
404     f2 g
405   }
406   \new Staff \with {
407      \remove "Time_signature_engraver"
408      \remove "Clef_engraver"
409   } {
410     f2 g2
411   }
412 >>
413 @end lilypond
414
415 In the second stave there are no time signature or clef symbols.  This
416 is a rather crude method of making objects disappear since it will affect
417 the entire staff. The spacing is adversely influenced too. A more
418 sophisticated methods of blanking objects is shown in @ref{Common
419 tweaks}.
420
421 The next example shows a practical application.  Bar lines and time
422 signatures are normally synchronized across the score.  This is done
423 by the @code{Timing_engraver}. This plug-in keeps an administration of
424 time signature, location within the measure, etc. By moving the
425 @code{Timing_engraver} engraver from @code{Score} to @code{Staff}
426 context, we can have a score where each staff has its own time
427 signature.
428
429 @cindex polymetric scores
430
431
432 @lilypond[relative=1,raggedright,verbatim,fragment]
433 \new Score \with {
434   \remove "Timing_engraver"
435 } <<
436   \new Staff \with {
437     \consists "Timing_engraver"
438   } {
439       \time 3/4
440       c4 c c c c c
441   }
442   \new Staff \with {
443     \consists "Timing_engraver"
444   } {
445        \time 2/4
446        c4 c c c c c
447   }
448 >>
449 @end lilypond
450
451
452 @node Layout tunings within contexts
453 @subsection Layout tunings within contexts
454
455 Each context is responsible for creating certain types of graphical
456 objects. The settings used for printing these objects are also stored by
457 context. By changing these settings, the appearance of objects can be
458 altered.
459  
460 The syntax for this is
461
462 @example
463   \override @var{context}.@var{name}@code{ #'}@var{property} = #@var{value}
464 @end example
465
466 Here @var{name} is the name of a graphical object, like @code{Stem} or
467 @code{NoteHead}, and @var{property} is an internal variable of the
468 formatting system (`grob property' or `layout property'). The latter is a
469 symbol, so it must be quoted. The subsection @ref{Constructing a
470 tweak} explains what to fill in for @var{name}, @var{property}, and
471 @var{value}. Here we only discuss functionality of this command.
472
473 The command
474
475 @verbatim
476   \override Staff.Stem #'thickness = #4.0 
477 @end verbatim
478
479 @noindent
480 makes stems thicker (the default is 1.3, with staff line thickness as a
481 unit). Since the command specifies @context{Staff} as context, it only
482 applies to the current staff. Other staves will keep their normal
483 appearance.  Here we see the command in action:
484
485 @lilypond[verbatim,relative=2,fragment]
486   c4
487   \override Staff.Stem #'thickness = #4.0 
488   c4
489   c4
490   c4
491 @end lilypond
492
493 The @code{\override} command changes the definition of the @code{Stem}
494 within the current @context{Staff}. After the command is interpreted
495 all stems are thickened.
496
497 Analogous to @code{\set}, the @var{context} argument may be left out,
498 causing it to default to @context{Voice}, and adding @code{\once} applies
499 the change during one timestep only 
500
501 @lilypond[fragment,verbatim,relative=2]
502   c4
503   \once \override Stem #'thickness = #4.0 
504   c4
505   c4 
506 @end lilypond
507
508 The @code{\override} must be done before the object is
509 started. Therefore, when altering @emph{Spanner} objects, like slurs or
510 beams, the @code{\override} command must be executed at the moment when
511 the object is created. In this example,
512
513
514 @lilypond[fragment,verbatim,relative=2]
515   \override Slur #'thickness = #3.0
516   c8[( c
517   \override Beam #'thickness = #0.6
518   c8 c]) 
519 @end lilypond
520
521 @noindent
522 the slur is fatter but the beam is not. This is because the command for
523 @code{Beam} comes after the Beam is started. Therefore it has no effect.
524
525 Analogous to @code{\unset}, the @code{\revert} command for a context
526 undoes a @code{\override} command; like with @code{\unset}, it only
527 affects settings that were made in the same context. In other words, the
528 @code{\revert} in the next example does not do anything.
529
530 @verbatim
531   \override Voice.Stem #'thickness = #4.0
532   \revert Staff.Stem #'thickness
533 @end verbatim
534
535
536
537
538 @seealso
539
540 Internals: @internalsref{OverrideProperty}, @internalsref{RevertProperty},
541 @internalsref{PropertySet}, @internalsref{All-backend-properties}, and
542 @internalsref{All-layout-objects}.
543
544
545 @refbugs
546
547 The back-end is not very strict in type-checking object properties.
548 Cyclic references in Scheme values for properties can cause hangs
549 or crashes, or both.
550
551
552 @node Changing context default settings
553 @subsection Changing context default settings
554
555 The adjustments of the previous subsections (@ref{Changing context
556 properties on the fly}, @ref{Modifying context plug-ins} and
557 @ref{Layout tunings within contexts}) can also be entered separate
558 from the music, in the @code{\layout} block,
559
560 @example
561 \layout @{
562   @dots{}
563   \context @{
564     \Staff
565
566     \set fontSize = #-2
567     \override Stem #'thickness = #4.0
568     \remove "Time_signature_engraver"
569   @}
570 @}
571 @end example
572
573 Here
574 @example
575   \Staff
576 @end example
577
578 @noindent
579 takes the existing definition for context @context{Staff} from the
580 identifier @code{\Staff}. 
581
582 The statements
583 @example
584     \set fontSize = #-2
585     \override Stem #'thickness = #4.0
586     \remove "Time_signature_engraver"
587 @end example
588
589 @noindent
590 affect all staves in the score.
591
592 Other contexts can be modified analogously.
593
594 The @code{\set} keyword is optional within the @code{\layout} block, so
595
596 @example
597 \context @{
598   @dots{}
599   fontSize = #-2
600 @}
601 @end example
602
603 @noindent
604 will also work.
605
606
607
608 @refbugs
609
610 It is not possible to collect context changes in a variable, and apply
611 them to one @code{\context} definition by referring to that variable.
612
613
614 @node Defining new contexts
615 @subsection Defining new contexts
616
617 Specific contexts, like @context{Staff} and @code{Voice}, are made of
618 simple building blocks, and it is possible to compose engraver
619 plug-ins in different combinations, thereby creating new types of
620 contexts.
621
622 The next example shows how to build a different type of
623 @context{Voice} context from scratch.  It will be similar to
624 @code{Voice}, but print centered slash noteheads only. It can be used
625 to indicate improvisation in Jazz pieces,
626
627 @lilypond[raggedright]
628   \layout { \context {
629     \name ImproVoice
630     \type "Engraver_group_engraver"
631     \consists "Note_heads_engraver"
632     \consists "Text_engraver"
633     \consists Pitch_squash_engraver
634     squashedPosition = #0
635     \override NoteHead #'style = #'slash
636     \override Stem #'transparent = ##t
637     \alias Voice
638   }
639   \context { \Staff
640     \accepts "ImproVoice"
641   }}
642
643
644 \relative c'' {
645     a4 d8 bes8 \new ImproVoice { c4^"ad lib" c 
646      c4 c^"undress" c_"while playing :)" c } 
647     a1 
648 }
649 @end lilypond
650
651
652 These settings are again done within a @code{\context} block inside a
653 @code{\layout} block,
654
655 @example
656   \layout @{
657     \context @{
658       @dots{}
659     @}
660   @}
661 @end example
662
663 In the following discussion, the example input shown should go on the
664 @dots{} in the previous fragment.
665
666 First, name the context gets a name. Instead of @context{Voice} it
667 will be called @context{ImproVoice},
668
669 @verbatim
670   \name ImproVoice
671 @end verbatim
672
673 Since it is similar to the @context{Voice}, we want commands that work
674 on (existing) @context{Voice}s to remain working. This is achieved by
675 giving the new context an alias @context{Voice},
676
677 @verbatim
678   \alias Voice
679 @end verbatim
680
681 The context will print notes, and instructive texts
682
683 @verbatim
684   \consists Note_heads_engraver
685   \consists Text_engraver
686 @end verbatim
687
688 but only on the center line,
689
690 @verbatim
691   \consists Pitch_squash_engraver
692   squashedPosition = #0
693 @end verbatim
694
695 The @internalsref{Pitch_squash_engraver} modifies note heads (created
696 by @internalsref{Note_heads_engraver}) and sets their vertical
697 position to the value of @code{squashedPosition}, in this case
698 @code{0}, the center line.
699
700 The notes look like a  slash, without a stem,
701
702 @verbatim
703     \override NoteHead #'style = #'slash
704     \override Stem #'transparent = ##t
705 @end verbatim
706
707
708 All these plug-ins have to cooperate, and this is achieved with a
709 special plug-in, which must be marked with the keyword @code{\type}.
710 This should always be @internalsref{Engraver_group_engraver},
711
712 @example
713  \type "Engraver_group_engraver"
714 @end example
715
716 Putting together, we get
717
718 @verbatim
719   \context {
720     \name ImproVoice
721     \type "Engraver_group_engraver"
722     \consists "Note_heads_engraver"
723     \consists "Text_engraver"
724     \consists Pitch_squash_engraver
725     squashedPosition = #0
726     \override NoteHead #'style = #'slash
727     \override Stem #'transparent = ##t
728     \alias Voice
729   }
730 @end verbatim
731
732 Contexts form hierarchies. We want to hang the @context{ImproVoice}
733 under @context{Staff}, just like normal @code{Voice}s. Therefore, we
734 modify the @code{Staff} definition with the @code{\accepts}
735 command,@footnote{The opposite of @code{\accepts} is @code{\denies},
736 which is sometimes when reusing existing context definitions. }
737
738
739
740 @verbatim
741   \context {
742     \Staff
743     \accepts ImproVoice    
744   }
745 @end verbatim 
746
747 Putting both into a @code{\layout} block, like
748
749 @example
750   \layout @{
751     \context @{
752       \name ImproVoice
753       @dots{}
754     @}
755   \context @{
756     \Staff
757     \accepts "ImproVoice"
758   @}
759 @}
760 @end example
761
762 Then the output at the start of this subsection can be entered as
763
764 @verbatim
765 \relative c'' {
766      a4 d8 bes8
767      \new ImproVoice {
768        c4^"ad lib" c 
769        c4 c^"undress"
770        c c_"while playing :)"
771      }
772      a1
773 }
774 @end verbatim
775   
776
777     
778
779 @node The \override command
780 @section The \override command
781
782 In the previous section, we have already touched on a command that
783 changes layout details, the @code{\override} command. In this section,
784 we will look at in more detail how to use the command in practice.
785 First, we will give a a few versatile commands, which are sufficient
786 for many situations. The next section will discuss general use of
787 @code{\override}.
788
789
790 @menu
791 * Common tweaks::               
792 * Constructing a tweak::        
793 * Navigating the program reference::  
794 * Layout interfaces::           
795 * Determining the grob property::  
796 * Difficult tweaks::            
797 @end menu
798
799
800
801 @node Common tweaks
802 @subsection Common tweaks
803
804 Some overrides are so common that predefined commands are provided as
805 a short-cut, for example, @code{\slurUp} and @code{\stemDown}. These
806 commands are described in
807 @ifhtml
808 the
809 @end ifhtml
810 @ref{Notation manual}, under the sections for slurs and stems
811 respectively.
812
813 The exact tuning possibilities for each type of layout object are
814 documented in the program reference of the respective
815 object. However, many layout objects share properties, which can be
816 used to apply generic tweaks.  We mention a few of these:
817
818 @itemize @bullet
819 @item The @code{extra-offset} property, which
820 @cindex @code{extra-offset}
821 has a pair of numbers as value, moves around objects in the printout.
822 The first number controls left-right movement; a positive number will
823 move the object to the right.  The second number controls up-down
824 movement; a positive number will move it higher.  The units of these
825 offsets are staff-spaces.  The @code{extra-offset} property is a
826 low-level feature: the formatting engine is completely oblivious to
827 these offsets.
828
829 In the following example, the second fingering is moved a little to
830 the left, and 1.8 staff space downwards:
831
832 @cindex setting object properties
833
834 @lilypond[fragment,relative=1,verbatim]
835 \stemUp
836 f-5
837 \once \override Fingering
838     #'extra-offset = #'(-0.3 . -1.8) 
839 f-5
840 @end lilypond
841
842 @item
843 Setting the @code{transparent} property will cause an object to be printed
844 in `invisible ink': the object is not printed, but all its other
845 behavior is retained. The object still takes up space, it takes part in
846 collisions, and slurs, and ties and beams can be attached to it.
847
848 @cindex transparent objects
849 @cindex removing objects
850 @cindex hiding objects
851 @cindex invisible objects
852 The following example demonstrates how to connect different voices
853 using ties. Normally, ties only connect two notes in the same
854 voice. By introducing a tie in a different voice,
855
856 @lilypond[fragment,relative=2]
857   << {
858       b8~ b8\noBeam
859   } \\ {
860        b[ g8]
861   } >>
862 @end lilypond
863
864 @noindent
865 and blanking the first up-stem in that voice, the tie appears to cross
866 voices:
867
868 @lilypond[fragment,relative=2,verbatim]
869   << {
870       \once \override Stem #'transparent = ##t
871       b8~ b8\noBeam
872   } \\ {
873        b[ g8]
874   } >>
875 @end lilypond
876
877 @item
878 The @code{padding} property for objects with
879 @cindex @code{padding}
880 @code{side-position-interface} can be set to increase distance between
881 symbols that are printed above or below notes. We only give an
882 example; a more elaborate explanation is in @ref{Constructing a
883 tweak}:
884
885 @lilypond[fragment,relative=1,verbatim]
886   c2\fermata
887   \override Script #'padding = #3
888   b2\fermata
889 @end lilypond
890
891 @end itemize
892
893 More specific overrides are also possible.  The next section
894 discusses in depth how to figure out these statements for yourself.
895
896
897 @node Constructing a tweak
898 @subsection Constructing a tweak
899
900 The general procedure of changing output, that is, entering
901 a command like
902
903 @example
904         \override Voice.Stem #'thickness = #3.0
905 @end example
906
907 @noindent
908 means that we have to determine these bits of information:
909
910 @itemize
911 @item the context: here @context{Voice}.
912 @item the layout object: here @code{Stem}.
913 @item the layout property: here @code{thickness}
914 @item a sensible value: here @code{3.0}
915 @end itemize  
916
917
918 @cindex internal documentation
919 @cindex finding graphical objects
920 @cindex graphical object descriptions 
921 @cindex tweaking
922 @cindex @code{\override}
923 @cindex @code{\set}
924 @cindex internal documentation
925
926 We demonstrate how to glean this information from the notation manual
927 and the program reference.
928
929 @node Navigating the program reference
930 @subsection Navigating the program reference
931
932 Suppose we want to move the fingering indication in the fragment
933 below:
934
935 @lilypond[fragment,relative=2,verbatim]
936 c-2
937 \stemUp
938 f
939 @end lilypond
940
941 If you visit the documentation on fingering instructions (in
942 @ref{Fingering instructions}), you will notice that there is written:
943
944 @quotation
945 @seealso
946
947 Program reference: @internalsref{FingerEvent} and @internalsref{Fingering}.
948
949 @end quotation
950
951
952
953 This fragment points to two parts of the program reference: a page
954 on @code{FingerEvent} and on @code{Fingering}.
955
956 The page on  @code{FingerEvent} describes the properties of the  music
957 expression for the input @code{-2}. The page contains many links
958 forward.  For example, it says
959
960 @quotation
961   Accepted by: @internalsref{Fingering_engraver},
962 @end quotation 
963
964 @noindent
965 That link brings us to the documentation for the Engraver, the
966 plug-in, which says
967
968 @quotation
969   This engraver creates the following layout objects: @internalsref{Fingering}.
970 @end quotation
971
972 In other words, once the @code{FingerEvent}s are interpreted, the
973 @code{Fingering_engraver} plug-in will process them.
974 The @code{Fingering_engraver} is also listed to create
975 @internalsref{Fingering} objects,
976
977
978   Lo and behold, that is also the
979 second bit of information listed under @b{See also} in the Notation
980 manual. By clicking around in the program reference, we can follow the
981 flow of information within the program, either forward (like we did
982 here), or backwards, following links like this:
983
984 @itemize @bullet
985
986 @item @internalsref{Fingering}:
987   @internalsref{Fingering} objects are created by:
988   @b{@internalsref{Fingering_engraver}}
989
990 @item @internalsref{Fingering_engraver}:
991 Music types accepted: @b{@internalsref{fingering-event}}
992 @item @internalsref{fingering-event}:
993 Music event type @code{fingering-event} is in Music expressions named
994 @b{@internalsref{FingerEvent}}
995 @end itemize
996
997 This path goes against the flow of information in the program: it
998 starts from the output, and ends at the input event.
999
1000 The program reference can also be browsed like a normal document.  It
1001 contains a chapter on
1002 @ifhtml
1003 @internalsref{Music-definitions},
1004 @end ifhtml
1005 @ifnothtml
1006 @code{Music definitions}
1007 @end ifnothtml
1008 on @internalsref{Translation}, and the @internalsref{Backend}. Every
1009 chapter lists all the definitions used, and all properties that may be
1010 tuned.
1011
1012  
1013 @node Layout interfaces
1014 @subsection Layout interfaces
1015
1016 @cindex interface, layout
1017 @cindex layout interface
1018
1019 The HTML page which we found in the previous section, describes the
1020 layout object called @internalsref{Fingering}. Such an object is a
1021 symbol within the score. It has properties, which store numbers (like
1022 thicknesses and directions), but also pointers to related objects.  A
1023 layout object is also called @emph{grob},
1024 @cindex grob
1025 which is short for Graphical Object.
1026
1027
1028 The page for @code{Fingering} lists the definitions for the
1029 @code{Fingering} object. For example, the page says
1030
1031 @quotation
1032   @code{padding} (dimension, in staff space):
1033   
1034   @code{0.6}
1035 @end quotation
1036
1037 which means that the number will be kept at a distance of at least 0.6
1038 of the note head.
1039
1040
1041 Each layout object may have several functions as a notational or
1042 typographical element. For example, the Fingering object
1043 has the following aspects
1044
1045 @itemize @bullet
1046 @item Its size is independent of the horizontal spacing, unlike slurs or beams.
1047
1048 @item It is a piece of text. Granted, it is usually a very short text.
1049
1050 @item That piece of text is typeset with a font, unlike slurs or beams.
1051 @item Horizontally, the center of the symbol should be aligned to the
1052 center of the notehead
1053 @item Vertically, the symbol is placed next to the note and the staff.
1054
1055 @item The
1056  vertical position is also coordinated with other super and subscript
1057 symbols.
1058 @end itemize
1059
1060 Each of these aspects is captured in a so-called @emph{interface},
1061 which are listed on the @internalsref{Fingering} page at the bottom
1062
1063 @quotation
1064 This object supports the following interfaces:
1065 @internalsref{item-interface},
1066 @internalsref{self-alignment-interface},
1067 @internalsref{side-position-interface}, @internalsref{text-interface},
1068 @internalsref{text-script-interface}, @internalsref{font-interface},
1069 @internalsref{finger-interface}, and @internalsref{grob-interface}.
1070 @end quotation
1071
1072 Clicking any of the links will take you to the page of the respective
1073 object interface.  Each interface has a number of properties.  Some of
1074 them are not user-serviceable (``Internal properties''), but others
1075 are.
1076
1077 We have been talking of `the' @code{Fingering} object, but actually it
1078 does not amount to much. The initialization file
1079 @file{scm/define-grobs.scm} shows the soul of the `object',
1080
1081 @verbatim
1082    (Fingering
1083      . (
1084         (print-function . ,Text_interface::print)
1085         (padding . 0.6)
1086         (staff-padding . 0.6)
1087         (self-alignment-X . 0)
1088         (self-alignment-Y . 0)
1089         (script-priority . 100)
1090         (font-encoding . number)
1091         (font-size . -5)
1092         (meta . ((interfaces . (finger-interface font-interface
1093                text-script-interface text-interface
1094                side-position-interface self-alignment-interface
1095                item-interface))))
1096   ))
1097 @end verbatim
1098
1099 @noindent
1100 As you can see, the @code{Fingering} object is nothing more than a
1101 bunch of variable settings, and the webpage in the Program Reference
1102 is directly generated from this definition.
1103
1104 @node Determining the grob property
1105 @subsection Determining the grob property
1106
1107
1108 Recall that we wanted to change the position of the @b{2} in 
1109
1110 @lilypond[fragment,relative=2,verbatim]
1111 c-2
1112 \stemUp
1113 f
1114 @end lilypond
1115
1116 Since the @b{2} is vertically positioned next to its note, we have to
1117 meddle with the interface associated with this positioning. This is
1118 done using @code{side-position-interface}. The page for this interface 
1119 says
1120
1121 @quotation
1122 @code{side-position-interface}
1123
1124   Position a victim object (this one) next to other objects (the
1125   support).  The property @code{direction} signifies where to put the
1126   victim object relative to the support (left or right, up or down?)
1127 @end quotation
1128
1129 @cindex padding
1130 @noindent
1131 below this description, the variable @code{padding} is described as
1132 @quotation
1133 @table @code
1134 @item padding
1135  (dimension, in staff space)
1136
1137  Add this much extra space between objects that are next to each
1138   other. 
1139 @end table
1140 @end quotation
1141
1142 By increasing the value of @code{padding}, we can move away the
1143 fingering.  The following command inserts 3 staff spaces of white
1144 between the note and the fingering:
1145 @example
1146 \once \override Voice.Fingering #'padding = #3
1147 @end example
1148
1149 Inserting this command before the Fingering object is created,
1150 i.e. before @code{c2}, yields the following result:
1151
1152 @lilypond[relative=2,fragment,verbatim]
1153 \once \override Voice.Fingering #'padding = #3
1154 c-2
1155 \stemUp
1156 f
1157 @end lilypond
1158
1159
1160 In this case, the context for this tweak is @context{Voice}.  This
1161 fact can also be deduced from the program reference, for the page for
1162 the @internalsref{Fingering_engraver} plug-in says
1163
1164 @quotation
1165   Fingering_engraver is part of contexts: @dots{} @b{@internalsref{Voice}}
1166 @end quotation
1167
1168 @node Difficult tweaks
1169 @subsection Difficult tweaks
1170
1171 There are two classes of difficult adjustments. First, when there are
1172 several of the same objects at one point, and you want to adjust only
1173 one. For example, if you want to change only one note head in a chord.
1174
1175 In this case, the @code{\applyoutput} function must be used.  The
1176 next example defines a Scheme function @code{set-position-font-size}
1177 that sets the @code{font-size} property, but only  
1178 on objects that have @internalsref{note-head-interface} and are at the
1179 right Y-position.
1180
1181 @lilypond[verbatim]
1182 #(define ((set-position-font-size pos size) grob origin current)
1183   (let*
1184       ((interfaces (ly:grob-property grob 'interfaces))
1185        (position (ly:grob-property grob 'staff-position)))
1186   (if (and
1187   
1188         ; is this a note head?
1189         (memq 'note-head-interface interfaces)
1190
1191         ; is the Y coordinate right?
1192         (= pos position))
1193
1194       ; then do it.
1195       (set! (ly:grob-property grob 'font-size) size))))
1196
1197 \relative {
1198     c
1199     \applyoutput #(set-position-font-size -2 4)
1200     <c e g>
1201 }
1202 @end lilypond
1203
1204 @noindent
1205 A similar technique can be used for accidentals. In that case, the
1206 function should check for @code{accidental-interface}.
1207
1208 Another difficult adjustment is the appearance of spanner objects,
1209 such as slur and tie. Initially, only one of these objects is created,
1210 and they can be adjust with the normal mechanism. However, in some
1211 cases the spanners cross line breaks. If this happens, these objects
1212 are cloned.  A separate object is created for every system that it is
1213 in. These are clones of the original object and inherit all
1214 properties, including @code{\override}s.
1215
1216 In other words, an @code{\override} always affects all pieces of a
1217 broken spanner. To change only one part of a spanner at a line break,
1218 it is necessary to hook into the formatting process. The
1219 @code{after-line-breaking-callback} property contains the Scheme procedure
1220 that is called after line breaks have been determined, and layout
1221 objects have been split over different systems.
1222
1223 In the following example, we define a procedure
1224 @code{my-callback}. This procedure
1225  
1226 @itemize @bullet
1227 @item
1228 determines if we have been split across line breaks
1229 @item
1230 if yes, retrieves all the split objects
1231 @item
1232 checks if we are the last of the split objects
1233 @item
1234 if yes, it sets @code{extra-offset}.
1235 @end itemize
1236
1237 This procedure is installed into @internalsref{Tie}, so the last part
1238 of broken tie is translated up.
1239
1240
1241 @lilypond[verbatim,raggedright]
1242 #(define (my-callback grob)
1243   (let* (
1244
1245       ; have we been split? 
1246       (orig (ly:grob-original grob))
1247
1248       ; if yes, get the split pieces (our siblings)
1249       (siblings (if (ly:grob? orig) (ly:spanner-broken-into orig) '() )))
1250
1251       
1252     (if (and (>= (length siblings) 2)
1253              (eq? (car (last-pair siblings)) grob))
1254         (ly:grob-set-property! grob 'extra-offset '(-2 . 5))
1255         )))
1256
1257 \relative c'' { 
1258     \override Tie  #'after-line-breaking-callback =
1259     #my-callback
1260     c1 ~ \break c2 ~ c
1261 }
1262 @end lilypond
1263
1264
1265 When applying this trick, the new @code{after-line-breaking-callback}
1266 should also call the old @code{after-line-breaking-callback}, if there
1267 is one. For example, if using this with @code{Slur},
1268 @code{Slur::after_line_breaking} should also be called.
1269
1270 @node Fonts
1271 @section Fonts
1272
1273 @menu
1274 * Selecting font sizes::        
1275 * Font selection::              
1276 @end menu
1277
1278
1279
1280 @node Selecting font sizes
1281 @subsection Selecting font sizes
1282
1283
1284 The easiest method of setting the font size of any context, is by
1285 setting the @code{fontSize} property.
1286
1287 @lilypond[fragment,relative=1,verbatim]
1288   c8
1289   \set fontSize = #-4
1290   c f
1291   \set fontSize = #3
1292   g
1293 @end lilypond
1294
1295 It does not change the size of variable symbols, such as beams or
1296 slurs.
1297
1298 Internally, the @code{fontSize} context property will cause
1299 @code{font-size} property to be set in all layout objects.  The value
1300 of @code{font-size} is a number indicating the size relative to the
1301 standard size for the current staff height.  Each step up is an
1302 increase of approximately 12% of the font size. Six steps is exactly a
1303 factor two. The Scheme function @code{magstep} converts a
1304 @code{font-size} number to a scaling factor.
1305
1306 @lilypond[fragment,relative=1,verbatim]
1307   c8
1308   \override NoteHead #'font-size = #-4
1309   c f
1310   \override NoteHead #'font-size = #3
1311   g
1312 @end lilypond
1313
1314 LilyPond has fonts in different design sizes. The music fonts for
1315 smaller sizes are chubbier, while the text fonts are relatively wider.
1316 Font size changes are achieved by scaling the design size that is
1317 closest to the desired size. The standard font size (for
1318 @code{font-size} equals 0), depends on the standard staff height. For
1319 a 20 pt staff, a 10pt font is selected.
1320
1321 The @code{font-size} mechanism does not work for fonts selected
1322 through @code{font-name}. These may be scaled with
1323 @code{font-magnification}. The @code{font-size} property can only be
1324 set on layout objects that use fonts; these are the ones supporting
1325 @internalsref{font-interface} layout interface.
1326
1327 @refcommands
1328
1329 The following commands set @code{fontSize} for the current voice:
1330
1331 @cindex @code{\tiny}
1332 @code{\tiny}, 
1333 @cindex @code{\small}
1334 @code{\small}, 
1335 @cindex @code{\normalsize}
1336 @code{\normalsize}.
1337
1338
1339
1340 @cindex magnification
1341 @cindex cue notes
1342
1343
1344 @node Font selection
1345 @subsection Font selection
1346
1347
1348
1349 @cindex font selection
1350 @cindex font magnification
1351 @cindex @code{font-interface}
1352
1353 By setting the object properties described below, you can select a
1354 font from the preconfigured font families.  LilyPond has default
1355 support for the feta music fonts and @TeX{}'s Computer Modern text
1356 fonts.
1357
1358
1359 @itemize @bullet
1360 @item @code{font-encoding}
1361 is a symbol that sets layout of the glyphs. Choices include @code{ec}
1362 for @TeX{} EC font encoding, @code{fetaBraces} (for piano staff
1363 braces), @code{fetaMusic} (the standard music font, including ancient
1364 glyphs), @code{fetaDynamic} (for dynamic signs) and @code{fetaNumber}
1365 for the number font.
1366
1367
1368 @item @code{font-family}
1369  is a symbol indicating the general class of the typeface.  Supported are
1370 @code{roman} (Computer Modern), @code{sans}, and @code{typewriter}.
1371   
1372 @item @code{font-shape}
1373   is a symbol indicating the shape of the font, there are typically
1374 several font shapes available for each font family. Choices are
1375 @code{italic}, @code{caps}, and @code{upright}.
1376
1377 @item @code{font-series}
1378 is a  symbol indicating the series of the font. There are typically several
1379 font series for each font family and shape. Choices are @code{medium}
1380 and @code{bold}. 
1381
1382 @end itemize
1383
1384 Fonts selected in the way sketched above come from a predefined style
1385 sheet.
1386
1387  The font used for printing a object can be selected by setting
1388 @code{font-name}, e.g.
1389 @example
1390   \override Staff.TimeSignature
1391       #'font-name = #"cmr17"
1392 @end example
1393
1394 @noindent
1395 Any font can be used, as long as it is available to @TeX{}. Possible
1396 fonts include foreign fonts or fonts that do not belong to the
1397 Computer Modern font family.  The size of fonts selected in this way
1398 can be changed with the @code{font-magnification} property.  For
1399 example, @code{2.0} blows up all letters by a factor 2 in both
1400 directions.
1401
1402 @cindex font size
1403 @cindex font magnification
1404
1405
1406
1407 @seealso
1408
1409 Init files: @file{ly/declarations-init.ly} contains hints how new
1410 fonts may be added to LilyPond.
1411
1412
1413
1414 @node Text markup
1415 @section Text markup
1416 @cindex text markup
1417 @cindex markup text
1418
1419
1420 @cindex typeset text
1421
1422 The internal mechanism to typeset texts is accessed with the keyword
1423 @code{\markup}. Within markup mode, you can enter texts similar to
1424 lyrics. They are simply entered, while commands use the backslash @code{\}.
1425 @cindex markup
1426
1427 @lilypond[verbatim,fragment,relative=1]
1428  c1^\markup { hello }
1429  c1_\markup { hi there }
1430  c1^\markup { hi \bold there, is \italic anyone home? }
1431 @end lilypond
1432
1433 @cindex font switching
1434
1435 The markup in the example demonstrates font switching commands.  The
1436 command @code{\bold} and @code{\italic} apply to the first following 
1437 word only; enclose a set of texts with braces to apply a command
1438 to more words:
1439 @example
1440   \markup @{ \bold @{ hi there @} @}
1441 @end example
1442
1443 @noindent
1444 For clarity, you can also do this for single arguments, e.g.
1445
1446 @verbatim
1447   \markup { is \italic { anyone } home }
1448 @end verbatim
1449
1450 @cindex font size, texts
1451
1452
1453 In markup mode you can compose expressions, similar to mathematical
1454 expressions, XML documents, and music expressions.  The braces group
1455 notes into horizontal lines. Other types of lists also exist: you can
1456 stack expressions grouped with @code{<} and @code{>} vertically with
1457 the command @code{\column}. Similarly, @code{\center-align} aligns
1458 texts by their center lines:
1459
1460 @lilypond[verbatim,fragment,relative=1]
1461  c1^\markup { \column < a bbbb c > }
1462  c1^\markup { \center-align < a bbbb c > }
1463  c1^\markup { \line < a b c > }
1464 @end lilypond
1465
1466
1467 Markups can be stored in variables, and these variables
1468 may be attached to notes, like
1469 @verbatim
1470 allegro = \markup { \bold \large { Allegro } }
1471  { a^\allegro b c d }
1472 @end verbatim
1473
1474
1475 Some objects have alignment procedures of their own, which cancel out
1476 any effects of alignments applied to their markup arguments as a
1477 whole.  For example, the @internalsref{RehearsalMark} is horizontally
1478 centered, so using @code{\mark \markup @{ \left-align .. @}} has no
1479 effect.
1480
1481 Similarly, for moving whole texts over notes with
1482 @code{\raise}, use the following trick:
1483 @lilypond[verbatim]
1484 {
1485   c'^\markup { \raise #0.5 not-raised }
1486   c'^\markup {  "" \raise #0.5 raised }
1487 }
1488 @end lilypond
1489
1490 On the second note, the text @code{raised} is moved relative to the
1491 empty string @code{""} which is not visible.  Alternatively, complete
1492 objects can be moved with layout properties such as @code{padding} and
1493 @code{extra-offset}.
1494
1495
1496
1497
1498 @seealso
1499
1500 Init files:  @file{scm/new-markup.scm}.
1501
1502
1503 @refbugs
1504
1505 No kerning or generation of ligatures is only done when the by @TeX{}
1506 backend is used.  In this case, LilyPond does not account for them so
1507 texts will be spaced slightly too wide.
1508
1509 Syntax errors for markup mode are confusing.
1510
1511
1512 @menu
1513 * Text encoding::               
1514 * Nested scores::               
1515 * Overview of text markup commands::  
1516 @end menu
1517
1518 @node Text encoding
1519 @subsection Text encoding
1520
1521 Texts can be entered in different encodings.  The encoding of the
1522 file can be set with @code{\encoding}.
1523
1524 @example
1525   \encoding "latin1"
1526 @end example
1527
1528 This command may be placed anywhere in the input file. The current
1529 encoding is passed as an extra argument to @code{\markup} commands,
1530 and is passed similarly to lyric syllables.
1531
1532 If no @code{\encoding} has been specified, then the encoding is taken
1533 from the @code{\layout} block (or @code{\paper}, if @code{\layout}
1534 does not specify encoding). The variable @code{inputencoding} may be
1535 set to a string or symbol specifying  the encoding, e.g.
1536
1537 @verbatim
1538   \layout {
1539     inputencoding = "latin1"
1540   } 
1541 @end verbatim
1542
1543 Normal strings, are unaffected by @code{\encoding}. This means that
1544 the following will usually not produce ba@ss{}tuba in the title.
1545
1546 @verbatim
1547   \header {
1548     title = "Grazing cow"
1549     instrument = "Baßtuba"
1550   }
1551 @end verbatim
1552
1553 Rather, you should say
1554 @verbatim
1555     instrument = \markup { Baßtuba }
1556 @end verbatim
1557
1558 @noindent
1559 or set @code{inputencoding} in the @code{\paper} block. 
1560
1561 There is a special encoding, called @code{TeX}. This encoding does not
1562 reencode text for the font used. Rather, it tries to guess the width
1563 of @TeX{} commands, such as @code{\"}. Strings encoded with @code{TeX}
1564 are passed to the output back-end verbatim.
1565
1566 @cindex encoding
1567 @cindex @code{\encoding}
1568 @cindex inputencoding
1569 @cindex @TeX{} commands in strings
1570
1571
1572 @node Nested scores
1573 @subsection Nested scores
1574
1575 It is possible to nest music inside markups, by adding a @code{\score}
1576 block to markup expression. Such a score must contain a @code{\layout}
1577 block.
1578
1579 @lilypond[verbatim,raggedright]
1580 \relative {
1581   c4  d^\markup {
1582     \score {
1583       \relative { c4 d e f }
1584       \layout { }
1585     }
1586   }
1587   e f
1588 }
1589 @end lilypond
1590  
1591
1592
1593 @node  Overview of text markup commands
1594 @subsection Overview of text markup commands
1595
1596 The following commands can all be used inside @code{\markup @{ @}}.
1597
1598 @include markup-commands.tely
1599
1600
1601 @node Global layout
1602 @section Global layout
1603
1604 The global layout determined by three factors: the page layout, the
1605 line breaks, and the spacing. These all influence each other. The
1606 choice of spacing determines how densely each system of music is set,
1607 which influences where line breaks are chosen, and thus ultimately how
1608 many pages a piece of music takes.
1609
1610 Globally spoken, this procedure happens in three steps: first,
1611 flexible distances (``springs'') are chosen, based on durations. All
1612 possible line breaking combination are tried, and the one with the
1613 best results --- a layout that has uniform density and requires as
1614 little stretching or cramping as possible --- is chosen.
1615
1616 After spacing and linebreaking, the systems are distributed across
1617 pages, taking into account the size of the page, and the size of the
1618 titles.
1619
1620
1621
1622 @menu
1623 * Setting global staff size::   
1624 * Vertical spacing of piano staves::  
1625 * Vertical spacing::            
1626 * Horizontal spacing::          
1627 * Line length::                 
1628 * Line breaking::               
1629 * Multiple movements::          
1630 * Creating titles::             
1631 * Page breaking::               
1632 * paper size::                  
1633 * Page layout::                 
1634 @end menu
1635
1636
1637 @node Setting global staff size
1638 @subsection Setting global staff size
1639
1640 @cindex font size, setting
1641 @cindex staff size, setting
1642 @cindex @code{layout} file
1643
1644 The Feta font provides musical symbols at eight  different
1645 sizes. Each font is tuned for a different staff size: at a smaller size
1646 the font becomes heavier, to match the relatively heavier staff lines.
1647 The recommended font sizes are listed in the following table:
1648
1649 @multitable @columnfractions  .25 .25 .25 .25
1650
1651 @item @b{font name}
1652 @tab @b{staff height (pt)}
1653 @tab @b{staff height (mm)}
1654 @tab @b{use}
1655
1656 @item feta11
1657 @tab 11.22
1658 @tab 3.9 
1659 @tab pocket scores
1660
1661 @item feta13
1662 @tab 12.60
1663 @tab 4.4
1664 @tab
1665  
1666 @item feta14
1667 @tab 14.14
1668 @tab 5.0
1669 @tab 
1670
1671 @item feta16
1672 @tab 15.87
1673 @tab 5.6
1674 @tab 
1675
1676 @item feta18
1677 @tab 17.82
1678 @tab 6.3
1679 @tab song books
1680
1681 @item feta20
1682 @tab 20
1683 @tab 7.0
1684 @tab standard parts 
1685
1686 @item feta23
1687 @tab 22.45 
1688 @tab 7.9
1689 @tab 
1690
1691 @item feta26
1692 @tab 25.2 
1693 @tab 8.9
1694 @tab
1695 @c modern rental material  ?
1696
1697 @end multitable
1698
1699 These fonts are available in any sizes. The context property
1700 @code{fontSize} and the layout property @code{staff-space} (in
1701 @internalsref{StaffSymbol}) can be used to tune size for individual
1702 staves. The size of individual staves are relative to the global size,
1703 which can be set   in the following manner:
1704
1705 @example
1706   #(set-global-staff-size 14)
1707 @end example
1708
1709 This sets the global default size to 14pt staff height, and scales all
1710 fonts accordingly.
1711
1712 @seealso
1713
1714 This manual: @ref{Selecting font sizes}.
1715
1716
1717
1718
1719 @node Vertical spacing of piano staves
1720 @subsection Vertical spacing of piano staves
1721
1722 The distance between staves of a @internalsref{PianoStaff} cannot be
1723 computed during formatting. Rather, to make cross-staff beaming work
1724 correctly, that distance has to be fixed beforehand.
1725  
1726 The distance of staves in a @code{PianoStaff} is set with the
1727 @code{forced-distance} property of the
1728 @internalsref{VerticalAlignment} object, created in
1729 @internalsref{PianoStaff}.
1730
1731 It can be adjusted as follows
1732 @verbatim
1733 \new PianoStaff \with {
1734    \override VerticalAlignment #'forced-distance = #7
1735 } {
1736   ...
1737 }
1738 @end verbatim
1739 This would bring the staves together at a distance of 7 staff spaces,
1740 measured from the center line of each staff.
1741
1742 The difference is demonstrated in the following example,
1743 @lilypond[verbatim]
1744 \relative <<
1745   \new PianoStaff \with {
1746     \override VerticalAlignment #'forced-distance = #7
1747   } <<
1748     \new Staff { c1 }
1749     \new Staff { c }
1750   >>
1751   \new PianoStaff <<
1752     \new Staff { c }
1753     \new Staff { c }
1754   >>
1755 >>    
1756 @end lilypond
1757
1758
1759
1760 @refbugs
1761
1762 @code{forced-distance} cannot be changed per system.
1763
1764 @node Vertical spacing
1765 @subsection Vertical spacing
1766
1767 @cindex vertical spacing
1768 @cindex distance between staves
1769 @cindex staff distance
1770 @cindex between staves, distance
1771 @cindex staves per page
1772 @cindex space between staves
1773
1774 The height of each system is determined automatically. To prevent
1775 systems from bumping into each other, some minimum distances are set.
1776 By changing these, you can put staves closer together, and thus put
1777 more systems onto one page.
1778
1779 Normally staves are stacked vertically. To make staves maintain a
1780 distance, their vertical size is padded. This is done with the
1781 property @code{minimumVerticalExtent}. It takes a pair of numbers, so
1782 if you want to make it smaller from its default, then you could set
1783 @example
1784   \set Staff.minimumVerticalExtent = #'(-4 . 4)
1785 @end example
1786 This sets the vertical size of the current staff to 4 staff spaces on
1787 either side of the center staff line.  The argument of
1788 @code{minimumVerticalExtent} is interpreted as an interval, where the
1789 center line is the 0, so the first number is generally negative.  The
1790 staff can be made larger at the bottom by setting it to @code{(-6
1791 . 4)}. 
1792
1793
1794 @seealso
1795
1796 Internals: Vertical alignment of staves is handled by the
1797 @internalsref{VerticalAlignment} object.
1798
1799 @refbugs
1800
1801 @code{minimumVerticalExtent} is syntactic sugar for setting
1802 @code{minimum-Y-extent} of the @internalsref{VerticalAxisGroup} of the
1803 current context. It can only be changed score wide.
1804
1805
1806
1807 @node Horizontal spacing
1808 @subsection Horizontal Spacing
1809
1810 The spacing engine translates differences in durations into
1811 stretchable distances (``springs'') of differring lengths. Longer
1812 durations get more space, shorter durations get less.  The shortest
1813 durations get a fixed amount of space (which is controlled by
1814 @code{shortest-duration-space} in the @internalsref{SpacingSpanner} object). 
1815 The longer the duration, the more space it gets: doubling a
1816 duration adds a fixed amount (this amount is controlled by
1817 @code{spacing-increment}) of space to the note.
1818
1819 For example, the following piece contains lots of half, quarter, and
1820 8th notes, the eighth note is followed by 1 note head width (NHW). 
1821 The quarter note is followed by 2 NHW, the half by 3 NHW, etc.
1822 @lilypond[fragment,verbatim,relative=1]
1823 c2 c4. c8 c4. c8 c4. c8 c8
1824 c8 c4 c4 c4
1825 @end lilypond
1826
1827 Normally, @code{spacing-increment} is set to 1.2 staff space, which is
1828 approximately the width of a note head, and
1829 @code{shortest-duration-space} is set to 2.0, meaning that the
1830 shortest note gets 2.4 staff space (2.0 times the
1831 @code{spacing-increment}) of horizontal space. This space is counted
1832 from the left edge of the symbol, so the shortest notes are generally
1833 followed by one NHW of space.
1834
1835 If one would follow the above procedure exactly, then adding a single
1836 32th note to a score that uses 8th and 16th notes, would widen up the
1837 entire score a lot. The shortest note is no longer a 16th, but a 32nd,
1838 thus adding 1 NHW to every note. To prevent this, the shortest
1839 duration for spacing is not the shortest note in the score, but rather
1840 the one which occurs most frequently.
1841
1842
1843 The most common shortest duration is determined as follows: in every
1844 measure, the shortest duration is determined. The most common short
1845 duration, is taken as the basis for the spacing, with the stipulation
1846 that this shortest duration should always be equal to or shorter than
1847 1/8th note. The shortest duration is printed when you run
1848 @code{lilypond} with the @code{--verbose} option.
1849
1850 These durations may also be customized. If you set the
1851 @code{common-shortest-duration} in @internalsref{SpacingSpanner}, then
1852 this sets the base duration for spacing. The maximum duration for this
1853 base (normally 1/8th), is set through @code{base-shortest-duration}.
1854
1855 @cindex @code{common-shortest-duration}
1856 @cindex @code{base-shortest-duration}
1857 @cindex @code{stem-spacing-correction}
1858 @cindex @code{spacing}
1859
1860 Notes that are even shorter than the commoon shortest note are
1861 followed by a space that is proportional to their duration relative to
1862 the common shortest note.  So if we were to add only a few 16th notes
1863 to the example above, they would be followed by half a NHW:
1864
1865 @lilypond[fragment,verbatim,relative=2]
1866  c2 c4. c8 c4. c16[ c] c4. c8 c8 c8 c4 c4 c4
1867 @end lilypond
1868
1869
1870 In the introduction (see @ref{Engraving}), it was explained that stem
1871 directions influence spacing. This is controlled with the
1872 @code{stem-spacing-correction} property in the
1873 @internalsref{NoteSpacing}, object. These are generated for every
1874 @internalsref{Voice} context. The @code{StaffSpacing} object
1875 (generated at @internalsref{Staff} context) contains the same property
1876 for controlling the stem/bar line spacing. The following example shows
1877 these corrections, once with default settings, and once with
1878 exaggerated corrections:
1879
1880 @lilypond[raggedright]
1881 {
1882       c'4 e''4 e'4 b'4 |
1883       b'4 e''4 b'4 e''4|
1884       \override Staff.NoteSpacing #'stem-spacing-correction = #1.5
1885       \override Staff.StaffSpacing #'stem-spacing-correction = #1.5
1886       c'4 e''4 e'4 b'4 |
1887       b'4 e''4 b'4 e''4|      
1888 }
1889 @end lilypond
1890
1891
1892 @seealso
1893
1894 Internals: @internalsref{SpacingSpanner}, @internalsref{NoteSpacing},
1895 @internalsref{StaffSpacing}, @internalsref{SeparationItem}, and
1896 @internalsref{SeparatingGroupSpanner}.
1897
1898 @refbugs
1899
1900 Spacing is determined on a score wide basis. If you have a score that
1901 changes its character (measured in durations) halfway during the
1902 score, the part containing the longer durations will be spaced too
1903 widely.
1904
1905 There is no convenient mechanism to manually override spacing.  The
1906 following work-around may be used to insert extra space into a score.
1907 @example
1908  \once \override Score.SeparationItem #'padding = #1
1909 @end example
1910
1911 No work-around exists for decreasing the amount of space.
1912
1913 @node Line length
1914 @subsection Line length
1915
1916 @cindex page breaks
1917 @cindex breaking pages
1918
1919 @cindex @code{indent}
1920 @cindex @code{linewidth}
1921
1922 @c Although linewidth can be set in \layout, it should be set in paper
1923 @c block, to get page layout right.
1924 @c Setting indent in \paper block makes not much sense, but it works.
1925
1926 @c Bit verbose and vague, use examples?
1927 The most basic settings influencing the spacing are @code{indent} and
1928 @code{linewidth}.  They are set in the @code{\layout} block.  They
1929 control the indentation of the first line of music, and the lengths of
1930 the lines.
1931
1932 If @code{raggedright} is set to true in the @code{\layout} block, then
1933 the lines are justified at their natural length.  This useful for
1934 short fragments, and for checking how tight the natural spacing is.
1935
1936 @cindex page layout
1937 @cindex vertical spacing
1938
1939 The option @code{raggedlast} is similar to @code{raggedright}, but
1940 only affects the last line of the piece.  No restrictions are put on
1941 that line.  The result is similar to formatting text paragraphs.  In a
1942 paragraph, the last line simply takes its natural length.
1943 @c Note that for text there are several options for the last line.
1944 @c While Knuth TeX uses natural length, lead typesetters use the same
1945 @c stretch as the previous line.  eTeX uses \lastlinefit to
1946 @c interpolate between both these solutions.
1947
1948 @node Line breaking
1949 @subsection Line breaking
1950
1951 @cindex line breaks
1952 @cindex breaking lines
1953
1954 Line breaks are normally computed automatically. They are chosen such
1955 that lines look neither cramped nor loose, and that consecutive lines
1956 have similar density.
1957
1958 Occasionally you might want to override the automatic breaks; you can
1959 do this by  specifying @code{\break}. This will force a line break at
1960 this point.  Line breaks can only occur at places where there are bar
1961 lines.  If you want to have a line break where there is no bar line,
1962 you can force an invisible bar line by entering @code{\bar
1963 ""}. Similarly, @code{\noBreak} forbids a line break at a 
1964 point.
1965
1966
1967 @cindex regular line breaks
1968 @cindex four bar music. 
1969
1970 For line breaks at regular intervals  use @code{\break} separated by
1971 skips and repeated with @code{\repeat}:
1972 @example
1973 <<  \repeat unfold 7 @{
1974          s1 \noBreak s1 \noBreak
1975          s1 \noBreak s1 \break  @}
1976    @emph{the real music}
1977 >> 
1978 @end  example
1979
1980 @noindent
1981 This makes the following 28 measures (assuming 4/4 time) be broken every
1982 4 measures, and only there.
1983
1984 @refcommands
1985
1986 @code{\break}, and @code{\noBreak}.
1987 @cindex @code{\break}
1988 @cindex @code{\noBreak}
1989
1990 @seealso
1991
1992 Internals: @internalsref{BreakEvent}.
1993
1994
1995
1996 @node Multiple movements
1997 @subsection Multiple movements
1998
1999 @cindex bibliographic information
2000 @cindex titles
2001 @cindex composer
2002 @cindex Engraved by LilyPond
2003
2004 A document may contains multiple pieces of music. Examples of these
2005 are an etude book, or an orchestral part with multiple movements.
2006 Each movement is entered with a @code{\score} block,
2007
2008 @example
2009   \score @{
2010      @var{..music..}
2011   @}
2012 @end example
2013
2014 The movements are combined together to  
2015 @code{\book} block is used to group the individual movements.
2016
2017 @example
2018 \book @{
2019   \score @{
2020      @var{..}
2021   @}
2022   \score @{
2023      @var{..}
2024   @}
2025 @}
2026 @end example
2027
2028
2029 The header for each piece of music can be put inside the @code{\score}
2030 block.  The @code{piece} name from the header will be printed before
2031 each movement.  The title for the entire book can be put inside the
2032 @code{\book}, but if it is not present, the @code{\header} which is at
2033 the top of the file is inserted.
2034
2035 @cindex Engraved by LilyPond
2036 @cindex signature line
2037
2038 @example 
2039 \book @{
2040   \header @{
2041     title = "Eight miniatures" 
2042     composer = "Igor Stravinsky"
2043   @}
2044   \score @{
2045     @dots{}
2046     \header @{ piece = "Romanze" @}
2047   @}
2048   \score @{
2049     @dots{}
2050     \header @{ piece = "Menuetto" @}
2051   @}
2052 @}
2053 @end example
2054
2055 @node Creating titles
2056 @subsection Creating titles
2057
2058 Titles are created for each @code{\score} block, and over a
2059 @code{\book}.
2060
2061 The contents of the titles are taken from the @code{\header} blocks.
2062 The header block for a book supports the following 
2063 @table @code
2064 @item title
2065     The title of the music. Centered on top of the first page.
2066 @item subtitle
2067     Subtitle, centered below the title.
2068 @item poet
2069     Name of the poet, left flushed below the subtitle.
2070 @item composer
2071     Name of the composer, right flushed below the subtitle.
2072 @item meter
2073     Meter string, left flushed below the poet.
2074 @item opus
2075     Name of the opus, right flushed below the composer.
2076 @item arranger
2077     Name of the arranger, right flushed below the opus.
2078 @item instrument
2079     Name of the instrument, centered below the arranger.
2080 @item dedication            
2081     To whom the piece is dedicated.
2082 @item piece
2083     Name of the piece, left flushed below the instrument.
2084 @end table
2085
2086 This is a demonstration of the fields available, 
2087
2088 @lilypond[verbatim]
2089 \book {
2090   \header {
2091     title = "Title"
2092     subtitle = "and the subtitle"
2093     subsubtitle = "Sub sub title"
2094     poet = "Poet"
2095     composer = "Composer"
2096     texttranslator = "Text Translator"
2097     meter = "Meter"
2098     arranger = "Arranger"
2099     instrument = "Instrument"
2100     piece = "Piece"
2101   }
2102
2103   \score {
2104     \header {
2105       piece = "piece1"
2106       opus = "opus1" 
2107     }
2108     { c'1 }
2109   }
2110   \score {
2111     \header {
2112       piece = "piece2"
2113       opus = "opus2" 
2114     }
2115     { c'1 }
2116   }
2117   \paper {
2118     linewidth = 8.0 \cm
2119   }
2120 }
2121 @end lilypond
2122
2123 Different fonts may be selected for each element, by using a
2124 @code{\markup}, e.g.
2125
2126 @verbatim
2127   \header {
2128     title = \markup { \italic { The italic title } }
2129   }
2130 @end verbatim
2131
2132 A more advanced option is to change the Scheme functions
2133 @code{make-book-title} and @code{make-score-title} functions, defined
2134 in the @code{\paper} of the @code{\book} block. These functions
2135 create a block of titling, given the information in the
2136 @code{\header}. The init file @file{ly/titling.scm} shows how the
2137 default format is created, and it may be used as a template for
2138 different styles.
2139
2140  
2141 @cindex \paper
2142 @cindex header
2143 @cindex footer
2144 @cindex page layout
2145 @cindex titles
2146
2147
2148
2149
2150 @node Page breaking
2151 @subsection Page breaking
2152
2153 The default page breaking may be overriden by inserting
2154 @code{\pageBreak} or @code{\noPageBreak} commands. These commands are
2155 analogous to @code{\break} and @code{\noBreak}. They should be
2156 inserted with a bar line. These commands force and forbid a page-break
2157 from happening.  Of course, the @code{\pageBreak} command also forces
2158 a line break.
2159
2160 Page breaks are computed by the @code{page-breaking} function in the
2161 @code{\paper} block. 
2162
2163 @refcommands
2164
2165 @cindex @code{\pageBreak}
2166 @code{\pageBreak}
2167 @cindex  @code{\noPageBreak} 
2168 @code{\noPageBreak} 
2169
2170 @node paper size
2171 @subsection paper size
2172
2173 @cindex paper size
2174 @cindex page size
2175 @cindex @code{papersize}
2176
2177 To change the paper size, there are two commands,
2178 @example
2179         #(set-default-paper-size "a4")
2180         \layout@{
2181            #(set-paper-size "a4")
2182         @}
2183 @end example
2184 The second one sets the size of the @code{\layout} block that it is in.
2185
2186 The following paper sizes are supported.
2187
2188 @table @code
2189 @item a6
2190 @item a5
2191 @item a4
2192 @item a3
2193 @item legal
2194 @item letter
2195 @item tabloid
2196 @end table 
2197
2198 @cindex orientation
2199 @cindex landscape
2200
2201 If the symbol @code{landscape} is supplied as argument to
2202 @code{set-default-paper-size}, the pages will be rotated 90 degrees,
2203 and line widths will be set longer correspondingly.
2204
2205 @example
2206 #(set-default-paper-size "a6" 'landscape)
2207 @end example 
2208
2209 @node Page layout
2210 @subsection Page layout
2211
2212 @cindex page layout
2213 @cindex margins
2214 @cindex header, page
2215 @cindex footer, page
2216
2217 LilyPond will do page layout, setting margins and adding headers and
2218 footers to each page.
2219
2220 The default layout responds to the following settings in the
2221 @code{\paper} block
2222
2223 @cindex \paper
2224
2225 @table @code
2226 @item firstpagenumber
2227  The value of the page number of the first page. Default is 1.
2228 @item printfirstpagenumber
2229  If set to true will print the page number in the first page. Default is
2230  false.
2231 @item hsize
2232  The width of the page
2233 @item vsize
2234  The height of the page
2235 @item topmargin
2236  Margin between header and top of the page
2237 @item bottommargin
2238  Margin between footer and bottom of the page
2239 @item leftmargin
2240  Margin between the left side of the page and the beginning  of the music
2241 @item linewidth
2242  The length of the systems
2243 @item headsep
2244  Distance between top-most music system and the page header
2245 @item footsep
2246  Distance between bottom-most music system and the page footer
2247 @item raggedbottom
2248  If set to true, systems will not be spread across the page.
2249
2250  This should be set false for pieces that have only two or three
2251 systems per page, for example orchestral scores.
2252  
2253 @item raggedlastbottom
2254  If set to false, systems will be spread to fill the last page.
2255
2256  Pieces that amply fill two pages or more should have this set to
2257 true.
2258
2259 @item betweensystemspace
2260   This dimensions determines the distance between systems. It is the
2261 ideal distance between the center of the bottom staff of one system,
2262 and the center of the top staff of the next system.
2263
2264 Increasing this will provide a more even appearance of the page at the
2265 cost of using more vertical space.
2266
2267 @item betweensystempadding
2268 This dimension is the minimum amount of white space that will always
2269 be present between the bottom most symbol of one system, and the
2270 topmost of the next system.
2271
2272 Increasing this will put systems whose bounding boxes almost touch
2273 farther apart.
2274
2275 @item aftertitlespace
2276 Amount of space between title and the first system
2277 @item beforetitlespace 
2278 Amount of space between last system of the previous piece and  the
2279 title of the next
2280 @item betweentitlespace
2281 Amount of space between consecutive titles (eg. the title   of the
2282 book and the title of piece).
2283
2284 @end table
2285
2286 @example
2287         \paper@{
2288            hsize = 2\cm
2289            topmargin = 3\cm
2290            bottommargin = 3\cm
2291            raggedlastbottom = ##t
2292         @}
2293 @end example
2294
2295 You can also define these values in scheme. In that case @code{mm},
2296 @code{in}, @code{pt} and @code{cm} are variables defined in
2297 @file{paper-defaults.ly} with values in millimeters. That's why the
2298 value has to be multiplied in the example above.
2299
2300 @example
2301         \paper@{
2302         #(define bottommargin (* 2 cm)) 
2303         @}
2304 @end example
2305
2306 @cindex copyright
2307 @cindex tagline
2308
2309 The default footer is empty, except for the first page, where it the
2310 @code{copyright} field from @code{\header} is inserted, and the last
2311 page, where @code{tagline} from @code{\header} is added. The default
2312 tagline is ``Engraved by LilyPond (@var{version})''.@footnote{Nicely
2313 printed parts are good PR for us, so please leave the tagline if you
2314 can.}
2315
2316 The header and footer are created by the functions @code{make-footer}
2317 and @code{make-header}, defined in @code{\paper}. The default
2318 implementations are in @file{scm/page-layout.scm}.
2319
2320 The following settings influence the header and footer layout.
2321
2322 @table @code
2323 @item printpagenumber
2324   this boolean controls whether a pagenumber is printed. 
2325 @end table
2326
2327 The page layout itself is done by two functions in the
2328 @code{\paper}, @code{page-music-height} and
2329 @code{page-make-stencil}. The former tells the line-breaking algorithm
2330 how much space can be spent on a page, the latter creates the actual
2331 page given the system to put on it.
2332
2333
2334 @seealso
2335
2336 Examples: @inputfileref{input/test,page-breaks.ly}
2337
2338 @refbugs
2339
2340 The option rightmargin is defined but doesn't set the right margin
2341 yet. The value for the right margin has to be defined adjusting the
2342 values of the leftmargin and linewidth.
2343
2344 The default page header puts the page number and the @code{instrument}
2345 field from the @code{\header} block on a line.
2346
2347
2348
2349 @node File structure
2350 @section File structure
2351
2352 The bigger part of this manual is concerned with entering various
2353 forms of music in LilyPond. However, many music expressions are not
2354 valid input on their own, for example, a @code{.ly} file containing
2355 only a note
2356 @example
2357   c'4
2358 @end example
2359
2360 @noindent
2361 will result in a parsing error. Instead, music should be inside other
2362 expressions, which may be put in a file by themselves. Such
2363 expressions are called toplevel expressions.  This section enumerates
2364 them all.
2365
2366 A @code{.ly} file contains any number of toplevel expressions, where a
2367 toplevel expressions is one of the following
2368
2369 @itemize @bullet
2370 @item An output definition, such as @code{\paper}, @code{\midi}
2371 and @code{\layout}. Such a definition at toplevel changes the default
2372 settings for the block entered.
2373
2374 @item An @code{\header} block. This sets the global header block. This
2375 is the block containing the definitions for book-wide settings, like
2376 composer, title, etc. 
2377
2378 @item An @code{\addquote} statement. See @ref{Quoting other voices}
2379 for more information.
2380
2381 @item A @code{\score} block. This score will be collected with other
2382 toplevel scores, and combined as a single @code{\book}.
2383
2384 This behavior can be changed by setting the variable
2385 @code{toplevel-score-handler} at toplevel.  The default handler is
2386 defined in the init file @file{scm/lily.scm}.
2387
2388 @item
2389 A @code{\book} block logically combines multiple movements
2390 (ie. multiple @code{\score} blocks) into one document. A number of
2391 @code{\scores} creates a single output file, where all movement are
2392 concatenated..
2393
2394 This behavior can be changed by setting the variable
2395 @code{toplevel-book-handler} at toplevel.  The default handler is
2396 defined in the init file @file{scm/lily.scm}.
2397
2398
2399 @item A compound music expression, such as
2400 @example
2401   @{ c'4 d' e'2 @}
2402 @end example
2403
2404 This will add the piece in a @code{\score}, and formats it into a
2405 single book together with all other toplevel @code{\score}s and music
2406 expressions.
2407  
2408 This behavior can be changed by setting the variable
2409 @code{toplevel-music-handler} at toplevel. The default handler is
2410 defined in the init file @file{scm/lily.scm}.
2411  
2412 @end itemize
2413
2414 The following example shows three things which may be entered at
2415 toplevel
2416 @verbatim
2417    \layout  {
2418      % movements are non-justified by default    
2419      raggedright = ##t
2420    }
2421
2422    \header {
2423       title = "Do-re-mi"
2424    }
2425    
2426    { c'4 d' e2 }
2427 @end verbatim
2428
2429
2430 At any point in a file, any of the following lexical instructions can
2431 be entered:
2432
2433 @itemize @bullet
2434 @item @code{\version}
2435 @item @code{\include}
2436 @item @code{\encoding}
2437 @item @code{\renameinput}
2438 @end itemize 
2439