]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/changing-defaults.itely
Use image.
[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
19 @iftex
20 Program reference manual.
21 @end iftex
22 @ifnottex
23 @ref{Top,Program reference,,lilypond-internals}.
24 @end ifnottex
25 That manual
26 lists all different variables, functions and options available in
27 LilyPond.  It is written as a HTML document, which is available
28 @uref{http://@/lilypond@/.org/@/doc/@/v2.8/@/Documentation/@/user/@/
29 lilypond@/-internals/,on@/-line},
30 but is also included with the LilyPond documentation package.
31
32 There are four areas where the default settings may be changed:
33
34 @itemize @bullet
35 @item
36 Automatic notation: changing the automatic creation of notation
37 elements.  For example, changing the beaming rules.
38
39 @item
40 Output: changing the appearance of individual
41 objects.  For example, changing stem directions or the location of
42 subscripts.
43   
44 @item
45 Context: changing aspects of the translation from music events to
46 notation.  For example, giving each staff a separate time signature. 
47   
48 @item
49 Global layout: changing the appearance of the spacing, line
50 breaks, and page dimensions.  These modifications are discussed
51 in @ref{Global issues}.
52 @end itemize
53
54 Internally, LilyPond uses Scheme (a LISP dialect) to provide
55 infrastructure.  Overriding layout decisions in effect accesses the
56 program internals, which requires Scheme input.  Scheme elements are
57 introduced in a @code{.ly} file with the hash mark
58 @code{#}.@footnote{@ref{Scheme tutorial} contains a short tutorial
59 on entering numbers, lists, strings, and symbols in Scheme.}
60
61
62 @menu
63 * Automatic notation::          
64 * Interpretation contexts::     
65 * The \override command::       
66 @end menu
67
68  
69 @node Automatic notation
70 @section Automatic notation
71
72 This section describes how to change the way that accidentals and
73 beams are automatically displayed.
74
75 @menu
76 * Automatic accidentals::       
77 * Setting automatic beam behavior::  
78 @end menu
79
80 @node Automatic accidentals
81 @subsection Automatic accidentals
82 @cindex Automatic accidentals
83
84 Common rules for typesetting accidentals have been placed in a
85 function.  This function is called as follows
86
87 @cindex @code{set-accidental-style}
88 @example
89 #(set-accidental-style 'STYLE #('CONTEXT#))
90 @end example
91
92 The function can take two arguments: the name of the accidental style,
93 and an optional argument that denotes the context that should be
94 changed.  If no context name is supplied, @code{Staff} is the default,
95 but you may wish to apply the accidental style to a single @code{Voice}
96 instead.
97
98 @c TODO: we should create a very clear example, and show every
99 @c accidental style on that example (with the example specially
100 @c constructed so that it illustrates all the differences).  -gp
101
102 The following accidental styles are supported
103 @table @code
104 @item default
105 This is the default typesetting behavior.  It corresponds
106 to 18th century common practice: Accidentals are
107 remembered to the end of the measure in which they occur and
108 only on their own octave.
109
110 @item voice
111 The normal behavior is to remember the accidentals on
112 Staff-level.  This variable, however, typesets accidentals
113 individually for each voice.  Apart from that, the rule is similar to
114 @code{default}.
115
116 As a result, accidentals from one voice do not get canceled in other
117 voices, which is often an unwanted result
118
119 @lilypond[quote,ragged-right,relative=1,fragment,verbatim]
120 \new Staff <<
121   #(set-accidental-style 'voice)
122   <<
123     { es g } \\
124     { c, e }
125 >> >>
126 @end lilypond
127
128 The @code{voice} option should be used if the voices
129 are to be read solely by individual musicians.  If the staff is to be
130 used by one musician (e.g., a conductor) then
131 @code{modern} or @code{modern-cautionary}
132 should be used instead.
133
134 @item modern
135 @cindex @code{modern} style accidentals
136 This rule corresponds to the common practice in the 20th century.  This rule
137 prints the same accidentals as @code{default}, but temporary
138 accidentals also are canceled in other octaves.  Furthermore,
139 in the same octave, they also get canceled in the following
140 measure
141
142 @lilypond[quote,ragged-right,fragment,verbatim]
143 #(set-accidental-style 'modern)
144 cis' c'' cis'2 | c'' c'
145 @end lilypond
146
147 @item @code{modern-cautionary}
148 @cindex @code{modern-cautionary}
149 This rule is similar to @code{modern}, but the ``extra'' accidentals
150 (the ones not typeset by @code{default}) are typeset as cautionary
151 accidentals.  They are printed in reduced size or with parentheses
152 @lilypond[quote,ragged-right,fragment,verbatim]
153 #(set-accidental-style 'modern-cautionary)
154 cis' c'' cis'2 | c'' c'
155 @end lilypond
156
157 @cindex @code{modern-voice}
158 @item modern-voice
159 This rule is used for multivoice accidentals to be read both by musicians
160 playing one voice and musicians playing all voices.  Accidentals are
161 typeset for each voice, but they @emph{are} canceled across voices in
162 the same @internalsref{Staff}.
163
164 @cindex @code{modern-voice-cautionary}
165 @item modern-voice-cautionary
166 This rule is the same as @code{modern-voice}, but with the extra
167 accidentals (the ones not typeset by @code{voice}) typeset
168 as cautionaries.  Even though all accidentals typeset by
169 @code{default} @emph{are} typeset by this variable,
170 some of them are typeset as cautionaries.
171
172 @item piano
173 @cindex @code{piano} accidentals
174 This rule reflects 20th century practice for piano notation.  Very similar to
175 @code{modern} but accidentals also get canceled
176 across the staves in the same @internalsref{GrandStaff} or
177 @internalsref{PianoStaff}.
178
179 @item piano-cautionary
180 @cindex @code{#(set-accidental-style 'piano-cautionary)}
181 Same as @code{#(set-accidental-style 'piano)} but with the extra
182 accidentals typeset as cautionaries.
183
184 @item no-reset
185 @cindex @code{no-reset} accidental style
186 This is the same as @code{default} but with accidentals lasting
187 ``forever'' and not only until the next measure
188 @lilypond[quote,ragged-right,fragment,verbatim,relative=1]
189 #(set-accidental-style 'no-reset)
190 c1 cis cis c
191 @end lilypond
192
193 @item forget
194 This is sort of the opposite of @code{no-reset}: Accidentals
195 are not remembered at all---and hence all accidentals are
196 typeset relative to the key signature, regardless of what was
197 before in the music
198
199 @lilypond[quote,ragged-right,fragment,verbatim,relative=1]
200 #(set-accidental-style 'forget)
201 \key d\major c4 c cis cis d d dis dis
202 @end lilypond
203 @end table
204
205
206 @seealso
207
208 Program reference: @internalsref{Accidental_engraver},
209 @internalsref{Accidental}, and @internalsref{AccidentalPlacement}.
210
211
212 @refbugs
213
214 Simultaneous notes are considered to be entered in sequential
215 mode.  This means that in a chord the accidentals are typeset as if the
216 notes in the chord happen one at a time, in the order in which
217 they appear in the input file.  This is a problem when accidentals
218 in a chord depend on each other,
219 which does not happen for the default accidental style.  The problem
220 can be solved by manually inserting @code{!} and @code{?} for the
221 problematic notes.
222
223
224 @node Setting automatic beam behavior
225 @subsection Setting automatic beam behavior
226
227 @cindex @code{autoBeamSettings}
228 @cindex @code{(end * * * *)}
229 @cindex @code{(begin * * * *)}
230 @cindex automatic beams, tuning
231 @cindex tuning automatic beaming
232
233 @c [TODO: use \applyContext]
234
235 In normal time signatures, automatic beams can start on any note but can
236 only end in a few positions within the measure: beams can end on a beat,
237 or at durations specified by the properties in
238 @code{autoBeamSettings}.  The properties in @code{autoBeamSettings}
239 consist of a list of rules for where beams can begin and end.  The
240 default @code{autoBeamSettings} rules are defined in
241 @file{scm/@/auto@/-beam@/.scm}.
242
243 In order to add a rule to the list, use
244 @example
245 #(override-auto-beam-setting '(be p q n m) a b [context])
246 @end example
247
248 @itemize @bullet
249
250 @item @code{be} is either "begin" or "end".
251
252 @item @code{p/q} is the duration of the note for which you want
253 to add a rule.  A beam is considered to have the duration of its
254 shortest note.  Set @code{p} and @code{q} to @code{'*'} to
255 have this apply to any beam.
256
257 @item @code{n/m} is the time signature to which
258 this rule should apply.  Set @code{n} and @code{m} to @code{'*'}
259 to have this apply in any time signature.
260
261 @item @code{a/b} is the position in the bar at which the beam should 
262 begin/end.
263
264 @item @code{context} is optional, and it specifies the context at which
265 the change should be made.  The default is @code{'Voice}.
266 @code{#(score-override-auto-beam-setting '(A B C D) E F)} is equivalent to
267 @code{#(override-auto-beam-setting '(A B C D) E F 'Score)}.
268
269 @end itemize
270
271 For example, if automatic beams should always end on the first quarter
272 note, use
273
274 @example
275 #(override-auto-beam-setting '(end * * * *) 1 4)
276 @end example
277
278 You can force the beam settings to only take effect on beams whose shortest
279 note is a certain duration
280
281 @lilypond[quote,fragment,ragged-right,verbatim,relative=2]
282 \time 2/4
283 #(override-auto-beam-setting '(end 1 16 * *) 1 16)
284 a16 a a a a a a a |
285 a32 a a a a16 a a a a a |
286 #(override-auto-beam-setting '(end 1 32 * *) 1 16)
287 a32 a a a a16 a a a a a |
288 @end lilypond
289
290 You can force the beam settings to only take effect in certain time
291 signatures
292
293 @lilypond[quote,fragment,ragged-right,verbatim,relative=2]
294 \time 5/8
295 #(override-auto-beam-setting '(end * * 5 8) 2 8)
296 c8 c d d d
297 \time 4/4
298 e8 e f f e e d d
299 \time 5/8
300 c8 c d d d
301 @end lilypond
302
303 You can also remove a previously set beam-ending rule by using
304
305 @example
306 #(revert-auto-beam-setting '(be p q n m) a b [context])
307 @end example
308
309 @noindent
310 be, p, q, n, m, a, b and context are the same as above.  Note that the
311 default rules are specified in @file{scm/@/auto@/-beam@/.scm},
312 so you can revert rules that you did not explicitly create.
313
314 @lilypond[quote,fragment,ragged-right,verbatim,relative=2]
315 \time 4/4
316 a16 a a a a a a a a a a a a a a a
317 #(revert-auto-beam-setting '(end 1 16 4 4) 1 4)
318 a16 a a a a a a a a a a a a a a a
319 @end lilypond
320
321 The rule in a revert-auto-beam-setting statement must exactly match the
322 original rule.  That is, no wildcard expansion is taken into account.
323
324 @lilypond[quote,fragment,ragged-right,verbatim,relative=2]
325 \time 1/4
326 #(override-auto-beam-setting '(end 1 16 1 4) 1 8)
327 a16 a a a
328 #(revert-auto-beam-setting '(end 1 16 * *) 1 8) % this won't revert it!
329 a a a a
330 #(revert-auto-beam-setting '(end 1 16 1 4) 1 8) % this will
331 a a a a
332 @end lilypond
333
334
335
336 @c TODO:  old material -- not covered by above stuff, I think.
337 If automatic beams should end on every quarter in 5/4 time, specify
338 all endings
339 @example
340 #(override-auto-beam-setting '(end * * * *) 1 4 'Staff)
341 #(override-auto-beam-setting '(end * * * *) 1 2 'Staff)
342 #(override-auto-beam-setting '(end * * * *) 3 4 'Staff)
343 #(override-auto-beam-setting '(end * * * *) 5 4 'Staff)
344 @dots{}
345 @end example
346
347 The same syntax can be used to specify beam starting points.  In this
348 example, automatic beams can only end on a dotted quarter note
349 @example
350 #(override-auto-beam-setting '(end * * * *) 3 8)
351 #(override-auto-beam-setting '(end * * * *) 1 2)
352 #(override-auto-beam-setting '(end * * * *) 7 8)
353 @end example
354 In 4/4 time signature, this means that automatic beams could end only on
355 3/8 and on the fourth beat of the measure (after 3/4, that is 2 times
356 3/8, has passed within the measure).
357
358 @cindex automatic beam generation
359 @cindex autobeam
360 @cindex @code{autoBeaming}
361 @cindex lyrics
362
363 If beams are used to indicate melismata in songs, then automatic
364 beaming should be switched off with @code{\autoBeamOff}.
365
366
367 @refcommands
368
369 @cindex @code{\autoBeamOff}
370 @code{\autoBeamOff},
371 @cindex @code{\autoBeamOn}
372 @code{\autoBeamOn}.
373
374
375 @refbugs
376
377 If a score ends while an automatic beam has not been ended and is
378 still accepting notes, this last beam will not be typeset at all.  The
379 same holds polyphonic voices, entered with @code{<< @dots{} \\ @dots{}
380 >>}.  If a polyphonic voice ends while an automatic beam is still
381 accepting notes, it is not typeset.
382
383
384 @node Interpretation contexts
385 @section Interpretation contexts
386
387 This section describes what contexts are, and how to modify them.
388
389 @menu
390 * Contexts explained::          
391 * Creating contexts::           
392 * Changing context properties on the fly::  
393 * Modifying context plug-ins::  
394 * Layout tunings within contexts::  
395 * Changing context default settings::  
396 * Defining new contexts::       
397 @end menu
398
399
400 @node Contexts explained
401 @subsection Contexts explained
402
403 When music is printed, a lot of notational elements must be added to the
404 input.  For example, compare the input and output of the following example:
405
406 @lilypond[quote,verbatim,relative=2,fragment]
407 cis4 cis2. g4
408 @end lilypond
409
410 The input is rather sparse, but in the output, bar lines, accidentals,
411 clef, and time signature are added.  LilyPond @emph{interprets} the
412 input.  During this step, the musical information is inspected in time
413 order, similar to reading a score from left to right.  While reading
414 the input, the program remembers where measure boundaries are, and which
415 pitches require explicit accidentals.  This information can be presented on
416 several levels.  For example, the effect of an accidental is limited
417 to a single staff, while a bar line must be synchronized across the
418 entire score.
419
420 Within LilyPond, these rules and bits of information are grouped in
421 @emph{Contexts}.  Some examples of contexts are @context{Voice},
422 @context{Staff}, and @context{Score}.  They are hierarchical, for
423 example: a @context{Staff} can contain many @context{Voice}s, and a
424 @context{Score} can contain many @context{Staff} contexts.
425
426 @c  FIXME: doesn't work yet!  -gp
427 @c @image{context-example,,,eps}
428
429 Each context has the responsibility for enforcing some notation rules,
430 creating some notation objects and maintaining the associated
431 properties.  For example, the @context{Voice} context may introduce an
432 accidental and then the @context{Staff} context maintains the rule to
433 show or suppress the accidental for the remainder of the measure.  The
434 synchronization of bar lines is handled at @context{Score} context.
435
436 However, in some music we may not want the bar lines to be
437 synchronized -- consider a polymetric score in 4/4 and 3/4 time.  In
438 such cases, we must modify the default settings of the @context{Score}
439 and @context{Staff} contexts.
440
441 For very simple scores, contexts are created implicitly, and you need
442 not be aware of them.  For larger pieces, such as anything with more
443 than one staff, they must be
444 created explicitly to make sure that you get as many staves as you
445 need, and that they are in the correct order.  For typesetting pieces
446 with specialized notation, it can be useful to modify existing or
447 to define new contexts.
448
449
450 A complete description of all available contexts is in the program
451 reference, see
452 @ifhtml
453 @internalsref{Contexts}.
454 @end ifhtml
455 @ifnothtml 
456 Translation @arrow{} Context.
457 @end ifnothtml
458
459 @c [TODO: describe propagation]
460
461
462 @node Creating contexts
463 @subsection Creating contexts
464
465 For scores with only one voice and one staff, contexts are
466 created automatically.  For more complex scores, it is necessary to
467 create them by hand.  There are three commands that do this.
468
469 @itemize @bullet
470
471 @item
472 The easiest command is @code{\new}, and it also the quickest to type.
473 It is prepended to a music expression, for example
474
475 @cindex @code{\new}
476 @cindex new contexts
477 @cindex Context, creating
478
479 @example
480 \new @var{type} @var{music expression}
481 @end example
482
483 @noindent
484 where @var{type} is a context name (like @code{Staff} or
485 @code{Voice}).  This command creates a new context, and starts
486 interpreting the @var{music expression} with that.
487
488 A practical application of @code{\new} is a score with many
489 staves.  Each part that should be on its own staff, is preceded with 
490 @code{\new Staff}.
491
492 @lilypond[quote,verbatim,relative=2,ragged-right,fragment]
493 <<
494   \new Staff { c4 c }
495   \new Staff { d4 d }
496 >>
497 @end lilypond
498
499 The @code{\new} command may also give a name to the context,
500
501 @example
502 \new @var{type} = @var{id} @var{music}
503 @end example
504 However, this user specified name is only used if there is no other
505 context already earlier with the same name.
506
507
508 @cindex @code{\context}
509
510 @item
511 Like @code{\new}, the @code{\context} command also directs a music
512 expression to a context object, but gives the context an explicit name.  The
513 syntax is
514
515 @example
516 \context @var{type} = @var{id} @var{music}
517 @end example
518
519 This form will search for an existing context of type @var{type}
520 called @var{id}.  If that context does not exist yet, a new
521 context with the specified name is created.  This is useful if
522 the context is referred to later on.  For example, when
523 setting lyrics the melody is in a named context
524
525 @example
526 \context Voice = "@b{tenor}" @var{music}
527 @end example
528
529 @noindent
530 so the texts can be properly aligned to its notes,
531
532 @example
533 \new Lyrics \lyricsto "@b{tenor}" @var{lyrics} 
534 @end example
535
536 @noindent
537
538 Another possible use of named contexts is funneling two different
539 music expressions into one context.  In the following example,
540 articulations and notes are entered separately,
541
542 @example
543 music = @{ c4 c4 @}
544 arts = @{ s4-. s4-> @}
545 @end example
546
547 They are combined by sending both to the same @context{Voice} context,
548
549 @example
550 <<
551   \new Staff \context Voice = "A" \music
552   \context Voice = "A" \arts
553 >>
554 @end example
555 @lilypond[quote,ragged-right]
556 music = { c4 c4 }
557 arts = { s4-. s4-> }
558 \relative c'' <<
559   \new Staff \context Voice = "A" \music
560   \context Voice = "A" \arts
561 >>
562 @end lilypond
563
564 With this mechanism, it is possible to define an Urtext (original
565 edition), with the option to put several distinct articulations on the
566 same notes.
567
568 @cindex creating contexts
569
570 @item
571 The third command for creating contexts is
572 @example
573 \context @var{type} @var{music}
574 @end example
575
576
577 @noindent
578 This is similar to @code{\context} with @code{= @var{id}}, but matches
579 any context of type @var{type}, regardless of its given name.
580
581 This variant is used with music expressions that can be interpreted at
582 several levels.  For example, the @code{\applyOutput} command (see
583 @ref{Running a function on all layout objects}).  Without an explicit
584 @code{\context}, it is usually applied to @context{Voice}
585
586 @example
587 \applyOutput #@var{function}   % apply to Voice
588 @end example
589
590 To have it interpreted at the @context{Score} or @context{Staff} level use
591 these forms
592
593 @example
594 \context Score \applyOutput #@var{function}
595 \context Staff \applyOutput #@var{function}
596 @end example
597
598 @end itemize
599
600
601 @node Changing context properties on the fly
602 @subsection Changing context properties on the fly
603
604 @cindex properties
605 @cindex @code{\set}
606 @cindex changing properties
607
608 Each context can have different @emph{properties}, variables contained
609 in that context.  They can be changed during the interpretation step.
610 This is achieved by inserting the @code{\set} command in the music,
611
612 @example
613 \set @var{context}.@var{prop} = #@var{value}
614 @end example
615
616 For example,
617 @lilypond[quote,verbatim,relative=2,fragment]
618 R1*2 
619 \set Score.skipBars = ##t
620 R1*2
621 @end lilypond
622
623 This command skips measures that have no notes.  The result is that
624 multi-rests are condensed.  The value assigned is a Scheme object.  In
625 this case, it is @code{#t}, the boolean True value.
626
627 If the @var{context} argument is left out, then the current bottom-most
628 context (typically @context{ChordNames}, @context{Voice}, or
629 @context{Lyrics}) is used.  In this example,
630
631 @lilypond[quote,verbatim,relative=2,fragment]
632 c8 c c c
633 \set autoBeaming = ##f
634 c8 c c c
635 @end lilypond
636
637 @noindent
638 the @var{context} argument to @code{\set} is left out, so automatic
639 beaming is switched off in the current @internalsref{Voice}.  Note that
640 the bottom-most context does not always contain the property that you
641 wish to change -- for example, attempting to set the @code{skipBars}
642 property (of the bottom-most context, in this case @code{Voice}) will
643 have no effect.
644
645 @lilypond[quote,verbatim,relative=2,fragment]
646 R1*2 
647 \set skipBars = ##t
648 R1*2
649 @end lilypond
650
651 Contexts are hierarchical, so if a bigger context was specified, for
652 example @context{Staff}, then the change would also apply to all
653 @context{Voice}s in the current stave.  The change is applied
654 `on-the-fly', during the music, so that the setting only affects the
655 second group of eighth notes.
656
657 @cindex @code{\unset} 
658
659 There is also an @code{\unset} command,
660 @example
661 \unset @var{context}.@var{prop}
662 @end example
663
664 @noindent
665 which removes the definition of @var{prop}.  This command removes
666 the definition only if it is set in @var{context}, so
667
668 @example
669 \set Staff.autoBeaming = ##f
670 @end example
671
672 @noindent
673 introduces a property setting at @code{Staff} level.  The setting also
674 applies to the current @code{Voice}.  However,
675
676 @example
677 \unset Voice.autoBeaming
678 @end example
679
680 @noindent
681 does not have any effect.  To cancel this setting, the @code{\unset}
682 must be specified on the same level as the original @code{\set}.  In
683 other words, undoing the effect of @code{Staff.autoBeaming = ##f}
684 requires
685 @example
686 \unset Staff.autoBeaming
687 @end example
688
689 Like @code{\set}, the @var{context} argument does not have to be
690 specified for a bottom context, so the two statements
691
692 @example
693 \set Voice.autoBeaming = ##t 
694 \set autoBeaming = ##t 
695 @end example 
696
697 @noindent
698 are equivalent.
699
700
701 @cindex \once
702 Settings that should only apply to a single time-step can be entered
703 with @code{\once}, for example in
704
705 @lilypond[quote,verbatim,relative=2,fragment]
706 c4
707 \once \set fontSize = #4.7
708 c4
709 c4
710 @end lilypond
711
712 the property @code{fontSize} is unset automatically after the second
713 note.
714
715 A full description of all available context properties is in the
716 program reference, see
717 @ifhtml
718 @internalsref{Tunable context properties}.
719 @end ifhtml
720 @ifnothtml
721 Translation @arrow{} Tunable context properties.
722 @end ifnothtml
723
724
725 @node Modifying context plug-ins
726 @subsection Modifying context plug-ins
727
728 Notation contexts (like @code{Score} and @code{Staff}) not only
729 store properties,
730 they also contain plug-ins called ``engravers'' that create notation
731 elements.  For example, the @code{Voice} context contains a
732 @code{Note_head_engraver} and the @code{Staff} context contains a
733 @code{Key_signature_engraver}.
734
735 For a full a description of each plug-in, see 
736 @ifhtml
737 @internalsref{Engravers}.
738 @end ifhtml
739 @ifnothtml
740 Program reference @arrow Translation @arrow{} Engravers.
741 @end ifnothtml
742 Every context described in
743 @ifhtml
744 @internalsref{Contexts}
745 @end ifhtml
746 @ifnothtml 
747 Program reference @arrow Translation @arrow{} Context.
748 @end ifnothtml
749 lists the engravers used for that context.
750
751
752 It can be useful to shuffle around these plug-ins.  This is done by
753 starting a new context with @code{\new} or @code{\context}, and
754 modifying it,
755
756 @cindex @code{\with}
757
758 @example
759 \new @var{context} \with @{
760   \consists @dots{}
761   \consists @dots{}
762   \remove @dots{}
763   \remove @dots{}
764   @emph{etc.}
765 @}
766 @{
767   @emph{..music..}
768 @}
769 @end example
770
771 @noindent
772 where the @dots{} should be the name of an engraver.  Here is a simple
773 example which removes @code{Time_signature_engraver} and
774 @code{Clef_engraver} from a @code{Staff} context,
775
776 @lilypond[quote,relative=1,verbatim,fragment]
777 <<
778   \new Staff {
779     f2 g
780   }
781   \new Staff \with {
782      \remove "Time_signature_engraver"
783      \remove "Clef_engraver"
784   } {
785     f2 g2
786   }
787 >>
788 @end lilypond
789
790 In the second staff there are no time signature or clef symbols.  This
791 is a rather crude method of making objects disappear since it will affect
792 the entire staff.  This method also influences the spacing, which may or
793 may not be desirable.  A more
794 sophisticated method of blanking objects is shown in @ref{Common tweaks}.
795
796 The next example shows a practical application.  Bar lines and time
797 signatures are normally synchronized across the score.  This is done
798 by the @code{Timing_translator} and @code{Default_bar_line_engraver}.
799 This plug-in keeps an administration of time signature, location
800 within the measure, etc.  By moving thes engraver from @code{Score} to
801 @code{Staff} context, we can have a score where each staff has its own
802 time signature.
803
804 @cindex polymetric scores
805 @cindex Time signatures, multiple
806
807 @lilypond[quote,relative=1,ragged-right,verbatim,fragment]
808 \new Score \with {
809   \remove "Timing_translator"
810   \remove "Default_bar_line_engraver"
811 } <<
812   \new Staff \with {
813     \consists "Timing_translator"
814     \consists "Default_bar_line_engraver"
815   } {
816       \time 3/4
817       c4 c c c c c
818   }
819   \new Staff \with {
820     \consists "Timing_translator"
821     \consists "Default_bar_line_engraver"
822   } {
823        \time 2/4
824        c4 c c c c c
825   }
826 >>
827 @end lilypond
828
829
830 @node Layout tunings within contexts
831 @subsection Layout tunings within contexts
832
833 Each context is responsible for creating certain types of graphical
834 objects.  The settings used for printing these objects are also stored by
835 context.  By changing these settings, the appearance of objects can be
836 altered.
837  
838 The syntax for this is
839
840 @example
841 \override @var{context}.@var{name} #'@var{property} = #@var{value}
842 @end example
843
844 Here @var{name} is the name of a graphical object, like @code{Stem} or
845 @code{NoteHead}, and @var{property} is an internal variable of the
846 formatting system (`grob property' or `layout property').  The latter is a
847 symbol, so it must be quoted.  The subsection @ref{Constructing a
848 tweak} explains what to fill in for @var{name}, @var{property}, and
849 @var{value}.  Here we only discuss the functionality of this command.
850
851 The command
852
853 @verbatim
854 \override Staff.Stem #'thickness = #4.0 
855 @end verbatim
856
857 @noindent
858 makes stems thicker (the default is 1.3, with staff line thickness as a
859 unit).  Since the command specifies @context{Staff} as context, it only
860 applies to the current staff.  Other staves will keep their normal
861 appearance.  Here we see the command in action:
862
863 @lilypond[quote,verbatim,relative=2,fragment]
864 c4
865 \override Staff.Stem #'thickness = #4.0 
866 c4
867 c4
868 c4
869 @end lilypond
870
871 The @code{\override} command changes the definition of the @code{Stem}
872 within the current @context{Staff}.  After the command is interpreted
873 all stems are thickened.
874
875 Analogous to @code{\set}, the @var{context} argument may be left out,
876 causing it to default to @context{Voice}, and adding @code{\once} applies
877 the change during one timestep only 
878
879 @lilypond[quote,fragment,verbatim,relative=2]
880 c4
881 \once \override Stem #'thickness = #4.0 
882 c4
883 c4 
884 @end lilypond
885
886 The @code{\override} must be done before the object is
887 started.  Therefore, when altering @emph{Spanner} objects such as slurs
888 or beams, the @code{\override} command must be executed at the moment
889 when the object is created.  In this example,
890
891 @lilypond[quote,fragment,verbatim,relative=2]
892 \override Slur #'thickness = #3.0
893 c8[( c
894 \override Beam #'thickness = #0.6
895 c8 c]) 
896 @end lilypond
897
898 @noindent
899 the slur is fatter but the beam is not.  This is because the command for
900 @code{Beam} comes after the Beam is started, so it has no effect.
901
902 Analogous to @code{\unset}, the @code{\revert} command for a context
903 undoes an @code{\override} command; like with @code{\unset}, it only
904 affects settings that were made in the same context.  In other words, the
905 @code{\revert} in the next example does not do anything.
906
907 @example
908 \override Voice.Stem #'thickness = #4.0
909 \revert Staff.Stem #'thickness
910 @end example
911
912 Some tweakable options are called ``subproperties'' and reside inside
913 properties.  To tweak those, use commands of the form
914
915 @c leave this as a long long
916 @example
917 \override @var{context}.@var{name} #'@var{property} #'@var{subproperty} = #@var{value}
918 @end example
919
920 @noindent
921 such as
922
923 @example
924 \override Stem #'details #'beamed-lengths = #'(4 4 3)
925 @end example
926
927
928 @seealso
929
930 Internals: @internalsref{OverrideProperty}, @internalsref{RevertProperty},
931 @internalsref{PropertySet}, @internalsref{Backend}, and
932 @internalsref{All layout objects}.
933
934
935 @refbugs
936
937 The back-end is not very strict in type-checking object properties.
938 Cyclic references in Scheme values for properties can cause hangs
939 or crashes, or both.
940
941
942 @node Changing context default settings
943 @subsection Changing context default settings
944
945 The adjustments of the previous subsections (@ref{Changing context
946 properties on the fly}, @ref{Modifying context plug-ins}, and
947 @ref{Layout tunings within contexts}) can also be entered separately
948 from the music in the @code{\layout} block,
949
950 @example
951 \layout @{
952   @dots{}
953   \context @{
954     \Staff
955
956     \set fontSize = #-2
957     \override Stem #'thickness = #4.0
958     \remove "Time_signature_engraver"
959   @}
960 @}
961 @end example
962
963 Here @code{\Staff} takes the existing definition for context @context{Staff} from the
964 identifier @code{\Staff}. 
965
966 The statements
967 @example
968 \set fontSize = #-2
969 \override Stem #'thickness = #4.0
970 \remove "Time_signature_engraver"
971 @end example
972
973 @noindent
974 affect all staves in the score.  Other contexts can be modified
975 analogously.
976
977 The @code{\set} keyword is optional within the @code{\layout} block, so
978
979 @example
980 \context @{
981   @dots{}
982   fontSize = #-2
983 @}
984 @end example
985
986 @noindent
987 will also work.
988
989
990
991 @refbugs
992
993 It is not possible to collect context changes in a variable and apply
994 them to a @code{\context} definition by referring to that variable.
995
996 The @code{\RemoveEmptyStaffContext} will overwrite your current
997 @code{\Staff} settings.  If you wish to change the defaults for a
998 staff which uses @code{\RemoveEmptyStaffContext}, you must do so
999 after calling @code{\RemoveemptyStaffContext}, ie
1000
1001 @example
1002 \layout @{
1003   \context @{
1004     \RemoveEmptyStaffContext
1005
1006     \override Stem #'thickness = #4.0
1007   @}
1008 @}
1009 @end example
1010
1011
1012 @node Defining new contexts
1013 @subsection Defining new contexts
1014
1015 Specific contexts, like @context{Staff} and @code{Voice}, are made of
1016 simple building blocks.  It is possible to create new types of
1017 contexts with different combinations of engraver plug-ins.
1018
1019 The next example shows how to build a different type of
1020 @context{Voice} context from scratch.  It will be similar to
1021 @code{Voice}, but only prints centered slash noteheads.  It can be used
1022 to indicate improvisation in jazz pieces,
1023
1024 @lilypond[quote,ragged-right]
1025 \layout { \context {
1026   \name ImproVoice
1027   \type "Engraver_group"
1028   \consists "Note_heads_engraver"
1029   \consists "Text_engraver"
1030   \consists Pitch_squash_engraver
1031   squashedPosition = #0
1032   \override NoteHead #'style = #'slash
1033   \override Stem #'transparent = ##t
1034   \alias Voice
1035 }
1036 \context { \Staff
1037   \accepts "ImproVoice"
1038 }}
1039
1040 \relative c'' {
1041   a4 d8 bes8 \new ImproVoice { c4^"ad lib" c 
1042    c4 c^"undress" c_"while playing :)" c } 
1043   a1 
1044 }
1045 @end lilypond
1046
1047
1048 These settings are defined within a @code{\context} block inside a
1049 @code{\layout} block,
1050
1051 @example
1052 \layout @{
1053   \context @{
1054     @dots{}
1055   @}
1056 @}
1057 @end example
1058
1059 In the following discussion, the example input shown should go on the
1060 @dots{} in the previous fragment.
1061
1062 First the context's name is defined.  Instead of @context{Voice} it
1063 will be called @context{ImproVoice},
1064
1065 @example
1066 \name ImproVoice
1067 @end example
1068
1069 Since it is similar to the @context{Voice}, we want commands that work
1070 on (existing) @context{Voice}s to remain working.  This is achieved by
1071 giving the new context an alias @context{Voice},
1072
1073 @example
1074 \alias Voice
1075 @end example
1076
1077 The context will print notes, and instructive texts
1078
1079 @example
1080 \consists Note_heads_engraver
1081 \consists Text_engraver
1082 @end example
1083
1084 but only on the center line,
1085
1086 @example
1087 \consists Pitch_squash_engraver
1088 squashedPosition = #0
1089 @end example
1090
1091 The @internalsref{Pitch_squash_engraver} modifies note heads (created
1092 by @internalsref{Note_heads_engraver}) and sets their vertical
1093 position to the value of @code{squashedPosition}, in this case@tie{}@code{0},
1094 the center line.
1095
1096 The notes look like a slash, and have no stem,
1097
1098 @example
1099 \override NoteHead #'style = #'slash
1100 \override Stem #'transparent = ##t
1101 @end example
1102
1103 All these plug-ins have to cooperate, and this is achieved with a
1104 special plug-in, which must be marked with the keyword @code{\type}.
1105 This should always be @internalsref{Engraver_group},
1106
1107 @example
1108 \type "Engraver_group"
1109 @end example
1110
1111 Put together, we get
1112
1113 @example
1114 \context @{
1115   \name ImproVoice
1116   \type "Engraver_group"
1117   \consists "Note_heads_engraver"
1118   \consists "Text_engraver"
1119   \consists Pitch_squash_engraver
1120   squashedPosition = #0
1121   \override NoteHead #'style = #'slash
1122   \override Stem #'transparent = ##t
1123   \alias Voice
1124 @}
1125 @end example
1126
1127 @cindex @code{\accepts}
1128 Contexts form hierarchies.  We want to hang the @context{ImproVoice}
1129 under @context{Staff}, just like normal @code{Voice}s.  Therefore, we
1130 modify the @code{Staff} definition with the @code{\accepts}
1131 command,
1132
1133 @example
1134 \context @{
1135   \Staff
1136   \accepts ImproVoice    
1137 @}
1138 @end example
1139
1140 @cindex @code{\denies}
1141 The opposite of @code{\accepts} is @code{\denies},
1142 which is sometimes needed when reusing existing context definitions.
1143
1144 Putting both into a @code{\layout} block, like
1145
1146 @example
1147 \layout @{
1148   \context @{
1149     \name ImproVoice
1150     @dots{}
1151   @}
1152   \context @{
1153     \Staff
1154     \accepts "ImproVoice"
1155   @}
1156 @}
1157 @end example
1158
1159 Then the output at the start of this subsection can be entered as
1160
1161 @example
1162 \relative c'' @{
1163   a4 d8 bes8
1164   \new ImproVoice @{
1165     c4^"ad lib" c 
1166     c4 c^"undress"
1167     c c_"while playing :)"
1168   @}
1169   a1
1170 @}
1171 @end example
1172   
1173
1174     
1175
1176 @node The \override command
1177 @section The \override command
1178
1179 In the previous section, we have already touched on a command that
1180 changes layout details: the @code{\override} command.  In this section,
1181 we will look in more detail at how to use the command in practice.
1182
1183
1184 @menu
1185 * Constructing a tweak::        
1186 * Navigating the program reference::  
1187 * Layout interfaces::           
1188 * Determining the grob property::  
1189 * Objects connected to the input::  
1190 * \set vs. \override::          
1191 * Difficult tweaks::            
1192 @end menu
1193
1194
1195
1196 @node Constructing a tweak
1197 @subsection Constructing a tweak
1198
1199 Commands which change output generally look like
1200
1201 @example
1202 \override Voice.Stem #'thickness = #3.0
1203 @end example
1204
1205 @noindent
1206 This means that we must determine these bits of information:
1207
1208 @itemize
1209 @item the context: here @context{Voice}.
1210 @item the layout object: here @code{Stem}.
1211 @item the layout property: here @code{thickness}.
1212 @item a sensible value: here @code{3.0}.
1213 @end itemize  
1214
1215 Some tweakable options are called ``subproperties'' and reside inside
1216 properties.  To tweak those, use commands in the form
1217
1218 @example
1219 \override Stem #'details #'beamed-lengths = #'(4 4 3)
1220 @end example
1221
1222 @cindex internal documentation
1223 @cindex finding graphical objects
1224 @cindex graphical object descriptions 
1225 @cindex tweaking
1226 @cindex @code{\override}
1227 @cindex internal documentation
1228
1229 We demonstrate how to glean this information from the notation manual
1230 and the program reference.
1231
1232
1233 @node Navigating the program reference
1234 @subsection Navigating the program reference
1235
1236 Suppose we want to move the fingering indication in the fragment
1237 below:
1238
1239 @lilypond[quote,fragment,relative=2,verbatim]
1240 c-2
1241 \stemUp
1242 f
1243 @end lilypond
1244
1245 If you visit the documentation on fingering instructions (in
1246 @ref{Fingering instructions}), you will notice:
1247
1248 @quotation
1249 @seealso
1250
1251 Program reference: @internalsref{Fingering}.
1252
1253 @end quotation
1254
1255
1256 @c  outdated info; probably will delete.
1257 @ignore
1258 This fragment points to two parts of the program reference: a page
1259 on @code{FingerEvent} and one on @code{Fingering}.
1260
1261 The page on @code{FingerEvent} describes the properties of the music
1262 expression for the input @code{-2}.  The page contains many links
1263 forward.  For example, it says
1264
1265 @quotation
1266 Accepted by: @internalsref{Fingering_engraver},
1267 @end quotation 
1268
1269 @noindent
1270 That link brings us to the documentation for the Engraver, the
1271 plug-in, which says
1272
1273 @quotation
1274 This engraver creates the following layout objects: @internalsref{Fingering}.
1275 @end quotation
1276
1277 In other words, once the @code{FingerEvent}s are interpreted, the
1278 @code{Fingering_engraver} plug-in will process them.
1279 @end ignore
1280
1281 @ignore
1282 @c  I can't figure out what this is supposed to mean.  -gp
1283
1284 The @code{Fingering_engraver} is also listed to create
1285 @internalsref{Fingering} objects,
1286
1287 @c  old info?  it doesn't make any sense to me with our current docs.
1288 This is also the
1289 second bit of information listed under @b{See also} in the Notation
1290 manual.
1291 @end ignore
1292
1293 Follow the link to @internalsref{Fingering}.  At the top of the
1294 page, you will see
1295
1296 @quotation
1297 Fingering objects are created by: @internalsref{Fingering_engraver} and
1298 @internalsref{New_fingering_engraver}.
1299 @end quotation
1300
1301 By clicking around in the program reference, we can follow the
1302 flow of information within the program, following links like this:
1303
1304 @itemize @bullet
1305
1306 @item @internalsref{Fingering}:
1307 @internalsref{Fingering} objects are created by:
1308 @b{@internalsref{Fingering_engraver}}
1309
1310 @item @internalsref{Fingering_engraver}:
1311 Music types accepted: @b{@internalsref{fingering-event}}
1312
1313 @item @internalsref{fingering-event}:
1314 Music event type @code{fingering-event} is in Music expressions named
1315 @b{@internalsref{FingerEvent}}
1316 @end itemize
1317
1318 This path goes against the flow of information in the program: it
1319 starts from the output, and ends at the input event.  You could
1320 also start at an input event, and read with the flow of
1321 information, eventually ending up at the output object(s).
1322
1323 The program reference can also be browsed like a normal document.  It
1324 contains chapters on
1325 @ifhtml
1326 @internalsref{Music definitions},
1327 @end ifhtml
1328 @ifnothtml
1329 @code{Music definitions}
1330 @end ifnothtml
1331 on @internalsref{Translation}, and the @internalsref{Backend}.  Every
1332 chapter lists all the definitions used and all properties that may be
1333 tuned.
1334
1335  
1336 @node Layout interfaces
1337 @subsection Layout interfaces
1338
1339 @cindex interface, layout
1340 @cindex layout interface
1341 @cindex grob
1342
1343 The HTML page that we found in the previous section describes the
1344 layout object called @internalsref{Fingering}.  Such an object is a
1345 symbol within the score.  It has properties that store numbers (like
1346 thicknesses and directions), but also pointers to related objects.  A
1347 layout object is also called a @emph{Grob}, which is short for Graphical
1348 Object.  For more details about Grobs, see @internalsref{grob-interface}.
1349
1350 The page for @code{Fingering} lists the definitions for the
1351 @code{Fingering} object.  For example, the page says
1352
1353 @quotation
1354 @code{padding} (dimension, in staff space):
1355   
1356 @code{0.5}
1357 @end quotation
1358
1359 @noindent
1360 which means that the number will be kept at a distance of at least 0.6
1361 of the note head.
1362
1363
1364 Each layout object may have several functions as a notational or
1365 typographical element.  For example, the Fingering object
1366 has the following aspects
1367
1368 @itemize @bullet
1369 @item
1370 Its size is independent of the horizontal spacing, unlike slurs or beams.
1371
1372 @item
1373 It is a piece of text.  Granted, it is usually a very short text.
1374
1375 @item
1376 That piece of text is typeset with a font, unlike slurs or beams.
1377
1378 @item
1379 Horizontally, the center of the symbol should be aligned to the
1380 center of the notehead.
1381
1382 @item
1383 Vertically, the symbol is placed next to the note and the staff.
1384
1385 @item
1386 The vertical position is also coordinated with other superscript
1387 and subscript symbols.
1388 @end itemize
1389
1390 Each of these aspects is captured in so-called @emph{interface}s,
1391 which are listed on the @internalsref{Fingering} page at the bottom
1392
1393 @quotation
1394 This object supports the following interfaces:
1395 @internalsref{item-interface},
1396 @internalsref{self-alignment-interface},
1397 @internalsref{side-position-interface}, @internalsref{text-interface},
1398 @internalsref{text-script-interface}, @internalsref{font-interface},
1399 @internalsref{finger-interface}, and @internalsref{grob-interface}.
1400 @end quotation
1401
1402 Clicking any of the links will take you to the page of the respective
1403 object interface.  Each interface has a number of properties.  Some of
1404 them are not user-serviceable (``Internal properties''), but others
1405 can be modified.
1406
1407 We have been talking of @emph{the} @code{Fingering} object, but actually it
1408 does not amount to much.  The initialization file (see
1409 @ref{Default files})
1410 @file{scm/@/define@/-grobs@/.scm} shows the soul of the `object',
1411
1412 @example
1413 (Fingering
1414   . ((padding . 0.5)
1415      (avoid-slur . around)
1416      (slur-padding . 0.2)
1417      (staff-padding . 0.5)
1418      (self-alignment-X . 0)
1419      (self-alignment-Y . 0)
1420      (script-priority . 100)
1421      (stencil . ,ly:text-interface::print)
1422      (direction . ,ly:script-interface::calc-direction)
1423      (font-encoding . fetaNumber)
1424      (font-size . -5)           ; don't overlap when next to heads.
1425      (meta . ((class . Item)
1426      (interfaces . (finger-interface
1427                     font-interface
1428                     text-script-interface
1429                     text-interface
1430                     side-position-interface
1431                     self-alignment-interface
1432                     item-interface))))))
1433 @end example
1434
1435 @noindent
1436 As you can see, the @code{Fingering} object is nothing more than a
1437 bunch of variable settings, and the webpage in the Program Reference
1438 is directly generated from this definition.
1439
1440
1441 @node Determining the grob property
1442 @subsection Determining the grob property
1443
1444 Recall that we wanted to change the position of the @b{2} in 
1445
1446 @lilypond[quote,fragment,relative=2,verbatim]
1447 c-2
1448 \stemUp
1449 f
1450 @end lilypond
1451
1452 Since the @b{2} is vertically positioned next to its note, we have to
1453 meddle with the interface associated with this positioning.  This is
1454 done using @code{side-position-interface}.  The page for this interface 
1455 says
1456
1457 @quotation
1458 @code{side-position-interface}
1459
1460 Position a victim object (this one) next to other objects (the
1461 support).  The property @code{direction} signifies where to put the
1462 victim object relative to the support (left or right, up or down?)
1463 @end quotation
1464
1465 @cindex padding
1466 @noindent
1467 Below this description, the variable @code{padding} is described as
1468
1469 @quotation
1470 @table @code
1471 @item padding
1472 (dimension, in staff space)
1473
1474 Add this much extra space between objects that are next to each other. 
1475 @end table
1476 @end quotation
1477
1478 By increasing the value of @code{padding}, we can move the
1479 fingering away from the notehead.  The following command inserts
1480 3 staff spaces of white
1481 between the note and the fingering:
1482 @example
1483 \once \override Voice.Fingering #'padding = #3
1484 @end example
1485
1486 Inserting this command before the Fingering object is created,
1487 i.e., before @code{c2}, yields the following result:
1488
1489 @lilypond[quote,relative=2,fragment,verbatim]
1490 \once \override Voice.Fingering #'padding = #3
1491 c-2
1492 \stemUp
1493 f
1494 @end lilypond
1495
1496
1497 In this case, the context for this tweak is @context{Voice}.  This
1498 fact can also be deduced from the program reference, for the page for
1499 the @internalsref{Fingering_engraver} plug-in says
1500
1501 @quotation
1502 Fingering_engraver is part of contexts: @dots{} @b{@internalsref{Voice}}
1503 @end quotation
1504
1505
1506 @node Objects connected to the input
1507 @subsection Objects connected to the input
1508
1509 @cindex @code{\tweak}
1510
1511 In some cases, it is possible to take a short-cut for tuning graphical
1512 objects. For objects that result directly from a piece of the input,
1513 you can use the @code{\tweak} function, for example
1514
1515 @lilypond[relative=2,fragment,verbatim,ragged-right]
1516 <
1517   c
1518   \tweak #'color #red d
1519   g
1520   \tweak #'duration-log #1  a
1521 >4-\tweak #'padding #10 -. 
1522 @end lilypond
1523
1524 As you can see, properties are set directly in the objects directly,
1525 without mentioning the grob name or context where this should be
1526 applied.
1527
1528 This technique only works for objects that are directly connected to
1529 an @internalsref{event} from the input, for example
1530
1531 @itemize @bullet
1532 @item note heads, caused by chord-pitch (i.e., notes inside a chord).
1533 @item articulation signs, caused by articulation instructions.
1534 @end itemize
1535
1536 It notably does not work for stems and accidentals (these are caused
1537 by note heads, not by music events) or clefs (these are not caused by
1538 music inputs, but rather by the change of a property value).
1539
1540 There are very few objects which are @emph{directly} connected to
1541 output.  A normal note (like @code{c4}) is not directly connected
1542 to output, so
1543
1544 @example
1545 \tweak #'color #red c4
1546 @end example
1547
1548 @noindent
1549 will not change color.  See @ref{Displaying music expressions} for
1550 details.
1551
1552
1553 @node \set vs. \override
1554 @subsection \set vs. \override
1555
1556 We have seen two methods of changing properties: @code{\set} and
1557 @code{\override}.  There are actually two different kinds of
1558 properties.
1559
1560 Contexts can have properties, which are usually named in
1561 @code{studlyCaps}.  They mostly control the translation from
1562 music to notatino, eg. @code{localKeySignature} (for determining
1563 whether to print accidentals), @code{measurePosition} (for
1564 determining when to print a barline).  Context properties can 
1565 change value over time while interpreting a piece of music;
1566 @code{measurePosition} is an obvious example of
1567 this.  Context properties are modified with @code{\set}.
1568
1569 There is a special type of context property: the element
1570 description. These properties are named in @code{StudlyCaps}
1571 (starting with capital letters).  They contain the
1572 ``default settings'' for said graphical object as an
1573 association list.  See @file{scm/@/define@/-grobs@/.scm}
1574 to see what kind of settings there are.  Element descriptions
1575 may be modified with @code{\override}.
1576
1577 @code{\override} is actually a shorthand;
1578
1579 @example
1580 \override @var{context}.@var{name} #'@var{property} = #@var{value}
1581 @end example
1582
1583 @noindent
1584 is more or less equivalent to
1585
1586 @c  leave this long line -gp
1587 @example
1588 \set @var{context}.@var{name} #'@var{property} = #(cons (cons '@var{property} @var{value}) <previous value of @var{context})
1589 @end example
1590
1591 The value of @code{context} (the alist) is used to initalize
1592 the properties of individual grobs.  Grobs also have
1593 properties, named in scheme style, with
1594 @code{dashed-words}.  The values of grob properties change
1595 during the formatting process: formatting basically amounts
1596 to computing properties using callback functions.
1597
1598 @code{fontSize} is a special property: it is equivalent to
1599 entering @code{\override ... #'font-size} for all pertinent
1600 objects.  Since this is a common change, the special
1601 property (modified with @code{\set}) was created.
1602
1603
1604 @node Difficult tweaks
1605 @subsection Difficult tweaks
1606
1607 There are a few classes of difficult adjustments.  
1608
1609 @itemize @bullet
1610
1611
1612 @item
1613 One type of difficult adjustment is the appearance of spanner objects,
1614 such as slur and tie.  Initially, only one of these objects is created,
1615 and they can be adjusted with the normal mechanism.  However, in some
1616 cases the spanners cross line breaks.  If this happens, these objects
1617 are cloned.  A separate object is created for every system that it is
1618 in.  These are clones of the original object and inherit all
1619 properties, including @code{\override}s.
1620
1621
1622 In other words, an @code{\override} always affects all pieces of a
1623 broken spanner.  To change only one part of a spanner at a line break,
1624 it is necessary to hook into the formatting process.  The
1625 @code{after-line-breaking} callback contains the Scheme procedure that
1626 is called after the line breaks have been determined, and layout
1627 objects have been split over different systems.
1628
1629 In the following example, we define a procedure
1630 @code{my-callback}.  This procedure
1631  
1632 @itemize @bullet
1633 @item
1634 determines if we have been split across line breaks
1635 @item
1636 if yes, retrieves all the split objects
1637 @item
1638 checks if we are the last of the split objects
1639 @item
1640 if yes, it sets @code{extra-offset}.
1641 @end itemize
1642
1643 This procedure is installed into @internalsref{Tie}, so the last part
1644 of the broken tie is translated up.
1645
1646 @lilypond[quote,verbatim,ragged-right]
1647 #(define (my-callback grob)
1648   (let* (
1649          ; have we been split? 
1650          (orig (ly:grob-original grob))
1651
1652          ; if yes, get the split pieces (our siblings)
1653          (siblings (if (ly:grob? orig)
1654                      (ly:spanner-broken-into orig) '() )))
1655
1656    (if (and (>= (length siblings) 2)
1657              (eq? (car (last-pair siblings)) grob))
1658      (ly:grob-set-property! grob 'extra-offset '(-2 . 5)))))
1659
1660 \relative c'' { 
1661   \override Tie #'after-line-breaking =
1662   #my-callback
1663   c1 ~ \break c2 ~ c
1664 }
1665 @end lilypond
1666
1667 @noindent
1668 When applying this trick, the new @code{after-line-breaking} callback
1669 should also call the old one @code{after-line-breaking}, if there is
1670 one.  For example, if using this with @code{Hairpin},
1671 @code{ly:hairpin::after-line-breaking} should also be called.
1672
1673
1674 @item Some objects cannot be changed with @code{\override} for
1675 technical reasons. Examples of those are @code{NonMusicalPaperColumn}
1676 and @code{PaperColumn}.  They can be changed with the
1677 @code{\outputProperty} function, which works similar to @code{\once
1678 \override}, but uses a different syntax,
1679
1680 @example 
1681 \outputProperty
1682 #"Score.NonMusicalPaperColumn"  % Grob name
1683 #'line-break-system-details     % Property name  
1684 #'((next-padding . 20))         % Value
1685 @end example
1686
1687 @end itemize