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