]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/changing-defaults.itely
Fix some bugs in the dynamic engraver and PostScript backend
[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 @findex 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 @findex 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 @findex 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 @findex 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 @findex 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 @findex 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 @findex #(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 @findex 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 @findex autoBeamSettings
228 @findex (end * * * *)
229 @findex (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 @findex 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 @findex \autoBeamOff
370 @code{\autoBeamOff},
371 @findex \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 @quotation
427 @image{context-example,5cm,,}
428 @end quotation
429
430 Each context has the responsibility for enforcing some notation rules,
431 creating some notation objects and maintaining the associated
432 properties.  For example, the @context{Voice} context may introduce an
433 accidental and then the @context{Staff} context maintains the rule to
434 show or suppress the accidental for the remainder of the measure.  The
435 synchronization of bar lines is handled at @context{Score} context.
436
437 However, in some music we may not want the bar lines to be
438 synchronized -- consider a polymetric score in 4/4 and 3/4 time.  In
439 such cases, we must modify the default settings of the @context{Score}
440 and @context{Staff} contexts.
441
442 For very simple scores, contexts are created implicitly, and you need
443 not be aware of them.  For larger pieces, such as anything with more
444 than one staff, they must be
445 created explicitly to make sure that you get as many staves as you
446 need, and that they are in the correct order.  For typesetting pieces
447 with specialized notation, it can be useful to modify existing or
448 to define new contexts.
449
450
451 A complete description of all available contexts is in the program
452 reference, see
453 @ifhtml
454 @internalsref{Contexts}.
455 @end ifhtml
456 @ifnothtml
457 Translation @arrow{} Context.
458 @end ifnothtml
459
460 @c [TODO: describe propagation]
461
462
463 @node Creating contexts
464 @subsection Creating contexts
465
466 For scores with only one voice and one staff, contexts are
467 created automatically.  For more complex scores, it is necessary to
468 create them by hand.  There are three commands that do this.
469
470 @itemize @bullet
471
472 @item
473 The easiest command is @code{\new}, and it also the quickest to type.
474 It is prepended to a music expression, for example
475
476 @findex \new
477 @cindex new contexts
478 @cindex Context, creating
479
480 @example
481 \new @var{type} @var{music expression}
482 @end example
483
484 @noindent
485 where @var{type} is a context name (like @code{Staff} or
486 @code{Voice}).  This command creates a new context, and starts
487 interpreting the @var{music expression} with that.
488
489 A practical application of @code{\new} is a score with many
490 staves.  Each part that should be on its own staff, is preceded with
491 @code{\new Staff}.
492
493 @lilypond[quote,verbatim,relative=2,ragged-right,fragment]
494 <<
495   \new Staff { c4 c }
496   \new Staff { d4 d }
497 >>
498 @end lilypond
499
500 The @code{\new} command may also give a name to the context,
501
502 @example
503 \new @var{type} = @var{id} @var{music}
504 @end example
505 However, this user specified name is only used if there is no other
506 context already earlier with the same name.
507
508
509 @findex \context
510
511 @item
512 Like @code{\new}, the @code{\context} command also directs a music
513 expression to a context object, but gives the context an explicit name.  The
514 syntax is
515
516 @example
517 \context @var{type} = @var{id} @var{music}
518 @end example
519
520 This form will search for an existing context of type @var{type}
521 called @var{id}.  If that context does not exist yet, a new
522 context with the specified name is created.  This is useful if
523 the context is referred to later on.  For example, when
524 setting lyrics the melody is in a named context
525
526 @example
527 \context Voice = "@b{tenor}" @var{music}
528 @end example
529
530 @noindent
531 so the texts can be properly aligned to its notes,
532
533 @example
534 \new Lyrics \lyricsto "@b{tenor}" @var{lyrics}
535 @end example
536
537 @noindent
538
539 Another possible use of named contexts is funneling two different
540 music expressions into one context.  In the following example,
541 articulations and notes are entered separately,
542
543 @example
544 music = @{ c4 c4 @}
545 arts = @{ s4-. s4-> @}
546 @end example
547
548 They are combined by sending both to the same @context{Voice} context,
549
550 @example
551 <<
552   \new Staff \context Voice = "A" \music
553   \context Voice = "A" \arts
554 >>
555 @end example
556 @lilypond[quote,ragged-right]
557 music = { c4 c4 }
558 arts = { s4-. s4-> }
559 \relative c'' <<
560   \new Staff \context Voice = "A" \music
561   \context Voice = "A" \arts
562 >>
563 @end lilypond
564
565 With this mechanism, it is possible to define an Urtext (original
566 edition), with the option to put several distinct articulations on the
567 same notes.
568
569 @cindex creating contexts
570
571 @item
572 The third command for creating contexts is
573 @example
574 \context @var{type} @var{music}
575 @end example
576
577
578 @noindent
579 This is similar to @code{\context} with @code{= @var{id}}, but matches
580 any context of type @var{type}, regardless of its given name.
581
582 This variant is used with music expressions that can be interpreted at
583 several levels.  For example, the @code{\applyOutput} command (see
584 @ref{Running a function on all layout objects}).  Without an explicit
585 @code{\context}, it is usually applied to @context{Voice}
586
587 @example
588 \applyOutput #'@var{context} #@var{function}   % apply to Voice
589 @end example
590
591 To have it interpreted at the @context{Score} or @context{Staff} level use
592 these forms
593
594 @example
595 \context \applyOutput #'Score #@var{function}
596 \context \applyOutput #'Staff #@var{function}
597 @end example
598
599 @end itemize
600
601
602 @node Changing context properties on the fly
603 @subsection Changing context properties on the fly
604
605 @cindex properties
606 @findex \set
607 @cindex changing properties
608
609 Each context can have different @emph{properties}, variables contained
610 in that context.  They can be changed during the interpretation step.
611 This is achieved by inserting the @code{\set} command in the music,
612
613 @example
614 \set @var{context}.@var{prop} = #@var{value}
615 @end example
616
617 For example,
618 @lilypond[quote,verbatim,relative=2,fragment]
619 R1*2
620 \set Score.skipBars = ##t
621 R1*2
622 @end lilypond
623
624 This command skips measures that have no notes.  The result is that
625 multi-rests are condensed.  The value assigned is a Scheme object.  In
626 this case, it is @code{#t}, the boolean True value.
627
628 If the @var{context} argument is left out, then the current bottom-most
629 context (typically @context{ChordNames}, @context{Voice}, or
630 @context{Lyrics}) is used.  In this example,
631
632 @lilypond[quote,verbatim,relative=2,fragment]
633 c8 c c c
634 \set autoBeaming = ##f
635 c8 c c c
636 @end lilypond
637
638 @noindent
639 the @var{context} argument to @code{\set} is left out, so automatic
640 beaming is switched off in the current @internalsref{Voice}.  Note that
641 the bottom-most context does not always contain the property that you
642 wish to change -- for example, attempting to set the @code{skipBars}
643 property (of the bottom-most context, in this case @code{Voice}) will
644 have no effect.
645
646 @lilypond[quote,verbatim,relative=2,fragment]
647 R1*2
648 \set skipBars = ##t
649 R1*2
650 @end lilypond
651
652 Contexts are hierarchical, so if a bigger context was specified, for
653 example @context{Staff}, then the change would also apply to all
654 @context{Voice}s in the current stave.  The change is applied
655 `on-the-fly', during the music, so that the setting only affects the
656 second group of eighth notes.
657
658 @findex \unset
659
660 There is also an @code{\unset} command,
661 @example
662 \unset @var{context}.@var{prop}
663 @end example
664
665 @noindent
666 which removes the definition of @var{prop}.  This command removes
667 the definition only if it is set in @var{context}, so
668
669 @example
670 \set Staff.autoBeaming = ##f
671 @end example
672
673 @noindent
674 introduces a property setting at @code{Staff} level.  The setting also
675 applies to the current @code{Voice}.  However,
676
677 @example
678 \unset Voice.autoBeaming
679 @end example
680
681 @noindent
682 does not have any effect.  To cancel this setting, the @code{\unset}
683 must be specified on the same level as the original @code{\set}.  In
684 other words, undoing the effect of @code{Staff.autoBeaming = ##f}
685 requires
686 @example
687 \unset Staff.autoBeaming
688 @end example
689
690 Like @code{\set}, the @var{context} argument does not have to be
691 specified for a bottom context, so the two statements
692
693 @example
694 \set Voice.autoBeaming = ##t
695 \set autoBeaming = ##t
696 @end example
697
698 @noindent
699 are equivalent.
700
701
702 @cindex \once
703 Settings that should only apply to a single time-step can be entered
704 with @code{\once}, for example in
705
706 @lilypond[quote,verbatim,relative=2,fragment]
707 c4
708 \once \set fontSize = #4.7
709 c4
710 c4
711 @end lilypond
712
713 the property @code{fontSize} is unset automatically after the second
714 note.
715
716 A full description of all available context properties is in the
717 program reference, see
718 @ifhtml
719 @internalsref{Tunable context properties}.
720 @end ifhtml
721 @ifnothtml
722 Translation @arrow{} Tunable context properties.
723 @end ifnothtml
724
725
726 @node Modifying context plug-ins
727 @subsection Modifying context plug-ins
728
729 Notation contexts (like @code{Score} and @code{Staff}) not only
730 store properties,
731 they also contain plug-ins called ``engravers'' that create notation
732 elements.  For example, the @code{Voice} context contains a
733 @code{Note_head_engraver} and the @code{Staff} context contains a
734 @code{Key_signature_engraver}.
735
736 For a full a description of each plug-in, see
737 @ifhtml
738 @internalsref{Engravers}.
739 @end ifhtml
740 @ifnothtml
741 Program reference @arrow Translation @arrow{} Engravers.
742 @end ifnothtml
743 Every context described in
744 @ifhtml
745 @internalsref{Contexts}
746 @end ifhtml
747 @ifnothtml
748 Program reference @arrow Translation @arrow{} Context.
749 @end ifnothtml
750 lists the engravers used for that context.
751
752
753 It can be useful to shuffle around these plug-ins.  This is done by
754 starting a new context with @code{\new} or @code{\context}, and
755 modifying it,
756
757 @findex \with
758
759 @example
760 \new @var{context} \with @{
761   \consists @dots{}
762   \consists @dots{}
763   \remove @dots{}
764   \remove @dots{}
765   @emph{etc.}
766 @}
767 @{
768   @emph{..music..}
769 @}
770 @end example
771
772 @noindent
773 where the @dots{} should be the name of an engraver.  Here is a simple
774 example which removes @code{Time_signature_engraver} and
775 @code{Clef_engraver} from a @code{Staff} context,
776
777 @lilypond[quote,relative=1,verbatim,fragment]
778 <<
779   \new Staff {
780     f2 g
781   }
782   \new Staff \with {
783      \remove "Time_signature_engraver"
784      \remove "Clef_engraver"
785   } {
786     f2 g2
787   }
788 >>
789 @end lilypond
790
791 In the second staff there are no time signature or clef symbols.  This
792 is a rather crude method of making objects disappear since it will affect
793 the entire staff.  This method also influences the spacing, which may or
794 may not be desirable.  A more
795 sophisticated method of blanking objects is shown in @ref{Common tweaks}.
796
797 The next example shows a practical application.  Bar lines and time
798 signatures are normally synchronized across the score.  This is done
799 by the @code{Timing_translator} and @code{Default_bar_line_engraver}.
800 This plug-in keeps an administration of time signature, location
801 within the measure, etc.  By moving thes engraver from @code{Score} to
802 @code{Staff} context, we can have a score where each staff has its own
803 time signature.
804
805 @cindex polymetric scores
806 @cindex Time signatures, multiple
807
808 @lilypond[quote,relative=1,ragged-right,verbatim,fragment]
809 \new Score \with {
810   \remove "Timing_translator"
811   \remove "Default_bar_line_engraver"
812 } <<
813   \new Staff \with {
814     \consists "Timing_translator"
815     \consists "Default_bar_line_engraver"
816   } {
817       \time 3/4
818       c4 c c c c c
819   }
820   \new Staff \with {
821     \consists "Timing_translator"
822     \consists "Default_bar_line_engraver"
823   } {
824        \time 2/4
825        c4 c c c c c
826   }
827 >>
828 @end lilypond
829
830
831 @node Layout tunings within contexts
832 @subsection Layout tunings within contexts
833
834 Each context is responsible for creating certain types of graphical
835 objects.  The settings used for printing these objects are also stored by
836 context.  By changing these settings, the appearance of objects can be
837 altered.
838
839 The syntax for this is
840
841 @example
842 \override @var{context}.@var{name} #'@var{property} = #@var{value}
843 @end example
844
845 Here @var{name} is the name of a graphical object, like @code{Stem} or
846 @code{NoteHead}, and @var{property} is an internal variable of the
847 formatting system (`grob property' or `layout property').  The latter is a
848 symbol, so it must be quoted.  The subsection @ref{Constructing a
849 tweak} explains what to fill in for @var{name}, @var{property}, and
850 @var{value}.  Here we only discuss the functionality of this command.
851
852 The command
853
854 @verbatim
855 \override Staff.Stem #'thickness = #4.0
856 @end verbatim
857
858 @noindent
859 makes stems thicker (the default is 1.3, with staff line thickness as a
860 unit).  Since the command specifies @context{Staff} as context, it only
861 applies to the current staff.  Other staves will keep their normal
862 appearance.  Here we see the command in action:
863
864 @lilypond[quote,verbatim,relative=2,fragment]
865 c4
866 \override Staff.Stem #'thickness = #4.0
867 c4
868 c4
869 c4
870 @end lilypond
871
872 The @code{\override} command changes the definition of the @code{Stem}
873 within the current @context{Staff}.  After the command is interpreted
874 all stems are thickened.
875
876 Analogous to @code{\set}, the @var{context} argument may be left out,
877 causing it to default to @context{Voice}, and adding @code{\once} applies
878 the change during one timestep only
879
880 @lilypond[quote,fragment,verbatim,relative=2]
881 c4
882 \once \override Stem #'thickness = #4.0
883 c4
884 c4
885 @end lilypond
886
887 The @code{\override} must be done before the object is
888 started.  Therefore, when altering @emph{Spanner} objects such as slurs
889 or beams, the @code{\override} command must be executed at the moment
890 when the object is created.  In this example,
891
892 @lilypond[quote,fragment,verbatim,relative=2]
893 \override Slur #'thickness = #3.0
894 c8[( c
895 \override Beam #'thickness = #0.6
896 c8 c])
897 @end lilypond
898
899 @noindent
900 the slur is fatter but the beam is not.  This is because the command for
901 @code{Beam} comes after the Beam is started, so it has no effect.
902
903 Analogous to @code{\unset}, the @code{\revert} command for a context
904 undoes an @code{\override} command; like with @code{\unset}, it only
905 affects settings that were made in the same context.  In other words, the
906 @code{\revert} in the next example does not do anything.
907
908 @example
909 \override Voice.Stem #'thickness = #4.0
910 \revert Staff.Stem #'thickness
911 @end example
912
913 Some tweakable options are called ``subproperties'' and reside inside
914 properties.  To tweak those, use commands of the form
915
916 @c leave this as a long long
917 @example
918 \override @var{context}.@var{name} #'@var{property} #'@var{subproperty} = #@var{value}
919 @end example
920
921 @noindent
922 such as
923
924 @example
925 \override Stem #'details #'beamed-lengths = #'(4 4 3)
926 @end example
927
928
929 @seealso
930
931 Internals: @internalsref{OverrideProperty}, @internalsref{RevertProperty},
932 @internalsref{PropertySet}, @internalsref{Backend}, and
933 @internalsref{All layout objects}.
934
935
936 @refbugs
937
938 The back-end is not very strict in type-checking object properties.
939 Cyclic references in Scheme values for properties can cause hangs
940 or crashes, or both.
941
942
943 @node Changing context default settings
944 @subsection Changing context default settings
945
946 The adjustments of the previous subsections (@ref{Changing context
947 properties on the fly}, @ref{Modifying context plug-ins}, and
948 @ref{Layout tunings within contexts}) can also be entered separately
949 from the music in the @code{\layout} block,
950
951 @example
952 \layout @{
953   @dots{}
954   \context @{
955     \Staff
956
957     \set fontSize = #-2
958     \override Stem #'thickness = #4.0
959     \remove "Time_signature_engraver"
960   @}
961 @}
962 @end example
963
964 Here @code{\Staff} takes the existing definition for context @context{Staff} from the
965 identifier @code{\Staff}.
966
967 The statements
968 @example
969 \set fontSize = #-2
970 \override Stem #'thickness = #4.0
971 \remove "Time_signature_engraver"
972 @end example
973
974 @noindent
975 affect all staves in the score.  Other contexts can be modified
976 analogously.
977
978 The @code{\set} keyword is optional within the @code{\layout} block, so
979
980 @example
981 \context @{
982   @dots{}
983   fontSize = #-2
984 @}
985 @end example
986
987 @noindent
988 will also work.
989
990
991
992 @refbugs
993
994 It is not possible to collect context changes in a variable and apply
995 them to a @code{\context} definition by referring to that variable.
996
997 The @code{\RemoveEmptyStaffContext} will overwrite your current
998 @code{\Staff} settings.  If you wish to change the defaults for a
999 staff which uses @code{\RemoveEmptyStaffContext}, you must do so
1000 after calling @code{\RemoveemptyStaffContext}, ie
1001
1002 @example
1003 \layout @{
1004   \context @{
1005     \RemoveEmptyStaffContext
1006
1007     \override Stem #'thickness = #4.0
1008   @}
1009 @}
1010 @end example
1011
1012
1013 @node Defining new contexts
1014 @subsection Defining new contexts
1015
1016 Specific contexts, like @context{Staff} and @code{Voice}, are made of
1017 simple building blocks.  It is possible to create new types of
1018 contexts with different combinations of engraver plug-ins.
1019
1020 The next example shows how to build a different type of
1021 @context{Voice} context from scratch.  It will be similar to
1022 @code{Voice}, but only prints centered slash noteheads.  It can be used
1023 to indicate improvisation in jazz pieces,
1024
1025 @lilypond[quote,ragged-right]
1026 \layout { \context {
1027   \name ImproVoice
1028   \type "Engraver_group"
1029   \consists "Note_heads_engraver"
1030   \consists "Text_engraver"
1031   \consists Pitch_squash_engraver
1032   squashedPosition = #0
1033   \override NoteHead #'style = #'slash
1034   \override Stem #'transparent = ##t
1035   \alias Voice
1036 }
1037 \context { \Staff
1038   \accepts "ImproVoice"
1039 }}
1040
1041 \relative c'' {
1042   a4 d8 bes8 \new ImproVoice { c4^"ad lib" c
1043    c4 c^"undress" c_"while playing :)" c }
1044   a1
1045 }
1046 @end lilypond
1047
1048
1049 These settings are defined within a @code{\context} block inside a
1050 @code{\layout} block,
1051
1052 @example
1053 \layout @{
1054   \context @{
1055     @dots{}
1056   @}
1057 @}
1058 @end example
1059
1060 In the following discussion, the example input shown should go on the
1061 @dots{} in the previous fragment.
1062
1063 First the context's name is defined.  Instead of @context{Voice} it
1064 will be called @context{ImproVoice},
1065
1066 @example
1067 \name ImproVoice
1068 @end example
1069
1070 Since it is similar to the @context{Voice}, we want commands that work
1071 on (existing) @context{Voice}s to remain working.  This is achieved by
1072 giving the new context an alias @context{Voice},
1073
1074 @example
1075 \alias Voice
1076 @end example
1077
1078 The context will print notes, and instructive texts
1079
1080 @example
1081 \consists Note_heads_engraver
1082 \consists Text_engraver
1083 @end example
1084
1085 but only on the center line,
1086
1087 @example
1088 \consists Pitch_squash_engraver
1089 squashedPosition = #0
1090 @end example
1091
1092 The @internalsref{Pitch_squash_engraver} modifies note heads (created
1093 by @internalsref{Note_heads_engraver}) and sets their vertical
1094 position to the value of @code{squashedPosition}, in this case@tie{}@code{0},
1095 the center line.
1096
1097 The notes look like a slash, and have no stem,
1098
1099 @example
1100 \override NoteHead #'style = #'slash
1101 \override Stem #'transparent = ##t
1102 @end example
1103
1104 All these plug-ins have to cooperate, and this is achieved with a
1105 special plug-in, which must be marked with the keyword @code{\type}.
1106 This should always be @internalsref{Engraver_group},
1107
1108 @example
1109 \type "Engraver_group"
1110 @end example
1111
1112 Put together, we get
1113
1114 @example
1115 \context @{
1116   \name ImproVoice
1117   \type "Engraver_group"
1118   \consists "Note_heads_engraver"
1119   \consists "Text_engraver"
1120   \consists Pitch_squash_engraver
1121   squashedPosition = #0
1122   \override NoteHead #'style = #'slash
1123   \override Stem #'transparent = ##t
1124   \alias Voice
1125 @}
1126 @end example
1127
1128 @findex \accepts
1129 Contexts form hierarchies.  We want to hang the @context{ImproVoice}
1130 under @context{Staff}, just like normal @code{Voice}s.  Therefore, we
1131 modify the @code{Staff} definition with the @code{\accepts}
1132 command,
1133
1134 @example
1135 \context @{
1136   \Staff
1137   \accepts ImproVoice
1138 @}
1139 @end example
1140
1141 @findex \denies
1142 The opposite of @code{\accepts} is @code{\denies},
1143 which is sometimes needed when reusing existing context definitions.
1144
1145 Putting both into a @code{\layout} block, like
1146
1147 @example
1148 \layout @{
1149   \context @{
1150     \name ImproVoice
1151     @dots{}
1152   @}
1153   \context @{
1154     \Staff
1155     \accepts "ImproVoice"
1156   @}
1157 @}
1158 @end example
1159
1160 Then the output at the start of this subsection can be entered as
1161
1162 @example
1163 \relative c'' @{
1164   a4 d8 bes8
1165   \new ImproVoice @{
1166     c4^"ad lib" c
1167     c4 c^"undress"
1168     c c_"while playing :)"
1169   @}
1170   a1
1171 @}
1172 @end example
1173
1174
1175
1176
1177 @node The \override command
1178 @section The \override command
1179
1180 In the previous section, we have already touched on a command that
1181 changes layout details: the @code{\override} command.  In this section,
1182 we will look in more detail at how to use the command in practice.
1183
1184
1185 @menu
1186 * Constructing a tweak::        
1187 * Navigating the program reference::  
1188 * Layout interfaces::           
1189 * Determining the grob property::  
1190 * Objects connected to the input::  
1191 * \set vs. \override::          
1192 * Difficult tweaks::            
1193 @end menu
1194
1195
1196
1197 @node Constructing a tweak
1198 @subsection Constructing a tweak
1199
1200 Commands which change output generally look like
1201
1202 @example
1203 \override Voice.Stem #'thickness = #3.0
1204 @end example
1205
1206 @noindent
1207 This means that we must determine these bits of information:
1208
1209 @itemize
1210 @item the context: here @context{Voice}.
1211 @item the layout object: here @code{Stem}.
1212 @item the layout property: here @code{thickness}.
1213 @item a sensible value: here @code{3.0}.
1214 @end itemize
1215
1216 Some tweakable options are called ``subproperties'' and reside inside
1217 properties.  To tweak those, use commands in the form
1218
1219 @example
1220 \override Stem #'details #'beamed-lengths = #'(4 4 3)
1221 @end example
1222
1223 @cindex internal documentation
1224 @cindex finding graphical objects
1225 @cindex graphical object descriptions
1226 @cindex tweaking
1227 @findex \override
1228 @cindex internal documentation
1229
1230 We demonstrate how to glean this information from the notation manual
1231 and the program reference.
1232
1233
1234 @node Navigating the program reference
1235 @subsection Navigating the program reference
1236
1237 Suppose we want to move the fingering indication in the fragment
1238 below:
1239
1240 @lilypond[quote,fragment,relative=2,verbatim]
1241 c-2
1242 \stemUp
1243 f
1244 @end lilypond
1245
1246 If you visit the documentation on fingering instructions (in
1247 @ref{Fingering instructions}), you will notice:
1248
1249 @quotation
1250 @seealso
1251
1252 Program reference: @internalsref{Fingering}.
1253
1254 @end quotation
1255
1256
1257 @c  outdated info; probably will delete.
1258 @ignore
1259 This fragment points to two parts of the program reference: a page
1260 on @code{FingerEvent} and one on @code{Fingering}.
1261
1262 The page on @code{FingerEvent} describes the properties of the music
1263 expression for the input @code{-2}.  The page contains many links
1264 forward.  For example, it says
1265
1266 @quotation
1267 Accepted by: @internalsref{Fingering_engraver},
1268 @end quotation
1269
1270 @noindent
1271 That link brings us to the documentation for the Engraver, the
1272 plug-in, which says
1273
1274 @quotation
1275 This engraver creates the following layout objects: @internalsref{Fingering}.
1276 @end quotation
1277
1278 In other words, once the @code{FingerEvent}s are interpreted, the
1279 @code{Fingering_engraver} plug-in will process them.
1280 @end ignore
1281
1282 @ignore
1283 @c  I can't figure out what this is supposed to mean.  -gp
1284
1285 The @code{Fingering_engraver} is also listed to create
1286 @internalsref{Fingering} objects,
1287
1288 @c  old info?  it doesn't make any sense to me with our current docs.
1289 This is also the
1290 second bit of information listed under @b{See also} in the Notation
1291 manual.
1292 @end ignore
1293
1294 Follow the link to @internalsref{Fingering}.  At the top of the
1295 page, you will see
1296
1297 @quotation
1298 Fingering objects are created by: @internalsref{Fingering_engraver} and
1299 @internalsref{New_fingering_engraver}.
1300 @end quotation
1301
1302 By clicking around in the program reference, we can follow the
1303 flow of information within the program, following links like this:
1304
1305 @itemize @bullet
1306
1307 @item @internalsref{Fingering}:
1308 @internalsref{Fingering} objects are created by:
1309 @internalsref{Fingering_engraver}
1310
1311 @item @internalsref{Fingering_engraver}:
1312 Music types accepted: @internalsref{fingering-event}
1313
1314 @item @internalsref{fingering-event}:
1315 Music event type @code{fingering-event} is in Music expressions named
1316 @internalsref{FingerEvent}
1317 @end itemize
1318
1319 This path goes against the flow of information in the program: it
1320 starts from the output, and ends at the input event.  You could
1321 also start at an input event, and read with the flow of
1322 information, eventually ending up at the output object(s).
1323
1324 The program reference can also be browsed like a normal document.  It
1325 contains chapters on
1326 @ifhtml
1327 @internalsref{Music definitions},
1328 @end ifhtml
1329 @ifnothtml
1330 @code{Music definitions}
1331 @end ifnothtml
1332 on @internalsref{Translation}, and the @internalsref{Backend}.  Every
1333 chapter lists all the definitions used and all properties that may be
1334 tuned.
1335
1336
1337 @node Layout interfaces
1338 @subsection Layout interfaces
1339
1340 @cindex interface, layout
1341 @cindex layout interface
1342 @cindex grob
1343
1344 The HTML page that we found in the previous section describes the
1345 layout object called @internalsref{Fingering}.  Such an object is a
1346 symbol within the score.  It has properties that store numbers (like
1347 thicknesses and directions), but also pointers to related objects.  A
1348 layout object is also called a @emph{Grob}, which is short for Graphical
1349 Object.  For more details about Grobs, see @internalsref{grob-interface}.
1350
1351 The page for @code{Fingering} lists the definitions for the
1352 @code{Fingering} object.  For example, the page says
1353
1354 @quotation
1355 @code{padding} (dimension, in staff space):
1356
1357 @code{0.5}
1358 @end quotation
1359
1360 @noindent
1361 which means that the number will be kept at a distance of at least 0.6
1362 of the note head.
1363
1364
1365 Each layout object may have several functions as a notational or
1366 typographical element.  For example, the Fingering object
1367 has the following aspects
1368
1369 @itemize @bullet
1370 @item
1371 Its size is independent of the horizontal spacing, unlike slurs or beams.
1372
1373 @item
1374 It is a piece of text.  Granted, it is usually a very short text.
1375
1376 @item
1377 That piece of text is typeset with a font, unlike slurs or beams.
1378
1379 @item
1380 Horizontally, the center of the symbol should be aligned to the
1381 center of the notehead.
1382
1383 @item
1384 Vertically, the symbol is placed next to the note and the staff.
1385
1386 @item
1387 The vertical position is also coordinated with other superscript
1388 and subscript symbols.
1389 @end itemize
1390
1391 Each of these aspects is captured in so-called @emph{interface}s,
1392 which are listed on the @internalsref{Fingering} page at the bottom
1393
1394 @quotation
1395 This object supports the following interfaces:
1396 @internalsref{item-interface},
1397 @internalsref{self-alignment-interface},
1398 @internalsref{side-position-interface}, @internalsref{text-interface},
1399 @internalsref{text-script-interface}, @internalsref{font-interface},
1400 @internalsref{finger-interface}, and @internalsref{grob-interface}.
1401 @end quotation
1402
1403 Clicking any of the links will take you to the page of the respective
1404 object interface.  Each interface has a number of properties.  Some of
1405 them are not user-serviceable (``Internal properties''), but others
1406 can be modified.
1407
1408 We have been talking of @emph{the} @code{Fingering} object, but actually it
1409 does not amount to much.  The initialization file (see
1410 @ref{Default files})
1411 @file{scm/@/define@/-grobs@/.scm} shows the soul of the `object',
1412
1413 @example
1414 (Fingering
1415   . ((padding . 0.5)
1416      (avoid-slur . around)
1417      (slur-padding . 0.2)
1418      (staff-padding . 0.5)
1419      (self-alignment-X . 0)
1420      (self-alignment-Y . 0)
1421      (script-priority . 100)
1422      (stencil . ,ly:text-interface::print)
1423      (direction . ,ly:script-interface::calc-direction)
1424      (font-encoding . fetaNumber)
1425      (font-size . -5)           ; don't overlap when next to heads.
1426      (meta . ((class . Item)
1427      (interfaces . (finger-interface
1428                     font-interface
1429                     text-script-interface
1430                     text-interface
1431                     side-position-interface
1432                     self-alignment-interface
1433                     item-interface))))))
1434 @end example
1435
1436 @noindent
1437 As you can see, the @code{Fingering} object is nothing more than a
1438 bunch of variable settings, and the webpage in the Program Reference
1439 is directly generated from this definition.
1440
1441
1442 @node Determining the grob property
1443 @subsection Determining the grob property
1444
1445 Recall that we wanted to change the position of the @b{2} in
1446
1447 @lilypond[quote,fragment,relative=2,verbatim]
1448 c-2
1449 \stemUp
1450 f
1451 @end lilypond
1452
1453 Since the @b{2} is vertically positioned next to its note, we have to
1454 meddle with the interface associated with this positioning.  This is
1455 done using @code{side-position-interface}.  The page for this interface
1456 says
1457
1458 @quotation
1459 @code{side-position-interface}
1460
1461 Position a victim object (this one) next to other objects (the
1462 support).  The property @code{direction} signifies where to put the
1463 victim object relative to the support (left or right, up or down?)
1464 @end quotation
1465
1466 @cindex padding
1467 @noindent
1468 Below this description, the variable @code{padding} is described as
1469
1470 @quotation
1471 @table @code
1472 @item padding
1473 (dimension, in staff space)
1474
1475 Add this much extra space between objects that are next to each other.
1476 @end table
1477 @end quotation
1478
1479 By increasing the value of @code{padding}, we can move the
1480 fingering away from the notehead.  The following command inserts
1481 3 staff spaces of white
1482 between the note and the fingering:
1483 @example
1484 \once \override Voice.Fingering #'padding = #3
1485 @end example
1486
1487 Inserting this command before the Fingering object is created,
1488 i.e., before @code{c2}, yields the following result:
1489
1490 @lilypond[quote,relative=2,fragment,verbatim]
1491 \once \override Voice.Fingering #'padding = #3
1492 c-2
1493 \stemUp
1494 f
1495 @end lilypond
1496
1497
1498 In this case, the context for this tweak is @context{Voice}.  This
1499 fact can also be deduced from the program reference, for the page for
1500 the @internalsref{Fingering_engraver} plug-in says
1501
1502 @quotation
1503 Fingering_engraver is part of contexts: @dots{} @internalsref{Voice}
1504 @end quotation
1505
1506
1507 @node Objects connected to the input
1508 @subsection Objects connected to the input
1509
1510 @findex \tweak
1511
1512 In some cases, it is possible to take a short-cut for tuning graphical
1513 objects. For objects that result directly from a piece of the input,
1514 you can use the @code{\tweak} function, for example
1515
1516 @lilypond[relative=2,fragment,verbatim,ragged-right]
1517 <
1518   c
1519   \tweak #'color #red d
1520   g
1521   \tweak #'duration-log #1  a
1522 >4-\tweak #'padding #10 -.
1523 @end lilypond
1524
1525 As you can see, properties are set directly in the objects directly,
1526 without mentioning the grob name or context where this should be
1527 applied.
1528
1529 This technique only works for objects that are directly connected to
1530 an @internalsref{event} from the input, for example
1531
1532 @itemize @bullet
1533 @item note heads, caused by chord-pitch (i.e., notes inside a chord).
1534 @item articulation signs, caused by articulation instructions.
1535 @end itemize
1536
1537 It notably does not work for stems and accidentals (these are caused
1538 by note heads, not by music events) or clefs (these are not caused by
1539 music inputs, but rather by the change of a property value).
1540
1541 There are very few objects which are @emph{directly} connected to
1542 output.  A normal note (like @code{c4}) is not directly connected
1543 to output, so
1544
1545 @example
1546 \tweak #'color #red c4
1547 @end example
1548
1549 @noindent
1550 will not change color.  See @ref{Displaying music expressions} for
1551 details.
1552
1553
1554 @node \set vs. \override
1555 @subsection \set vs. \override
1556
1557 We have seen two methods of changing properties: @code{\set} and
1558 @code{\override}.  There are actually two different kinds of
1559 properties.
1560
1561 Contexts can have properties, which are usually named in
1562 @code{studlyCaps}.  They mostly control the translation from
1563 music to notatino, eg. @code{localKeySignature} (for determining
1564 whether to print accidentals), @code{measurePosition} (for
1565 determining when to print a barline).  Context properties can
1566 change value over time while interpreting a piece of music;
1567 @code{measurePosition} is an obvious example of
1568 this.  Context properties are modified with @code{\set}.
1569
1570 There is a special type of context property: the element
1571 description. These properties are named in @code{StudlyCaps}
1572 (starting with capital letters).  They contain the
1573 ``default settings'' for said graphical object as an
1574 association list.  See @file{scm/@/define@/-grobs@/.scm}
1575 to see what kind of settings there are.  Element descriptions
1576 may be modified with @code{\override}.
1577
1578 @code{\override} is actually a shorthand;
1579
1580 @example
1581 \override @var{context}.@var{name} #'@var{property} = #@var{value}
1582 @end example
1583
1584 @noindent
1585 is more or less equivalent to
1586
1587 @c  leave this long line -gp
1588 @example
1589 \set @var{context}.@var{name} #'@var{property} = #(cons (cons '@var{property} @var{value}) <previous value of @var{context})
1590 @end example
1591
1592 The value of @code{context} (the alist) is used to initalize
1593 the properties of individual grobs.  Grobs also have
1594 properties, named in scheme style, with
1595 @code{dashed-words}.  The values of grob properties change
1596 during the formatting process: formatting basically amounts
1597 to computing properties using callback functions.
1598
1599 @code{fontSize} is a special property: it is equivalent to
1600 entering @code{\override ... #'font-size} for all pertinent
1601 objects.  Since this is a common change, the special
1602 property (modified with @code{\set}) was created.
1603
1604
1605 @node Difficult tweaks
1606 @subsection Difficult tweaks
1607
1608 There are a few classes of difficult adjustments.
1609
1610 @itemize @bullet
1611
1612
1613 @item
1614 One type of difficult adjustment is the appearance of spanner objects,
1615 such as slur and tie.  Initially, only one of these objects is created,
1616 and they can be adjusted with the normal mechanism.  However, in some
1617 cases the spanners cross line breaks.  If this happens, these objects
1618 are cloned.  A separate object is created for every system that it is
1619 in.  These are clones of the original object and inherit all
1620 properties, including @code{\override}s.
1621
1622
1623 In other words, an @code{\override} always affects all pieces of a
1624 broken spanner.  To change only one part of a spanner at a line break,
1625 it is necessary to hook into the formatting process.  The
1626 @code{after-line-breaking} callback contains the Scheme procedure that
1627 is called after the line breaks have been determined, and layout
1628 objects have been split over different systems.
1629
1630 In the following example, we define a procedure
1631 @code{my-callback}.  This procedure
1632
1633 @itemize @bullet
1634 @item
1635 determines if we have been split across line breaks
1636 @item
1637 if yes, retrieves all the split objects
1638 @item
1639 checks if we are the last of the split objects
1640 @item
1641 if yes, it sets @code{extra-offset}.
1642 @end itemize
1643
1644 This procedure is installed into @internalsref{Tie}, so the last part
1645 of the broken tie is translated up.
1646
1647 @lilypond[quote,verbatim,ragged-right]
1648 #(define (my-callback grob)
1649   (let* (
1650          ; have we been split?
1651          (orig (ly:grob-original grob))
1652
1653          ; if yes, get the split pieces (our siblings)
1654          (siblings (if (ly:grob? orig)
1655                      (ly:spanner-broken-into orig) '() )))
1656
1657    (if (and (>= (length siblings) 2)
1658              (eq? (car (last-pair siblings)) grob))
1659      (ly:grob-set-property! grob 'extra-offset '(-2 . 5)))))
1660
1661 \relative c'' {
1662   \override Tie #'after-line-breaking =
1663   #my-callback
1664   c1 ~ \break c2 ~ c
1665 }
1666 @end lilypond
1667
1668 @noindent
1669 When applying this trick, the new @code{after-line-breaking} callback
1670 should also call the old one @code{after-line-breaking}, if there is
1671 one.  For example, if using this with @code{Hairpin},
1672 @code{ly:hairpin::after-line-breaking} should also be called.
1673
1674
1675 @item Some objects cannot be changed with @code{\override} for
1676 technical reasons. Examples of those are @code{NonMusicalPaperColumn}
1677 and @code{PaperColumn}.  They can be changed with the
1678 @code{\outputProperty} function, which works similar to @code{\once
1679 \override}, but uses a different syntax,
1680
1681 @example
1682 \outputProperty
1683 #"Score.NonMusicalPaperColumn"  % Grob name
1684 #'line-break-system-details     % Property name
1685 #'((next-padding . 20))         % Value
1686 @end example
1687
1688 @end itemize