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