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.
10 @c A menu is needed before every deeper *section nesting of @node's; run
11 @c M-x texinfo-all-menus-update
12 @c to automatically fill in these menus before saving changes
15 @chapter Spacing issues
17 The global paper layout is determined by three factors: the page layout, the
18 line breaks, and the spacing. These all influence each other. The
19 choice of spacing determines how densely each system of music is set.
20 This influences where line breaks are chosen, and thus ultimately, how
21 many pages a piece of music takes.
23 Globally speaking, this procedure happens in four steps: first,
24 flexible distances (@q{springs}) are chosen, based on durations. All
25 possible line breaking combinations are tried, and a @q{badness} score
26 is calculated for each. Then the height of each possible system is
27 estimated. Finally, a page breaking and line breaking combination is chosen
28 so that neither the horizontal nor the vertical spacing is too cramped
34 * Displaying spacing::
37 * Horizontal spacing::
42 @section Paper and pages
44 This section deals with the boundaries that define the area
45 that music can be printed inside.
54 @subsection Paper size
60 To change the paper size, there are two commands,
62 #(set-default-paper-size "a4")
64 #(set-paper-size "a4")
68 The first command sets the size of all pages. The second command sets the
70 of the pages that the @code{\paper} block applies to -- if the @code{\paper}
71 block is at the top of the file, then it will apply to all pages. If the
72 @code{\paper} block is inside a @code{\book}, then the paper size will only
75 Support for the following paper sizes are included by default,
76 @code{a6}, @code{a5}, @code{a4}, @code{a3}, @code{legal}, @code{letter},
77 @code{11x17} (also known as tabloid).
79 Extra sizes may be added by editing the definition for
80 @code{paper-alist} in the initialization file @file{scm/paper.scm}.
85 If the symbol @code{landscape} is supplied as an argument to
86 @code{set-default-paper-size}, the pages will be rotated by 90 degrees,
87 and wider line widths will be set correspondingly.
90 #(set-default-paper-size "a6" 'landscape)
93 Setting the paper size will adjust a number of @code{\paper} variables
94 (such as margins). To use a particular paper size with altered
95 @code{\paper} variables, set the paper size before setting the variables.
99 @subsection Page formatting
101 @cindex page formatting
106 LilyPond will do page layout, set margins, and add headers and
107 footers to each page.
109 The default layout responds to the following settings in the
116 @funindex first-page-number
117 @item first-page-number
118 The value of the page number of the first page. Default is@tie{}1.
120 @funindex print-first-page-number
121 @item print-first-page-number
122 If set to true, will print the page number in the first page. Default is
125 @funindex print-page-number
126 @item print-page-number
127 If set to false, page numbers will not be printed. Default is true.
129 @funindex paper-width
131 The width of the page. The default is taken from the current paper size,
132 see @ref{Paper size}.
134 @funindex paper-height
136 The height of the page. The default is taken from the current paper size,
137 see @ref{Paper size}.
141 Margin between header and top of the page. Default is@tie{}5mm.
143 @funindex bottom-margin
145 Margin between footer and bottom of the page. Default is@tie{}6mm.
147 @funindex left-margin
149 Margin between the left side of the page and the beginning of the
150 music. Unset by default, which means that the margins is determined
151 based on the @code{paper-width} and @code{line-width} to center the
156 The length of the systems. Default is @code{paper-width} minus @tie{}20mm.
158 @funindex head-separation
159 @item head-separation
160 Distance between the top-most music system and the page header. Default
163 @funindex foot-separation
164 @item foot-separation
165 Distance between the bottom-most music system and the page
166 footer. Default is@tie{}4mm.
168 @funindex page-top-space
170 Distance from the top of the printable area to the center of the first
171 staff. This only works for staves which are vertically small. Big staves
172 are set with the top of their bounding box aligned to the top of the
173 printable area. Default is@tie{}12mm.
175 @funindex ragged-bottom
177 If set to true, systems will not be spread vertically across the page. This
178 does not affect the last page. Default is false.
180 This should be set to true for pieces that have only two or three
181 systems per page, for example orchestral scores.
183 @funindex ragged-last-bottom
184 @item ragged-last-bottom
185 If set to false, systems will be spread vertically to fill the last
186 page. Default is true.
188 Pieces that amply fill two pages or more should have this set to
191 @funindex system-count
193 This variable, if set, specifies into how many lines a score should be
194 broken. Unset by default.
196 @funindex between-system-space
197 @item between-system-space
198 This dimensions determines the distance between systems. It is the
199 ideal distance between the center of the bottom staff of one system
200 and the center of the top staff of the next system. Default is@tie{}20mm.
202 Increasing this will provide a more even appearance of the page at the
203 cost of using more vertical space.
205 @funindex between-system-padding
206 @item between-system-padding
207 This dimension is the minimum amount of white space that will always
208 be present between the bottom-most symbol of one system, and the
209 top-most of the next system. Default is@tie{}4mm.
211 Increasing this will put systems whose bounding boxes almost touch
214 @funindex page-breaking-between-system-padding
215 @item page-breaking-between-system-padding
216 This variable tricks the page breaker into thinking that
217 @code{between-system-padding} is set to something different than it
218 really is. For example, if this variable is set to something substantially
219 larger than @code{between-system-padding}, then the page-breaker will put
220 fewer systems on each page.
222 @funindex horizontal-shift
223 @item horizontal-shift
224 All systems (including titles and system separators) are shifted by
225 this amount to the right. Page markup, such as headers and footers are
226 not affected by this. The purpose of this variable is to make space
227 for instrument names at the left. Default is@tie{}0.
229 @funindex after-title-space
230 @item after-title-space
231 Amount of space between the title and the first system. Default is@tie{}5mm.
233 @funindex before-title-space
234 @item before-title-space
235 Amount of space between the last system of the previous piece and the
236 title of the next. Default is@tie{}10mm.
238 @funindex between-title-space
239 @item between-title-space
240 Amount of space between consecutive titles (e.g., the title of the
241 book and the title of a piece). Default is@tie{}2mm.
243 @funindex printallheaders
244 @item printallheaders
245 Setting this to #t will print all headers for each \score in the
246 output. Normally only the piece and opus \headers are printed.
248 @funindex systemSeparatorMarkup
249 @item systemSeparatorMarkup
250 This contains a markup object, which will be inserted between
251 systems. This is often used for orchestral scores. Unset by default.
253 The markup command @code{\slashSeparator} is provided as a sensible
256 @lilypond[ragged-right]
257 #(set-default-paper-size "a6" 'landscape)
260 \relative { c1 \break c1 }
263 systemSeparatorMarkup = \slashSeparator
268 @funindex blank-page-force
269 @item blank-page-force
270 The penalty for having a blank page in the middle of a
271 score. This is not used by @code{ly:optimal-breaking} since it will
272 never consider blank pages in the middle of a score. Default value
275 @funindex blank-last-page-force
276 @item blank-last-page-force
277 The penalty for ending the score on an odd-numbered page.
280 @funindex page-spacing-weight
281 @item page-spacing-weight
282 The relative importance of page (vertical) spacing and line (horizontal)
283 spacing. High values will make page spacing more important. Default
286 @funindex auto-first-page-number
287 @item auto-first-page-number
288 The page breaking algorithm is affected by the first page number being
289 odd or even. If this variable is set to #t, the page breaking algorithm
290 will decide whether to start with an odd or even number. This will
291 result in the first page number remaining as is or being increased by one.
299 The header and footer are created by the functions make-footer and
300 make-header, defined in \paper. The default implementations are in
301 ly/paper-defaults.ly and ly/titling-init.ly.
303 The page layout itself is done by two functions in the \paper block,
304 page-music-height and page-make-stencil. The former tells the
305 line-breaking algorithm how much space can be spent on a page, the
306 latter creates the actual page given the system to put on it.
308 You can define paper block values in Scheme. In that case mm, in, pt,
309 and cm are variables defined in paper-defaults.ly with values in
310 millimeters. That is why the value 2 cm must be multiplied in the
315 #(define bottom-margin (* 2 cm))
327 ragged-last-bottom = ##t
331 This second example centers page numbers at the bottom of every page.
335 print-page-number = ##t
336 print-first-page-number = ##t
337 oddHeaderMarkup = \markup \fill-line @{ " " @}
338 evenHeaderMarkup = \markup \fill-line @{ " " @}
339 oddFooterMarkup = \markup @{ \fill-line @{
340 \bold \fontsize #3 \on-the-fly #print-page-number-check-first
341 \fromproperty #'page:page-number-string @} @}
342 evenFooterMarkup = \markup @{ \fill-line @{
343 \bold \fontsize #3 \on-the-fly #print-page-number-check-first
344 \fromproperty #'page:page-number-string @} @}
348 You can also define these values in Scheme. In that case @code{mm},
349 @code{in}, @code{pt}, and @code{cm} are variables defined in
350 @file{paper-defaults.ly} with values in millimeters. That is why the
351 value must be multiplied in the example
355 #(define bottom-margin (* 2 cm))
359 The header and footer are created by the functions @code{make-footer}
360 and @code{make-header}, defined in @code{\paper}. The default
361 implementations are in @file{ly/@/paper@/-defaults@/.ly} and
362 @file{ly/@/titling@/-init@/.ly}.
364 The page layout itself is done by two functions in the
365 @code{\paper} block, @code{page-music-height} and
366 @code{page-make-stencil}. The former tells the line-breaking algorithm
367 how much space can be spent on a page, the latter creates the actual
368 page given the system to put on it.
373 The option right-margin is defined but doesn't set the right margin
374 yet. The value for the right margin has to be defined adjusting the
375 values of @code{left-margin} and @code{line-width}.
377 The default page header puts the page number and the @code{instrument}
378 field from the @code{\header} block on a line.
380 The titles (from the @code{\header@{@}} section) are treated as a
381 system, so @code{ragged-bottom} and @code{ragged-last-bottom} will
382 add space between the titles and the first system of the score.
386 @section Music layout
389 * Setting the staff size::
394 @node Setting the staff size
395 @subsection Setting the staff size
397 @cindex font size, setting
398 @cindex staff size, setting
399 @funindex layout file
401 To set the staff size globally for all scores in a file (or
402 in a @code{book} block, to be precise), use @code{set-global-staff-size}.
405 #(set-global-staff-size 14)
409 This sets the global default size to 14pt staff height and scales all
412 To set the staff size individually for each score, use
417 #(layout-set-staff-size 15)
422 The Feta font provides musical symbols at eight different
423 sizes. Each font is tuned for a different staff size: at a smaller size
424 the font becomes heavier, to match the relatively heavier staff lines.
425 The recommended font sizes are listed in the following table:
428 @multitable @columnfractions .15 .2 .22 .2
431 @tab @b{staff height (pt)}
432 @tab @b{staff height (mm)}
474 @c modern rental material?
479 These fonts are available in any sizes. The context property
480 @code{fontSize} and the layout property @code{staff-space} (in
481 @internalsref{StaffSymbol}) can be used to tune the size for individual
482 staves. The sizes of individual staves are relative to the global size.
490 This manual: @ref{Selecting notation font size}.
494 @subsection Score layout
498 While @code{\paper} contains settings that relate to the page formatting
499 of the whole document, @code{\layout} contains settings for score-specific
506 \override VerticalAxisGroup #'minimum-Y-extent = #'(-6 . 6)
509 \override TextScript #'padding = #1.0
510 \override Glissando #'thickness = #3
518 This manual: @ref{Changing context default settings}.
521 @node Displaying spacing
522 @section Displaying spacing
524 @funindex annotate-spacing
525 @cindex Spacing, display of properties
527 To graphically display the dimensions of vertical properties that may
528 be altered for page formatting, set @code{annotate-spacing} in the
529 @code{\paper} block, like this
533 #(set-default-paper-size "a6" 'landscape)
537 \paper { annotate-spacing = ##t }
541 @c need to have \book{} otherwise we get the separate systems. -hwn
544 @c FIXME: really bad vagueness due to bug in annotate-spacing. -gp
545 Some unit dimensions are measured in staff spaces, while others
546 are measured in millimeters.
548 (@var{a},@var{b}) are intervals, where @var{a} is the lower edge and
549 @var{b} the upper edge of the interval.
558 * Optimal page breaking::
559 * Optimal page turning::
561 * Using an extra voice for breaks::
565 @subsection Line breaking
568 @cindex breaking lines
570 Line breaks are normally computed automatically. They are chosen so
571 that lines look neither cramped nor loose, and that consecutive lines
572 have similar density.
574 Occasionally you might want to override the automatic breaks; you can
575 do this by specifying @code{\break}. This will force a line break at
576 this point. Line breaks can only occur at places where there are bar
577 lines. If you want to have a line break where there is no bar line,
578 you can force an invisible bar line by entering @code{\bar
579 ""}. Similarly, @code{\noBreak} forbids a line break at a
583 @cindex regular line breaks
584 @cindex four bar music.
586 For line breaks at regular intervals use @code{\break} separated by
587 skips and repeated with @code{\repeat}:
589 << \repeat unfold 7 @{
590 s1 \noBreak s1 \noBreak
591 s1 \noBreak s1 \break @}
592 @emph{the real music}
597 This makes the following 28 measures (assuming 4/4 time) be broken every
598 4 measures, and only there.
602 @code{\break}, and @code{\noBreak}.
608 Internals: @internalsref{LineBreakEvent}.
610 A linebreaking configuration can be saved as a @code{.ly} file
611 automatically. This allows vertical alignments to be stretched to
612 fit pages in a second formatting run. This is fairly new and
613 complicated. More details are available in
618 Line breaks can only occur if there is a @q{proper} bar line. A note
619 which is hanging over a bar line is not proper, such as
621 @lilypond[quote,ragged-right,relative=2,fragment,verbatim]
622 c4 c2 c2 \break % this does nothing
623 c2 c4 | % a break here would work
624 c4 c2 c4 ~ \break % as does this break
628 This can be avoided by removing the @code{Forbid_line_break_engraver}
629 and adding the line breaks in another voice:
631 @lilypond[quote,ragged-right,verbatim]
634 \remove Forbid_line_break_engraver
646 @subsection Page breaking
648 The default page breaking may be overriden by inserting
649 @code{\pageBreak} or @code{\noPageBreak} commands. These commands are
650 analogous to @code{\break} and @code{\noBreak}. They should be
651 inserted at a bar line. These commands force and forbid a page-break
652 from happening. Of course, the @code{\pageBreak} command also forces
655 The @code{\pageBreak} and @code{\noPageBreak} commands may also be
656 inserted at top-level, between scores and top-level markups.
658 Page breaks are computed by the @code{page-breaking} function.
659 LilyPond provides two algorithms for computing page
660 breaks, @code{ly:optimal-breaking} and @code{ly:page-turn-breaking}. The
661 default is @code{ly:optimal-breaking}, but the value can be changed in
662 the @code{\paper} block:
666 #(define page-breaking ly:page-turn-breaking)
670 The old page breaking algorithm is called
671 @code{optimal-page-breaks}. If you are having trouble with the new page
672 breakers, you can enable the old one as a workaround.
678 @funindex \noPageBreak
682 @node Optimal page breaking
683 @subsection Optimal page breaking
685 @funindex ly:optimal-breaking
687 The @code{ly:optimal-breaking} function is LilyPond's default method of
688 determining page breaks. It attempts to find a page breaking that minimizes
689 cramping and stretching, both horizontally and vertically. Unlike
690 @code{ly:page-turn-breaking}, it has no concept of page turns.
693 @node Optimal page turning
694 @subsection Optimal page turning
696 @funindex ly:page-turn-breaking
698 Often it is necessary to find a page breaking configuration so that there is
699 a rest at the end of every second page. This way, the musician can turn the
700 page without having to miss notes. The @code{ly:page-turn-breaking} function
701 attempts to find a page breaking minimizing cramping and stretching, but with
702 the additional restriction that it is only allowed to introduce page turns
705 There are two steps to using this page breaking function. First, you
706 must enable it in the @code{\paper} block, as explained in @ref{Page
707 breaking}. Then you must tell the function where you would like to allow
710 There are two ways to achieve the second step. First, you can specify each
711 potential page turn manually, by inserting @code{\allowPageTurn} into your
712 input file at the appropriate places.
714 If this is too tedious, you can add a @code{Page_turn_engraver} to a Staff or
715 Voice context. The @code{Page_turn_engraver} will scan the context for
716 sections without notes (note that it does not scan for rests; it scans for
717 the absence of notes. This is so that single-staff polyphony with rests in one
718 of the parts does not throw off the @code{Page_turn_engraver}). When it finds
719 a sufficiently long section without notes, the @code{Page_turn_engraver} will
720 insert an @code{\allowPageTurn} at the final barline in that section, unless
721 there is a @q{special} barline (such as a double bar), in which case the
722 @code{\allowPageTurn} will be inserted at the final @q{special} barline in
725 @funindex minimumPageTurnLength
726 The @code{Page_turn_engraver} reads the context property
727 @code{minimumPageTurnLength} to determine how long a note-free section must
728 be before a page turn is considered. The default value for
729 @code{minimumPageTurnLength} is @code{#(ly:make-moment 1 1)}. If you want
730 to disable page turns, you can set it to something very large.
733 \new Staff \with @{ \consists "Page_turn_engraver" @}
736 R1 | % a page turn will be allowed here
738 \set Staff.minimumPageTurnLength = #(ly:make-moment 5 2)
739 R1 | % a page turn will not be allowed here
741 R1*2 | % a page turn will be allowed here
746 @funindex minimumRepeatLengthForPageTurn
747 The @code{Page_turn_engraver} detects volta repeats. It will only allow a page
748 turn during the repeat if there is enough time at the beginning and end of the
749 repeat to turn the page back. The @code{Page_turn_engraver} can also disable
750 page turns if the repeat is very short. If you set the context property
751 @code{minimumRepeatLengthForPageTurn} then the @code{Page_turn_engraver} will
752 only allow turns in repeats whose duration is longer than this value.
754 The page turning commands, @code{\pageTurn}, @code{\noPageTurn} and
755 @code{\allowPageTurn}, may also be used at top-level, between scores and
762 @funindex \noPageTurn
764 @funindex \allowPageTurn
765 @code{\allowPageTurn}
769 There should only be one @code{Page_turn_engraver} in a score. If there is more
770 than one, they will interfere with each other.
773 @node Explicit breaks
774 @subsection Explicit breaks
776 Lily sometimes rejects explicit @code{\break} and @code{\pageBreak}
777 commands. There are two commands to override this behavior:
780 \override NonMusicalPaperColumn #'line-break-permission = ##f
781 \override NonMusicalPaperColumn #'page-break-permission = ##f
784 When @code{line-break-permission} is overriden to false, Lily will insert
785 line breaks at explicit @code{\break} commands and nowhere else. When
786 @code{page-break-permission} is overriden to false, Lily will insert
787 page breaks at explicit @code{\pageBreak} commands and nowhere else.
789 @lilypond[quote,verbatim]
798 \override NonMusicalPaperColumn #'line-break-permission = ##f
799 \override NonMusicalPaperColumn #'page-break-permission = ##f
802 \repeat unfold 2 { c'8 c'8 c'8 c'8 } \break
803 \repeat unfold 4 { c'8 c'8 c'8 c'8 } \break
804 \repeat unfold 6 { c'8 c'8 c'8 c'8 } \break
805 \repeat unfold 8 { c'8 c'8 c'8 c'8 } \pageBreak
806 \repeat unfold 8 { c'8 c'8 c'8 c'8 } \break
807 \repeat unfold 6 { c'8 c'8 c'8 c'8 } \break
808 \repeat unfold 4 { c'8 c'8 c'8 c'8 } \break
809 \repeat unfold 2 { c'8 c'8 c'8 c'8 }
816 @node Using an extra voice for breaks
817 @subsection Using an extra voice for breaks
819 Line- and page-breaking information usually appears within note entry directly.
824 \repeat unfold 2 @{ c'4 c'4 c'4 c'4 @}
826 \repeat unfold 3 @{ c'4 c'4 c'4 c'4 @}
831 This makes @code{\break} and @code{\pageBreak} commands easy to enter but mixes
832 music entry with information that specifies how music should lay out
833 on the page. You can keep music entry and line- and page-breaking
834 information in two separate places by introducing an extra voice to
835 contain the breaks. This extra voice
836 contains only skips together with @code{\break}, @code{pageBreak} and other
837 breaking layout information.
839 @lilypond[quote,verbatim]
849 \repeat unfold 2 { c'4 c'4 c'4 c'4 }
850 \repeat unfold 3 { c'4 c'4 c'4 c'4 }
851 \repeat unfold 6 { c'4 c'4 c'4 c'4 }
852 \repeat unfold 5 { c'4 c'4 c'4 c'4 }
858 This pattern becomes especially helpful when overriding
859 @code{line-break-system-details} and the other useful but long properties of
860 @code{NonMusicalPaperColumnGrob}, as explained in @ref{Vertical spacing}.
862 @lilypond[quote,verbatim]
867 \overrideProperty "Score.NonMusicalPaperColumn"
868 #'line-break-system-details #'((Y-offset . 0))
871 \overrideProperty "Score.NonMusicalPaperColumn"
872 #'line-break-system-details #'((Y-offset . 35))
875 \overrideProperty "Score.NonMusicalPaperColumn"
876 #'line-break-system-details #'((Y-offset . 70))
879 \overrideProperty "Score.NonMusicalPaperColumn"
880 #'line-break-system-details #'((Y-offset . 105))
884 \repeat unfold 2 { c'4 c'4 c'4 c'4 }
885 \repeat unfold 3 { c'4 c'4 c'4 c'4 }
886 \repeat unfold 6 { c'4 c'4 c'4 c'4 }
887 \repeat unfold 5 { c'4 c'4 c'4 c'4 }
894 @node Vertical spacing
895 @section Vertical spacing
897 @cindex vertical spacing
898 @cindex spacing, vertical
900 Vertical spacing is controlled by three things: the amount of
901 space available (i.e., paper size and margins), the amount of
902 space between systems, and the amount of space between
903 staves inside a system.
906 * Vertical spacing inside a system::
907 * Vertical spacing between systems::
908 * Explicit staff and system positioning::
909 * Two-pass vertical spacing::
910 * Vertical collision avoidance::
914 @node Vertical spacing inside a system
915 @subsection Vertical spacing inside a system
917 @cindex distance between staves
918 @cindex staff distance
919 @cindex space between staves
920 @cindex space inside systems
922 The height of each system is determined automatically. To prevent
923 staves from bumping into each other, some minimum distances are set.
924 By changing these, you can put staves closer together. This
925 reduces the amount of space each system requires, and may result
926 in having more systems per page.
928 Normally staves are stacked vertically. To make staves maintain a
929 distance, their vertical size is padded. This is done with the
930 property @code{minimum-Y-extent}. When applied to a
931 @internalsref{VerticalAxisGroup}, it controls the size of a horizontal
932 line, such as a staff or a line of lyrics. @code{minimum-Y-extent}
933 takes a pair of numbers, so
934 if you want to make it smaller than its default @code{#'(-4 . 4)}
938 \override Staff.VerticalAxisGroup #'minimum-Y-extent = #'(-3 . 3)
942 This sets the vertical size of the current staff to 3 staff spaces on
943 either side of the center staff line. The value @code{(-3 . 3)} is
944 interpreted as an interval, where the center line is the 0, so the
945 first number is generally negative. The numbers need not match;
946 for example, the staff can be made larger at the bottom by setting
947 it to @code{(-6 . 4)}.
949 After page breaks are determined, the vertical spacing within each
950 system is reevaluated in order to fill the page more evenly; if a page
951 has space left over, systems are stretched in order to fill that space.
952 The amount of stretching can be configured though the @code{max-stretch}
953 property of the @internalsref{VerticalAlignment} grob. To disable this
954 stretching entirely, set @code{max-stretch} to zero.
956 In some situations, you may want to stretch most of a system while
957 leaving some parts fixed. For example, if a piano part occurs in the
958 middle of an orchestral score, you may want to leave the piano staves
959 close to each other while stretching the rest of the score. The
960 @code{keep-fixed-while-stretching} property of
961 @internalsref{VerticalAxisGroup} can be used to achieve this. When set
962 to @code{##t}, this property keeps its staff (or line of lyrics) from
963 moving relative to the one directly above it. In the example above,
964 you would override @code{keep-fixed-while-stretching} to @code{##t} in
965 the second piano staff:
968 #(set-default-paper-size "a6")
969 #(set-global-staff-size 14.0)
973 ragged-last-bottom = ##f
981 \new Staff {c' d' e' f'}
982 \new Staff {c' d' e' f'}
983 \new Staff {c' d' e' f'}
988 \new Staff {c' d' e' f'}
990 \override VerticalAxisGroup #'keep-fixed-while-stretching = ##t
997 \new Staff {c' d' e' f'}
998 \new Staff {c' d' e' f'}
1007 Internals: Vertical alignment of staves is handled by the
1008 @internalsref{VerticalAlignment} object. The context parameters
1009 specifying the vertical extent are described in connection with
1010 the @internalsref{Axis_group_engraver}.
1012 Example files: @lsr{spacing,page-spacing.ly},
1013 @lsr{spacing,alignment-vertical-spacing.ly}.
1016 @node Vertical spacing between systems
1017 @subsection Vertical spacing between systems
1019 Space between systems are controlled by four @code{\paper} variables,
1023 between-system-space = 1.5\cm
1024 between-system-padding = #1
1026 ragged-last-bottom=##f
1031 @node Explicit staff and system positioning
1032 @subsection Explicit staff and system positioning
1034 One way to understand the @code{VerticalAxisGroup} and @code{\paper}
1035 settings explained in the previous two sections is as a collection of
1036 different settings that primarily concern the amount of vertical padding
1037 different staves and systems running down the page.
1039 It is possible to approach vertical spacing in a different way using
1040 @code{NonMusicalPaperColumn #'line-break-system-details}. Where
1041 @code{VerticalAxisGroup} and @code{\paper} settings specify vertical padding,
1042 @code{NonMusicalPaperColumn #'line-break-system-details} specifies exact
1043 vertical positions on the page.
1045 @code{NonMusicalPaperColumn #'line-break-system-details} accepts an associative
1046 list of five different settings:
1049 @item @code{X-offset}
1050 @item @code{Y-offset}
1051 @item @code{alignment-offsets}
1052 @item @code{alignment-extra-space}
1053 @item @code{fixed-alignment-extra-space}
1056 Grob overrides, including the overrides for @code{NonMusicalPaperColumn}
1057 below, can occur in any of three different places in an input file:
1060 @item in the middle of note entry directly
1061 @item in a @code{\context} block
1062 @item in the @code{\with} block
1065 When we override @code{NonMusicalPaperColumn}, we use the usual
1066 @code{\override} command in @code{\context} blocks and in the
1067 @code{\with} block. On the other hand, when we override
1068 @code{NonMusicalPaperColumn} in the middle of note entry,
1069 use the special @code{\overrideProperty} command. Here are some
1070 example @code{NonMusicalPaperColumn} overrides with the special
1071 @code{\overrideProperty} command:
1074 \overrideProperty NonMusicalPaperColumn
1075 #'line-break-system-details #'((X-offset . 20))
1077 \overrideProperty NonMusicalPaperColumn
1078 #'line-break-system-details #'((Y-offset . 40))
1080 \overrideProperty NonMusicalPaperColumn
1081 #'line-break-system-details #'((X-offset . 20) (Y-offset . 40))
1083 \override NonMusicalPaperColumn
1084 #'line-break-system-details #'((alignment-offsets . (0 -15)))
1086 \override NonMusicalPaperColumn
1087 #'line-break-system-details #'((X-offset . 20) (Y-offset . 40)
1088 (alignment-offsets . (0 -15)))
1091 To understand how each of these different settings work, we begin
1092 by looking at an example that includes no overrides at all.
1094 @lilypond[quote,ragged-right]
1102 \new Voice { \repeat unfold 18 { c'4 c'4 c'4 c'4 } }
1105 \repeat unfold 18 { d'4 d'4 d'4 d'4 }
1110 This score isolates line- and page-breaking information in a dedicated
1111 voice. This technique of creating a breaks voice will help keep layout
1112 separate from music entry as our example becomes more complicated.
1113 See @ref{Using an extra voice for breaks}.
1115 Explicit @code{\breaks} evenly divide the music into six measures per
1116 line. Vertical spacing results from LilyPond's defaults. To set
1117 the vertical startpoint of each system explicitly, we can set
1118 the @code{Y-offset} pair in the @code{line-break-system-details}
1119 attribute of the @code{NonMusicalPaperColumn} grob:
1121 @lilypond[quote,ragged-right]
1125 \overrideProperty #"Score.NonMusicalPaperColumn"
1126 #'line-break-system-details #'((Y-offset . 0))
1128 \overrideProperty #"Score.NonMusicalPaperColumn"
1129 #'line-break-system-details #'((Y-offset . 40))
1131 \overrideProperty #"Score.NonMusicalPaperColumn"
1132 #'line-break-system-details #'((Y-offset . 80))
1135 \new Voice { \repeat unfold 18 { c'4 c'4 c'4 c'4 } }
1138 \repeat unfold 18 { d'4 d'4 d'4 d'4 }
1143 Note that @code{line-break-system-details} takes an associative list of
1144 potentially many values, but that we set only one value here. Note,
1145 too, that the @code{Y-offset} property here determines the exact vertical
1146 position on the page at which each new system will render.
1148 Now that we have set the vertical startpoint of each system
1149 explicitly, we can also set the vertical startpoint of each staff
1150 within each system manually. We do this using the @code{alignment-offsets}
1151 subproperty of @code{line-break-system-details}.
1153 @lilypond[quote,ragged-right]
1157 \overrideProperty #"Score.NonMusicalPaperColumn"
1158 #'line-break-system-details #'((Y-offset . 20)
1159 (alignment-offsets . (0 -15)))
1161 \overrideProperty #"Score.NonMusicalPaperColumn"
1162 #'line-break-system-details #'((Y-offset . 60)
1163 (alignment-offsets . (0 -15)))
1165 \overrideProperty #"Score.NonMusicalPaperColumn"
1166 #'line-break-system-details #'((Y-offset . 100)
1167 (alignment-offsets . (0 -15)))
1170 \new Voice { \repeat unfold 18 { c'4 c'4 c'4 c'4 } }
1173 \repeat unfold 18 { d'4 d'4 d'4 d'4 }
1178 Note that here we assign two different values to the
1179 @code{line-break-system-details} attribute of the
1180 @code{NonMusicalPaperColumn} grob. Though the
1181 @code{line-break-system-details} attribute alist accepts many
1182 additional spacing parameters (including, for example, a corresponding
1183 @code{X-offset} pair), we need only set the @code{Y-offset} and
1184 @code{alignment-offsets} pairs to control the vertical startpoint of
1185 every system and every staff. Finally, note that @code{alignment-offsets}
1186 specifies the vertical positioning of staves but not of staff groups.
1188 @lilypond[quote,ragged-right]
1192 \overrideProperty #"Score.NonMusicalPaperColumn"
1193 #'line-break-system-details #'((Y-offset . 0)
1194 (alignment-offsets . (0 -30 -40)))
1196 \overrideProperty #"Score.NonMusicalPaperColumn"
1197 #'line-break-system-details #'((Y-offset . 60)
1198 (alignment-offsets . (0 -10 -20)))
1200 \overrideProperty #"Score.NonMusicalPaperColumn"
1201 #'line-break-system-details #'((Y-offset . 100)
1202 (alignment-offsets . (0 -10, -40)))
1205 \new Voice { \repeat unfold 18 { c'4 c'4 c'4 c'4 } }
1209 \repeat unfold 18 { d'4 d'4 d'4 d'4 }
1212 \repeat unfold 18 { e'4 e'4 e'4 e'4 }
1218 Some points to consider:
1221 @item When using @code{alignment-offsets}, lyrics count as a staff.
1223 @item The units of the numbers passed to @code{X-offset},
1224 @code{Y-offset} and @code{alignment-offsets} are interpreted as multiples
1225 of the distance between adjacent staff lines. Positive values move staves
1226 and lyrics up, negative values move staves and lyrics down.
1228 @item Because the @code{NonMusicalPaperColumn #'line-break-system-details}
1229 settings given here allow the positioning of staves and systems anywhere
1230 on the page, it is possible to violate paper or margin boundaries or even
1231 to print staves or systems on top of one another. Reasonable values
1232 passed to these different settings will avoid this.
1236 @node Two-pass vertical spacing
1237 @subsection Two-pass vertical spacing
1239 Warning: two-pass vertical spacing is deprecated and will be removed in
1240 a future version of LilyPond. Systems are now stretched automatically
1241 in a single pass. See @ref{Vertical spacing inside a system}.
1243 In order to automatically stretch systems so that they should fill the
1244 space left on a page, a two-pass technique can be used:
1247 @item In the first pass, the amount of vertical space used to increase
1248 the height of each system is computed and dumped to a file.
1249 @item In the second pass, spacing inside the systems are
1250 stretched according to the data in the page layout file.
1253 The @code{ragged-bottom} property adds space between systems, while
1254 the two-pass technique adds space between staves inside a system.
1256 To allow this behaviour, a @code{tweak-key} variable has to be set in
1257 each score @code{\layout} block, and the tweaks included in each score
1258 music, using the @code{\scoreTweak} music function.
1262 %% include the generated page layout file:
1263 \includePageLayoutFile
1268 %% Include this score tweaks:
1269 \scoreTweak "scoreA"
1270 { \clef french c''1 \break c''1 }
1272 \new Staff { \clef soprano g'1 g'1 }
1273 \new Staff { \clef mezzosoprano e'1 e'1 }
1274 \new Staff { \clef alto g1 g1 }
1275 \new Staff { \clef bass c1 c1 }
1278 piece = "Score with tweaks"
1280 %% Define how to name the tweaks for this score:
1281 \layout { #(define tweak-key "scoreA") }
1286 For the first pass, the @code{dump-tweaks} option should be set to
1287 generate the page layout file.
1290 lilypond -dbackend=null -d dump-tweaks <file>.ly
1295 @node Vertical collision avoidance
1296 @subsection Vertical collision avoidance
1298 @funindex outside-staff-priority
1299 @funindex outside-staff-padding
1300 @funindex outside-staff-horizontal-padding
1302 Intuitively, there are some objects in musical notation that belong
1303 to the staff and there are other objects that should be placed outside
1304 the staff. Objects belonging outside the staff include things such as
1305 rehearsal marks, text and dynamic markings (from now on, these will
1306 be called outside-staff objects). LilyPond's rule for the
1307 vertical placement of outside-staff objects is to place them as close
1308 to the staff as possible but not so close that they collide with
1311 LilyPond uses the @code{outside-staff-priority} property to determine
1312 whether a grob is an outside-staff object: if @code{outside-staff-priority}
1313 is a number, the grob is an outside-staff object. In addition,
1314 @code{outside-staff-priority} tells LilyPond in which order the objects
1317 First, LilyPond places all the objects that do not belong outside
1318 the staff. Then it sorts the outside-staff objects according to their
1319 @code{outside-staff-priority} (in increasing order). One by one, LilyPond
1320 takes the outside-staff objects and places them so that they do
1321 not collide with any objects that have already been placed. That
1322 is, if two outside-staff grobs are competing for the same space, the one
1323 with the lower @code{outside-staff-priority} will be placed closer to
1326 @lilypond[quote,ragged-right,relative=2,fragment,verbatim]
1329 \once \override TextScript #'outside-staff-priority = #1
1330 c4_"Text"\pp % this time the text will be closer to the staff
1332 % by setting outside-staff-priority to a non-number, we
1333 % disable the automatic collision avoidance
1334 \once \override TextScript #'outside-staff-priority = ##f
1335 \once \override DynamicLineSpanner #'outside-staff-priority = ##f
1336 c4_"Text"\pp % now they will collide
1339 The vertical padding between an outside-staff object and the
1340 previously-positioned grobs can be controlled with
1341 @code{outside-staff-padding}.
1343 @lilypond[quote,ragged-right,relative=2,fragment,verbatim]
1344 \once \override TextScript #'outside-staff-padding = #0
1345 a'^"This text is placed very close to the note"
1346 \once \override TextScript #'outside-staff-padding = #3
1347 c^"This text is padded away from the previous text"
1348 c^"This text is placed close to the previous text"
1351 By default, outside-staff objects are placed without regard to
1352 their horizontal distance from the previously-posititioned grobs. This
1353 can lead to situations in which objects are placed very close to each
1354 other horizontally. Setting @code{outside-staff-horizontal-padding}
1355 causes an object to be offset vertically so that such a situation
1358 @lilypond[quote,ragged-right,relative=2,fragment,verbatim]
1359 % the markup is too close to the following note
1362 % setting outside-staff-horizontal-padding fixes this
1364 \once \override TextScript #'outside-staff-horizontal-padding = #1
1371 @node Horizontal spacing
1372 @section Horizontal Spacing
1374 @cindex horizontal spacing
1375 @cindex spacing, horizontal
1378 * Horizontal spacing overview::
1379 * New spacing area::
1380 * Changing horizontal spacing::
1382 * Proportional notation::
1386 @node Horizontal spacing overview
1387 @subsection Horizontal spacing overview
1389 The spacing engine translates differences in durations into stretchable
1390 distances (@q{springs}) of differring lengths. Longer durations get
1391 more space, shorter durations get less. The shortest durations get a
1392 fixed amount of space (which is controlled by
1393 @code{shortest-duration-space} in the @internalsref{SpacingSpanner}
1394 object). The longer the duration, the more space it gets: doubling a
1395 duration adds a fixed amount (this amount is controlled by
1396 @code{spacing-increment}) of space to the note.
1398 For example, the following piece contains lots of half, quarter, and
1399 8th notes; the eighth note is followed by 1 note head width (NHW).
1400 The quarter note is followed by 2 NHW, the half by 3 NHW, etc.
1402 @lilypond[quote,fragment,verbatim,relative=1]
1403 c2 c4. c8 c4. c8 c4. c8 c8
1407 Normally, @code{spacing-increment} is set to 1.2 staff space, which is
1408 approximately the width of a note head, and
1409 @code{shortest-duration-space} is set to 2.0, meaning that the
1410 shortest note gets 2.4 staff space (2.0 times the
1411 @code{spacing-increment}) of horizontal space. This space is counted
1412 from the left edge of the symbol, so the shortest notes are generally
1413 followed by one NHW of space.
1415 If one would follow the above procedure exactly, then adding a single
1416 32nd note to a score that uses 8th and 16th notes, would widen up the
1417 entire score a lot. The shortest note is no longer a 16th, but a 32nd,
1418 thus adding 1 NHW to every note. To prevent this, the shortest
1419 duration for spacing is not the shortest note in the score, but rather
1420 the one which occurs most frequently.
1423 The most common shortest duration is determined as follows: in every
1424 measure, the shortest duration is determined. The most common shortest
1425 duration is taken as the basis for the spacing, with the stipulation
1426 that this shortest duration should always be equal to or shorter than
1427 an 8th note. The shortest duration is printed when you run
1428 @code{lilypond} with the @code{--verbose} option.
1430 These durations may also be customized. If you set the
1431 @code{common-shortest-duration} in @internalsref{SpacingSpanner}, then
1432 this sets the base duration for spacing. The maximum duration for this
1433 base (normally an 8th), is set through @code{base-shortest-duration}.
1435 @funindex common-shortest-duration
1436 @funindex base-shortest-duration
1437 @funindex stem-spacing-correction
1440 Notes that are even shorter than the common shortest note are
1441 followed by a space that is proportional to their duration relative to
1442 the common shortest note. So if we were to add only a few 16th notes
1443 to the example above, they would be followed by half a NHW:
1445 @lilypond[quote,fragment,verbatim,relative=2]
1446 c2 c4. c8 c4. c16[ c] c4. c8 c8 c8 c4 c4 c4
1450 In the introduction (see @ref{Engraving}), it was explained that stem
1451 directions influence spacing. This is controlled with the
1452 @code{stem-spacing-correction} property in the
1453 @internalsref{NoteSpacing}, object. These are generated for every
1454 @internalsref{Voice} context. The @code{StaffSpacing} object
1455 (generated in @internalsref{Staff} context) contains the same property
1456 for controlling the stem/bar line spacing. The following example shows
1457 these corrections, once with default settings, and once with
1458 exaggerated corrections:
1460 @lilypond[quote,ragged-right]
1464 \override Staff.NoteSpacing #'stem-spacing-correction = #1.5
1465 \override Staff.StaffSpacing #'stem-spacing-correction = #1.5
1471 Proportional notation is supported; see @ref{Proportional notation}.
1476 Internals: @internalsref{SpacingSpanner}, @internalsref{NoteSpacing},
1477 @internalsref{StaffSpacing}, @internalsref{SeparationItem}, and
1478 @internalsref{SeparatingGroupSpanner}.
1483 There is no convenient mechanism to manually override spacing. The
1484 following work-around may be used to insert extra space into a score.
1486 \once \override Score.SeparationItem #'padding = #1
1489 No work-around exists for decreasing the amount of space.
1492 @node New spacing area
1493 @subsection New spacing area
1495 New sections with different spacing parameters can be started with
1496 @code{newSpacingSection}. This is useful when there are
1497 sections with a different notions of long and short notes.
1499 In the following example, the time signature change introduces a new
1500 section, and hence the 16ths notes are spaced wider.
1502 @lilypond[relative,fragment,verbatim,quote]
1505 c8 c c4 c16[ c c8] c4
1512 The @code{\newSpacingSection} command creates a new
1513 @internalsref{SpacingSpanner} object, and hence new @code{\override}s
1514 may be used in that location.
1517 @node Changing horizontal spacing
1518 @subsection Changing horizontal spacing
1520 Horizontal spacing may be altered with the
1521 @code{base-shortest-duration} property. Here
1522 we compare the same music; once without altering
1523 the property, and then altered. Larger values
1524 of @code{ly:make-moment} will produce smaller
1525 music. Note that @code{ly:make-moment} constructs
1526 a duration, so @code{1 4} is a longer duration
1529 @lilypond[relative,verbatim,line-width=12\cm]
1532 g4 e e2 | f4 d d2 | c4 d e f | g4 g g2 |
1533 g4 e e2 | f4 d d2 | c4 e g g | c,1 |
1534 d4 d d d | d4 e f2 | e4 e e e | e4 f g2 |
1535 g4 e e2 | f4 d d2 | c4 e g g | c,1 |
1540 @lilypond[relative,verbatim,line-width=12\cm]
1543 g4 e e2 | f4 d d2 | c4 d e f | g4 g g2 |
1544 g4 e e2 | f4 d d2 | c4 e g g | c,1 |
1545 d4 d d d | d4 e f2 | e4 e e e | e4 f g2 |
1546 g4 e e2 | f4 d d2 | c4 e g g | c,1 |
1551 \override SpacingSpanner
1552 #'base-shortest-duration = #(ly:make-moment 1 16)
1561 By default, spacing in tuplets depends on various non-duration
1562 factors (such as accidentals, clef changes, etc). To disregard
1563 such symbols and force uniform equal-duration spacing, use
1564 @code{Score.SpacingSpanner #'uniform-stretching}. This
1565 property can only be changed at the beginning of a score,
1567 @lilypond[quote,ragged-right,relative=2,fragment,verbatim]
1569 \override SpacingSpanner #'uniform-stretching = ##t
1587 When @code{strict-note-spacing} is set, notes are spaced without
1588 regard for clefs, bar lines, and grace notes,
1590 @lilypond[quote,ragged-right,relative=2,fragment,verbatim]
1591 \override Score.SpacingSpanner #'strict-note-spacing = ##t
1592 \new Staff { c8[ c \clef alto c \grace { c16[ c] } c8 c c] c32[ c32] }
1597 @subsection Line length
1600 @cindex breaking pages
1603 @funindex line-width
1604 @funindex ragged-right
1605 @funindex ragged-last
1607 @c Although line-width can be set in \layout, it should be set in paper
1608 @c block, to get page layout right.
1609 @c Setting indent in \paper block makes not much sense, but it works.
1611 @c Bit verbose and vague, use examples?
1612 The most basic settings influencing the spacing are @code{indent} and
1613 @code{line-width}. They are set in the @code{\layout} block. They
1614 control the indentation of the first line of music, and the lengths of
1617 If @code{ragged-right} is set to true in the @code{\layout} block, then
1618 systems ends at their natural horizontal length, instead of being spread
1619 horizontally to fill the whole line. This is useful for
1620 short fragments, and for checking how tight the natural spacing is.
1623 @cindex vertical spacing
1625 The option @code{ragged-last} is similar to @code{ragged-right}, but
1626 only affects the last line of the piece. No restrictions are put on
1627 that line. The result is similar to formatting text paragraphs. In a
1628 paragraph, the last line simply takes its natural horizontal length.
1629 @c Note that for text there are several options for the last line.
1630 @c While Knuth TeX uses natural length, lead typesetters use the same
1631 @c stretch as the previous line. eTeX uses \lastlinefit to
1632 @c interpolate between both these solutions.
1643 @node Proportional notation
1644 @subsection Proportional notation
1646 LilyPond supports proportional notation, a type of horizontal spacing
1647 in which each note consumes an amount of horizontal space exactly
1648 equivalent to its rhythmic duration. This type of proportional spacing
1649 is comparable to horizontal spacing on top of graph paper. Some late
1650 20th- and early 21st-century scores use proportional notation to
1651 clarify complex rhythmic relationships or to faciliate the placement
1652 of timelines or other graphics directly in the score.
1654 LilyPond supports five different settings for proportional notation,
1655 which may be used together or alone:
1658 @item @code{proportionalNotationDuration}
1659 @item @code{uniform-stretching}
1660 @item @code{strict-note-spacing}
1661 @item @code{\remove Separating_line_group_engraver}
1662 @item @code{\override PaperColumn #'used = ##t}
1665 In the examples that follow, we explore these five different
1666 proportional notation settings and examine how these settings interact.
1668 We start with the following one-measure example, which uses classical
1669 spacing with ragged-right turned on.
1671 @lilypond[quote,verbatim,ragged-right]
1673 \new RhythmicStaff {
1677 c'16 c'16 c'16 c'16 c'16
1683 Notice that the half note which begins the measure takes up far less
1684 than half of the horizontal space of the measure. Likewise, the
1685 sixteenth notes and sixteenth-note quintuplets (or twentieth notes)
1686 which end the measure together take up far more than half the
1687 horizontal space of the measure.
1689 In classical engraving, this spacing may be exactly what we want
1690 because we can borrow horizontal space from the half note and conserve
1691 horizontal space across the measure as a whole.
1693 On the other hand, if we want to insert a measured timeline or other
1694 graphic above or below our score, we need proportional notation. We
1695 turn proportional notation on with the proportionalNotationDuration
1698 @lilypond[quote,verbatim,ragged-right]
1700 proportionalNotationDuration = #(ly:make-moment 1 20)
1702 \new RhythmicStaff {
1706 c'16 c'16 c'16 c'16 c'16
1712 The half note at the beginning of the measure and the faster notes in
1713 the second half of the measure now occupy equal amounts of horizontal
1714 space. We could place a measured timeline or graphic above or below
1717 The @code{proportionalNotationDuration} setting is a context setting that
1718 lives in @context{Score}. Recall that context settings appear in one of
1719 three locations in our input file -- in a @code{\with} block, in a
1720 @code{\context} block, or directly in music entry
1721 preceeded by the @code{\set} command. As with all
1722 context settings, users can pick which of the three different
1723 locations they would like to set @code{proportionalNotationDuration}.
1725 The @code{proportionalNotationDuration} setting takes a single argument,
1726 which is the reference duration against which all music will be
1727 spaced. The LilyPond Scheme function make-moment takes two arguments
1728 -- a numerator and denominator which together express some fraction of
1729 a whole note. The call @code{#(ly:make-moment 1 20)} therefore produces a
1730 reference duration of a twentieth note. The values
1731 @code{#(ly:make-moment 1 16)}, @code{#(ly:make-moment 1 8)}, and
1732 @code{#(ly:make-moment 3 97)} are all possible as well.
1734 How do we select the right reference duration to pass to
1735 @code{proportionalNotationDuration}? Usually by a process of trial and error,
1736 beginning with a duration close to the fastest (or smallest) duration
1737 in the piece. Smaller reference durations space music loosely; larger
1738 reference durations space music tightly.
1740 @lilypond[quote,verbatim,ragged-right]
1742 proportionalNotationDuration = #(ly:make-moment 1 8)
1744 \new RhythmicStaff {
1748 c'16 c'16 c'16 c'16 c'16
1754 proportionalNotationDuration = #(ly:make-moment 1 16)
1756 \new RhythmicStaff {
1760 c'16 c'16 c'16 c'16 c'16
1766 proportionalNotationDuration = #(ly:make-moment 1 32)
1768 \new RhythmicStaff {
1772 c'16 c'16 c'16 c'16 c'16
1778 Note that too large a reference duration -- such as the eighth note,
1779 above -- spaces music too tightly and can cause notehead collisions.
1780 Note also that proportional notation in general takes up more
1781 horizontal space that does classical spacing. Proportional spacing
1782 provides rhythmic clarity at the expense of horizontal space.
1784 Next we examine how to optimally space overlapping tuplets.
1786 We start by examining what happens to our original example, with
1787 classical spacing, when we add a second staff with a different type of
1790 @lilypond[quote,verbatim,ragged-right]
1792 \new RhythmicStaff {
1796 c'16 c'16 c'16 c'16 c'16
1799 \new RhythmicStaff {
1801 c'8 c'8 c'8 c'8 c'8 c'8 c'8 c'8 c'8
1807 The spacing is bad because the evenly notes of the bottom staff do not
1808 stretch uniformly. Classical engraving includes very few complex
1809 triplets and so classical engraving rules can generate this type of
1810 result. Setting @code{proportionalNotationDuration} remedies this
1811 situation considerably.
1813 @lilypond[quote,verbatim,ragged-right]
1815 proportionalNotationDuration = #(ly:make-moment 1 20)
1817 \new RhythmicStaff {
1821 c'16 c'16 c'16 c'16 c'16
1824 \new RhythmicStaff {
1826 c'8 c'8 c'8 c'8 c'8 c'8 c'8 c'8 c'8
1832 But if we look very carefully we can see that notes of the second half
1833 of the 9-tuplet space ever so slightly more widely than do the notes
1834 of the first half of the 9-tuplet. To ensure uniform stretching, we
1835 turn on @code{uniform-stretching}, which is a property of
1836 @code{SpacingSpanner}.
1838 @lilypond[quote,verbatim,ragged-right]
1840 proportionalNotationDuration = #(ly:make-moment 1 20)
1841 \override SpacingSpanner #'uniform-stretching = ##t
1843 \new RhythmicStaff {
1847 c'16 c'16 c'16 c'16 c'16
1850 \new RhythmicStaff {
1852 c'8 c'8 c'8 c'8 c'8 c'8 c'8 c'8 c'8
1858 Our two-staff example now spaces exactly, our rhythmic relationships
1859 are visually clear, and we can include a measured timeline or graphic
1862 The @code{SpacingSpanner} is an abstract grob that lives in the
1863 @context{Score} context. As with our settings of
1864 @code{proportionalNotationDuration},
1865 overrides to the @code{SpacingSpanner} can occur in any of three different
1866 places in our input file -- in the Score @code{\with} block, in a
1867 Score @code{\context} block, or in note entry directly.
1869 There is by default only one @code{SpacingSpanner} per @code{Score}. This
1870 means that, by default, @code{uniform-stretching} is either turned on for the
1871 entire score or turned off for the entire score. We can, however,
1872 override this behavior and turn on different spacing features at
1873 different places in the score. We do this with the command
1874 @code{\newSpacingSection}. See @ref{New spacing area}, for more info.
1876 Next we examine the effects of the @code{Separating_line_group_engraver} and
1877 see why proportional scores frequently remove this engraver. The following
1878 example shows that there is a small amount of @qq{preferatory} space
1879 just before the first note in each system.
1881 @lilypond[quote,verbatim,ragged-right]
1894 The amount of this preferatory space is the same whether after a time
1895 signature, a key signature or a clef. @code{Separating_line_group_engraver}
1896 is responsible for this space. Removing @code{Separating_line_group_engraver}
1897 reduces this space to zero.
1899 @lilypond[quote,verbatim,ragged-right]
1905 \remove Separating_line_group_engraver
1913 Nonmusical elements like time signatures, key signatures, clefs and
1914 accidentals are problemmatic in proportional notation. None of these
1915 elements has rhythmic duration. But all of these elements consume
1916 horizontal space. Different proportional scores approach these
1917 problems differently.
1919 It may be possible to avoid spacing problems with key signatures
1920 simply by not having any. This is a valid option since most
1921 proportional scores are contemporary music. The same may be true
1922 of time signatures, especially for those scores
1923 that include a measured timeline or other graphic. But these scores
1924 are exceptional and most proportional scores include at least some
1925 time signatures. Clefs and accidentals are even more essential.
1927 So what strategies exist for spacing nonmusical elements in a
1928 proportional context? One good option is the @code{strict-note-spacing}
1929 property of @code{SpacingSpanner}. Compare the two scores below:
1931 @lilypond[quote,verbatim,ragged-right]
1933 \set Score.proportionalNotationDuration = #(ly:make-moment 1 16)
1943 \set Score.proportionalNotationDuration = #(ly:make-moment 1 16)
1944 \override Score.SpacingSpanner #'strict-note-spacing = ##t
1954 Both scores are proportional, but the spacing in the first score is
1955 too loose because of the clef change. The spacing of the second score
1956 remains strict, however, because @code{strict-note-spacing} is turned
1957 on. Turning on @code{strict-note-spacing} causes the width of time
1958 signatures, key signatures and clefs to play no part in the spacing
1959 algorithm. Accidentals are a different matter, however. By default, all
1960 accidentals consume a little extra space, as the following pair of
1963 @lilypond[quote,verbatim,ragged-right]
1965 \set Score.proportionalNotationDuration = #(ly:make-moment 1 32)
1977 \set Score.proportionalNotationDuration = #(ly:make-moment 1 32)
1989 Both scores are proportional but the second score exhibits spacing
1990 irregularities due to accidentals. Turning on @code{strict-note-spacing}
1991 does not work for accidentals. Instead,
1992 we override the @code{X-extent} of all accidentals to zero and then move the
1993 accidentals to the left of the notes they modify.
1995 @lilypond[quote,verbatim,ragged-right]
1997 \set Score.proportionalNotationDuration = #(ly:make-moment 1 32)
1998 \override Accidental #'X-extent = #'(0 . 0)
1999 \override Accidental #'extra-offset = #'(-1 . 0)
2011 In addition to the settings given here, there are other settings that
2012 frequently appear in proportional scores. These include:
2015 @item @code{\override SpacingSpanner #'strict-grace-spacing = ##t}
2016 @item @code{tupletFullLength = ##t}
2017 @item @code{\override Beam #'breakable = ##t}
2018 @item @code{\override Glissando #'breakable = ##t}
2019 @item @code{\override TextSpanner #'breakable = ##t}
2020 @item @code{\remove Forbid_line_break_engraver in the Voice context}
2023 These settings space grace notes strictly, extend tuplet brackets to
2024 mark both rhythmic start- and stop-points, and allow spanning elements
2025 to break across systems and pages. See the respective parts of the manual
2026 for these related settings.