1 @c -*- coding: utf-8; mode: texinfo; -*-
2 @c This file is part of lilypond.tely
4 Translation of GIT committish: FILL-IN-HEAD-COMMITTISH
6 When revising a translation, copy the HEAD committish of the
7 version that you are working on. See TRANSLATION for details.
12 @node Changing defaults
13 @chapter Changing defaults
15 @strong{N.B. This Chapter is still being developed at present.}
17 The purpose of LilyPond's design is to provide the finest quality
18 output by default. Nevertheless, it may happen that you need to
19 change this default layout. The layout is controlled through a large
20 number of @q{knobs and switches} collectively called @q{properties}.
21 A tutorial introduction to accessing and modifying these properties
22 can be found in the Learning Manual, see @rlearning{Tweaking output}.
23 This should be read first. This chapter covers similar ground, but
24 in a style more appropriate to a reference manual.
26 @cindex Internals Reference
28 The definitive description of the controls available for tuning can
29 be found in a separate document: @rinternalsnamed{Top,the Internals
30 Reference}. That manual lists all the variables, functions and
31 options available in LilyPond. It is written as a HTML document,
33 @c leave the @uref as one long line.
34 @uref{http://@/lilypond@/.org/@/doc/@/stable/@/Documentation/@/user/@/lilypond@/-internals/,on@/-line},
35 and is also included with the LilyPond documentation package.
37 @c TODO The following is at variance to what actually follows. Fix -td
40 There are four areas where the default settings may be changed:
44 Automatic notation: changing the automatic creation of notation
45 elements. For example, changing the beaming rules.
48 Output: changing the appearance of individual
49 objects. For example, changing stem directions or the location of
53 Context: changing aspects of the translation from music events to
54 notation. For example, giving each staff a separate time signature.
57 Page layout: changing the appearance of the spacing, line
58 breaks, and page dimensions. These modifications are discussed
59 @c in @ref{notation}, and @ref{Spacing issues}.
62 Internally, LilyPond uses Scheme (a LISP dialect) to provide
63 infrastructure. Overriding layout decisions in effect accesses the
64 program internals, which requires Scheme input. Scheme elements are
65 introduced in a @code{.ly} file with the hash mark
66 @code{#}.@footnote{@rlearning{Scheme tutorial}, contains a short tutorial
67 on entering numbers, lists, strings, and symbols in Scheme.}
73 * Interpretation contexts::
74 * Explaining the Internals Reference::
75 * Modifying properties::
76 * Useful concepts and properties::
79 * Discussion of specific tweaks::
83 @node Interpretation contexts
84 @section Interpretation contexts
86 This section describes what contexts are, and how to modify them.
89 * Contexts explained::
91 * Modifying context plug-ins::
92 * Changing context default settings::
93 * Defining new contexts::
98 @node Contexts explained
99 @subsection Contexts explained
102 @c TODO Rethink and rewrite
104 >> > > - list of contexts: my *danger unmaintainable*
105 >> > > alarm just went off. I'm
107 I knew it would... And leaving out some of them is perfectly fine
109 I do think that a list like this, with the main contexts and a
111 description of what they do (perhaps also with a note about what
113 behavior is associated with each of them, but this may be
115 should be there, and then we could simply list the remaining ones
117 further explanation and with links to the IR.
120 @c TODO Improve layout, order and consistency of wording -td
122 @c TODO Add introduction which explains contexts in generality -td
124 Contexts are arranged heirarchically:
127 * Score - the master of all contexts::
128 * Top-level contexts - staff containers::
129 * Intermediate-level contexts - staves::
130 * Bottom-level contexts - voices::
133 @node Score - the master of all contexts
134 @unnumberedsubsubsec Score - the master of all contexts
136 This is the top level notation context. No other context can
137 contain a Score context. By default the Score context handles
138 the administration of time signatures and makes sure that items
139 such as clefs, time signatures, and key-signatures are aligned
142 A Score context is instantiated implicitly when a
143 @code{\score @{@dots{}@}} or @code{\layout @{@dots{}@}} block is
144 processed, or explicitly when a @code{\new Score} command is
147 @node Top-level contexts - staff containers
148 @unnumberedsubsubsec Top-level contexts - staff containers
150 @strong{@emph{StaffGroup}}
152 Groups staves while adding a bracket on the left side, grouping
153 the staves together. The bar lines of the contained staves are
154 connected vertically. StaffGroup only consists of a collection
155 of staves, with a bracket in front and spanning bar lines.
157 @strong{@emph{ChoirStaff}}
159 Identical to StaffGroup except that the bar lines of the contained
160 staves are not connected vertically.
162 @strong{@emph{GrandStaff}}
164 A group of staves, with a brace on the left side, grouping
165 the staves together. The bar lines of the contained staves are
166 connected vertically.
168 @strong{@emph{PianoStaff}}
170 TODO No longer correct? Check. -td
172 Just like GrandStaff but with a forced distance between the
173 staves, so cross staff beaming and slurring can be used.
175 @strong{@emph{InnerStaffGroup}}
179 @strong{@emph{InnerChoirStaff}}
183 @node Intermediate-level contexts - staves
184 @unnumberedsubsubsec Intermediate-level contexts - staves
186 @strong{@emph{Staff}}
188 Handles clefs, bar lines, keys, accidentals. It can contain
191 @strong{@emph{RhythmicStaff}}
193 Like Staff but for printing rhythms. Pitches are ignored;
194 the notes are printed on one line.
196 @strong{@emph{TabStaff}}
198 Context for generating tablature. By default lays the music
199 expression out as a guitar tablature, printed on six lines.
201 @strong{@emph{DrumStaff}}
203 Handles typesetting for percussion. Can contain DrumVoice
205 @strong{@emph{VaticanaStaff}}
207 Same as Staff, except that it is designed for typesetting
208 a piece in gregorian style.
210 @strong{@emph{MensuralStaff}}
212 Same as Staff, except that it is designed for typesetting
213 a piece in mensural style.
215 @node Bottom-level contexts - voices
216 @unnumberedsubsubsec Bottom-level contexts - voices
218 Voice-level contexts initialise certain properties and start
219 appropriate engravers. Being bottom-level contexts, they cannot
220 contain other contexts.
222 @strong{@emph{Voice}}
224 Corresponds to a voice on a staff. This context handles the
225 conversion of dynamic signs, stems, beams, super- and sub-scripts,
226 slurs, ties, and rests. You have to instantiate this explicitly
227 if you require multiple voices on the same staff.
229 @strong{@emph{VaticanaVoice}}
231 Same as Voice, except that it is designed for typesetting a piece
234 @strong{@emph{MensuralVoice}}
236 Same as Voice, with modifications for typesetting a piece in
239 @strong{@emph{Lyrics}}
241 Corresponds to a voice with lyrics. Handles the printing of a
242 single line of lyrics.
244 @strong{@emph{DrumVoice}}
246 The voice context used in a percussion staff.
248 @strong{@emph{FiguredBass}}
250 The context in which BassFigure objects are created from
251 input entered in @code{\figuremode} mode.
253 @strong{@emph{TabVoice}}
255 The voice context used within a TabStaff context. Usually left to
256 be created implicitly.
258 @strong{@emph{ChordNames}}
260 Typesets chord names.
262 ------------------------------
266 Then the following, which I don't know what to do with:
268 * GregorianTranscriptionVoice
269 * GregorianTranscriptionStaff
272 Engraves fretboards from chords. Not easy... Not
274 There is now some documentation on FretBoards in the NR, under
275 instrument-specific notation -- cds.
279 * CueVoice Not documented
281 Hard coded entry point for LilyPond. Cannot be tuned.
283 Silently discards all musical information given to this
287 @node Creating contexts
288 @subsection Creating contexts
290 @c TODO \new Score and \score
291 @c TODO more complete descriptions rather than learning style
293 For scores with only one voice and one staff, contexts are
294 created automatically. For more complex scores, it is necessary to
295 create them by hand. There are three commands that do this.
300 The easiest command is @code{\new}, and it also the quickest to type.
301 It is prepended to a music expression, for example
305 @cindex Context, creating
308 \new @var{type} @var{music expression}
312 where @var{type} is a context name (like @code{Staff} or
313 @code{Voice}). This command creates a new context, and starts
314 interpreting the @var{music expression} with that.
316 A practical application of @code{\new} is a score with many
317 staves. Each part that should be on its own staff, is preceded with
320 @lilypond[quote,verbatim,relative=2,ragged-right,fragment]
327 The @code{\new} command may also give a name to the context,
330 \new @var{type} = @var{id} @var{music}
332 However, this user specified name is only used if there is no other
333 context already earlier with the same name.
339 Like @code{\new}, the @code{\context} command also directs a music
340 expression to a context object, but gives the context an explicit name. The
344 \context @var{type} = @var{id} @var{music}
347 This form will search for an existing context of type @var{type}
348 called @var{id}. If that context does not exist yet, a new
349 context with the specified name is created. This is useful if
350 the context is referred to later on. For example, when
351 setting lyrics the melody is in a named context
354 \context Voice = "@b{tenor}" @var{music}
358 so the texts can be properly aligned to its notes,
361 \new Lyrics \lyricsto "@b{tenor}" @var{lyrics}
366 Another possible use of named contexts is funneling two different
367 music expressions into one context. In the following example,
368 articulations and notes are entered separately,
372 arts = @{ s4-. s4-> @}
375 They are combined by sending both to the same @code{Voice} context,
379 \new Staff \context Voice = "A" \music
380 \context Voice = "A" \arts
383 @lilypond[quote,ragged-right]
387 \new Staff \context Voice = "A" \music
388 \context Voice = "A" \arts
392 With this mechanism, it is possible to define an Urtext (original
393 edition), with the option to put several distinct articulations on the
396 @cindex creating contexts
399 The third command for creating contexts is
401 \context @var{type} @var{music}
406 This is similar to @code{\context} with @code{= @var{id}}, but matches
407 any context of type @var{type}, regardless of its given name.
409 This variant is used with music expressions that can be interpreted at
410 several levels. For example, the @code{\applyOutput} command (see
411 @ref{Running a function on all layout objects}). Without an explicit
412 @code{\context}, it is usually applied to @code{Voice}
415 \applyOutput #'@var{context} #@var{function} % apply to Voice
418 To have it interpreted at the @code{Score} or @code{Staff} level use
422 \applyOutput #'Score #@var{function}
423 \applyOutput #'Staff #@var{function}
429 @node Modifying context plug-ins
430 @subsection Modifying context plug-ins
432 @c TODO Should this be Modifying engravers or Modifying contexts?
434 Notation contexts (like @code{Score} and @code{Staff}) not only
436 they also contain plug-ins called @q{engravers} that create notation
437 elements. For example, the @code{Voice} context contains a
438 @code{Note_head_engraver} and the @code{Staff} context contains a
439 @code{Key_signature_engraver}.
441 For a full a description of each plug-in, see
443 @rinternals{Engravers and Performers}.
446 Internals Reference @expansion{} Translation @expansion{} Engravers.
448 Every context described in
450 @rinternals{Contexts}
453 Internals Reference @expansion{} Translation @expansion{} Context.
455 lists the engravers used for that context.
458 It can be useful to shuffle around these plug-ins. This is done by
459 starting a new context with @code{\new} or @code{\context}, and
465 \new @var{context} \with @{
478 where the @dots{} should be the name of an engraver. Here is a simple
479 example which removes @code{Time_signature_engraver} and
480 @code{Clef_engraver} from a @code{Staff} context,
482 @lilypond[quote,relative=1,verbatim,fragment]
488 \remove "Time_signature_engraver"
489 \remove "Clef_engraver"
496 In the second staff there are no time signature or clef symbols. This
497 is a rather crude method of making objects disappear since it will affect
498 the entire staff. This method also influences the spacing, which may or
499 may not be desirable. More sophisticated methods of blanking objects
500 are shown in @rlearning{Visibility and color of objects}.
502 The next example shows a practical application. Bar lines and time
503 signatures are normally synchronized across the score. This is done
504 by the @code{Timing_translator} and @code{Default_bar_line_engraver}.
505 This plug-in keeps an administration of time signature, location
506 within the measure, etc. By moving these engraver from @code{Score} to
507 @code{Staff} context, we can have a score where each staff has its own
510 @cindex polymetric scores
511 @cindex Time signatures, multiple
513 @lilypond[quote,relative=1,ragged-right,verbatim,fragment]
515 \remove "Timing_translator"
516 \remove "Default_bar_line_engraver"
519 \consists "Timing_translator"
520 \consists "Default_bar_line_engraver"
526 \consists "Timing_translator"
527 \consists "Default_bar_line_engraver"
536 @node Changing context default settings
537 @subsection Changing context default settings
539 The adjustments of the previous subsections (
540 @ref{The set command}, @ref{Modifying context plug-ins}, and
541 @ref{Overview of modifying properties}) can also be entered
542 separately from the music in the @code{\layout} block,
551 \override Stem #'thickness = #4.0
552 \remove "Time_signature_engraver"
557 The @code{\Staff} command brings in the existing definition of the
558 staff context so that it can be modified.
563 \override Stem #'thickness = #4.0
564 \remove "Time_signature_engraver"
568 affect all staves in the score. Other contexts can be modified
571 The @code{\set} keyword is optional within the @code{\layout} block, so
587 It is not possible to collect context changes in a variable and apply
588 them to a @code{\context} definition by referring to that variable.
590 The @code{\RemoveEmptyStaffContext} will overwrite your current
591 @code{\Staff} settings. If you wish to change the defaults for a
592 staff which uses @code{\RemoveEmptyStaffContext}, you must do so
593 after calling @code{\RemoveEmptyStaffContext}, ie
598 \RemoveEmptyStaffContext
600 \override Stem #'thickness = #4.0
605 TODO: add \with in here.
609 @node Defining new contexts
610 @subsection Defining new contexts
612 Specific contexts, like @code{Staff} and @code{Voice}, are made of
613 simple building blocks. It is possible to create new types of
614 contexts with different combinations of engraver plug-ins.
616 The next example shows how to build a different type of
617 @code{Voice} context from scratch. It will be similar to
618 @code{Voice}, but only prints centered slash note heads. It can be used
619 to indicate improvisation in jazz pieces,
621 @lilypond[quote,ragged-right]
624 \type "Engraver_group"
625 \consists "Note_heads_engraver"
626 \consists "Text_engraver"
627 \consists Pitch_squash_engraver
628 squashedPosition = #0
629 \override NoteHead #'style = #'slash
630 \override Stem #'transparent = ##t
634 \accepts "ImproVoice"
638 a4 d8 bes8 \new ImproVoice { c4^"ad lib" c
639 c4 c^"undress" c_"while playing :)" c }
645 These settings are defined within a @code{\context} block inside a
646 @code{\layout} block,
656 In the following discussion, the example input shown should go in place
657 of the @dots{} in the previous fragment.
659 First it is necessary to define a name for the new context:
665 Since it is similar to the @code{Voice}, we want commands that work
666 on (existing) @code{Voice}s to remain working. This is achieved by
667 giving the new context an alias @code{Voice},
673 The context will print notes and instructive texts, so we need to add
674 the engravers which provide this functionality,
677 \consists Note_heads_engraver
678 \consists Text_engraver
681 but we only need this on the center line,
684 \consists Pitch_squash_engraver
685 squashedPosition = #0
688 The @rinternals{Pitch_squash_engraver} modifies note heads (created
689 by @rinternals{Note_heads_engraver}) and sets their vertical
690 position to the value of @code{squashedPosition}, in this case@tie{}@code{0},
693 The notes look like a slash, and have no stem,
696 \override NoteHead #'style = #'slash
697 \override Stem #'transparent = ##t
700 All these plug-ins have to cooperate, and this is achieved with a
701 special plug-in, which must be marked with the keyword @code{\type}.
702 This should always be @code{Engraver_group}.
705 \type "Engraver_group"
713 \type "Engraver_group"
714 \consists "Note_heads_engraver"
715 \consists "Text_engraver"
716 \consists Pitch_squash_engraver
717 squashedPosition = #0
718 \override NoteHead #'style = #'slash
719 \override Stem #'transparent = ##t
725 Contexts form hierarchies. We want to hang the @code{ImproVoice}
726 under @code{Staff}, just like normal @code{Voice}s. Therefore, we
727 modify the @code{Staff} definition with the @code{\accepts}
738 The opposite of @code{\accepts} is @code{\denies},
739 which is sometimes needed when reusing existing context definitions.
741 Putting both into a @code{\layout} block, like
751 \accepts "ImproVoice"
756 Then the output at the start of this subsection can be entered as
764 c c_"while playing :)"
771 @node Aligning contexts
772 @subsection Aligning contexts
774 New contexts may be aligned above or below existing contexts. This
775 could be useful in setting up a vocal staff (@rlearning{Vocal ensembles}) and
778 @c TODO Better example needed. Ref LM, and expand on it.
781 @findex alignAboveContext
782 @findex alignBelowContext
784 @lilypond[quote,ragged-right]
787 \relative c' \new Staff = "main" {
790 \new Staff \with {alignAboveContext=main} \ossia
798 @node Explaining the Internals Reference
799 @section Explaining the Internals Reference
803 * Navigating the program reference::
804 * Layout interfaces::
805 * Determining the grob property::
806 * Naming conventions::
809 @node Navigating the program reference
810 @subsection Navigating the program reference
812 @c TODO remove this (it's in the LM)
813 @c Replace with more factual directions
815 Suppose we want to move the fingering indication in the fragment
818 @lilypond[quote,fragment,relative=2,verbatim]
824 If you visit the documentation on fingering instructions (in
825 @ref{Fingering instructions}), you will notice:
830 Internals Reference: @rinternals{Fingering}.
835 @c outdated info; probably will delete.
837 This fragment points to two parts of the program reference: a page
838 on @code{FingeringEvent} and one on @code{Fingering}.
840 The page on @code{FingeringEvent} describes the properties of the music
841 expression for the input @code{-2}. The page contains many links
842 forward. For example, it says
845 Accepted by: @rinternals{Fingering_engraver},
849 That link brings us to the documentation for the Engraver, the
853 This engraver creates the following layout objects: @rinternals{Fingering}.
856 In other words, once the @code{FingeringEvent}s are interpreted, the
857 @code{Fingering_engraver} plug-in will process them.
861 @c I can't figure out what this is supposed to mean. -gp
863 The @code{Fingering_engraver} is also listed to create
864 @rinternals{Fingering} objects,
866 @c old info? it doesn't make any sense to me with our current docs.
868 second bit of information listed under @b{See also} in the Notation
873 The programmer's reference is available as an HTML document. It is
874 highly recommended that you read it in HTML form, either online or
875 by downloading the HTML documentation. This section will be much more
876 difficult to understand if you are using the
880 Follow the link to @rinternals{Fingering}. At the top of the
884 Fingering objects are created by: @rinternals{Fingering_engraver} and
885 @rinternals{New_fingering_engraver}.
888 By following related links inside the program reference, we can follow the
889 flow of information within the program:
893 @item @rinternals{Fingering}:
894 @rinternals{Fingering} objects are created by:
895 @rinternals{Fingering_engraver}
897 @item @rinternals{Fingering_engraver}:
898 Music types accepted: @rinternals{fingering-event}
900 @item @rinternals{fingering-event}:
901 Music event type @code{fingering-event} is in Music expressions named
902 @rinternals{FingeringEvent}
905 This path goes against the flow of information in the program: it
906 starts from the output, and ends at the input event. You could
907 also start at an input event, and read with the flow of
908 information, eventually ending up at the output object(s).
910 The program reference can also be browsed like a normal document. It
913 @rinternals{Music definitions},
916 @code{Music definitions}
918 on @rinternals{Translation}, and the @rinternals{Backend}. Every
919 chapter lists all the definitions used and all properties that may be
923 @node Layout interfaces
924 @subsection Layout interfaces
926 @cindex interface, layout
927 @cindex layout interface
930 The HTML page that we found in the previous section describes the
931 layout object called @rinternals{Fingering}. Such an object is a
932 symbol within the score. It has properties that store numbers (like
933 thicknesses and directions), but also pointers to related objects. A
934 layout object is also called a @emph{Grob}, which is short for Graphical
935 Object. For more details about Grobs, see @rinternals{grob-interface}.
937 The page for @code{Fingering} lists the definitions for the
938 @code{Fingering} object. For example, the page says
941 @code{padding} (dimension, in staff space):
947 which means that the number will be kept at a distance of at least 0.5
951 Each layout object may have several functions as a notational or
952 typographical element. For example, the Fingering object
953 has the following aspects
957 Its size is independent of the horizontal spacing, unlike slurs or beams.
960 It is a piece of text. Granted, it is usually a very short text.
963 That piece of text is typeset with a font, unlike slurs or beams.
966 Horizontally, the center of the symbol should be aligned to the
967 center of the note head.
970 Vertically, the symbol is placed next to the note and the staff.
973 The vertical position is also coordinated with other superscript
974 and subscript symbols.
977 Each of these aspects is captured in so-called @emph{interface}s,
978 which are listed on the @rinternals{Fingering} page at the bottom
981 This object supports the following interfaces:
982 @rinternals{item-interface},
983 @rinternals{self-alignment-interface},
984 @rinternals{side-position-interface}, @rinternals{text-interface},
985 @rinternals{text-script-interface}, @rinternals{font-interface},
986 @rinternals{finger-interface}, and @rinternals{grob-interface}.
989 Clicking any of the links will take you to the page of the respective
990 object interface. Each interface has a number of properties. Some of
991 them are not user-serviceable (@q{Internal properties}), but others
994 We have been talking of @emph{the} @code{Fingering} object, but actually it
995 does not amount to much. The initialization file (see
996 @rlearning{Other sources of information})
997 @file{scm/@/define@/-grobs@/.scm} shows the soul of the @q{object},
1002 (avoid-slur . around)
1003 (slur-padding . 0.2)
1004 (staff-padding . 0.5)
1005 (self-alignment-X . 0)
1006 (self-alignment-Y . 0)
1007 (script-priority . 100)
1008 (stencil . ,ly:text-interface::print)
1009 (direction . ,ly:script-interface::calc-direction)
1010 (font-encoding . fetaNumber)
1011 (font-size . -5) ; don't overlap when next to heads.
1012 (meta . ((class . Item)
1013 (interfaces . (finger-interface
1015 text-script-interface
1017 side-position-interface
1018 self-alignment-interface
1019 item-interface))))))
1023 As you can see, the @code{Fingering} object is nothing more than a
1024 bunch of variable settings, and the webpage in the Internals Reference
1025 is directly generated from this definition.
1028 @node Determining the grob property
1029 @subsection Determining the grob property
1031 @c TODO remove this (it's in the LM)
1032 @c Replace with more factual directions
1034 Recall that we wanted to change the position of the @b{2} in
1036 @lilypond[quote,fragment,relative=2,verbatim]
1042 Since the @b{2} is vertically positioned next to its note, we have to
1043 meddle with the interface associated with this positioning. This is
1044 done using @code{side-position-interface}. The page for this interface
1048 @code{side-position-interface}
1050 Position a victim object (this one) next to other objects (the
1051 support). The property @code{direction} signifies where to put the
1052 victim object relative to the support (left or right, up or down?)
1057 Below this description, the variable @code{padding} is described as
1062 (dimension, in staff space)
1064 Add this much extra space between objects that are next to each other.
1068 By increasing the value of @code{padding}, we can move the
1069 fingering away from the note head. The following command inserts
1070 3 staff spaces of white
1071 between the note and the fingering:
1073 \once \override Voice.Fingering #'padding = #3
1076 Inserting this command before the Fingering object is created,
1077 i.e., before @code{c2}, yields the following result:
1079 @lilypond[quote,relative=2,fragment,verbatim]
1080 \once \override Voice.Fingering #'padding = #3
1087 In this case, the context for this tweak is @code{Voice}. This
1088 fact can also be deduced from the program reference, for the page for
1089 the @rinternals{Fingering_engraver} plug-in says
1092 Fingering_engraver is part of contexts: @dots{} @rinternals{Voice}
1096 @node Naming conventions
1097 @subsection Naming conventions
1099 Another thing that is needed, is an overview of the various naming
1102 scheme functions: lowercase-with-hyphens (incl. one-word
1104 scheme functions: ly:plus-scheme-style
1105 music events, music classes and music properties:
1107 Grob interfaces: scheme-style
1108 backend properties: scheme-style (but X and Y!)
1109 contexts (and MusicExpressions and grobs): Capitalized or
1111 context properties: lowercaseFollowedByCamelCase
1113 Capitalized_followed_by_lowercase_and_with_underscores
1115 Which of these are conventions and which are rules?
1116 Which are rules of the underlying language, and which are
1120 @node Modifying properties
1121 @section Modifying properties
1123 @c TODO change the menu and subsection node names to use
1124 @c backslash once the new macro to handle the refs
1125 @c is available. Need to find and change all refs at
1126 @c the same time. -td
1129 * Overview of modifying properties::
1131 * The override command::
1132 * The tweak command::
1133 * set versus override::
1137 @node Overview of modifying properties
1138 @subsection Overview of modifying properties
1140 Each context is responsible for creating certain types of graphical
1141 objects. The settings used for printing these objects are also stored by
1142 context. By changing these settings, the appearance of objects can be
1145 The syntax for this is
1148 \override @var{context}.@var{name} #'@var{property} = #@var{value}
1151 Here @var{name} is the name of a graphical object, like
1152 @code{Stem} or @code{NoteHead}, and @var{property} is an internal
1153 variable of the formatting system (@q{grob property} or @q{layout
1154 property}). The latter is a symbol, so it must be quoted. The
1155 subsection @ref{Modifying properties}, explains what to fill in
1156 for @var{name}, @var{property}, and @var{value}. Here we only
1157 discuss the functionality of this command.
1162 \override Staff.Stem #'thickness = #4.0
1166 makes stems thicker (the default is 1.3, with staff line thickness as a
1167 unit). Since the command specifies @code{Staff} as context, it only
1168 applies to the current staff. Other staves will keep their normal
1169 appearance. Here we see the command in action:
1171 @lilypond[quote,verbatim,relative=2,fragment]
1173 \override Staff.Stem #'thickness = #4.0
1179 The @code{\override} command changes the definition of the @code{Stem}
1180 within the current @code{Staff}. After the command is interpreted
1181 all stems are thickened.
1183 Analogous to @code{\set}, the @var{context} argument may be left out,
1184 causing the default context @code{Voice} to be used. Adding
1185 @code{\once} applies the change during one timestep only.
1187 @lilypond[quote,fragment,verbatim,relative=2]
1189 \once \override Stem #'thickness = #4.0
1194 The @code{\override} must be done before the object is
1195 started. Therefore, when altering @emph{Spanner} objects such as slurs
1196 or beams, the @code{\override} command must be executed at the moment
1197 when the object is created. In this example,
1199 @lilypond[quote,fragment,verbatim,relative=2]
1200 \override Slur #'thickness = #3.0
1202 \override Beam #'thickness = #0.6
1207 the slur is fatter but the beam is not. This is because the command for
1208 @code{Beam} comes after the Beam is started, so it has no effect.
1210 Analogous to @code{\unset}, the @code{\revert} command for a context
1211 undoes an @code{\override} command; like with @code{\unset}, it only
1212 affects settings that were made in the same context. In other words, the
1213 @code{\revert} in the next example does not do anything.
1216 \override Voice.Stem #'thickness = #4.0
1217 \revert Staff.Stem #'thickness
1220 Some tweakable options are called @q{subproperties} and reside inside
1221 properties. To tweak those, use commands of the form
1223 @c leave this as a long long
1225 \override @var{context}.@var{name} #'@var{property} #'@var{subproperty} = #@var{value}
1232 \override Stem #'details #'beamed-lengths = #'(4 4 3)
1238 Internals: @rinternals{OverrideProperty}, @rinternals{RevertProperty},
1239 @rinternals{PropertySet}, @rinternals{Backend}, and
1240 @rinternals{All layout objects}.
1245 The back-end is not very strict in type-checking object properties.
1246 Cyclic references in Scheme values for properties can cause hangs
1247 or crashes, or both.
1251 @node The set command
1252 @subsection The @code{\set} command
1256 @cindex changing properties
1258 Each context can have different @emph{properties}, variables contained
1259 in that context. They can be changed during the interpretation step.
1260 This is achieved by inserting the @code{\set} command in the music,
1263 \set @var{context}.@var{prop} = #@var{value}
1267 @lilypond[quote,verbatim,relative=2,fragment]
1269 \set Score.skipBars = ##t
1273 This command skips measures that have no notes. The result is that
1274 multi-rests are condensed. The value assigned is a Scheme object. In
1275 this case, it is @code{#t}, the boolean True value.
1277 If the @var{context} argument is left out, then the current bottom-most
1278 context (typically @code{ChordNames}, @code{Voice}, or
1279 @code{Lyrics}) is used. In this example,
1281 @lilypond[quote,verbatim,relative=2,fragment]
1283 \set autoBeaming = ##f
1288 the @var{context} argument to @code{\set} is left out, so automatic
1289 beaming is switched off in the current @rinternals{Voice}. Note that
1290 the bottom-most context does not always contain the property that you
1291 wish to change -- for example, attempting to set the @code{skipBars}
1292 property (of the bottom-most context, in this case @code{Voice}) will
1295 @lilypond[quote,verbatim,relative=2,fragment]
1301 Contexts are hierarchical, so if a bigger context was specified, for
1302 example @code{Staff}, then the change would also apply to all
1303 @code{Voice}s in the current stave. The change is applied
1304 @q{on-the-fly}, during the music, so that the setting only affects the
1305 second group of eighth notes.
1309 There is also an @code{\unset} command,
1311 \unset @var{context}.@var{prop}
1315 which removes the definition of @var{prop}. This command removes
1316 the definition only if it is set in @var{context}, so
1319 \set Staff.autoBeaming = ##f
1323 introduces a property setting at @code{Staff} level. The setting also
1324 applies to the current @code{Voice}. However,
1327 \unset Voice.autoBeaming
1331 does not have any effect. To cancel this setting, the @code{\unset}
1332 must be specified on the same level as the original @code{\set}. In
1333 other words, undoing the effect of @code{Staff.autoBeaming = ##f}
1336 \unset Staff.autoBeaming
1339 Like @code{\set}, the @var{context} argument does not have to be
1340 specified for a bottom context, so the two statements
1343 \set Voice.autoBeaming = ##t
1344 \set autoBeaming = ##t
1352 Settings that should only apply to a single time-step can be entered
1353 with @code{\once}, for example in
1355 @lilypond[quote,verbatim,relative=2,fragment]
1357 \once \set fontSize = #4.7
1362 the property @code{fontSize} is unset automatically after the second
1365 A full description of all available context properties is in the
1366 program reference, see
1368 @rinternals{Tunable context properties}.
1371 Translation @expansion{} Tunable context properties.
1376 @node The override command
1377 @subsection The @code{\override} command
1379 Commands which change output generally look like
1382 \override Voice.Stem #'thickness = #3.0
1386 To construct this tweak we must determine these bits of information:
1389 @item the context: here @code{Voice}.
1390 @item the layout object: here @code{Stem}.
1391 @item the layout property: here @code{thickness}.
1392 @item a sensible value: here @code{3.0}.
1395 Some tweakable options are called @q{subproperties} and reside inside
1396 properties. To tweak those, use commands in the form
1399 \override Stem #'details #'beamed-lengths = #'(4 4 3)
1402 @cindex internal documentation
1403 @cindex finding graphical objects
1404 @cindex graphical object descriptions
1407 @cindex internal documentation
1409 For many properties, regardless of the data type of the property, setting the
1410 property to false ( @code{##f} ) will result in turning it off, causing
1411 LilyPond to ignore that property entirely. This is particularly useful for
1412 turning off grob properties which may otherwise be causing problems.
1414 We demonstrate how to glean this information from the notation manual
1415 and the program reference.
1418 @node The tweak command
1419 @subsection The @code{\tweak} command
1424 In some cases, it is possible to take a short-cut for tuning
1425 graphical objects. For objects that are created directly from
1426 an item in the input file, you can use the @code{\tweak} command.
1429 @lilypond[relative=2,verbatim]
1434 \tweak #'duration-log #1
1437 -\tweak #'padding #8
1441 @cindex chord, modifying one note in
1443 But the main use of the @code{\tweak} command is to modify just
1444 one of a number of notation elements which start at the same musical
1445 moment, like the notes of a chord, or tuplet brackets which start
1448 For an introduction to the syntax and uses of the tweak command
1449 see @rlearning{Tweaking methods}.
1451 The @code{\tweak} command sets a property in the following object
1452 directly, without requiring the grob name or context to be
1453 specified. For this to work, it is necessary for the @code{\tweak}
1454 command to remain immediately adjacent to the object to which it is
1455 to apply after the input file has been converted to a music stream.
1456 This is often not the case, as many additional elements are inserted
1457 into the music stream implicitly. For example, when a note which is
1458 not part of a chord is processed, Lilypond implicitly inserts a
1459 @code{ChordEvent} event before the note, so separating the tweak
1460 from the note. However, if chord symbols are placed round the
1461 tweak and the note, the @code{\tweak} command comes after the
1462 @code{ChordEvent} in the music stream, so remaining adjacent to the
1463 note, and able to modify it.
1467 @lilypond[relative=2,verbatim,quote]
1468 <\tweak #'color #red c>4
1474 @lilypond[relative=2,verbatim,quote]
1475 \tweak #'color #red c4
1478 When several similar items are placed at the same musical moment,
1479 the @code{\override} command cannot be used to modify just one of
1480 them -- this is where the @code{\tweak} command must be used.
1481 Items which may appear more than once at the same musical moment
1482 include the following:
1484 @c TODO expand to include any further uses of \tweak
1486 @item note heads of notes inside a chord
1487 @item articulation signs on a single note
1488 @item ties between notes in a chord
1489 @item tuplet brackets starting at the same time
1492 @c TODO add examples of these
1495 and @code{\tweak} may be used to modify any single occurrence of
1498 Notably the @code{\tweak} command cannot be used to modify stems,
1499 beams or accidentals, since these are generated later by note heads,
1500 rather than by music elements in the input stream. Nor can a
1501 @code{\tweak} command be used to modify clefs or time signatures,
1502 since these become separated from any preceding @code{\tweak}
1503 command in the input stream by the automatic insertion of extra
1504 elements required to specify the context.
1506 But the @code{\tweak} command can be used as an alternative to
1507 the @code{\override} command to modify those notational elements
1508 that do not cause any additional implicit elements to be added
1509 before them in the music stream. For example, slurs may be
1510 modified in this way:
1512 @lilypond[verbatim,quote,relative=1]
1513 c-\tweak #'thickness #5 ( d e f)
1516 Also several @code{\tweak} commands may be placed before a
1517 notational element -- all affect it:
1519 @lilypond[verbatim,quote,relative=1]
1521 -\tweak #'style #'dashed-line
1522 -\tweak #'dash-fraction #0.2
1523 -\tweak #'thickness #3
1524 -\tweak #'color #red
1529 The music stream which is generated from a section of an input file,
1530 including any automatically inserted elements, may be examined,
1531 see @ref{Displaying music expressions}. This may be helpful in
1532 determining what may be modified by a @code{\tweak} command.
1537 @rlearning{Tweaking methods}.
1540 @ref{Displaying music expressions}.
1544 @cindex tweaks in a variable
1545 The @code{\tweak} command cannot be used inside a variable.
1547 @cindex tweaks in lyrics
1548 The @code{\tweak} commands cannot be used in @code{\lyricmode}.
1550 @cindex tweaking control points
1551 @cindex control points, tweaking
1553 The @code{\tweak} command cannot be used to modify the control
1554 points of just one of several ties in a chord, other than the first
1555 one encountered in the input file.
1557 @node set versus override
1558 @subsection @code{\set} vs. @code{\override}
1560 We have seen two methods of changing properties: @code{\set} and
1561 @code{\override}. There are actually two different kinds of
1564 Contexts can have properties, which are usually named in
1565 @code{studlyCaps}. They mostly control the translation from
1566 music to notation, eg. @code{localKeySignature} (for determining
1567 whether to print accidentals), @code{measurePosition} (for
1568 determining when to print a bar line). Context properties can
1569 change value over time while interpreting a piece of music;
1570 @code{measurePosition} is an obvious example of
1571 this. Context properties are modified with @code{\set}.
1573 There is a special type of context property: the element
1574 description. These properties are named in @code{StudlyCaps}
1575 (starting with capital letters). They contain the
1576 @q{default settings} for said graphical object as an
1577 association list. See @file{scm/@/define@/-grobs@/.scm}
1578 to see what kind of settings there are. Element descriptions
1579 may be modified with @code{\override}.
1581 @code{\override} is actually a shorthand;
1584 \override @var{context}.@var{name} #'@var{property} = #@var{value}
1588 is more or less equivalent to
1590 @c leave this long line -gp
1592 \set @var{context}.@var{name} #'@var{property} = #(cons (cons '@var{property} @var{value}) <previous value of @var{context})
1595 The value of @code{context} (the alist) is used to initialize
1596 the properties of individual grobs. Grobs also have
1597 properties, named in Scheme style, with
1598 @code{dashed-words}. The values of grob properties change
1599 during the formatting process: formatting basically amounts
1600 to computing properties using callback functions.
1602 @code{fontSize} is a special property: it is equivalent to
1603 entering @code{\override ... #'font-size} for all pertinent
1604 objects. Since this is a common change, the special
1605 property (modified with @code{\set}) was created.
1608 @node Useful concepts and properties
1609 @section Useful concepts and properties
1614 * Direction and placement::
1615 * Distances and measurements::
1620 @subsection Input modes
1622 The way in which the notation contained within an input file is
1623 interpreted is determined by the current input mode.
1627 This is activated with the @code{\chordmode} command, and causes
1628 input to be interpreted with the syntax of chord notation, see
1629 @ref{Chord notation}. Chords are rendered as notes on a staff.
1631 Chord mode is also activated with the @code{\chords} command.
1632 This also creates a new @code{ChordNames} context and
1633 causes the following input to be interpreted with the syntax of
1634 chord notation and rendered as chord names in the @code{ChordNames}
1635 context, see @ref{Printing chord names}.
1639 This is activated with the @code{\drummode} command, and causes
1640 input to be interpreted with the syntax of drum notation, see
1641 @ref{Basic percussion notation}.
1643 Drum mode is also activated with the @code{\drums} command.
1644 This also creates a new @code{DrumStaff} context and causes the
1645 following input to be interpreted with the syntax of drum notation
1646 and rendered as drum symbols on a drum staff, see @ref{Basic
1647 percussion notation}.
1649 @strong{Figure mode}
1651 This is activated with the @code{\figuremode} command, and causes
1652 input to be interpreted with the syntax of figured bass, see
1653 @ref{Entering figured bass}.
1655 Figure mode is also activated with the @code{\figures} command.
1656 This also creates a new @code{FiguredBass} context and causes the
1657 following input to be interpreted with the figured bass syntax
1658 and rendered as figured bass symbols in the @code{FiguredBass}
1659 context, see @ref{Introduction to figured bass}.
1661 @strong{Fret and tab modes}
1663 There are no special input modes for entering fret and tab symbols.
1665 To create tab diagrams, enter notes or chords in note mode and
1666 render them in a @code{TabStaff} context, see
1667 @ref{Default tablatures}.
1669 To create fret diagrams above a staff, you have two choices.
1670 You can either use the @code{FretBoards} context (see
1671 @ref{Automatic fret diagrams} or you can enter them as a markup
1672 above the notes using the @code{\fret-diagram} command (see
1673 @ref{Fret diagram markups}).
1675 @strong{Lyrics mode}
1677 This is activated with the @code{\lyricmode} command, and causes
1678 input to be interpreted as lyric syllables with optional durations
1679 and associated lyric modifiers, see @ref{Vocal music}.
1681 Lyric mode is also activated with the @code{\addlyrics} command.
1682 This also creates a new @code{Lyrics} context and an implicit
1683 @code{\lyricsto} command which associates the following lyrics
1684 with the preceding music.
1686 @strong{Markup mode}
1688 This is activated with the @code{\markup} command, and causes
1689 input to be interpreted with the syntax of markup, see
1690 @ref{Text markup commands}.
1692 @c silly work-around for texinfo broken-ness
1693 @c (@strong{Note...} causes a spurious cross-reference in Info)
1696 This is the default mode or it may be activated with the
1697 @code{\notemode} command. Input is interpreted as pitches,
1698 durations, markup, etc and typeset as musical notation on a staff.
1700 It is not normally necessary to specify note mode explicitly, but
1701 it may be useful to do so in certain situations, for example if you
1702 are in lyric mode, chord mode or any other mode and want to insert
1703 something that only can be done with note mode syntax.
1705 For example, to indicate dynamic markings for the verses of a
1706 choral pieces it is necessary to enter note mode to interpret
1709 @lilypond[verbatim,relative=2,quote]
1712 \notemode{\set stanza = \markup{ \dynamic f 1. } }
1716 \notemode{\set stanza = \markup{ \dynamic p 2. } }
1723 @node Direction and placement
1724 @subsection Direction and placement
1726 In typesetting music the direction and placement of many items is
1727 a matter of choice. For example, the stems of notes can
1728 be directed up or down; lyrics, dynamics, and other expressive
1729 marks may be placed above or below the staff; text may be aligned
1730 left, right or center; etc. Most of these choices may be left to
1731 be determined automatically by LilyPond, but in some cases it may
1732 be desirable to force a particular direction or placement.
1734 @strong{Default actions}
1736 By default some directions are always up or always down (e.g.
1737 dynamics or fermata), while other things can alternate between
1738 up or down based on the stem direction (like slurs or accents).
1740 @c TODO Add table showing these
1742 @strong{Context layout}
1744 Contexts are positioned in a system from top to bottom in the
1745 order in which they are encountered. Note, however, that a
1746 context will be created implicitly if a command is encountered
1747 when there is no suitable context available to contain it.
1749 @c TODO Add example ?
1751 The default order in which contexts are laid out can be changed,
1752 see @ref{Aligning contexts}
1754 @strong{Articulation direction indicators}
1756 When adding articulations to notes the direction indicator,
1757 @code{^} (meaning @qq{up}), @code{_} (meaning @qq{down}) or
1758 @code{-} (meaning @qq{use default direction}), can usually be
1759 omitted, in which case @code{-} is assumed. But a direction
1760 indicator is @strong{always} required before
1763 @item @code{\tweak} commands
1764 @item @code{\markup} commands
1765 @item @code{\tag} commands
1766 @item string markups, e.g. -"string"
1767 @item fingering instructions, e.g. @code{-1}
1768 @item articulation shortcuts, e.g. @code{-.}, @code{->}, @code{--}
1771 @strong{The direction property}
1773 The position or direction of many layout objects is controlled
1774 by the @code{direction} property.
1776 The value of the @code{direction} property may be
1777 set to @code{1}, meaning @qq{up} or @qq{above}, or to @code{-1},
1778 meaning @qq{down} or @qq{below}. The symbols @code{UP} and
1779 @code{DOWN} may be used instead of @code{1} and @code{-1}
1780 respectively. The default direction may be specified by setting
1781 @code{direction} to @code{0} or @code{CENTER}. Alternatively,
1782 in many cases predefined commands
1783 exist to specify the direction. These are all of the form
1786 @code{\xxxUp}, @code{xxxDown}, @code{xxxNeutral}
1789 where @code{xxxNeutral} means @qq{use the default direction}.
1790 See @rlearning{Within-staff objects}.
1792 In a few cases, arpeggio being the only common example, the value
1793 of the @code{direction} property specifies whether the object
1794 is to be placed to the right or left of the parent object. In
1795 this case @code{-1} or @code{LEFT} means @qq{to the left} and
1796 @code{1} or @code{RIGHT} means @qq{to the right}. @code{0}
1797 or @code{CENTER} means @qq{use the default} direction, as before.
1800 These all have side-axis set to #X
1801 AmbitusAccidental - direction has no effect
1803 StanzaNumber - not tried
1804 TrillPitchAccidental - not tried
1805 TrillPitchGroup - not tried
1810 @node Distances and measurements
1811 @subsection Distances and measurements
1813 DISCUSS after working on other sections.
1815 TODO: staff spaces. Maybe move into tweaks?
1819 @subsection Spanners
1821 Many objects of musical notation extend over several notes or even
1822 several bars. Examples are crescendi, trills, tuplet brackets, and
1823 volta repeat brackets. Such objects are called @qq{spanners}, and
1824 have special properties to control their appearance and behaviour.
1825 Some of these properties are common to all spanners; others are
1826 restricted to a sub-set of the spanners.
1828 @node Common properties
1829 @section Common properties
1832 * Controlling visibility of objects::
1834 * Rotating objects::
1835 * Aligning objects::
1838 @node Controlling visibility of objects
1839 @subsection Controlling visibility of objects
1841 @cindex objects, visibility of
1842 @cindex grobs, visibility of
1843 @cindex visibility of objects
1845 There are four main ways in which the visibility of layout objects
1846 can be controlled: their stencil can be removed, they can be made
1847 transparent, they can be colored white, or their
1848 @code{break-visibility} property can be overridden. The first
1849 three apply to all layout objects; the last to just a few -- the
1850 @emph{breakable} objects. The Learning Manual introduces these
1851 four techniques, see @rlearning{Visibility and color of objects}.
1853 There are also a few other techniques which are specific to
1854 certain layout objects. These are covered under Special
1858 * Removing the stencil::
1859 * Making objects transparent::
1860 * Painting objects white::
1861 * Using break-visibility::
1862 * Special considerations::
1866 @node Removing the stencil
1867 @unnumberedsubsubsec Removing the stencil
1869 @cindex stencil, removing
1871 Every layout object has a stencil property. By default this is set
1872 to the specific function which draws that object. If this property
1873 is overridden to @code{#f} no function will be called and the object
1874 will not be drawn. The default action can be recovered with
1877 @lilypond[quote,verbatim,relative=1]
1879 \override Score.BarLine #'stencil = ##f
1881 \revert Score.BarLine #'stencil
1885 @node Making objects transparent
1886 @unnumberedsubsubsec Making objects transparent
1888 @cindex transparent, making objects
1890 Every layout object has a transparent property which by default is
1891 set to @code{#f}. If set to @code{#t} the object still occupies
1892 space but is made invisible.
1894 @lilypond[quote,verbatim,relative=2]
1896 \once \override NoteHead #'transparent = ##t
1900 @node Painting objects white
1901 @unnumberedsubsubsec Painting objects white
1903 @cindex objects, coloring
1904 @cindex coloring objects
1906 @cindex printing order
1907 @cindex overwriting objects
1908 @cindex objects, overwriting
1909 @cindex grobs, overwriting
1911 Every layout object has a color property which by default is set
1912 to @code{black}. If this is overridden to @code{white} the object
1913 will be indistinguishable from the white background. However,
1914 if the object crosses other objects the color of the crossing
1915 points will be determined by the order in which they are drawn,
1916 and this may leave a ghostly image of the white object, as shown
1919 @lilypond[quote,verbatim,relative=2]
1920 \override Staff.Clef #'color = #white
1924 This may be avoided by changing the order of printing the objects.
1925 All layout objects have a @code{layer} property which should be set
1926 to an integer. Objects with the lowest value of @code{layer} are
1927 drawn first, then objects with progressively higher values are drawn,
1928 so objects with higher values overwrite objects with lower values.
1929 By default most objects are assigned a @code{layer} value of
1930 @code{1}, although a few objects, including @code{StaffSymbol} and
1931 @code{BarLine}, are assigned a value of @code{0}. The order of
1932 printing objects with the same value of @code{layer} is indeterminate.
1934 In the example above the white clef, with a default @code{layer}
1935 value of @code{1}, is drawn after the staff lines (default
1936 @code{layer} value @code{0}), so overwriting them. To change this,
1937 the @code{Clef} object must be given in a lower value of
1938 @code{layer}, say @code{-1}, so that it is drawn earlier:
1940 @lilypond[quote,verbatim,relative=2]
1941 \override Staff.Clef #'color = #white
1942 \override Staff.Clef #'layer = #-1
1946 @node Using break-visibility
1947 @unnumberedsubsubsec Using break-visibility
1949 @c TODO Add making other objects breakable
1951 @cindex break-visibility
1953 Most layout objects are printed only once, but some like
1954 bar lines, clefs, time signatures and key signatures, may need
1955 to be printed twice when a line break occurs -- once at the end
1956 of the line and again at the start of the next line. Such
1957 objects are called @emph{breakable}, and have a property, the
1958 @code{break-visibility} property to control their visibility
1959 at the three positions in which they may appear -- at the
1960 start of a line, within a line if they are changed, and at the
1961 end of a line if a change takes place there.
1963 For example, the time signature
1964 by default will be printed at the start of the first line, but
1965 nowhere else unless it changes, when it will be printed at the
1966 point at which the change occurs. If this change occurs at the
1967 end of a line the new time signature will be printed at the start
1968 of the next line and a cautionary time signature will be printed
1969 at the end of the previous line as well.
1971 This behaviour is controlled by the @code{break-visibility}
1972 property, which is explained in
1973 @c Leave this ref on a newline - formats incorrectly otherwise -td
1974 @rlearning{Visibility and color of objects}. This property takes
1975 a vector of three booleans which, in order, determine whether the
1976 object is printed at the end of, within the body of, or at the
1977 beginning of a line. Or to be more precise, before a line break,
1978 where there is no line break, or after a line break.
1980 Alternatively, seven of the eight combinations may be specified
1981 by pre-defined functions, defined in @file{scm/output-lib.scm},
1982 where the last three columns indicate whether the layout objects
1983 will be visible in the positions shown at the head of the columns:
1985 @multitable @columnfractions .40 .15 .1 .1 .1
1986 @c TODO check these more carefully
1987 @headitem Function @tab Vector @tab Before @tab At no @tab After
1988 @headitem form @tab form @tab break @tab break @tab break
1990 @item @code{all-invisible} @tab @code{'#(#f #f #f)} @ @ @tab no @tab no @tab no
1991 @item @code{begin-of-line-visible} @tab @code{'#(#f #f #t)} @tab no @tab no @tab yes
1992 @item @code{end-of-line-visible} @tab @code{'#(#t #f #f)} @tab yes @tab no @tab no
1993 @item @code{all-visible} @tab @code{'#(#t #t #t)} @tab yes @tab yes @tab yes
1994 @c The center-visible function is not defined
1995 @c @item @code{center-visible} @tab @code{'#(#f #t #f)} @tab no @tab yes @tab no
1996 @item @code{begin-of-line-invisible} @tab @code{'#(#t #t #f)} @tab yes @tab yes @tab no
1997 @item @code{end-of-line-invisible} @tab @code{'#(#f #t #t)} @tab no @tab yes @tab yes
1998 @item @code{center-invisible} @tab @code{'#(#t #f #t)} @tab yes @tab no @tab yes
2001 The @code{center-visible} function is not pre-defined.
2003 The default settings of @code{break-visibility} depend on the
2004 layout object. The following table shows all the layout objects
2005 of interest which are affected by @code{break-visibility} and the
2006 default setting of this property:
2008 @multitable @columnfractions .3 .3 .4
2010 @headitem Layout object @tab Usual context @tab Default setting
2012 @c omit Ambitus as it appears not to be affected by break-visibility -td
2013 @c @item @code{Ambitus} @tab as specified @tab @code{begin-of-line-visible}
2014 @item @code{BarLine} @tab @code{Score} @tab calculated
2015 @item @code{BarNumber} @tab @code{Score} @tab @code{begin-of-line-visible}
2016 @c omit the following item until it can be explained -td
2017 @c @item @code{BreakAlignGroup} @tab @code{Score} @tab calculated
2018 @item @code{BreathingSign} @tab @code{Voice} @tab @code{begin-of-line-invisible}
2019 @item @code{Clef} @tab @code{Staff} @tab @code{begin-of-line-visible}
2020 @item @code{Custos} @tab @code{Staff} @tab @code{end-of-line-visible}
2021 @item @code{DoublePercentRepeat} @tab @code{Voice} @tab @code{begin-of-line-invisible}
2022 @c omit KeyCancellation until it can be explained -td
2023 @c @item @code{KeyCancellation} @tab ?? @tab @code{begin-of-line-invisible}
2024 @item @code{KeySignature} @tab @code{Staff} @tab @code{begin-of-line-visible}
2025 @c omit LeftEdge until it can be explained -td
2026 @c @item @code{LeftEdge} @tab @code{Score} @tab @code{center-invisible}
2027 @item @code{OctavateEight} @tab @code{Staff} @tab @code{begin-of-line-visible}
2028 @item @code{RehearsalMark} @tab @code{Score} @tab @code{end-of-line-invisible}
2029 @item @code{TimeSignature} @tab @code{Staff} @tab @code{all-visible}
2033 The example below shows the use of the vector form to control the
2034 visibility of barlines:
2036 @lilypond[quote,verbatim,relative=1,ragged-right]
2039 % Remove bar line at the end of the current line
2040 \once \override Score.BarLine #'break-visibility = #'#(#f #t #t)
2046 Although all three components of the vector used to override
2047 @code{break-visibility} must be present, not all of them are
2048 effective with every layout object, and some combinations may
2049 even give errors. The following limitations apply:
2052 @item Bar lines cannot be printed at start of line.
2053 @item A bar number cannot be printed at the start of the first
2054 line unless it is set to be different from 1.
2055 @item Clef -- see below
2056 @item Double percent repeats are either all printed or all
2057 suppressed. Use begin-of line-invisible to print and
2058 all-invisible to suppress.
2059 @item Key signature -- see below
2060 @item OctavateEight -- see below
2063 @node Special considerations
2064 @unnumberedsubsubsec Special considerations
2066 @strong{@emph{Visibility following explicit changes}}
2068 @cindex key signature, visibility following explicit change
2069 @cindex explicitKeySignatureVisibility
2070 @cindex clef, visibility following explicit change
2071 @cindex explicitClefVisibility
2073 The @code{break-visibility} property controls the visibility of
2074 key signatures and changes of clef only at the start of lines,
2075 i.e. after a break. It has no effect on the visibility of the
2076 key signature or clef following an explicit key change or an
2077 explicit clef change within or at the end of a line. In the
2078 following example the key signature following the explicit change
2079 to B-flat major is still visible, even though @code{all-invisible}
2082 @lilypond[quote,verbatim,relative=1,ragged-right]
2085 % Try to remove all key signatures
2086 \override Staff.KeySignature #'break-visibility = #all-invisible
2094 The visibility of such explicit key signature and clef changes is
2095 controlled by the @code{explicitKeySignatureVisibility} and
2096 @code{explicitClefVisibility} properties. These are the equivalent
2097 of the @code{break-visibility} property and both take a vector of
2098 three booleans or the predefined functions listed above, exactly like
2099 @code{break-visibility}. Both are properties of the Staff context,
2100 not the layout objects themselves, and so they are set using the
2101 @code{\set} command. Both are set by default to @code{all-visible}.
2102 These properties control only the visibility of key signatures and
2103 clefs resulting from explicit changes and do not affect key
2104 signatures and clefs at the beginning of lines;
2105 @code{break-visibility} must still be overridden in the appropriate
2106 object to remove these.
2108 @lilypond[quote,verbatim,relative=1,ragged-right]
2111 \set Staff.explicitKeySignatureVisibility = #all-invisible
2112 \override Staff.KeySignature #'break-visibility = #all-invisible
2119 @strong{@emph{Visibility of cautionary accidentals}}
2121 To remove the cautionary accidentals printed at an explicit key
2122 change, set the Staff context property @code{printKeyCancellation}
2125 @lilypond[quote,verbatim,relative=1,ragged-right]
2128 \set Staff.explicitKeySignatureVisibility = #all-invisible
2129 \set Staff.printKeyCancellation = ##f
2130 \override Staff.KeySignature #'break-visibility = #all-invisible
2137 With these overrides only the accidentals before the notes remain
2138 to indicate the change of key.
2140 @c TODO Add visibility of cautionary accidentals before notes
2142 @strong{@emph{Automatic bars}}
2144 @cindex automaticBars
2145 @cindex bar lines, suppressing
2147 As a special case, the printing of bar lines can also be turned off
2148 by setting the @code{automaticBars} property in the Score context.
2149 If set to @code{#f}, bar lines will not be printed automatically;
2150 they must be explicitly created with a @code{\bar} command. Unlike
2151 the @code{\cadenzaOn} predefined command, measures are still counted.
2152 Bar generation will resume according to that count if this property
2153 is later set to @code{#t}. When set to @code{#f}, line breaks can
2154 occur only at explicit @code{\bar} commands.
2158 @strong{@emph{Octavated clefs}}
2160 @cindex octavated clefs, visibility of
2161 @cindex visibility of octavated clefs
2162 @cindex clefs, visibility of octavation
2164 The small octavation symbol on octavated clefs is produced by the
2165 @code{OctavateEight} layout object. Its visibility is controlled
2166 independently from that of the @code{Clef} object, so it is
2167 necessary to apply any required @code{break-visibility} overrides
2168 to both the @code{Clef} and the @code{OctavateEight} layout objects
2169 to fully suppress such clef symbols at the start of each line.
2171 For explicit clef changes, the @code{explicitClefVisibility}
2172 property controls both the clef symbol and any octavation symbol
2178 @rlearning{Visibility and color of objects}
2182 @subsection Line styles
2184 @c TODO: split the following explanations between expressive marks and
2185 @c text-related stuff. Perhaps create a new subsection named
2186 @c "Spanner limits", "Spanner boundaries"? -vv
2188 Some performance indications, e.g., @i{rallentando} and
2189 @i{accelerando} and @i{trills} are written as text and are
2190 extended over many measures with lines, sometimes dotted or wavy.
2192 These all use the same routines as the glissando for drawing the
2193 texts and the lines, and tuning their behavior is therefore also
2194 done in the same way. It is done with a spanner, and the routine
2195 responsible for drawing the spanners is
2196 @code{ly:line-interface::print}. This routine determines the
2197 exact location of the two @i{span points} and draws a line in
2198 between, in the style requested.
2200 Here is an example of the different line styles available, and how
2203 @lilypond[relative=2,ragged-right,verbatim,fragment]
2205 \once \override Glissando #'style = #'dashed-line
2207 \override Glissando #'style = #'dotted-line
2209 \override Glissando #'style = #'zigzag
2211 \override Glissando #'style = #'trill
2215 The information that determines the end-points is computed
2216 on-the-fly for every graphic object, but it is possible to
2219 @lilypond[relative=2,ragged-right,verbatim,fragment]
2221 \once \override Glissando #'bound-details #'right #'Y = #-2
2225 The @code{Glissando} object, like any other using the
2226 @code{ly:line-interface::print} routine, carries a nested
2227 association list. In the above statement, the value for @code{Y}
2228 is set to @code{-2} for the association list corresponding to the
2229 right end point. Of course, it is also possible to adjust the
2230 left side with @code{left} instead of @code{right}.
2232 If @code{Y} is not set, the value is computed from the vertical
2233 position of right attachment point of the spanner.
2235 In case of a line break, the values for the span-points are
2236 extended with contents of the @code{left-broken} and
2237 @code{right-broken} sublists, for example
2239 @lilypond[relative=2,ragged-right,verbatim,fragment]
2240 \override Glissando #'breakable = ##T
2241 \override Glissando #'bound-details #'right-broken #'Y = #-3
2242 c1 \glissando \break
2246 The following properties can be used for the
2250 This sets the Y-coordinate of the end point, in staff space. By
2251 default, it is the center of the bound object, so for a glissando
2252 it points to the vertical center of the note head.
2254 For horizontal spanners, such as text spanner and trill spanners,
2255 it is hardcoded to 0.
2258 This determines where the line starts and ends in X-direction,
2259 relative to the bound object. So, a value of @code{-1} (or
2260 @code{LEFT}) makes the line start/end at the left side of the note
2261 head it is attached to.
2264 This is the absolute coordinate of the end point. It is usually
2265 computed on the fly, and there is little use in overriding it.
2268 Line spanners may have symbols at the beginning or end, which is
2269 contained in this sub-property. This is for internal use, it is
2270 recommended to use @code{text}.
2273 This is a markup that is evaluated to yield stencil. It is used
2274 to put @i{cresc.} and @i{tr} on horizontal spanners.
2276 @lilypond[quote,ragged-right,fragment,relative=2,verbatim]
2277 \override TextSpanner #'bound-details #'left #'text
2278 = \markup { \small \bold Slower }
2279 c2\startTextSpan b c a\stopTextSpan
2282 @item stencil-align-dir-y
2283 @item stencil-offset
2284 Without setting this, the stencil is simply put there at the
2285 end-point, as defined by the @code{X} and @code{Y} sub properties.
2286 Setting either @code{stencil-align-dir-y} or @code{stencil-offset}
2287 will move the symbol at the edge relative to the end point of the
2290 @lilypond[relative=1,fragment,verbatim]
2291 \override TextSpanner #'bound-details
2292 #'left #'stencil-align-dir-y = #DOWN
2293 \override TextSpanner #'bound-details
2294 #'right #'stencil-align-dir-y = #UP
2296 \override TextSpanner #'bound-details
2297 #'left #'text = #"gggg"
2298 \override TextSpanner #'bound-details
2299 #'right #'text = #"hhhh"
2300 c4^\startTextSpan c c c \stopTextSpan
2304 Setting this sub property to @code{#t} produce an arrowhead at the
2308 This sub property controls the space between the specified
2309 end-point of the line and the actual end. Without padding, a
2310 glissando would start and end in the center of each note head.
2314 @c TODO: Move to 5.4.4
2316 The music function \endSpanners terminates spanners and hairpins
2317 after exactly one note.
2319 @lilypond[verbatim,quote,ragged-right,relative=2,fragment]
2321 c2 \startTextSpan c2
2325 When using \endSpanners it is not necessary to close
2326 \startTextSpan with \stopTextSpan, nor is it necessary to close
2333 Internals Reference: @rinternals{TextSpanner},
2334 @rinternals{Glissando}, @rinternals{VoiceFollower},
2335 @rinternals{TrillSpanner},
2336 @rinternals{line-spanner-interface}.
2339 @node Rotating objects
2340 @subsection Rotating objects
2342 Both layout objects and elements of markup text can be rotated by
2343 any angle about any point, but the method of doing so differs.
2346 * Rotating layout objects::
2350 @node Rotating layout objects
2351 @unnumberedsubsubsec Rotating layout objects
2353 @cindex rotating objects
2354 @cindex objects, rotating
2356 All layout objects which support the @code{grob-interface} can be
2357 rotated by setting their @code{rotation} property. This takes a
2358 list of three items: the angle of rotation counter-clockwise,
2359 and the x and y coordinates of the point relative to the object's
2360 reference point about which the rotation is to be performed. The
2361 angle of rotation is specified in degrees and the coordinates in
2364 The angle of rotation and the coordinates of the rotation point must
2365 be determined by trial and error.
2367 @cindex hairpins, angled
2368 @cindex angled hairpins
2370 There are only a few situations where the rotation of layout
2371 objects is useful; the following example shows one situation where
2374 @lilypond[quote,verbatim,relative=1]
2376 \override Hairpin #'rotation = #'(20 -1 0)
2380 @node Rotating markup
2381 @unnumberedsubsubsec Rotating markup
2383 All markup text can be rotated to lie at any angle by prefixing it
2384 with the @code{\rotate} command. The command takes two arguments:
2385 the angle of rotation in degrees counter-clockwise and the text to
2386 be rotated. The extents of the text are not rotated: they take
2387 their values from the extremes of the x and y coordinates of the
2388 rotated text. In the following example the
2389 @code{outside-staff-priority} property for text is set to @code{#f}
2390 to disable the automatic collision avoidance, which would push some
2391 of the text too high.
2393 @lilypond[quote,verbatim,relative=1]
2394 \override TextScript #'outside-staff-priority = ##f
2395 g4^\markup { \rotate #30 "a G" }
2396 b^\markup { \rotate #30 "a B" }
2397 des^\markup { \rotate #30 "a D-Flat" }
2398 fis^\markup { \rotate #30 "an F-Sharp" }
2402 @node Aligning objects
2403 @subsection Aligning objects
2405 Graphical objects which support the @code{self-alignment-interface} and/or
2406 the @code{side-position-interface} can be
2407 aligned to a previously placed object in a variety of ways. For a list of these objects, see
2408 @rinternals{self-alignment-interface} and @rinternals{side-position-interface}.
2410 All graphical objects have a reference point, a horizontal extent and a
2411 vertical extent. The horizontal extent is a pair of numbers
2412 giving the displacements from the reference point of the left and
2413 right edges, displacements to the left being negative. The
2414 vertical extent is a pair of numbers giving the displacement from
2415 the reference point to the bottom and top edges, displacements down
2418 An object's position on a staff is given by the values of the
2419 @code{X-offset} and @code{Y-offset} properties. The value of
2420 @code{X-offset} gives the displacement from the x coordinate of
2421 the reference point of the parent object, and the value of
2422 @code{Y-offset} gives the displacement from the center line of the
2423 staff. The values of @code{X-offset} and
2424 @code{Y-offset} may be set directly or may be set to be calculated
2425 by procedures in order to achieve alignment with the parent object
2428 @warning{Many objects have special positioning considerations which
2429 cause any setting of @code{X-offset} or @code{Y-offset} to be
2430 ignored or modified, even though the object supports the
2431 @code{self-alignment-interface}.}
2433 For example, an accidental can be repositioned
2434 vertically by setting @code{Y-offset} but any changes to
2435 @code{X-offset} have no effect.
2437 Rehearsal marks may be aligned with
2438 breakable objects such as bar lines, clef symbols, time signature
2439 symbols and key signatures. There are special properties to be
2440 found in the @code{break-aligned-interface} for positioning rehearsal
2441 marks on such objects.
2444 * Setting @code{X-offset} and @code{Y-offset} directly::
2445 * Using the @code{side-position-interface}::
2446 * Using the @code{self-alignment-interface}::
2447 * Using the @code{break-aligned-interface}::
2450 @node Setting @code{X-offset} and @code{Y-offset} directly
2451 @unnumberedsubsubsec Setting @code{X-offset} and @code{Y-offset} directly
2453 Numerical values may be given to the @code{X-offset} and @code{Y-offset}
2454 properties of many objects. The following example shows three
2455 notes with the default fingering position and the positions with @code{X-offset}
2456 and @code{Y-offset} modified.
2458 @lilypond[verbatim,quote,relative=2]
2461 -\tweak #'X-offset #0
2462 -\tweak #'Y-offset #0
2465 -\tweak #'X-offset #-1
2466 -\tweak #'Y-offset #1
2472 @node Using the @code{side-position-interface}
2473 @unnumberedsubsubsec Using the @code{side-position-interface}
2475 An object which supports the @code{side-position-interface} can be
2476 placed next to its parent object so that
2477 the specified edges of the two objects touch. The object may be
2478 placed above, below, to the right or to the left of the parent.
2479 The parent cannot be specified; it is determined by the order of
2480 elements in the input stream. Most objects have the associated
2481 note head as their parent.
2483 The values of the @code{side-axis} and @code{direction} properties
2484 determine where the object is to be placed, as follows:
2486 @c TODO add an example of each to the table
2488 @multitable @columnfractions .3 .3 .3
2489 @headitem @code{side-axis} @tab @code{direction} @tab
2490 @headitem property @tab property @tab Placement
2492 @item @code{0} @tab @code{-1} @tab left
2493 @item @code{0} @tab @code{1} @tab right
2494 @item @code{1} @tab @code{-1} @tab below
2495 @item @code{1} @tab @code{1} @tab above
2499 When @code{side-axis} is @code{0}, @code{X-offset} should be set to
2500 the procedure @code{ly:side-position-interface::x-aligned-side}.
2501 This procedure will return the correct value of @code{X-offset} to
2502 place the object to the left or right side of the parent according
2503 to value of @code{direction}.
2505 When @code{side-axis} is @code{1}, @code{Y-offset} should be set to
2506 the procedure @code{ly:side-position-interface::y-aligned-side}.
2507 This procedure will return the correct value of @code{Y-offset} to
2508 place the object to the top or bottom of the parent according
2509 to value of @code{direction}.
2511 @c TODO Add examples
2513 @node Using the @code{self-alignment-interface}
2514 @unnumberedsubsubsec Using the @code{self-alignment-interface}
2516 @emph{Self-aligning objects horizontally}
2518 The horizontal alignment of an object which supports the
2519 @code{self-alignment-interface} is controlled by the value of
2520 the @code{self-alignment-X} property, provided the object's
2521 @code{X-offset} property is set to
2522 @code{ly:self-alignment-interface::x-aligned-on-self}.
2523 @code{self-alignment-X} may be given any
2524 real value, in units of half the total X extent of the
2525 object. Negative values move the object to the right, positive
2526 to the left. A value of @code{0} centers the object on the
2527 reference point of its parent, a value of @code{-1} aligns the
2528 left edge of the object on the reference point of its parent,
2529 and a value of @code{1} aligns the right edge of the object on the
2530 reference point of its parent. The symbols @code{LEFT},
2531 @code{CENTER} and @code{RIGHT} may be used instead of the values
2532 @code{-1, 0, 1} respectively.
2534 Normally the @code{\override} command would be used to modify the
2535 value of @code{self-alignment-X}, but the @code{\tweak} command
2536 can be used to separately align several annotations on a single
2539 @lilypond[quote,verbatim,relative=1]
2541 -\tweak #'self-alignment-X #-1
2543 -\tweak #'self-alignment-X #0
2545 -\tweak #'self-alignment-X #RIGHT
2547 -\tweak #'self-alignment-X #-2.5
2548 ^"aligned further to the right"
2551 @emph{Self-aligning objects vertically}
2553 Objects may be aligned vertically in an analogous way to aligning
2554 them horizontally if the @code{Y-offset} property is set to
2555 @code{ly:self-alignment-interface::y-aligned-on-self}. However,
2556 other mechanisms are often involved in vertical alignment: the
2557 value of @code{Y-offset} is just one variable taken into account.
2558 This may make adjusting the value of some objects tricky.
2559 The units are just half the vertical extent of the object, which
2560 is usually quite small, so quite large numbers may be required.
2561 A value of @code{-1} aligns the lower edge of the object with
2562 the reference point of the parent object, a value of @code{0}
2563 aligns the center of the object with the reference point of the
2564 parent, and a value of @code{1} aligns the top edge of the object
2565 with the reference point of the parent. The symbols @code{DOWN},
2566 @code{CENTER}, @code{UP} may be substituted for @code{-1, 0, 1}
2569 @emph{Self-aligning objects in both directions}
2571 By setting both @code{X-offset} and @code{Y-offset}, an object may
2572 be aligned in both directions simultaneously.
2574 The following example shows how to adjust a fingering mark so
2575 that it nestles close to the note head.
2577 @lilypond[quote,verbatim,relative=2]
2579 -\tweak #'self-alignment-X #0.5 % move horizontally left
2580 -\tweak #'Y-offset #ly:self-alignment-interface::y-aligned-on-self
2581 -\tweak #'self-alignment-Y #-1 % move vertically up
2586 @unnumberedsubsubsec Using the @code{aligned-on-parent} procedures
2588 @c Cannot document as they do not seem to operate consistently on all objects -td
2589 @c TODO investigate further
2591 The @code{aligned-on-parent} procedures are used in the same way
2592 as the @code{aligned-on-self} procedures, they difference being
2593 that they permit an object to be aligned with the @emph{edges} of
2594 the parent rather than the parent's reference point. The following
2595 example shows the difference:
2599 @lilypond[verbatim,quote]
2605 @unnumberedsubsubsec Using the @code{centered-on-parent} procedures
2607 @c Cannot document as they do not seem to operate consistently on all objects -td
2608 @c TODO investigate further
2612 @c TODO The align-interface, BassFigureAlignment and VerticalAlignment
2614 @node Using the @code{break-aligned-interface}
2615 @unnumberedsubsubsec Using the @code{break-aligned-interface}
2617 Rehearsal marks may be aligned with notation objects other
2618 than bar lines. These objects include @code{ambitus},
2619 @code{breathing-sign}, @code{clef}, @code{custos}, @code{staff-bar},
2620 @code{left-edge}, @code{key-cancellation}, @code{key-signature}, and
2621 @code{time-signature}.
2623 By default, rehearsal marks will be horizontally centered above the
2626 @lilypond[verbatim,quote,relative=1]
2628 % the RehearsalMark will be centered above the Clef
2629 \override Score.RehearsalMark #'break-align-symbols = #'(clef)
2634 % the RehearsalMark will be centered above the TimeSignature
2635 \override Score.RehearsalMark #'break-align-symbols = #'(time-signature)
2643 The alignment of the rehearsal mark relative to the notation object
2644 can be changed, as shown in the following example. In a score with
2645 multiple staves, this setting should be done for all the staves.
2647 @lilypond[verbatim,quote,relative=1]
2648 % The RehearsalMark will be centered above the KeySignature
2649 \override Score.RehearsalMark #'break-align-symbols = #'(key-signature)
2655 % The RehearsalMark will be aligned with the left edge of the KeySignature
2656 \once \override Score.KeySignature #'break-align-anchor-alignment = #LEFT
2660 % The RehearsalMark will be aligned with the right edge of the KeySignature
2661 \once \override Score.KeySignature #'break-align-anchor-alignment = #RIGHT
2667 The rehearsal mark can also be offset to the right or left of the left edge
2668 by an arbitrary amount. The units are staff-spaces:
2670 @lilypond[verbatim,quote,relative=1]
2671 % The RehearsalMark will be aligned with the left edge of the KeySignature
2672 % and then shifted right by 3.5 staff-spaces
2673 \override Score.RehearsalMark #'break-align-symbols = #'(key-signature)
2674 \once \override Score.KeySignature #'break-align-anchor = #3.5
2678 % The RehearsalMark will be aligned with the left edge of the KeySignature
2679 % and then shifted left by 2 staff-spaces
2680 \once \override Score.KeySignature #'break-align-anchor = #-2
2686 @node Advanced tweaks
2687 @section Advanced tweaks
2690 * Vertical grouping of grobs::
2691 * Modifying ends of spanners::
2692 * Modifying stencils::
2693 * Modifying shapes::
2699 @node Vertical grouping of grobs
2700 @subsection Vertical grouping of grobs
2702 @c FIXME Expand this section
2704 The VerticalAlignment and VerticalAxisGroup grobs work together.
2705 VerticalAxisGroup groups together different grobs like Staff, Lyrics,
2706 etc. VerticalAlignment then vertically aligns the different grobs
2707 grouped together by VerticalAxisGroup. There is usually only one
2708 VerticalAlignment per score but every Staff, Lyrics, etc. has its own
2712 @node Modifying ends of spanners
2713 @subsection Modifying ends of spanners
2715 @c FIXME Write this section
2716 @c See earlier material in Line styles
2718 @node Modifying stencils
2719 @subsection Modifying stencils
2721 All layout objects have a @code{stencil} property which is part of
2722 the @code{grob-interface}. By default, this property is usually
2723 set to a function specific to the object that is tailor-made to
2724 render the symbol which represents it in the output. For example,
2725 the standard setting for the @code{stencil} property of the
2726 @code{MultiMeasureRest} object is @code{ly:multi-measure-rest::print}.
2728 The standard symbol for any object can be replaced by modifying the
2729 @code{stencil} property to reference a different, specially-written,
2730 procedure. This requires a high level of knowledge of the internal
2731 workings of LilyPond, but there is an easier way which can often
2732 produce adequate results.
2734 This is to set the @code{stencil} property to the procedure which
2735 prints text -- @code{ly:text-interface::print} -- and to add a
2736 @code{text} property to the object which is set to contain the
2737 markup text which produces the required symbol. Due to the
2738 flexibility of markup, much can be achieved -- see in particular
2739 @ref{Graphic notation inside markup}.
2741 The following example demonstrates this by changing the note head
2742 symbol to a cross within a circle.
2744 @lilypond[verbatim,quote]
2746 \once \override NoteHead #'stencil = #ly:text-interface::print
2747 \once \override NoteHead #'text = \markup {
2749 \halign #-0.7 \draw-circle #0.85 #0.2 ##f
2750 \musicglyph #"noteheads.s2cross"
2758 Any of the glyphs in the feta Font can be supplied to the
2759 @code{\musicglyph} markup command -- see @ref{The Feta font}.
2761 @c TODO Add inserting eps files or ref to later
2763 @c TODO Add inserting Postscript or ref to later
2768 @ref{Graphic notation inside markup},
2769 @ref{Formatting text},
2770 @ref{Text markup commands},
2771 @ref{The Feta font}.
2774 @node Modifying shapes
2775 @subsection Modifying shapes
2778 * Modifying ties and slurs::
2781 @node Modifying ties and slurs
2782 @unnumberedsubsubsec Modifying ties and slurs
2784 Ties, slurs and phrasing slurs are drawn as third-order Bézier
2785 curves. If the shape of the tie or slur which is calculated
2786 automatically is not optimum, the shape may be modified manually by
2787 explicitly specifying the four control points required to define
2788 a third-order Bézier curve.
2790 Third-order or cubic Bézier curves are defined by four control
2791 points. The first and fourth control points are precisely the
2792 starting and ending points of the curve. The intermediate two
2793 control points define the shape. Animations showing how the curve
2794 is drawn can be found on the web, but the following description
2795 may be helpful. The curve starts from the first control point
2796 heading directly towards the second, gradually bending over to
2797 head towards the third and continuing to bend over to head towards
2798 the fourth, arriving there travelling directly from the third
2799 control point. The curve is entirely contained in the
2800 quadrilateral defined by the four control points.
2802 Here is an example of a case where the tie is not optimum, and
2803 where @code{\tieDown} would not help.
2805 @lilypond[verbatim,quote,relative=1]
2809 { r4 <g c,> <g c,> <g c,> }
2813 One way of improving this tie is to manually modify its control
2816 The coordinates of the Bézier control points are specified in units
2817 of staff-spaces. The X@tie{}coordinate is relative to the reference
2818 point of the note to which the tie or slur is attached, and the
2819 Y@tie{}coordinate is relative to the staff center line. The
2820 coordinates are entered as a list of four pairs of decimal numbers
2821 (reals). One approach is to estimate the coordinates of the two
2822 end points, and then guess the two intermediate points. The optimum
2823 values are then found by trial and error.
2825 It is useful to remember that a symmetric curve requires symmetric
2826 control points, and that Bézier curves have the useful property that
2827 transformations of the curve such as translation, rotation and
2828 scaling can be achieved by applying the same transformation to the
2829 curve's control points.
2831 For the example above the following override gives a satisfactory
2834 @lilypond[verbatim,quote,relative=1]
2837 #'control-points = #'((1 . -1) (3 . 0.6) (12.5 . 0.6) (14.5 . -1))
2840 { r4 <g c,> <g c,> <g c,>4 }
2846 It is not possible to modify shapes of ties or slurs by changing
2847 the @code{control-points} property if there are more than one at
2848 the same musical moment, not even by using the @code{\tweak}
2853 @node Discussion of specific tweaks
2854 @section Discussion of specific tweaks
2857 * old Contexts explained::
2861 @node old Contexts explained
2862 @subsection old Contexts explained
2864 @c FIXME Delete this section? It is in LM
2865 @c Or leave heading and go on from LM?
2867 When music is printed, a lot of notational elements must be added to the
2868 output. For example, compare the input and output of the following example:
2870 @lilypond[quote,verbatim,relative=2,fragment]
2874 The input is rather sparse, but in the output, bar lines, accidentals,
2875 clef, and time signature are added. LilyPond @emph{interprets} the
2876 input. During this step, the musical information is inspected in time
2877 order, similar to reading a score from left to right. While reading
2878 the input, the program remembers where measure boundaries are, and which
2879 pitches require explicit accidentals. This information can be presented on
2880 several levels. For example, the effect of an accidental is limited
2881 to a single staff, while a bar line must be synchronized across the
2884 Within LilyPond, these rules and bits of information are grouped in
2885 @emph{Contexts}. Some examples of contexts are @code{Voice},
2886 @code{Staff}, and @code{Score}. They are hierarchical, for
2887 example: a @code{Staff} can contain many @code{Voice}s, and a
2888 @code{Score} can contain many @code{Staff} contexts.
2891 @sourceimage{context-example,5cm,,}
2894 Each context has the responsibility for enforcing some notation rules,
2895 creating some notation objects and maintaining the associated
2896 properties. For example, the @code{Voice} context may introduce an
2897 accidental and then the @code{Staff} context maintains the rule to
2898 show or suppress the accidental for the remainder of the measure. The
2899 synchronization of bar lines is handled at @code{Score} context.
2901 However, in some music we may not want the bar lines to be
2902 synchronized -- consider a polymetric score in 4/4 and 3/4 time. In
2903 such cases, we must modify the default settings of the @code{Score}
2904 and @code{Staff} contexts.
2906 For very simple scores, contexts are created implicitly, and you need
2907 not be aware of them. For larger pieces, such as anything with more
2908 than one staff, they must be
2909 created explicitly to make sure that you get as many staves as you
2910 need, and that they are in the correct order. For typesetting pieces
2911 with specialized notation, it can be useful to modify existing or
2912 to define new contexts.
2915 A complete description of all available contexts is in the program
2918 @rinternals{Contexts}.
2921 Translation @expansion{} Context.
2924 @c [TODO: describe propagation]