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}.
495 @code{layout-set-staff-size} does not change the distance between the
500 @subsection Score layout
504 While @code{\paper} contains settings that relate to the page formatting
505 of the whole document, @code{\layout} contains settings for score-specific
512 \override VerticalAxisGroup #'minimum-Y-extent = #'(-6 . 6)
515 \override TextScript #'padding = #1.0
516 \override Glissando #'thickness = #3
524 This manual: @ref{Changing context default settings}.
527 @node Displaying spacing
528 @section Displaying spacing
530 @funindex annotate-spacing
531 @cindex Spacing, display of properties
533 To graphically display the dimensions of vertical properties that may
534 be altered for page formatting, set @code{annotate-spacing} in the
535 @code{\paper} block, like this
538 @c need to have \book{} otherwise we get the separate systems. -hwn
540 #(set-default-paper-size "a6" 'landscape)
544 \paper { annotate-spacing = ##t }
549 @c TODO: really bad vagueness due to bug in annotate-spacing. -gp
551 Some unit dimensions are measured in staff spaces, while others
552 are measured in millimeters.
554 (@var{a},@var{b}) are intervals, where @var{a} is the lower edge and
555 @var{b} the upper edge of the interval.
564 * Optimal page breaking::
565 * Optimal page turning::
566 * Minimal page breaking::
568 * Using an extra voice for breaks::
572 @subsection Line breaking
575 @cindex breaking lines
577 Line breaks are normally computed automatically. They are chosen so
578 that lines look neither cramped nor loose, and that consecutive lines
579 have similar density.
581 Occasionally you might want to override the automatic breaks; you can
582 do this by specifying @code{\break}. This will force a line break at
583 this point. Line breaks can only occur at places where there are bar
584 lines. If you want to have a line break where there is no bar line,
585 you can force an invisible bar line by entering @code{\bar
586 ""}. Similarly, @code{\noBreak} forbids a line break at a
590 @cindex regular line breaks
591 @cindex four bar music.
593 For line breaks at regular intervals use @code{\break} separated by
594 skips and repeated with @code{\repeat}:
596 << \repeat unfold 7 @{
597 s1 \noBreak s1 \noBreak
598 s1 \noBreak s1 \break @}
599 @emph{the real music}
604 This makes the following 28 measures (assuming 4/4 time) be broken every
605 4 measures, and only there.
609 @code{\break}, and @code{\noBreak}.
615 Internals: @internalsref{LineBreakEvent}.
617 A linebreaking configuration can be saved as a @code{.ly} file
618 automatically. This allows vertical alignments to be stretched to
619 fit pages in a second formatting run. This is fairly new and
620 complicated. More details are available in
625 Line breaks can only occur if there is a @q{proper} bar line. A note
626 which is hanging over a bar line is not proper, such as
628 @lilypond[quote,ragged-right,relative=2,fragment,verbatim]
629 c4 c2 << c2 {s4 \break } >> % this does nothing
630 c2 c4 | % a break here would work
631 c4 c2 c4 ~ \break % as does this break
635 This can be avoided by removing the @code{Forbid_line_break_engraver}.
636 Note that manually forced line breaks have to be added in parallel
639 @lilypond[quote,ragged-right,verbatim]
641 \remove Forbid_line_break_engraver
643 c4 c2 << c2 {s4 \break } >> % now the break is allowed
648 Similarly, line breaks are normally forbidden when beams cross bar
649 lines. This behavior can be changed by setting
650 @code{\override Beam #'breakable = ##t}.
654 @subsection Page breaking
656 The default page breaking may be overriden by inserting
657 @code{\pageBreak} or @code{\noPageBreak} commands. These commands are
658 analogous to @code{\break} and @code{\noBreak}. They should be
659 inserted at a bar line. These commands force and forbid a page-break
660 from happening. Of course, the @code{\pageBreak} command also forces
663 The @code{\pageBreak} and @code{\noPageBreak} commands may also be
664 inserted at top-level, between scores and top-level markups.
666 Page breaks are computed by the @code{page-breaking} function. LilyPond
667 provides three algorithms for computing page breaks,
668 @code{ly:optimal-breaking}, @code{ly:page-turn-breaking} and
669 @code{ly:minimal-breaking}. The default is @code{ly:optimal-breaking},
670 but the value can be changed in the @code{\paper} block:
674 #(define page-breaking ly:page-turn-breaking)
678 The old page breaking algorithm is called
679 @code{optimal-page-breaks}. If you are having trouble with the new page
680 breakers, you can enable the old one as a workaround.
686 @funindex \noPageBreak
690 @node Optimal page breaking
691 @subsection Optimal page breaking
693 @funindex ly:optimal-breaking
695 The @code{ly:optimal-breaking} function is LilyPond's default method of
696 determining page breaks. It attempts to find a page breaking that minimizes
697 cramping and stretching, both horizontally and vertically. Unlike
698 @code{ly:page-turn-breaking}, it has no concept of page turns.
701 @node Optimal page turning
702 @subsection Optimal page turning
704 @funindex ly:page-turn-breaking
706 Often it is necessary to find a page breaking configuration so that there is
707 a rest at the end of every second page. This way, the musician can turn the
708 page without having to miss notes. The @code{ly:page-turn-breaking} function
709 attempts to find a page breaking minimizing cramping and stretching, but with
710 the additional restriction that it is only allowed to introduce page turns
713 There are two steps to using this page breaking function. First, you
714 must enable it in the @code{\paper} block, as explained in @ref{Page
715 breaking}. Then you must tell the function where you would like to allow
718 There are two ways to achieve the second step. First, you can specify each
719 potential page turn manually, by inserting @code{\allowPageTurn} into your
720 input file at the appropriate places.
722 If this is too tedious, you can add a @code{Page_turn_engraver} to a Staff or
723 Voice context. The @code{Page_turn_engraver} will scan the context for
724 sections without notes (note that it does not scan for rests; it scans for
725 the absence of notes. This is so that single-staff polyphony with rests in one
726 of the parts does not throw off the @code{Page_turn_engraver}). When it finds
727 a sufficiently long section without notes, the @code{Page_turn_engraver} will
728 insert an @code{\allowPageTurn} at the final bar line in that section, unless
729 there is a @q{special} bar line (such as a double bar), in which case the
730 @code{\allowPageTurn} will be inserted at the final @q{special} bar line in
733 @funindex minimumPageTurnLength
734 The @code{Page_turn_engraver} reads the context property
735 @code{minimumPageTurnLength} to determine how long a note-free section must
736 be before a page turn is considered. The default value for
737 @code{minimumPageTurnLength} is @code{#(ly:make-moment 1 1)}. If you want
738 to disable page turns, you can set it to something very large.
741 \new Staff \with @{ \consists "Page_turn_engraver" @}
744 R1 | % a page turn will be allowed here
746 \set Staff.minimumPageTurnLength = #(ly:make-moment 5 2)
747 R1 | % a page turn will not be allowed here
749 R1*2 | % a page turn will be allowed here
754 @funindex minimumRepeatLengthForPageTurn
755 The @code{Page_turn_engraver} detects volta repeats. It will only allow a page
756 turn during the repeat if there is enough time at the beginning and end of the
757 repeat to turn the page back. The @code{Page_turn_engraver} can also disable
758 page turns if the repeat is very short. If you set the context property
759 @code{minimumRepeatLengthForPageTurn} then the @code{Page_turn_engraver} will
760 only allow turns in repeats whose duration is longer than this value.
762 The page turning commands, @code{\pageTurn}, @code{\noPageTurn} and
763 @code{\allowPageTurn}, may also be used at top-level, between scores and
770 @funindex \noPageTurn
772 @funindex \allowPageTurn
773 @code{\allowPageTurn}
777 There should only be one @code{Page_turn_engraver} in a score. If there is more
778 than one, they will interfere with each other.
780 @node Minimal page breaking
781 @subsection Minimal page breaking
783 @funindex ly:minimal-breaking
785 The @code{ly:minimal-breaking} function performs minimal computations to
786 calculate the page breaking: it fills a page with as many systems as
787 possible before moving to the next one. Thus, it may be prefered for
788 scores with many pages, where the other page breaking functions could be
789 too slow or memory demanding, or a lot of texts. It is enabled using:
793 #(define page-breaking ly:minimal-breaking)
797 @node Explicit breaks
798 @subsection Explicit breaks
800 Lily sometimes rejects explicit @code{\break} and @code{\pageBreak}
801 commands. There are two commands to override this behavior:
804 \override NonMusicalPaperColumn #'line-break-permission = ##f
805 \override NonMusicalPaperColumn #'page-break-permission = ##f
808 When @code{line-break-permission} is overriden to false, Lily will insert
809 line breaks at explicit @code{\break} commands and nowhere else. When
810 @code{page-break-permission} is overriden to false, Lily will insert
811 page breaks at explicit @code{\pageBreak} commands and nowhere else.
813 @lilypond[quote,verbatim]
822 \override NonMusicalPaperColumn #'line-break-permission = ##f
823 \override NonMusicalPaperColumn #'page-break-permission = ##f
826 \repeat unfold 2 { c'8 c'8 c'8 c'8 } \break
827 \repeat unfold 4 { c'8 c'8 c'8 c'8 } \break
828 \repeat unfold 6 { c'8 c'8 c'8 c'8 } \break
829 \repeat unfold 8 { c'8 c'8 c'8 c'8 } \pageBreak
830 \repeat unfold 8 { c'8 c'8 c'8 c'8 } \break
831 \repeat unfold 6 { c'8 c'8 c'8 c'8 } \break
832 \repeat unfold 4 { c'8 c'8 c'8 c'8 } \break
833 \repeat unfold 2 { c'8 c'8 c'8 c'8 }
840 @node Using an extra voice for breaks
841 @subsection Using an extra voice for breaks
843 Line- and page-breaking information usually appears within note entry directly.
848 \repeat unfold 2 @{ c'4 c'4 c'4 c'4 @}
850 \repeat unfold 3 @{ c'4 c'4 c'4 c'4 @}
855 This makes @code{\break} and @code{\pageBreak} commands easy to enter but mixes
856 music entry with information that specifies how music should lay out
857 on the page. You can keep music entry and line- and page-breaking
858 information in two separate places by introducing an extra voice to
859 contain the breaks. This extra voice
860 contains only skips together with @code{\break}, @code{pageBreak} and other
861 breaking layout information.
863 @lilypond[quote,verbatim]
873 \repeat unfold 2 { c'4 c'4 c'4 c'4 }
874 \repeat unfold 3 { c'4 c'4 c'4 c'4 }
875 \repeat unfold 6 { c'4 c'4 c'4 c'4 }
876 \repeat unfold 5 { c'4 c'4 c'4 c'4 }
882 This pattern becomes especially helpful when overriding
883 @code{line-break-system-details} and the other useful but long properties of
884 @code{NonMusicalPaperColumnGrob}, as explained in @ref{Vertical spacing}.
886 @lilypond[quote,verbatim]
891 \overrideProperty "Score.NonMusicalPaperColumn"
892 #'line-break-system-details #'((Y-offset . 0))
895 \overrideProperty "Score.NonMusicalPaperColumn"
896 #'line-break-system-details #'((Y-offset . 35))
899 \overrideProperty "Score.NonMusicalPaperColumn"
900 #'line-break-system-details #'((Y-offset . 70))
903 \overrideProperty "Score.NonMusicalPaperColumn"
904 #'line-break-system-details #'((Y-offset . 105))
908 \repeat unfold 2 { c'4 c'4 c'4 c'4 }
909 \repeat unfold 3 { c'4 c'4 c'4 c'4 }
910 \repeat unfold 6 { c'4 c'4 c'4 c'4 }
911 \repeat unfold 5 { c'4 c'4 c'4 c'4 }
918 @node Vertical spacing
919 @section Vertical spacing
921 @cindex vertical spacing
922 @cindex spacing, vertical
924 Vertical spacing is controlled by three things: the amount of
925 space available (i.e., paper size and margins), the amount of
926 space between systems, and the amount of space between
927 staves inside a system.
930 * Vertical spacing inside a system::
931 * Vertical spacing between systems::
932 * Explicit staff and system positioning::
933 * Two-pass vertical spacing::
934 * Vertical collision avoidance::
938 @node Vertical spacing inside a system
939 @subsection Vertical spacing inside a system
941 @cindex distance between staves
942 @cindex staff distance
943 @cindex space between staves
944 @cindex space inside systems
946 The height of each system is determined automatically. To prevent
947 staves from bumping into each other, some minimum distances are set.
948 By changing these, you can put staves closer together. This
949 reduces the amount of space each system requires, and may result
950 in having more systems per page.
952 Normally staves are stacked vertically. To make staves maintain a
953 distance, their vertical size is padded. This is done with the
954 property @code{minimum-Y-extent}. When applied to a
955 @internalsref{VerticalAxisGroup}, it controls the size of a horizontal
956 line, such as a staff or a line of lyrics. @code{minimum-Y-extent}
957 takes a pair of numbers, so
958 if you want to make it smaller than its default @code{#'(-4 . 4)}
962 \override Staff.VerticalAxisGroup #'minimum-Y-extent = #'(-3 . 3)
966 This sets the vertical size of the current staff to 3 staff spaces on
967 either side of the center staff line. The value @code{(-3 . 3)} is
968 interpreted as an interval, where the center line is the 0, so the
969 first number is generally negative. The numbers need not match;
970 for example, the staff can be made larger at the bottom by setting
971 it to @code{(-6 . 4)}.
973 After page breaks are determined, the vertical spacing within each
974 system is reevaluated in order to fill the page more evenly; if a page
975 has space left over, systems are stretched in order to fill that space.
976 The amount of stretching can be configured though the @code{max-stretch}
977 property of the @internalsref{VerticalAlignment} grob. By default,
978 @code{max-stretch} is set to zero, disabling stretching. To enable
979 stretching, a sane value for @code{max-stretch}
980 is @code{ly:align-interface::calc-max-stretch}.
982 In some situations, you may want to stretch most of a system while
983 leaving some parts fixed. For example, if a piano part occurs in the
984 middle of an orchestral score, you may want to leave the piano staves
985 close to each other while stretching the rest of the score. The
986 @code{keep-fixed-while-stretching} property of
987 @internalsref{VerticalAxisGroup} can be used to achieve this. When set
988 to @code{##t}, this property keeps its staff (or line of lyrics) from
989 moving relative to the one directly above it. In the example above,
990 you would override @code{keep-fixed-while-stretching} to @code{##t} in
991 the second piano staff:
994 #(set-default-paper-size "a6")
995 #(set-global-staff-size 14.0)
999 ragged-last-bottom = ##f
1004 \override VerticalAlignment #'max-stretch = #ly:align-interface::calc-max-stretch
1011 \new Staff {c' d' e' f'}
1012 \new Staff {c' d' e' f'}
1013 \new Staff {c' d' e' f'}
1018 \new Staff {c' d' e' f'}
1020 \override VerticalAxisGroup #'keep-fixed-while-stretching = ##t
1027 \new Staff {c' d' e' f'}
1028 \new Staff {c' d' e' f'}
1037 Internals: Vertical alignment of staves is handled by the
1038 @internalsref{VerticalAlignment} object. The context parameters
1039 specifying the vertical extent are described in connection with
1040 the @internalsref{Axis_group_engraver}.
1042 Example files: @lsr{spacing,page-spacing.ly},
1043 @lsr{spacing,alignment-vertical-spacing.ly}.
1046 @node Vertical spacing between systems
1047 @subsection Vertical spacing between systems
1049 Space between systems are controlled by four @code{\paper} variables,
1053 between-system-space = 1.5\cm
1054 between-system-padding = #1
1056 ragged-last-bottom=##f
1060 When only a couple of flat systems are placed on a page, the resulting
1061 vertical spacing may be non-eleguant: one system at the top of the page,
1062 and the other at the bottom, with a huge gap between them. To avoid this
1063 situation, the space added between the systems can be limited. This
1064 feature is activated by setting to @code{#t} the
1065 @code{page-limit-inter-system-space} variable in the @code{\paper}
1066 block. The paper variable @code{page-limit-inter-system-space-factor}
1067 determines how much the space can be increased: for instance, the value
1068 @code{1.3} means that the space can be 30% larger than what it would be
1069 on a ragged-bottom page.
1071 In the following example, if the inter system space were not limited,
1072 the second system of page 1 would be placed at the page bottom. By
1073 activating the space limitation, the second system is placed closer to
1074 the first one. By setting @code{page-limit-inter-system-space-factor} to
1075 @code{1}, the spacing would the same as on a ragged-bottom page, like
1079 #(set-default-paper-size "a6")
1082 page-limit-inter-system-space = ##t
1083 page-limit-inter-system-space-factor = 1.3
1085 oddFooterMarkup = \markup "page bottom"
1086 evenFooterMarkup = \markup "page bottom"
1087 oddHeaderMarkup = \markup \fill-line {
1088 "page top" \fromproperty #'page:page-number-string }
1089 evenHeaderMarkup = \markup \fill-line {
1090 "page top" \fromproperty #'page:page-number-string }
1092 \new Staff << \repeat unfold 4 { g'4 g' g' g' \break }
1093 { s1*2 \pageBreak } >>
1097 @node Explicit staff and system positioning
1098 @subsection Explicit staff and system positioning
1100 One way to understand the @code{VerticalAxisGroup} and @code{\paper}
1101 settings explained in the previous two sections is as a collection of
1102 different settings that primarily concern the amount of vertical padding
1103 different staves and systems running down the page.
1105 It is possible to approach vertical spacing in a different way using
1106 @code{NonMusicalPaperColumn #'line-break-system-details}. Where
1107 @code{VerticalAxisGroup} and @code{\paper} settings specify vertical padding,
1108 @code{NonMusicalPaperColumn #'line-break-system-details} specifies exact
1109 vertical positions on the page.
1111 @code{NonMusicalPaperColumn #'line-break-system-details} accepts an associative
1112 list of five different settings:
1115 @item @code{X-offset}
1116 @item @code{Y-offset}
1117 @item @code{alignment-offsets}
1118 @item @code{alignment-extra-space}
1119 @item @code{fixed-alignment-extra-space}
1122 Grob overrides, including the overrides for @code{NonMusicalPaperColumn}
1123 below, can occur in any of three different places in an input file:
1126 @item in the middle of note entry directly
1127 @item in a @code{\context} block
1128 @item in the @code{\with} block
1131 When we override @code{NonMusicalPaperColumn}, we use the usual
1132 @code{\override} command in @code{\context} blocks and in the
1133 @code{\with} block. On the other hand, when we override
1134 @code{NonMusicalPaperColumn} in the middle of note entry,
1135 use the special @code{\overrideProperty} command. Here are some
1136 example @code{NonMusicalPaperColumn} overrides with the special
1137 @code{\overrideProperty} command:
1140 \overrideProperty NonMusicalPaperColumn
1141 #'line-break-system-details #'((X-offset . 20))
1143 \overrideProperty NonMusicalPaperColumn
1144 #'line-break-system-details #'((Y-offset . 40))
1146 \overrideProperty NonMusicalPaperColumn
1147 #'line-break-system-details #'((X-offset . 20) (Y-offset . 40))
1149 \override NonMusicalPaperColumn
1150 #'line-break-system-details #'((alignment-offsets . (0 -15)))
1152 \override NonMusicalPaperColumn
1153 #'line-break-system-details #'((X-offset . 20) (Y-offset . 40)
1154 (alignment-offsets . (0 -15)))
1157 To understand how each of these different settings work, we begin
1158 by looking at an example that includes no overrides at all.
1160 @lilypond[quote,ragged-right]
1168 \new Voice { \repeat unfold 18 { c'4 c'4 c'4 c'4 } }
1171 \repeat unfold 18 { d'4 d'4 d'4 d'4 }
1176 This score isolates line- and page-breaking information in a dedicated
1177 voice. This technique of creating a breaks voice will help keep layout
1178 separate from music entry as our example becomes more complicated.
1179 See @ref{Using an extra voice for breaks}.
1181 Explicit @code{\breaks} evenly divide the music into six measures per
1182 line. Vertical spacing results from LilyPond's defaults. To set
1183 the vertical startpoint of each system explicitly, we can set
1184 the @code{Y-offset} pair in the @code{line-break-system-details}
1185 attribute of the @code{NonMusicalPaperColumn} grob:
1187 @lilypond[quote,ragged-right]
1191 \overrideProperty #"Score.NonMusicalPaperColumn"
1192 #'line-break-system-details #'((Y-offset . 0))
1194 \overrideProperty #"Score.NonMusicalPaperColumn"
1195 #'line-break-system-details #'((Y-offset . 40))
1197 \overrideProperty #"Score.NonMusicalPaperColumn"
1198 #'line-break-system-details #'((Y-offset . 80))
1201 \new Voice { \repeat unfold 18 { c'4 c'4 c'4 c'4 } }
1204 \repeat unfold 18 { d'4 d'4 d'4 d'4 }
1209 Note that @code{line-break-system-details} takes an associative list of
1210 potentially many values, but that we set only one value here. Note,
1211 too, that the @code{Y-offset} property here determines the exact vertical
1212 position on the page at which each new system will render.
1214 Now that we have set the vertical startpoint of each system
1215 explicitly, we can also set the vertical startpoint of each staff
1216 within each system manually. We do this using the @code{alignment-offsets}
1217 subproperty of @code{line-break-system-details}.
1219 @lilypond[quote,ragged-right]
1223 \overrideProperty #"Score.NonMusicalPaperColumn"
1224 #'line-break-system-details #'((Y-offset . 20)
1225 (alignment-offsets . (0 -15)))
1227 \overrideProperty #"Score.NonMusicalPaperColumn"
1228 #'line-break-system-details #'((Y-offset . 60)
1229 (alignment-offsets . (0 -15)))
1231 \overrideProperty #"Score.NonMusicalPaperColumn"
1232 #'line-break-system-details #'((Y-offset . 100)
1233 (alignment-offsets . (0 -15)))
1236 \new Voice { \repeat unfold 18 { c'4 c'4 c'4 c'4 } }
1239 \repeat unfold 18 { d'4 d'4 d'4 d'4 }
1244 Note that here we assign two different values to the
1245 @code{line-break-system-details} attribute of the
1246 @code{NonMusicalPaperColumn} grob. Though the
1247 @code{line-break-system-details} attribute alist accepts many
1248 additional spacing parameters (including, for example, a corresponding
1249 @code{X-offset} pair), we need only set the @code{Y-offset} and
1250 @code{alignment-offsets} pairs to control the vertical startpoint of
1251 every system and every staff. Finally, note that @code{alignment-offsets}
1252 specifies the vertical positioning of staves but not of staff groups.
1254 @lilypond[quote,ragged-right]
1258 \overrideProperty #"Score.NonMusicalPaperColumn"
1259 #'line-break-system-details #'((Y-offset . 0)
1260 (alignment-offsets . (0 -30 -40)))
1262 \overrideProperty #"Score.NonMusicalPaperColumn"
1263 #'line-break-system-details #'((Y-offset . 60)
1264 (alignment-offsets . (0 -10 -20)))
1266 \overrideProperty #"Score.NonMusicalPaperColumn"
1267 #'line-break-system-details #'((Y-offset . 100)
1268 (alignment-offsets . (0 -10, -40)))
1271 \new Voice { \repeat unfold 18 { c'4 c'4 c'4 c'4 } }
1275 \repeat unfold 18 { d'4 d'4 d'4 d'4 }
1278 \repeat unfold 18 { e'4 e'4 e'4 e'4 }
1284 Some points to consider:
1287 @item When using @code{alignment-offsets}, lyrics count as a staff.
1289 @item The units of the numbers passed to @code{X-offset},
1290 @code{Y-offset} and @code{alignment-offsets} are interpreted as multiples
1291 of the distance between adjacent staff lines. Positive values move staves
1292 and lyrics up, negative values move staves and lyrics down.
1294 @item Because the @code{NonMusicalPaperColumn #'line-break-system-details}
1295 settings given here allow the positioning of staves and systems anywhere
1296 on the page, it is possible to violate paper or margin boundaries or even
1297 to print staves or systems on top of one another. Reasonable values
1298 passed to these different settings will avoid this.
1302 @node Two-pass vertical spacing
1303 @subsection Two-pass vertical spacing
1305 Warning: two-pass vertical spacing is deprecated and will be removed in
1306 a future version of LilyPond. Systems are now stretched automatically
1307 in a single pass. See @ref{Vertical spacing inside a system}.
1309 In order to automatically stretch systems so that they should fill the
1310 space left on a page, a two-pass technique can be used:
1313 @item In the first pass, the amount of vertical space used to increase
1314 the height of each system is computed and dumped to a file.
1315 @item In the second pass, spacing inside the systems are
1316 stretched according to the data in the page layout file.
1319 The @code{ragged-bottom} property adds space between systems, while
1320 the two-pass technique adds space between staves inside a system.
1322 To allow this behaviour, a @code{tweak-key} variable has to be set in
1323 each score @code{\layout} block, and the tweaks included in each score
1324 music, using the @code{\scoreTweak} music function.
1328 %% include the generated page layout file:
1329 \includePageLayoutFile
1334 %% Include this score tweaks:
1335 \scoreTweak "scoreA"
1336 { \clef french c''1 \break c''1 }
1338 \new Staff { \clef soprano g'1 g'1 }
1339 \new Staff { \clef mezzosoprano e'1 e'1 }
1340 \new Staff { \clef alto g1 g1 }
1341 \new Staff { \clef bass c1 c1 }
1344 piece = "Score with tweaks"
1346 %% Define how to name the tweaks for this score:
1347 \layout { #(define tweak-key "scoreA") }
1352 For the first pass, the @code{dump-tweaks} option should be set to
1353 generate the page layout file.
1356 lilypond -dbackend=null -d dump-tweaks <file>.ly
1361 @node Vertical collision avoidance
1362 @subsection Vertical collision avoidance
1364 @funindex outside-staff-priority
1365 @funindex outside-staff-padding
1366 @funindex outside-staff-horizontal-padding
1368 Intuitively, there are some objects in musical notation that belong
1369 to the staff and there are other objects that should be placed outside
1370 the staff. Objects belonging outside the staff include things such as
1371 rehearsal marks, text and dynamic markings (from now on, these will
1372 be called outside-staff objects). LilyPond's rule for the
1373 vertical placement of outside-staff objects is to place them as close
1374 to the staff as possible but not so close that they collide with
1377 LilyPond uses the @code{outside-staff-priority} property to determine
1378 whether a grob is an outside-staff object: if @code{outside-staff-priority}
1379 is a number, the grob is an outside-staff object. In addition,
1380 @code{outside-staff-priority} tells LilyPond in which order the objects
1383 First, LilyPond places all the objects that do not belong outside
1384 the staff. Then it sorts the outside-staff objects according to their
1385 @code{outside-staff-priority} (in increasing order). One by one, LilyPond
1386 takes the outside-staff objects and places them so that they do
1387 not collide with any objects that have already been placed. That
1388 is, if two outside-staff grobs are competing for the same space, the one
1389 with the lower @code{outside-staff-priority} will be placed closer to
1392 @lilypond[quote,ragged-right,relative=2,fragment,verbatim]
1395 \once \override TextScript #'outside-staff-priority = #1
1396 c4_"Text"\pp % this time the text will be closer to the staff
1398 % by setting outside-staff-priority to a non-number, we
1399 % disable the automatic collision avoidance
1400 \once \override TextScript #'outside-staff-priority = ##f
1401 \once \override DynamicLineSpanner #'outside-staff-priority = ##f
1402 c4_"Text"\pp % now they will collide
1405 The vertical padding between an outside-staff object and the
1406 previously-positioned grobs can be controlled with
1407 @code{outside-staff-padding}.
1409 @lilypond[quote,ragged-right,relative=2,fragment,verbatim]
1410 \once \override TextScript #'outside-staff-padding = #0
1411 a'^"This text is placed very close to the note"
1412 \once \override TextScript #'outside-staff-padding = #3
1413 c^"This text is padded away from the previous text"
1414 c^"This text is placed close to the previous text"
1417 TODO: this example doesn't work any more ?
1419 By default, outside-staff objects are placed without regard to
1420 their horizontal distance from the previously-posititioned grobs. This
1421 can lead to situations in which objects are placed very close to each
1422 other horizontally. Setting @code{outside-staff-horizontal-padding}
1423 causes an object to be offset vertically so that such a situation
1426 @lilypond[quote,ragged-right,relative=2,fragment,verbatim]
1427 % the markup is too close to the following note
1430 % setting outside-staff-horizontal-padding fixes this
1432 \once \override TextScript #'outside-staff-horizontal-padding = #1
1439 @node Horizontal spacing
1440 @section Horizontal Spacing
1442 @cindex horizontal spacing
1443 @cindex spacing, horizontal
1446 * Horizontal spacing overview::
1447 * New spacing area::
1448 * Changing horizontal spacing::
1450 * Proportional notation::
1454 @node Horizontal spacing overview
1455 @subsection Horizontal spacing overview
1457 The spacing engine translates differences in durations into stretchable
1458 distances (@q{springs}) of differring lengths. Longer durations get
1459 more space, shorter durations get less. The shortest durations get a
1460 fixed amount of space (which is controlled by
1461 @code{shortest-duration-space} in the @internalsref{SpacingSpanner}
1462 object). The longer the duration, the more space it gets: doubling a
1463 duration adds a fixed amount (this amount is controlled by
1464 @code{spacing-increment}) of space to the note.
1466 For example, the following piece contains lots of half, quarter, and
1467 8th notes; the eighth note is followed by 1 note head width (NHW).
1468 The quarter note is followed by 2 NHW, the half by 3 NHW, etc.
1470 @lilypond[quote,fragment,verbatim,relative=1]
1471 c2 c4. c8 c4. c8 c4. c8 c8
1475 Normally, @code{spacing-increment} is set to 1.2 staff space, which is
1476 approximately the width of a note head, and
1477 @code{shortest-duration-space} is set to 2.0, meaning that the
1478 shortest note gets 2.4 staff space (2.0 times the
1479 @code{spacing-increment}) of horizontal space. This space is counted
1480 from the left edge of the symbol, so the shortest notes are generally
1481 followed by one NHW of space.
1483 If one would follow the above procedure exactly, then adding a single
1484 32nd note to a score that uses 8th and 16th notes, would widen up the
1485 entire score a lot. The shortest note is no longer a 16th, but a 32nd,
1486 thus adding 1 NHW to every note. To prevent this, the shortest
1487 duration for spacing is not the shortest note in the score, but rather
1488 the one which occurs most frequently.
1491 The most common shortest duration is determined as follows: in every
1492 measure, the shortest duration is determined. The most common shortest
1493 duration is taken as the basis for the spacing, with the stipulation
1494 that this shortest duration should always be equal to or shorter than
1495 an 8th note. The shortest duration is printed when you run
1496 @code{lilypond} with the @code{--verbose} option.
1498 These durations may also be customized. If you set the
1499 @code{common-shortest-duration} in @internalsref{SpacingSpanner}, then
1500 this sets the base duration for spacing. The maximum duration for this
1501 base (normally an 8th), is set through @code{base-shortest-duration}.
1503 @funindex common-shortest-duration
1504 @funindex base-shortest-duration
1505 @funindex stem-spacing-correction
1508 Notes that are even shorter than the common shortest note are
1509 followed by a space that is proportional to their duration relative to
1510 the common shortest note. So if we were to add only a few 16th notes
1511 to the example above, they would be followed by half a NHW:
1513 @lilypond[quote,fragment,verbatim,relative=2]
1514 c2 c4. c8 c4. c16[ c] c4. c8 c8 c8 c4 c4 c4
1518 In the introduction (see @rlearning{Engraving}), it was explained that stem
1519 directions influence spacing. This is controlled with the
1520 @code{stem-spacing-correction} property in the
1521 @internalsref{NoteSpacing}, object. These are generated for every
1522 @internalsref{Voice} context. The @code{StaffSpacing} object
1523 (generated in @internalsref{Staff} context) contains the same property
1524 for controlling the stem/bar line spacing. The following example shows
1525 these corrections, once with default settings, and once with
1526 exaggerated corrections:
1528 @lilypond[quote,ragged-right]
1532 \override Staff.NoteSpacing #'stem-spacing-correction = #1.5
1533 \override Staff.StaffSpacing #'stem-spacing-correction = #1.5
1539 Proportional notation is supported; see @ref{Proportional notation}.
1544 Internals: @internalsref{SpacingSpanner}, @internalsref{NoteSpacing},
1545 @internalsref{StaffSpacing}, @internalsref{SeparationItem}, and
1546 @internalsref{SeparatingGroupSpanner}.
1551 There is no convenient mechanism to manually override spacing. The
1552 following work-around may be used to insert extra space into a score.
1554 \once \override Score.SeparationItem #'padding = #1
1557 No work-around exists for decreasing the amount of space.
1560 @node New spacing area
1561 @subsection New spacing area
1563 New sections with different spacing parameters can be started with
1564 @code{newSpacingSection}. This is useful when there are
1565 sections with a different notions of long and short notes.
1567 In the following example, the time signature change introduces a new
1568 section, and hence the 16ths notes are spaced wider.
1570 @lilypond[relative,fragment,verbatim,quote]
1573 c8 c c4 c16[ c c8] c4
1580 The @code{\newSpacingSection} command creates a new
1581 @internalsref{SpacingSpanner} object, and hence new @code{\override}s
1582 may be used in that location.
1585 @node Changing horizontal spacing
1586 @subsection Changing horizontal spacing
1588 Horizontal spacing may be altered with the
1589 @code{base-shortest-duration} property. Here
1590 we compare the same music; once without altering
1591 the property, and then altered. Larger values
1592 of @code{ly:make-moment} will produce smaller
1593 music. Note that @code{ly:make-moment} constructs
1594 a duration, so @code{1 4} is a longer duration
1597 @lilypond[relative,verbatim,line-width=12\cm]
1600 g4 e e2 | f4 d d2 | c4 d e f | g4 g g2 |
1601 g4 e e2 | f4 d d2 | c4 e g g | c,1 |
1602 d4 d d d | d4 e f2 | e4 e e e | e4 f g2 |
1603 g4 e e2 | f4 d d2 | c4 e g g | c,1 |
1608 @lilypond[relative,verbatim,line-width=12\cm]
1611 g4 e e2 | f4 d d2 | c4 d e f | g4 g g2 |
1612 g4 e e2 | f4 d d2 | c4 e g g | c,1 |
1613 d4 d d d | d4 e f2 | e4 e e e | e4 f g2 |
1614 g4 e e2 | f4 d d2 | c4 e g g | c,1 |
1619 \override SpacingSpanner
1620 #'base-shortest-duration = #(ly:make-moment 1 16)
1629 By default, spacing in tuplets depends on various non-duration
1630 factors (such as accidentals, clef changes, etc). To disregard
1631 such symbols and force uniform equal-duration spacing, use
1632 @code{Score.SpacingSpanner #'uniform-stretching}. This
1633 property can only be changed at the beginning of a score,
1635 @lilypond[quote,ragged-right,relative=2,fragment,verbatim]
1637 \override SpacingSpanner #'uniform-stretching = ##t
1655 When @code{strict-note-spacing} is set, notes are spaced without
1656 regard for clefs, bar lines, and grace notes,
1658 @lilypond[quote,ragged-right,relative=2,fragment,verbatim]
1659 \override Score.SpacingSpanner #'strict-note-spacing = ##t
1660 \new Staff { c8[ c \clef alto c \grace { c16[ c] } c8 c c] c32[ c32] }
1665 @subsection Line length
1668 @cindex breaking pages
1671 @funindex line-width
1672 @funindex ragged-right
1673 @funindex ragged-last
1675 @c Although line-width can be set in \layout, it should be set in paper
1676 @c block, to get page layout right.
1677 @c Setting indent in \paper block makes not much sense, but it works.
1679 @c Bit verbose and vague, use examples?
1680 The most basic settings influencing the spacing are @code{indent} and
1681 @code{line-width}. They are set in the @code{\layout} block. They
1682 control the indentation of the first line of music, and the lengths of
1685 If @code{ragged-right} is set to true in the @code{\layout} block, then
1686 systems ends at their natural horizontal length, instead of being spread
1687 horizontally to fill the whole line. This is useful for
1688 short fragments, and for checking how tight the natural spacing is.
1691 @cindex vertical spacing
1693 The option @code{ragged-last} is similar to @code{ragged-right}, but
1694 only affects the last line of the piece. No restrictions are put on
1695 that line. The result is similar to formatting text paragraphs. In a
1696 paragraph, the last line simply takes its natural horizontal length.
1697 @c Note that for text there are several options for the last line.
1698 @c While Knuth TeX uses natural length, lead typesetters use the same
1699 @c stretch as the previous line. eTeX uses \lastlinefit to
1700 @c interpolate between both these solutions.
1711 @node Proportional notation
1712 @subsection Proportional notation
1714 LilyPond supports proportional notation, a type of horizontal spacing
1715 in which each note consumes an amount of horizontal space exactly
1716 equivalent to its rhythmic duration. This type of proportional spacing
1717 is comparable to horizontal spacing on top of graph paper. Some late
1718 20th- and early 21st-century scores use proportional notation to
1719 clarify complex rhythmic relationships or to faciliate the placement
1720 of timelines or other graphics directly in the score.
1722 LilyPond supports five different settings for proportional notation,
1723 which may be used together or alone:
1726 @item @code{proportionalNotationDuration}
1727 @item @code{uniform-stretching}
1728 @item @code{strict-note-spacing}
1729 @item @code{\remove Separating_line_group_engraver}
1730 @item @code{\override PaperColumn #'used = ##t}
1733 In the examples that follow, we explore these five different
1734 proportional notation settings and examine how these settings interact.
1736 We start with the following one-measure example, which uses classical
1737 spacing with ragged-right turned on.
1739 @lilypond[quote,verbatim,ragged-right]
1741 \new RhythmicStaff {
1745 c'16 c'16 c'16 c'16 c'16
1751 Notice that the half note which begins the measure takes up far less
1752 than half of the horizontal space of the measure. Likewise, the
1753 sixteenth notes and sixteenth-note quintuplets (or twentieth notes)
1754 which end the measure together take up far more than half the
1755 horizontal space of the measure.
1757 In classical engraving, this spacing may be exactly what we want
1758 because we can borrow horizontal space from the half note and conserve
1759 horizontal space across the measure as a whole.
1761 On the other hand, if we want to insert a measured timeline or other
1762 graphic above or below our score, we need proportional notation. We
1763 turn proportional notation on with the proportionalNotationDuration
1766 @lilypond[quote,verbatim,ragged-right]
1768 proportionalNotationDuration = #(ly:make-moment 1 20)
1770 \new RhythmicStaff {
1774 c'16 c'16 c'16 c'16 c'16
1780 The half note at the beginning of the measure and the faster notes in
1781 the second half of the measure now occupy equal amounts of horizontal
1782 space. We could place a measured timeline or graphic above or below
1785 The @code{proportionalNotationDuration} setting is a context setting that
1786 lives in @code{Score}. Recall that context settings appear in one of
1787 three locations in our input file -- in a @code{\with} block, in a
1788 @code{\context} block, or directly in music entry
1789 preceeded by the @code{\set} command. As with all
1790 context settings, users can pick which of the three different
1791 locations they would like to set @code{proportionalNotationDuration}.
1793 The @code{proportionalNotationDuration} setting takes a single argument,
1794 which is the reference duration against which all music will be
1795 spaced. The LilyPond Scheme function make-moment takes two arguments
1796 -- a numerator and denominator which together express some fraction of
1797 a whole note. The call @code{#(ly:make-moment 1 20)} therefore produces a
1798 reference duration of a twentieth note. The values
1799 @code{#(ly:make-moment 1 16)}, @code{#(ly:make-moment 1 8)}, and
1800 @code{#(ly:make-moment 3 97)} are all possible as well.
1802 How do we select the right reference duration to pass to
1803 @code{proportionalNotationDuration}? Usually by a process of trial and error,
1804 beginning with a duration close to the fastest (or smallest) duration
1805 in the piece. Smaller reference durations space music loosely; larger
1806 reference durations space music tightly.
1808 @lilypond[quote,verbatim,ragged-right]
1810 proportionalNotationDuration = #(ly:make-moment 1 8)
1812 \new RhythmicStaff {
1816 c'16 c'16 c'16 c'16 c'16
1822 proportionalNotationDuration = #(ly:make-moment 1 16)
1824 \new RhythmicStaff {
1828 c'16 c'16 c'16 c'16 c'16
1834 proportionalNotationDuration = #(ly:make-moment 1 32)
1836 \new RhythmicStaff {
1840 c'16 c'16 c'16 c'16 c'16
1846 Note that too large a reference duration -- such as the eighth note,
1847 above -- spaces music too tightly and can cause note head collisions.
1848 Note also that proportional notation in general takes up more
1849 horizontal space that does classical spacing. Proportional spacing
1850 provides rhythmic clarity at the expense of horizontal space.
1852 Next we examine how to optimally space overlapping tuplets.
1854 We start by examining what happens to our original example, with
1855 classical spacing, when we add a second staff with a different type of
1858 @lilypond[quote,verbatim,ragged-right]
1860 \new RhythmicStaff {
1864 c'16 c'16 c'16 c'16 c'16
1867 \new RhythmicStaff {
1869 c'8 c'8 c'8 c'8 c'8 c'8 c'8 c'8 c'8
1875 The spacing is bad because the evenly notes of the bottom staff do not
1876 stretch uniformly. Classical engraving includes very few complex
1877 triplets and so classical engraving rules can generate this type of
1878 result. Setting @code{proportionalNotationDuration} remedies this
1879 situation considerably.
1881 @lilypond[quote,verbatim,ragged-right]
1883 proportionalNotationDuration = #(ly:make-moment 1 20)
1885 \new RhythmicStaff {
1889 c'16 c'16 c'16 c'16 c'16
1892 \new RhythmicStaff {
1894 c'8 c'8 c'8 c'8 c'8 c'8 c'8 c'8 c'8
1900 But if we look very carefully we can see that notes of the second half
1901 of the 9-tuplet space ever so slightly more widely than do the notes
1902 of the first half of the 9-tuplet. To ensure uniform stretching, we
1903 turn on @code{uniform-stretching}, which is a property of
1904 @code{SpacingSpanner}.
1906 @lilypond[quote,verbatim,ragged-right]
1908 proportionalNotationDuration = #(ly:make-moment 1 20)
1909 \override SpacingSpanner #'uniform-stretching = ##t
1911 \new RhythmicStaff {
1915 c'16 c'16 c'16 c'16 c'16
1918 \new RhythmicStaff {
1920 c'8 c'8 c'8 c'8 c'8 c'8 c'8 c'8 c'8
1926 Our two-staff example now spaces exactly, our rhythmic
1927 relationships are visually clear, and we can include a measured
1928 timeline or graphic if we want.
1930 Note that the LilyPond's proportional notation package expects
1931 that all proportional scores set the SpacingSpanner's
1932 'uniform-stretching attribute to ##t. Setting
1933 proportionalNotationDuration without also setting the
1934 SpacingSpanner's 'uniform-stretching attribute to ##t will, for
1935 example, cause Skips to consume an incorrect amount of horizontal
1938 The SpacingSpanner is an abstract grob that lives in the Score
1939 context. As with our settings of proportionalNotationDuration,
1940 overrides to the SpacingSpanner can occur in any of three
1941 different places in our input file – in the Score \with block, in
1942 a Score \context block, or in note entry directly.
1944 There is by default only one @code{SpacingSpanner} per @code{Score}. This
1945 means that, by default, @code{uniform-stretching} is either turned on for the
1946 entire score or turned off for the entire score. We can, however,
1947 override this behavior and turn on different spacing features at
1948 different places in the score. We do this with the command
1949 @code{\newSpacingSection}. See @ref{New spacing area}, for more info.
1951 Next we examine the effects of the @code{Separating_line_group_engraver} and
1952 see why proportional scores frequently remove this engraver. The following
1953 example shows that there is a small amount of @qq{preferatory} space
1954 just before the first note in each system.
1956 @lilypond[quote,verbatim,ragged-right]
1969 The amount of this preferatory space is the same whether after a time
1970 signature, a key signature or a clef. @code{Separating_line_group_engraver}
1971 is responsible for this space. Removing @code{Separating_line_group_engraver}
1972 reduces this space to zero.
1974 @lilypond[quote,verbatim,ragged-right]
1980 \remove Separating_line_group_engraver
1988 Nonmusical elements like time signatures, key signatures, clefs and
1989 accidentals are problemmatic in proportional notation. None of these
1990 elements has rhythmic duration. But all of these elements consume
1991 horizontal space. Different proportional scores approach these
1992 problems differently.
1994 It may be possible to avoid spacing problems with key signatures
1995 simply by not having any. This is a valid option since most
1996 proportional scores are contemporary music. The same may be true
1997 of time signatures, especially for those scores
1998 that include a measured timeline or other graphic. But these scores
1999 are exceptional and most proportional scores include at least some
2000 time signatures. Clefs and accidentals are even more essential.
2002 So what strategies exist for spacing nonmusical elements in a
2003 proportional context? One good option is the @code{strict-note-spacing}
2004 property of @code{SpacingSpanner}. Compare the two scores below:
2006 @lilypond[quote,verbatim,ragged-right]
2008 \set Score.proportionalNotationDuration = #(ly:make-moment 1 16)
2018 \set Score.proportionalNotationDuration = #(ly:make-moment 1 16)
2019 \override Score.SpacingSpanner #'strict-note-spacing = ##t
2029 Both scores are proportional, but the spacing in the first score
2030 is too loose because of the clef change. The spacing of the second
2031 score remains strict, however, because strict-note-spacing is
2032 turned on. Turning on strict-note-spacing causes the width of
2033 time signatures, key signatures, clefs and accidentals to play no
2034 part in the spacing algorithm.
2036 In addition to the settings given here, there are other settings
2037 that frequently appear in proportional scores. These include:
2040 @item @code{\override SpacingSpanner #'strict-grace-spacing = ##t}
2041 @item @code{tupletFullLength = ##t}
2042 @item @code{\override Beam #'breakable = ##t}
2043 @item @code{\override Glissando #'breakable = ##t}
2044 @item @code{\override TextSpanner #'breakable = ##t}
2045 @item @code{\remove Forbid_line_break_engraver in the Voice context}
2048 These settings space grace notes strictly, extend tuplet brackets to
2049 mark both rhythmic start- and stop-points, and allow spanning elements
2050 to break across systems and pages. See the respective parts of the manual
2051 for these related settings.