1 @c -*- coding: utf-8; mode: texinfo; -*-
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. For details, see the Contributors'
8 Guide, node Updating translation committishes..
16 Negative numbers are allowed:
17 > Are you sure? The following works well
19 > first-page-number = -2
21 > and prints page number -1 on the second page, for example.
24 In 5.2.1 the @refbugs (line 495 in spacing.itely on master) it
27 "@code{layout-set-staff-size} does not change the distance between
31 Could we add a sentence:
32 "Use instead the pair fontSize = #@var{N}
33 \override StaffSymbol #'staff-space = #(magstep
35 inside the Staff context to change the size of the font and the
37 staff lines accordingly."
39 Actually I found, that the @internalsref{StaffSymbol} at line 481
40 sends to an incomplete
41 documentation. The property staff-space is not explained here. I
42 thought Y-extent might be of
43 help, but it is in turn explained by x-space which again is
44 missing from the list. Who has the
45 knowledge to fix this?
49 http://code.google.com/p/lilypond/issues/detail?id=68
55 @chapter Spacing issues
57 The global paper layout is determined by three factors: the page layout, the
58 line breaks, and the spacing. These all influence each other. The
59 choice of spacing determines how densely each system of music is set.
60 This influences where line breaks are chosen, and thus ultimately, how
61 many pages a piece of music takes.
63 Globally speaking, this procedure happens in four steps: first,
64 flexible distances (@q{springs}) are chosen, based on durations. All
65 possible line breaking combinations are tried, and a @q{badness} score
66 is calculated for each. Then the height of each possible system is
67 estimated. Finally, a page breaking and line breaking combination is chosen
68 so that neither the horizontal nor the vertical spacing is too cramped
71 Settings which influence layout may be placed in two blocks.
72 The @code{\paper @{...@}} block is placed outside any
73 @code{\score @{...@}} blocks and contains settings that
74 relate to the entire document. The @code{\layout @{...@}}
75 block is placed within a @code{\score @{...@}} block and
76 contains settings for that particular score. If you have
77 only one @code{\score @{...@}} block the two have the same
78 effect. In general the commands shown in this chapter can
86 * Horizontal spacing::
87 * Fitting music onto fewer pages::
92 @section Paper and pages
94 This section deals with the boundaries that define the area
95 within which music can be printed.
104 @subsection Paper size
109 Two functions are available for changing the paper size:
110 @code{set-default-paper-size} and @code{set-paper-size}.
111 @code{set-default-paper-size} must be placed in the toplevel
112 scope, and @code{set-paper-size} must be placed in a @code{\paper}
116 #(set-default-paper-size "a4")
121 #(set-paper-size "a4")
126 @code{set-default-paper-size} sets the size of all pages, whereas
127 @code{set-paper-size} only sets the size of the pages that the
128 @code{\paper} block applies to. For example, if the @code{\paper}
129 block is at the top of the file, then it will apply the paper size
130 to all pages. If the @code{\paper} block is inside a
131 @code{\book}, then the paper size will only apply to that book.
133 Common paper sizes are available, including @code{a4},
134 @code{letter}, @code{legal}, and @code{11x17} (also known as
135 tabloid). Many more paper sizes are supported by default. For
136 details, see @file{scm/@/paper@/.scm}, and search for the
137 definition of @code{paper-alist}.
139 @c TODO add a new appendix for paper sizes (auto-generated) -pm
141 @warning{The default paper size is @code{a4}.}
143 Extra sizes may be added by editing the definition of
144 @code{paper-alist} in the initialization file
145 @file{scm/@/paper@/.scm}, however they will be overridden on a
151 If the symbol @code{'landscape} is supplied as an argument to
152 @code{set-default-paper-size}, pages will be rotated by 90
153 degrees, and wider line widths will be set accordingly.
156 #(set-default-paper-size "a6" 'landscape)
159 Setting the paper size will adjust a number of @code{\paper}
160 variables, such as margins. To use a particular paper size with
161 altered @code{\paper} variables, set the paper size before setting
167 @file{scm/@/paper@/.scm}.
173 @node Page formatting
174 @subsection Page formatting
178 Margins, headers, and footers and other layout variables are
179 automatically set according to the paper size.
181 Default margin values are accessible in
182 @file{ly/@/paper@/-defaults@/-init@/.ly}. They apply to the default
183 paper size (a4, unless specified differently) and are scaled
184 accordingly for other paper sizes.
186 This section lists and describes a number of paper variables that
190 * Fixed vertical dimensions::
191 * Flexible vertical dimensions::
192 * Horizontal dimensions::
193 * Other layout variables::
197 @node Fixed vertical dimensions
198 @unnumberedsubsubsec Fixed vertical dimensions
202 @funindex paper-height
204 The height of the page. Default: the height of the current paper
205 size. For details, see @ref{Paper size}.
210 The margin between the top of the page and the top of the
211 printable area. Default: @code{5\mm}.
214 @funindex bottom-margin
216 The margin between the bottom of the printable area and the bottom
217 of the page. Default: @code{6\mm}.
221 @node Flexible vertical dimensions
222 @unnumberedsubsubsec Flexible vertical dimensions
224 In most cases, it is preferable for the vertical distances between
225 certain items (such as margins, titles, systems, and separate
226 scores) to be flexible, so that they stretch and compress nicely
227 according to each situation. A number of @code{\paper} variables
228 (listed below) are available to fine-tune the stretching behavior
231 Note that the @code{\paper} variables discussed in this section do
232 not control the spacing of staves within individual systems.
233 Within-system spacing is controlled by grob properties, with
234 settings typically entered inside a @code{\score} or @code{layout}
235 block, and not inside a @code{\paper} block. See
236 @ref{Flexible vertical spacing within systems}.
239 @subsubheading Structure of spacing alists for @code{\paper} variables
241 Each of these variables is an alist (association list) containing
245 @item @code{padding} -- the minimum required amount of
246 unobstructed vertical whitespace between two items, measured in
247 staff-spaces. This can be thought of as the minimum height of an
248 unobstructed (invisible) rectangle that extends from the leftmost
249 to the rightmost point of the combined items.
251 @item @code{space} -- the default vertical distance, measured in
252 staff-spaces, between the @emph{reference points} of the two
253 items, when no collisions would result, and no stretching or
254 compressing is in effect. The reference point of a (title or
255 top-level) markup is its highest point, and the reference point of
256 a system is the vertical center of the nearest @code{StaffSymbol}
257 -- even if a non-staff line (such as a @code{Lyrics} context) is
258 in the way. Values for @code{space} that are less than either
259 @code{padding} or @code{minimum-distance} are not meaningful,
260 since the resulting distance will never be less than either
261 @code{padding} or @code{minimum-distance}.
263 @item @code{minimum-distance} -- the minimum required vertical
264 distance, measured in staff-spaces, between the reference points
265 of the two items, when compressing is in effect. Values for
266 @code{minimum-distance} that are less than @code{padding} are not
267 meaningful, since the resulting distance will never be less than
270 @item @code{stretchability} -- a unitless measure of the
271 dimension's relative propensity to stretch. If zero, the distance
272 will not stretch (unless collisions would result). When positive,
273 the significance of a particular dimension's @code{stretchability}
274 value lies only in its relation to the @code{stretchability}
275 values of the other dimensions. For example, if one dimension has
276 twice the @code{stretchability} of another, it will stretch twice
277 as easily. Values should be non-negative and finite. The value
278 @code{+inf.0} triggers a @code{programming_error} and is ignored,
279 but @code{1.0e7} can be used for an almost infinitely stretchable
280 spring. If unset, the default value is set to @code{space}. Note
281 that the dimension's propensity to @emph{compress} cannot be
282 directly set by the user and is equal to
283 (@code{space}@tie{}@minus{}@tie{}@code{minimum-distance}).
286 If a page has a ragged bottom, the resulting distance is the
291 @item @code{minimum-distance}, and
292 @item @code{padding} plus the smallest distance necessary to
293 eliminate collisions.
296 Specific methods for modifying alists are discussed in
297 @ref{Modifying alists}. The flexible vertical @code{\paper}
298 dimensions variables can only be set within a @code{\paper} block.
300 The following example demonstrates the two ways these alists can
301 be modified. The first declaration updates one key-value
302 individually, and the second complete re-defines the variable:
306 system-system-spacing #'space = #8
308 score-system-spacing =
311 (minimum-distance . 6)
312 (stretchability . 12))
316 The initialized default settings for these variables are defined
317 in @file{ly/paper-defaults-init.ly}.
320 @subsubheading Flexible vertical dimension @code{\paper} variables
322 The names of these variables follow the format
323 @code{@var{upper}-@var{lower}-spacing}, where @code{@var{upper}}
324 and @code{@var{lower}} are the items to be spaced. Each distance
325 is measured between the reference points of the two items (see the
326 description of the alist structure above). Note that in these
327 variable names, the term @q{@code{markup}} refers to both
328 @emph{title markups} (@code{bookTitleMarkup} or
329 @code{scoreTitleMarkup}) and @emph{top-level markups} (see
330 @ref{File structure}).
333 @item markup-system-spacing
334 @funindex markup-system-spacing
336 the distance between a (title or top-level) markup and the system
339 @item score-markup-spacing
340 @funindex score-markup-spacing
342 the distance between the last system of a score and the (title or
343 top-level) markup that follows it.
345 @item score-system-spacing
346 @funindex score-system-spacing
348 the distance between the last system of a score and the first
349 system of the score that follows it, when no (title or top-level)
350 markup exists between them.
352 @item system-system-spacing
353 @funindex system-system-spacing
355 the distance between two systems in the same score.
357 @item markup-markup-spacing
358 @funindex markup-markup-spacing
360 the distance between two (title or top-level) markups.
362 @item last-bottom-spacing
363 @funindex last-bottom-spacing
365 the distance from the last system or top-level markup on a page to
366 the bottom of the printable area (i.e. the top of the bottom
369 @item top-system-spacing
370 @funindex top-system-spacing
372 the distance from the top of the printable area (i.e. the bottom
373 of the top margin) to the first system on a page, when there is no
374 (title or top-level) markup between the two.
376 @item top-markup-spacing
377 @funindex top-markup-spacing
379 the distance from the top of the printable area (i.e. the bottom
380 of the top margin) to the first (title or top-level) markup on a
381 page, when there is no system between the two.
387 The header and footer are created by the functions
388 @code{make-footer} and @code{make-header}, defined in
389 @code{\paper}. The default implementations are in
390 @file{ly/paper-defaults.ly} and @file{ly/titling-init.ly}.
392 The page layout itself is done by two functions in the
393 @code{\paper} block, @code{page-music-height} and
394 @code{page-make-stencil}. The former tells the line-breaking
395 algorithm how much space can be spent on a page, the latter
396 creates the actual page given the system to put on it.
398 You can define @code{\paper} block values in Scheme. In that case
399 @code{mm}, @code{in}, @code{pt}, and @code{cm} are variables
400 defined in @file{paper-defaults.ly} with values in millimeters.
401 That is why the value @w{@code{2 cm}} must be multiplied in the
406 #(define bottom-margin (* 2 cm))
418 ragged-last-bottom = ##t
422 This second example centers page numbers at the bottom of every page.
426 print-page-number = ##t
427 print-first-page-number = ##t
428 oddHeaderMarkup = \markup \fill-line @{ " " @}
429 evenHeaderMarkup = \markup \fill-line @{ " " @}
430 oddFooterMarkup = \markup @{ \fill-line @{
431 \bold \fontsize #3 \on-the-fly #print-page-number-check-first
432 \fromproperty #'page:page-number-string @} @}
433 evenFooterMarkup = \markup @{ \fill-line @{
434 \bold \fontsize #3 \on-the-fly #print-page-number-check-first
435 \fromproperty #'page:page-number-string @} @}
441 @ref{Flexible vertical spacing within systems}.
447 @node Horizontal dimensions
448 @unnumberedsubsubsec Horizontal dimensions
451 There are a few variables that determine the horizontal dimensions
457 @funindex binding-offset
459 The amount @code{inner-margin} is increased
460 to make sure nothing will be hidden by the binding.
461 Works only with @code{two-sided} set to true. Default:
464 @item horizontal-shift
465 @funindex horizontal-shift
467 The amount that all systems (including titles and system
468 separators) are shifted to the right. Default: @code{0.0}.
473 The level of indentation for the first system in a score.
474 Default: @code{15\mm}.
477 @funindex inner-margin
479 The margin all pages have at the inner side if they are part
480 of a book. Works only with @code{two-sided} set to true.
481 Default: @code{10\mm}.
484 @funindex left-margin
486 The margin between the left edge of the page and the beginning of
487 each system. Default: @code{10\mm}.
492 The width of music systems. Default: @code{paper-width} minus
493 @code{left-margin} and @code{right-margin}.
496 @funindex outer-margin
498 The margin all pages have at the outer side if they are part
499 of a book. Works only with @code{two-sided} set to true.
500 Default: @code{20\mm}.
503 @funindex paper-width
505 The width of the page. Default: the width of the current paper
506 size. For details, see @ref{Paper size}.
509 @funindex right-margin
511 The margin between the right edge of the page and the end of
512 each system. Default: @code{10\mm}.
515 @funindex short-indent
517 The level of indentation for all systems in a score besides the
518 first system. Default: @code{0}.
522 If some values are not set, defaults will be taken. Their exact
523 value is adjusted, depending on the paper size specified. Currently,
524 the following values are affected by this scaling:
527 @item @var{left-margin}
528 @item @var{right-margin}
529 @item @var{top-margin}
530 @item @var{bottom-margin}
531 @item @var{head-separation}
532 @item @var{foot-separation}
534 @item @var{short-indent}
537 The settings for @code{line-width}, @code{left-margin},
538 @code{right-margin} and @code{paper-width} depend on
539 each other, but they do not have to be specified
548 In this example, only @code{left-margin} is set. The value for
549 @code{right-margin} will remain default, @code{line-width} is
550 calculated automatically.
558 Here @code{left-margin} and @code{right-margin} will be set
559 to the same value. Therefore, @code{line-width} is subtracted
560 from @code{paper-width} and divided by two. That means systems
561 are centered on the page, if only @code{line-width} is
564 Some checks occur to ensure the values are set correctly.
565 If the values do not match or systems would run off the page,
566 a warning is printed and default values are set.
577 These checks can be avoided by setting @code{check-consistency}
585 check-consistency = ##f
589 @warning{If @code{paper-width} is manually set, @code{line-width},
590 @code{left-margin}, @code{indent}, and @code{short-indent} may
591 have to be adjusted as well.}
599 @node Other layout variables
600 @unnumberedsubsubsec Other layout variables
602 These variables can be used to adjust page layout in general.
606 @item auto-first-page-number
607 @funindex auto-first-page-number
609 The page breaking algorithm is affected by the first page number
610 being odd or even. If set to true, the page breaking algorithm
611 will decide whether to start with an odd or even number. This
612 will result in the first page number remaining as is or being
613 increased by one. Default: @code{##f}.
617 TODO: this variable is used, but I don't know what it does. -pm
618 @item blank-after-score-page-force
619 @funindex blank-after-score-page-force
625 @item blank-last-page-force
626 @funindex blank-last-page-force
628 The penalty for ending the score on an odd-numbered page.
631 @item blank-page-force
632 @funindex blank-page-force
634 The penalty for having a blank page in the middle of a
635 score. This is not used by @code{ly:optimal-breaking} since it will
636 never consider blank pages in the middle of a score. Default:
639 @item check-consistency
640 @funindex check-consistency
642 If set to true, check whether @code{left-margin}, @code{right-margin} and
643 @code{line-width} fit each other. Also make sure that their combination
644 does not exceed the available @code{paper-width}. Default: @code{##t}.
646 @item first-page-number
647 @funindex first-page-number
649 The value of the page number on the first page. Default:
652 @item max-systems-per-page
653 @funindex max-systems-per-page
655 The maximum number of systems that will be placed on a page. This
656 is currently supported only by the @code{ly:optimal-breaking} algorithm.
659 @item min-systems-per-page
660 @funindex min-systems-per-page
662 The minimum number of systems that will be placed on a page. This
663 may cause pages to be overfilled if it is made too large. This is
664 currently supported only by the @code{ly:optimal-breaking} algorithm.
667 @item page-breaking-system-system-spacing
668 @funindex page-breaking-system-system-spacing
670 Tricks the page breaker into thinking that
671 @code{system-system-spacing} is set to something different than
672 it really is. For example, if
673 @code{page-breaking-system-system-spacing #'padding} is set to something
674 substantially larger than @code{system-system-spacing #'padding}, then the
675 page-breaker will put fewer systems on each page. Default: unset.
680 The number of pages to be used for a score. Default: unset.
682 @item page-spacing-weight
683 @funindex page-spacing-weight
685 The relative importance of page (vertical) spacing and line
686 (horizontal) spacing. High values will make page spacing more
687 important. Default: @code{#10}.
689 @item print-all-headers
690 @funindex print-all-headers
692 If set to true, this will print all headers for each \score in the
693 output. Normally only the piece and opus header variables are
694 printed. Default: @code{##f}.
696 @item print-first-page-number
697 @funindex print-first-page-number
699 If set to true, a page number is printed on the first page.
702 @item print-page-number
703 @funindex print-page-number
705 If set to false, page numbers are not printed. Default:
709 @funindex ragged-bottom
711 If set to true, systems will not spread vertically across the
712 page. This does not affect the last page. Default: @code{##f}.
714 This should be set to true for pieces that have only two or three
715 systems per page, for example orchestral scores.
718 @funindex ragged-last
720 If set to true, the last system in the score will not fill the
721 line width. Instead the last system ends at its natural
722 horizontal length. Default: @code{##f}.
724 @item ragged-last-bottom
725 @funindex ragged-last-bottom
727 If set to false, systems will spread vertically across the last
728 page. Default: @code{##t}.
730 Pieces that amply fill two pages or more should have this set to
733 It also affects the last page of book parts, ie parts of a book created
734 with @code{\bookpart} blocks.
737 @funindex ragged-right
739 If set to true, systems will not fill the line width. Instead,
740 systems end at their natural horizontal length. Default:
743 If the score has only one system, the default value is @code{##t}.
745 @item system-separator-markup
746 @funindex system-separator-markup
748 A markup object that is inserted between systems. This is often
749 used for orchestral scores. Default: unset.
751 The markup command @code{\slashSeparator} is provided as a sensible
754 @lilypond[quote,ragged-right]
755 #(set-default-paper-size "a6" 'landscape)
758 \relative c' { c1 \break c1 }
761 system-separator-markup = \slashSeparator
767 @funindex system-count
769 The number of systems to be used for a score.
772 @item systems-per-page
773 @funindex systems-per-page
775 The number of systems that should be placed on each page.
776 This is currently supported only by the @code{ly:optimal-breaking} algorithm.
783 @cindex binding gutter
785 If set to true, use @code{inner-margin}, @code{outer-margin} and
786 @code{binding-offset} to determine margins depending on whether
787 the page number is odd or even. This overrides @code{left-margin}
788 and @code{right-margin}. Default: @code{##f}.
800 The default page header puts the page number and the @code{instrument}
801 field from the @code{\header} block on a line.
803 The titles (from the @code{\header@{@}} section) are treated as a
804 system, so @code{ragged-bottom} and @code{ragged-last-bottom} will
805 add space between the titles and the first system of the score.
809 @section Music layout
812 * Setting the staff size::
817 @node Setting the staff size
818 @subsection Setting the staff size
820 @cindex font size, setting
821 @cindex staff size, setting
822 @funindex layout file
824 The default @strong{staff size} is set to 20 points.
825 This may be changed in two ways:
827 To set the staff size globally for all scores in a file (or
828 in a @code{book} block, to be precise), use @code{set-global-staff-size}.
831 #(set-global-staff-size 14)
835 This sets the global default size to 14pt staff height and scales all
838 To set the staff size individually for each score, use
843 #(layout-set-staff-size 15)
848 The Feta font provides musical symbols at eight different
849 sizes. Each font is tuned for a different staff size: at a smaller size
850 the font becomes heavier, to match the relatively heavier staff lines.
851 The recommended font sizes are listed in the following table:
854 @multitable @columnfractions .15 .2 .22 .2
857 @tab @b{staff height (pt)}
858 @tab @b{staff height (mm)}
900 @c modern rental material?
905 These fonts are available in any sizes. The context property
906 @code{fontSize} and the layout property @code{staff-space} (in
907 @rinternals{StaffSymbol}) can be used to tune the size for individual
908 staves. The sizes of individual staves are relative to the global size.
913 @ref{Selecting notation font size}.
921 @code{layout-set-staff-size} does not change the distance between the
926 @subsection Score layout
930 While @code{\paper} contains settings that relate to the page formatting
931 of the whole document, @code{\layout} contains settings for score-specific
938 \override TextScript #'padding = #1.0
939 \override Glissando #'thickness = #3
947 @ref{Changing context default settings}.
959 * Optimal page breaking::
960 * Optimal page turning::
961 * Minimal page breaking::
963 * Using an extra voice for breaks::
968 @subsection Line breaking
971 @cindex breaking lines
973 Line breaks are normally determined automatically. They are chosen
974 so that lines look neither cramped nor loose, and consecutive
975 lines have similar density. Occasionally you might want to
976 override the automatic breaks; you can do this by specifying
977 @code{\break}. This will force a line break at this point. However,
978 line breaks can only occur at the end of @q{complete} bars, i.e.,
979 where there are no notes or tuplets left @q{hanging} over the bar
980 line. If you want to have a line break where there is no bar line,
981 you can force an invisible bar line by entering @code{\bar ""},
982 although again there must be no notes left hanging over in any of
983 the staves at this point, or it will be ignored.
985 The opposite command, @code{\noBreak}, forbids a line break at the
986 bar line where it is inserted.
988 The most basic settings influencing line spacing are @code{indent}
989 and @code{line-width}. They are set in the @code{\layout} block.
990 They control the indentation of the first line of music, and the
991 lengths of the lines.
993 If @code{ragged-right} is set to true in the @code{\layout} block,
994 then systems end at their natural horizontal length, instead of
995 being spread horizontally to fill the whole line. This is useful
996 for short fragments, and for checking how tight the natural
999 @c TODO Check and add para on default for ragged-right
1001 The option @code{ragged-last} is similar to @code{ragged-right},
1002 but affects only the last line of the piece.
1014 @cindex regular line breaks
1015 @cindex four bar music.
1017 For line breaks at regular intervals use @code{\break} separated by
1018 skips and repeated with @code{\repeat}. For example, this would
1019 cause the following 28 measures (assuming 4/4 time) to be broken
1020 every 4 measures, and only there:
1023 << \repeat unfold 7 @{
1024 s1 \noBreak s1 \noBreak
1025 s1 \noBreak s1 \break @}
1026 @emph{the real music}
1031 A linebreaking configuration can be saved as a @code{.ly} file
1032 automatically. This allows vertical alignments to be stretched to
1033 fit pages in a second formatting run. This is fairly new and
1034 complicated. More details are available in
1047 Internals Reference:
1048 @rinternals{LineBreakEvent}.
1056 Line breaks can only occur if there is a @q{proper} bar line. A note
1057 which is hanging over a bar line is not proper, such as
1059 @lilypond[quote,ragged-right,relative=2,verbatim]
1060 c4 c2 << c2 {s4 \break } >> % this does nothing
1061 c2 c4 | % a break here would work
1062 c4 c2 c4 ~ \break % as does this break
1066 This can be avoided by removing the @code{Forbid_line_break_engraver}.
1067 Note that manually forced line breaks have to be added in parallel
1070 @lilypond[quote,ragged-right,verbatim]
1072 \remove Forbid_line_break_engraver
1074 c4 c2 << c2 {s4 \break } >> % now the break is allowed
1079 Similarly, line breaks are normally forbidden when beams cross bar
1080 lines. This behavior can be changed by setting
1081 @code{\override Beam #'breakable = ##t}.
1085 @subsection Page breaking
1087 The default page breaking may be overridden by inserting
1088 @code{\pageBreak} or @code{\noPageBreak} commands. These commands are
1089 analogous to @code{\break} and @code{\noBreak}. They should be
1090 inserted at a bar line. These commands force and forbid a page-break
1091 from happening. Of course, the @code{\pageBreak} command also forces
1094 The @code{\pageBreak} and @code{\noPageBreak} commands may also be
1095 inserted at top-level, between scores and top-level markups.
1097 There are also analogous settings to @code{ragged-right} and
1098 @code{ragged-last} which have the same effect on vertical spacing:
1099 @code{ragged-bottom} and @code{ragged-last-bottom}. If set to
1100 @code{##t} the systems on all pages or just the last page
1101 respectively will not be justified vertically.
1103 For more details see @ref{Vertical spacing}.
1105 Page breaks are computed by the @code{page-breaking} function. LilyPond
1106 provides three algorithms for computing page breaks,
1107 @code{ly:optimal-breaking}, @code{ly:page-turn-breaking} and
1108 @code{ly:minimal-breaking}. The default is @code{ly:optimal-breaking},
1109 but the value can be changed in the @code{\paper} block:
1113 #(define page-breaking ly:page-turn-breaking)
1119 When a book has many scores and pages, the page breaking problem may be
1120 difficult to solve, requiring large processing time and memory. To ease
1121 the page breaking process, @code{\bookpart} blocks are used to divide
1122 the book into several parts: the page breaking occurs separately on each
1123 part. Different page breaking functions may also be used in different
1129 subtitle = "Preface"
1132 %% In a part consisting mostly of text,
1133 %% ly:minimal-breaking may be preferred
1134 #(define page-breaking ly:minimal-breaking)
1136 \markup @{ @dots{} @}
1140 %% In this part, consisting of music, the default optimal
1141 %% page breaking function is used.
1143 subtitle = "First movement"
1145 \score @{ @dots{} @}
1152 @funindex \pageBreak
1154 @funindex \noPageBreak
1155 @code{\noPageBreak}.
1164 @node Optimal page breaking
1165 @subsection Optimal page breaking
1167 @funindex ly:optimal-breaking
1169 The @code{ly:optimal-breaking} function is LilyPond's default method of
1170 determining page breaks. It attempts to find a page breaking that minimizes
1171 cramping and stretching, both horizontally and vertically. Unlike
1172 @code{ly:page-turn-breaking}, it has no concept of page turns.
1180 @node Optimal page turning
1181 @subsection Optimal page turning
1183 @funindex ly:page-turn-breaking
1185 Often it is necessary to find a page breaking configuration so that there is
1186 a rest at the end of every second page. This way, the musician can turn the
1187 page without having to miss notes. The @code{ly:page-turn-breaking} function
1188 attempts to find a page breaking minimizing cramping and stretching, but with
1189 the additional restriction that it is only allowed to introduce page turns
1190 in specified places.
1192 There are two steps to using this page breaking function. First, you
1193 must enable it in the @code{\paper} block, as explained in @ref{Page
1194 breaking}. Then you must tell the function where you would like to allow
1197 There are two ways to achieve the second step. First, you can specify each
1198 potential page turn manually, by inserting @code{\allowPageTurn} into your
1199 input file at the appropriate places.
1201 If this is too tedious, you can add a @code{Page_turn_engraver} to a Staff or
1202 Voice context. The @code{Page_turn_engraver} will scan the context for
1203 sections without notes (note that it does not scan for rests; it scans for
1204 the absence of notes. This is so that single-staff polyphony with rests in one
1205 of the parts does not throw off the @code{Page_turn_engraver}). When it finds
1206 a sufficiently long section without notes, the @code{Page_turn_engraver} will
1207 insert an @code{\allowPageTurn} at the final bar line in that section, unless
1208 there is a @q{special} bar line (such as a double bar), in which case the
1209 @code{\allowPageTurn} will be inserted at the final @q{special} bar line in
1212 @funindex minimumPageTurnLength
1213 The @code{Page_turn_engraver} reads the context property
1214 @code{minimumPageTurnLength} to determine how long a note-free section must
1215 be before a page turn is considered. The default value for
1216 @code{minimumPageTurnLength} is @code{#(ly:make-moment 1 1)}. If you want
1217 to disable page turns, you can set it to something very large.
1220 \new Staff \with @{ \consists "Page_turn_engraver" @}
1223 R1 | % a page turn will be allowed here
1225 \set Staff.minimumPageTurnLength = #(ly:make-moment 5 2)
1226 R1 | % a page turn will not be allowed here
1228 R1*2 | % a page turn will be allowed here
1233 @funindex minimumRepeatLengthForPageTurn
1234 The @code{Page_turn_engraver} detects volta repeats. It will only allow a page
1235 turn during the repeat if there is enough time at the beginning and end of the
1236 repeat to turn the page back. The @code{Page_turn_engraver} can also disable
1237 page turns if the repeat is very short. If you set the context property
1238 @code{minimumRepeatLengthForPageTurn} then the @code{Page_turn_engraver} will
1239 only allow turns in repeats whose duration is longer than this value.
1241 The page turning commands, @code{\pageTurn}, @code{\noPageTurn} and
1242 @code{\allowPageTurn}, may also be used at top-level, between scores and
1249 @funindex \noPageTurn
1251 @funindex \allowPageTurn
1252 @code{\allowPageTurn}.
1263 There should only be one @code{Page_turn_engraver} in a score. If there is more
1264 than one, they will interfere with each other.
1267 @node Minimal page breaking
1268 @subsection Minimal page breaking
1270 @funindex ly:minimal-breaking
1272 The @code{ly:minimal-breaking} function performs minimal computations to
1273 calculate the page breaking: it fills a page with as many systems as
1274 possible before moving to the next one. Thus, it may be preferred for
1275 scores with many pages, where the other page breaking functions could be
1276 too slow or memory demanding, or a lot of texts. It is enabled using:
1280 #(define page-breaking ly:minimal-breaking)
1290 @node Explicit breaks
1291 @subsection Explicit breaks
1293 Lily sometimes rejects explicit @code{\break} and @code{\pageBreak}
1294 commands. There are two commands to override this behavior:
1297 \override NonMusicalPaperColumn #'line-break-permission = ##f
1298 \override NonMusicalPaperColumn #'page-break-permission = ##f
1301 When @code{line-break-permission} is overridden to false, Lily will insert
1302 line breaks at explicit @code{\break} commands and nowhere else. When
1303 @code{page-break-permission} is overridden to false, Lily will insert
1304 page breaks at explicit @code{\pageBreak} commands and nowhere else.
1306 @lilypond[quote,verbatim]
1315 \repeat unfold 2 { c'8 c'8 c'8 c'8 } \break
1316 \repeat unfold 4 { c'8 c'8 c'8 c'8 } \break
1317 \repeat unfold 6 { c'8 c'8 c'8 c'8 } \break
1318 \repeat unfold 8 { c'8 c'8 c'8 c'8 } \pageBreak
1319 \repeat unfold 8 { c'8 c'8 c'8 c'8 } \break
1320 \repeat unfold 6 { c'8 c'8 c'8 c'8 } \break
1321 \repeat unfold 4 { c'8 c'8 c'8 c'8 } \break
1322 \repeat unfold 2 { c'8 c'8 c'8 c'8 }
1327 \override NonMusicalPaperColumn #'line-break-permission = ##f
1328 \override NonMusicalPaperColumn #'page-break-permission = ##f
1340 @node Using an extra voice for breaks
1341 @subsection Using an extra voice for breaks
1343 Line- and page-breaking information usually appears within note entry directly.
1348 \repeat unfold 2 @{ c'4 c'4 c'4 c'4 @}
1350 \repeat unfold 3 @{ c'4 c'4 c'4 c'4 @}
1355 This makes @code{\break} and @code{\pageBreak} commands easy to enter but mixes
1356 music entry with information that specifies how music should lay out
1357 on the page. You can keep music entry and line- and page-breaking
1358 information in two separate places by introducing an extra voice to
1359 contain the breaks. This extra voice
1360 contains only skips together with @code{\break}, @code{pageBreak} and other
1361 breaking layout information.
1363 @lilypond[quote,verbatim]
1373 \repeat unfold 2 { c'4 c'4 c'4 c'4 }
1374 \repeat unfold 3 { c'4 c'4 c'4 c'4 }
1375 \repeat unfold 6 { c'4 c'4 c'4 c'4 }
1376 \repeat unfold 5 { c'4 c'4 c'4 c'4 }
1382 This pattern becomes especially helpful when overriding
1383 @code{line-break-system-details} and the other useful but long properties of
1384 @code{NonMusicalPaperColumnGrob}, as explained in @ref{Vertical spacing}.
1386 @lilypond[quote,verbatim]
1390 \overrideProperty "Score.NonMusicalPaperColumn"
1391 #'line-break-system-details #'((Y-offset . 0))
1394 \overrideProperty "Score.NonMusicalPaperColumn"
1395 #'line-break-system-details #'((Y-offset . 35))
1398 \overrideProperty "Score.NonMusicalPaperColumn"
1399 #'line-break-system-details #'((Y-offset . 70))
1402 \overrideProperty "Score.NonMusicalPaperColumn"
1403 #'line-break-system-details #'((Y-offset . 105))
1407 \repeat unfold 2 { c'4 c'4 c'4 c'4 }
1408 \repeat unfold 3 { c'4 c'4 c'4 c'4 }
1409 \repeat unfold 6 { c'4 c'4 c'4 c'4 }
1410 \repeat unfold 5 { c'4 c'4 c'4 c'4 }
1419 @ref{Vertical spacing}.
1425 @node Vertical spacing
1426 @section Vertical spacing
1428 @cindex vertical spacing
1429 @cindex spacing, vertical
1431 Vertical spacing is controlled by three things: the amount of
1432 space available (i.e., paper size and margins), the amount of
1433 space between systems, and the amount of space between
1434 staves inside a system.
1437 * Flexible vertical spacing within systems::
1438 * Explicit staff and system positioning::
1439 * Vertical collision avoidance::
1443 @node Flexible vertical spacing within systems
1444 @subsection Flexible vertical spacing within systems
1446 @cindex distance between staves
1447 @cindex staff distance
1448 @cindex space between staves
1449 @cindex space inside systems
1451 Three separate mechanisms control the flexible vertical spacing
1452 within systems, one for each of the following categories:
1455 @item @emph{ungrouped staves},
1456 @item @emph{grouped staves} (staves within a staff-group such as
1457 @code{ChoirStaff}, etc.), and
1458 @item @emph{non-staff lines} (such as @code{Lyrics},
1459 @code{ChordNames}, etc.).
1462 @c TODO: Clarify this. This almost implies that non-staff lines
1463 @c have NO effect on the spacing between staves. -mp
1465 The height of each system is determined in two steps. First, all
1466 of the staves are spaced according to the amount of space
1467 available. Then, the non-staff lines are distributed between the
1470 Note that the spacing mechanisms discussed in this section only
1471 control the vertical spacing of staves and non-staff lines within
1472 individual systems. The vertical spacing between separate
1473 systems, scores, markups, and margins is controlled by
1474 @code{\paper} variables, which are discussed in
1475 @ref{Flexible vertical dimensions}.
1478 * Within-system spacing properties::
1479 * Spacing of ungrouped staves::
1480 * Spacing of grouped staves::
1481 * Spacing of non-staff lines::
1485 @node Within-system spacing properties
1486 @unnumberedsubsubsec Within-system spacing properties
1488 The within-system vertical spacing mechanisms are controlled by
1489 two sets of grob properties. The first set is associated with the
1490 @code{VerticalAxisGroup} grob, which is created by all staves and
1491 non-staff lines. The second set is associated with the
1492 @code{StaffGrouper} grob, which can be created by staff-groups,
1493 but only if explicitly called. These properties are described
1494 individually at the end of this section.
1496 The names of these properties (except for @code{staff-affinity})
1497 follow the format @code{@var{item1}-@var{item2}-spacing}, where
1498 @code{@var{item1}} and @code{@var{item2}} are the items to be
1499 spaced. Note that @code{@var{item2}} is not necessarily below
1500 @code{@var{item1}}; for example,
1501 @code{nonstaff-relatedstaff-spacing} will measure upwards from the
1502 non-staff line if @code{staff-affinity} is @code{#UP}.
1504 Each distance is measured between the @emph{reference points} of
1505 the two items. The reference point for a staff is the vertical
1506 center of its @code{StaffSymbol} (i.e. the middle line if
1507 @code{line-count} is odd; the middle space if @code{line-count} is
1508 even). The reference points for individual non-staff lines are
1509 given in the following table:
1511 @multitable {Non-staff line} {Reference point}
1512 @headitem Non-staff line @tab Reference point
1513 @item @code{ChordNames} @tab baseline
1514 @item @code{NoteNames} @tab baseline
1515 @item @code{Lyrics} @tab baseline
1516 @item @code{Dynamics} @tab vertical center
1517 @item @code{FiguredBass} @tab highest point
1518 @item @code{FretBoards} @tab top line
1521 In the following image, horizontal lines indicate the positions
1522 of these reference points:
1524 @lilypond[quote,noragged-right,line-width=110\mm]
1525 #(define zero-space '((padding . -inf.0) (space . 0)))
1527 alignToZero = \with {
1528 \override VerticalAxisGroup #'nonstaff-relatedstaff-spacing = #zero-space
1529 \override VerticalAxisGroup #'nonstaff-nonstaff-spacing = #zero-space
1531 lowerCaseChords = \with {
1532 chordNameLowercaseMinor = ##t
1534 staffAffinityDown = \with {
1535 \override VerticalAxisGroup #'staff-affinity = #DOWN
1538 #(define-music-function
1539 (parser location context)
1541 #{ s1*0^\markup { \typewriter $context } #})
1544 \context { \Dynamics \alignToZero }
1545 \context { \FiguredBass \alignToZero }
1546 \context { \Lyrics \alignToZero }
1547 \context { \NoteNames \alignToZero }
1548 \context { \ChordNames \alignToZero \lowerCaseChords }
1549 \context { \FretBoards \alignToZero \staffAffinityDown }
1551 \override BarLine #'stencil = ##f
1552 \override DynamicText #'self-alignment-X = #-1
1553 \override FretBoard #'X-offset = #1.75
1554 \override InstrumentName #'minimum-Y-extent = #'(-2 . 2)
1555 \override InstrumentName #'extra-offset = #'(0 . -0.5)
1556 \override TextScript #'minimum-Y-extent = #'(-2 . 3)
1557 \override TimeSignature #'stencil = ##f
1561 %% These contexts have reference points at the baseline:
1562 %% ChordNames, NoteNames, and Lyrics
1564 \new ChordNames { \chords { g1:m } }
1565 \new NoteNames { s1 | g1 | }
1566 \new RhythmicStaff {
1567 \set RhythmicStaff.instrumentName = #"baseline "
1569 \labelContext "ChordNames" s1 |
1570 \labelContext "NoteNames" s1 |
1571 \labelContext "Lyrics" s1 |
1573 \new Lyrics { \lyrics { \skip 1*2 | ghijk1 | } }
1576 %% The reference point for Dynamics is its vertical center
1578 \new RhythmicStaff {
1579 \set RhythmicStaff.instrumentName = #"vertical center "
1580 \labelContext "Dynamics" s1*3
1582 \new Dynamics { s2\mp s\fp }
1585 %% The reference point for FiguredBass is its highest point
1587 \new RhythmicStaff {
1588 \set RhythmicStaff.instrumentName = #"highest point "
1589 \labelContext "FiguredBass" s1
1591 \new FiguredBass { \figuremode { <6 5>1 } }
1594 %% The reference point for FretBoards is the top line
1595 \include "predefined-guitar-fretboards.ly"
1597 \new FretBoards { \chordmode { e1 } }
1598 \new RhythmicStaff {
1599 \set RhythmicStaff.instrumentName = #"top line "
1600 \labelContext "FretBoards " s1
1605 Each of the vertical spacing grob properties (except
1606 @code{staff-affinity}) is stored as an alist (association list),
1607 and each uses the same alist structure as the @code{\paper}
1608 spacing variables discussed in @ref{Flexible vertical dimensions}.
1609 Specific methods for modifying alists are discussed in
1610 @ref{Modifying alists}. Grob properties should be adjusted with
1611 an @code{\override} inside a @code{\score} or @code{\layout}
1612 block, and not inside a @code{\paper} block.
1614 The following example demonstrates the two ways these alists can
1615 be modified. The first declaration updates one key-value
1616 individually, and the second completely re-defines the property:
1620 \override VerticalAxisGroup #'staff-staff-spacing #'space = #10
1624 \override VerticalAxisGroup #'staff-staff-spacing =
1627 (minimum-distance . 9)
1628 (stretchability . 10))
1632 To change any spacing settings globally, put them in the
1633 @code{\layout} block:
1639 \override VerticalAxisGroup #'staff-staff-spacing #'space = #10
1644 Standard settings for the vertical spacing grob properties are
1645 listed in @rinternals{VerticalAxisGroup} and
1646 @rinternals{StaffGrouper}. Default overrides for specific types
1647 of non-staff lines are listed in the relevant context descriptions
1648 in @rinternals{Contexts}.
1651 @subsubheading Properties of the @code{VerticalAxisGroup} grob
1653 @code{VerticalAxisGroup} properties are typically adjusted with an
1654 @code{\override} at the @code{Staff} level (or equivalent).
1657 @item staff-staff-spacing
1658 The distance between the current staff and the staff just below it
1659 in the same system, even if one or more non-staff lines (such as
1660 @code{Lyrics}) are placed between the two staves. Does not apply
1661 to the bottom staff of a system. This replaces any settings
1662 inherited from the @code{StaffGrouper} grob of the containing
1663 staff-group, if there is one. If this is unset, and there are no
1664 @code{StaffGrouper} properties to inherit, the
1665 @code{default-staff-staff-spacing} property is used.
1667 @item default-staff-staff-spacing
1668 The settings to use for @code{staff-staff-spacing} when it is
1669 unset. This applies to ungrouped staves and to grouped staves
1670 that do not inherit settings from the @code{StaffGrouper} grob.
1672 @item staff-affinity
1673 The direction of the staff to use for spacing the current
1674 non-staff line. Choices are @code{UP}, @code{DOWN}, and
1675 @code{CENTER}. If @code{CENTER}, the non-staff line will be
1676 placed equidistant between the two nearest staves on either side,
1677 unless collisions or other spacing constraints prevent this.
1678 Adjacent non-staff lines should have non-increasing
1679 @code{staff-affinity} from top to bottom, e.g. a non-staff line
1680 set to @code{UP} should not immediately follow one that is set to
1681 @code{DOWN}. Non-staff lines at the top of a system should use
1682 @code{DOWN}; those at the bottom should use @code{UP}. Setting
1683 @code{staff-affinity} for a staff causes it to be treated as a
1684 non-staff line. Setting @code{staff-affinity} to @code{#f} causes
1685 a non-staff line to be treated as a staff.
1687 @c TODO: verify last clause below ("even if other...")
1689 @item nonstaff-relatedstaff-spacing
1690 The distance between the current non-staff line and the nearest
1691 staff in the direction of @code{staff-affinity}, if there are no
1692 non-staff lines between the two, and @code{staff-affinity} is
1693 either @code{UP} or @code{DOWN}. If @code{staff-affinity} is
1694 @code{CENTER}, then @code{nonstaff-relatedstaff-spacing} is used
1695 for the nearest staves on @emph{both} sides, even if other
1696 non-staff lines appear between the current one and either of the
1699 @item nonstaff-nonstaff-spacing
1700 The distance between the current non-staff line and the next
1701 non-staff line in the direction of @code{staff-affinity}, if both
1702 are on the same side of the related staff, and
1703 @code{staff-affinity} is either @code{UP} or @code{DOWN}.
1705 @item nonstaff-unrelatedstaff-spacing
1706 The distance between the current non-staff line and the staff in
1707 the opposite direction from @code{staff-affinity}, if there are no
1708 other non-staff lines between the two, and @code{staff-affinity}
1709 is either @code{UP} or @code{DOWN}. This can be used, for
1710 example, to require a minimum amount of padding between a
1711 @code{Lyrics} line and the staff to which it does not belong.
1715 @subsubheading Properties of the @code{StaffGrouper} grob
1717 @code{StaffGrouper} properties are typically adjusted with an
1718 @code{\override} at the @code{StaffGroup} level (or equivalent).
1721 @item staff-staff-spacing
1722 The distance between consecutive staves within the current
1723 staff-group. The @code{staff-staff-spacing} property of an
1724 individual staff's @code{VerticalAxisGroup} grob will be used
1725 instead for any staves in the staff-group that have it set. Also
1726 see @code{default-staff-staff-spacing}.
1728 @item staffgroup-staff-spacing
1729 The distance between the last staff of the current staff-group and
1730 the staff just below it in the same system, even if one or more
1731 non-staff lines (such as @code{Lyrics}) exist between the two
1732 staves. Does not apply to the bottom staff of a system. The
1733 @code{staff-staff-spacing} property of an individual staff's
1734 @code{VerticalAxisGroup} grob will be used instead for any staves
1735 in the staff-group that have it set. Also see
1736 @code{default-staff-staff-spacing}.
1741 @file{ly/engraver-init.ly},
1742 @file{scm/define-grobs.scm}.
1744 Internals Reference:
1745 @rinternals{Contexts},
1746 @rinternals{VerticalAxisGroup},
1747 @rinternals{StaffGrouper}.
1750 @node Spacing of ungrouped staves
1751 @unnumberedsubsubsec Spacing of ungrouped staves
1753 @emph{Staves} (such as @code{Staff}, @code{DrumStaff},
1754 @code{TabStaff}, etc.) are contexts that can contain one or more
1755 voice contexts, but cannot contain any other staves.
1757 The following properties affect the spacing of @emph{ungrouped}
1761 @item @code{VerticalAxisGroup} properties:
1763 @item @code{staff-staff-spacing}
1767 These grob properties are described individually above; see
1768 @ref{Within-system spacing properties}.
1770 Additional properties are involved for staves that are part of a
1771 staff-group; see @ref{Spacing of grouped staves}.
1773 The following example shows how the @code{staff-staff-spacing}
1774 property can affect the spacing of ungrouped staves:
1776 @lilypond[verbatim,quote,staffsize=16]
1780 \override VerticalAxisGroup #'staff-staff-spacing =
1783 (minimum-distance . 7))
1788 % The very low note here needs more room than 'space can
1789 % provide, so the distance between this staff and the next is
1790 % determined by 'padding.
1791 \new Staff { b,2 r | }
1793 % Here, 'space provides enough room, and there is no need to
1794 % compress the space (towards 'minimum-distance) to make room
1795 % for anything else on the page, so the distance between this
1796 % staff and the next is determined by 'space.
1797 \new Staff { \clef bass g2 r | }
1799 % By setting 'padding to a negative value, staves can be made to
1800 % collide. The lowest acceptable value for 'space is 0.
1802 \override VerticalAxisGroup #'staff-staff-spacing =
1805 } { \clef bass g2 r | }
1806 \new Staff { \clef bass g2 r | }
1812 @file{scm/define-grobs.scm}.
1817 Internals Reference:
1818 @rinternals{VerticalAxisGroup}.
1821 @node Spacing of grouped staves
1822 @unnumberedsubsubsec Spacing of grouped staves
1824 In orchestral and other large scores, it is common to place staves
1825 in groups. The space between groups is typically larger than the
1826 space between staves of the same group.
1828 @emph{Staff-groups} (such as @code{StaffGroup}, @code{ChoirStaff},
1829 etc.) are contexts that can contain one or more staves
1832 The following properties affect the spacing of staves inside
1836 @item @code{VerticalAxisGroup} properties:
1838 @item @code{staff-staff-spacing}
1839 @item @code{default-staff-staff-spacing}
1841 @item @code{StaffGrouper} properties:
1843 @item @code{staff-staff-spacing}
1844 @item @code{staffgroup-staff-spacing}
1848 These grob properties are described individually above; see
1849 @ref{Within-system spacing properties}.
1851 The following example shows how properties of the
1852 @code{StaffGrouper} grob can affect the spacing of grouped staves:
1854 @lilypond[verbatim,quote,staffsize=16]
1858 \override StaffGrouper #'staff-staff-spacing #'padding = #0
1859 \override StaffGrouper #'staff-staff-spacing #'space = #1
1864 \new PianoStaff \with {
1865 \override StaffGrouper #'staffgroup-staff-spacing #'space = #20
1880 @file{scm/define-grobs.scm}.
1885 Internals Reference:
1886 @rinternals{VerticalAxisGroup},
1887 @rinternals{StaffGrouper}.
1890 @node Spacing of non-staff lines
1891 @unnumberedsubsubsec Spacing of non-staff lines
1893 @emph{Non-staff lines} (such as @code{Lyrics}, @code{ChordNames},
1894 etc.) are contexts whose layout objects are engraved like staves
1895 (i.e. in horizontal lines within systems). Specifically,
1896 non-staff lines are non-staff contexts that create the
1897 @code{VerticalAxisGroup} layout object.
1899 The following properties affect the spacing of non-staff lines:
1902 @item @code{VerticalAxisGroup} properties:
1904 @item @code{staff-affinity}
1905 @item @code{nonstaff-relatedstaff-spacing}
1906 @item @code{nonstaff-nonstaff-spacing}
1907 @item @code{nonstaff-unrelatedstaff-spacing}
1911 These grob properties are described individually above; see
1912 @ref{Within-system spacing properties}.
1914 The following example shows how the
1915 @code{nonstaff-nonstaff-spacing} property can affect the spacing
1916 of consecutive non-staff lines. Here, by setting the
1917 @code{stretchability} key to a very high value, the lyrics are
1918 able to stretch much more than usual:
1920 @lilypond[verbatim,quote,staffsize=16]
1924 \override VerticalAxisGroup
1925 #'nonstaff-nonstaff-spacing #'stretchability = #1000
1932 \override VerticalAxisGroup #'staff-staff-spacing = #'((space . 30))
1935 \override VerticalAxisGroup #'staff-affinity = #UP
1938 \override VerticalAxisGroup #'staff-affinity = #CENTER
1939 } \lyricmode { center }
1941 \override VerticalAxisGroup #'staff-affinity = #DOWN
1942 } \lyricmode { down }
1950 @file{ly/engraver-init.ly},
1951 @file{scm/define-grobs.scm}.
1956 @c @lsr{spacing,page-spacing.ly},
1957 @c @lsr{spacing,alignment-vertical-spacing.ly}.
1959 Internals Reference:
1960 @rinternals{Contexts},
1961 @rinternals{VerticalAxisGroup}.
1964 @node Explicit staff and system positioning
1965 @subsection Explicit staff and system positioning
1967 One way to understand the @code{VerticalAxisGroup} and @code{\paper}
1968 settings explained in the previous two sections is as a collection of
1969 different settings that primarily concern the amount of vertical padding
1970 different staves and systems running down the page.
1972 It is possible to approach vertical spacing in a different way using
1973 @code{NonMusicalPaperColumn #'line-break-system-details}. Where
1974 @code{VerticalAxisGroup} and @code{\paper} settings specify vertical padding,
1975 @code{NonMusicalPaperColumn #'line-break-system-details} specifies exact
1976 vertical positions on the page.
1978 @code{NonMusicalPaperColumn #'line-break-system-details} accepts an associative
1979 list of three different settings:
1982 @item @code{X-offset}
1983 @item @code{Y-offset}
1984 @item @code{alignment-distances}
1987 Grob overrides, including the overrides for @code{NonMusicalPaperColumn}
1988 below, can occur in any of three different places in an input file:
1991 @item in the middle of note entry directly
1992 @item in a @code{\context} block
1993 @item in the @code{\with} block
1996 When we override @code{NonMusicalPaperColumn}, we use the usual
1997 @code{\override} command in @code{\context} blocks and in the
1998 @code{\with} block. On the other hand, when we override
1999 @code{NonMusicalPaperColumn} in the middle of note entry,
2000 use the special @code{\overrideProperty} command. Here are some
2001 example @code{NonMusicalPaperColumn} overrides with the special
2002 @code{\overrideProperty} command:
2005 \overrideProperty NonMusicalPaperColumn
2006 #'line-break-system-details #'((X-offset . 20))
2008 \overrideProperty NonMusicalPaperColumn
2009 #'line-break-system-details #'((Y-offset . 40))
2011 \overrideProperty NonMusicalPaperColumn
2012 #'line-break-system-details #'((X-offset . 20) (Y-offset . 40))
2014 \overrideProperty NonMusicalPaperColumn
2015 #'line-break-system-details #'((alignment-distances . (15)))
2017 \overrideProperty NonMusicalPaperColumn
2018 #'line-break-system-details #'((X-offset . 20) (Y-offset . 40)
2019 (alignment-distances . (15)))
2022 To understand how each of these different settings work, we begin
2023 by looking at an example that includes no overrides at all.
2025 @c \book { } is required in these examples to ensure the spacing
2026 @c overrides can be seen between systems. -np
2029 \header { tagline = ##f }
2030 \paper { left-margin = 0\mm }
2040 \new Voice { \repeat unfold 15 { c'4 c' c' c' } }
2043 \repeat unfold 15 { d'4 d' d' d' }
2050 This score isolates line- and page-breaking information in a dedicated
2051 voice. This technique of creating a breaks voice will help keep layout
2052 separate from music entry as our example becomes more complicated.
2053 See @ref{Using an extra voice for breaks}.
2055 Explicit @code{\breaks} evenly divide the music into six measures per
2056 line. Vertical spacing results from LilyPond's defaults. To set
2057 the vertical startpoint of each system explicitly, we can set
2058 the @code{Y-offset} pair in the @code{line-break-system-details}
2059 attribute of the @code{NonMusicalPaperColumn} grob:
2062 \header { tagline = ##f }
2063 \paper { left-margin = 0\mm }
2069 \overrideProperty #"Score.NonMusicalPaperColumn"
2070 #'line-break-system-details #'((Y-offset . 0))
2072 \overrideProperty #"Score.NonMusicalPaperColumn"
2073 #'line-break-system-details #'((Y-offset . 40))
2075 \overrideProperty #"Score.NonMusicalPaperColumn"
2076 #'line-break-system-details #'((Y-offset . 80))
2079 \new Voice { \repeat unfold 15 { c'4 c' c' c' } }
2082 \repeat unfold 15 { d'4 d' d' d' }
2089 Note that @code{line-break-system-details} takes an associative list of
2090 potentially many values, but that we set only one value here. Note,
2091 too, that the @code{Y-offset} property here determines the exact vertical
2092 position on the page at which each new system will render.
2094 Now that we have set the vertical startpoint of each system
2095 explicitly, we can also set the vertical distances between staves
2096 within each system manually. We do this using the @code{alignment-distances}
2097 subproperty of @code{line-break-system-details}.
2100 \header { tagline = ##f }
2101 \paper { left-margin = 0\mm }
2107 \overrideProperty #"Score.NonMusicalPaperColumn"
2108 #'line-break-system-details #'((Y-offset . 20)
2109 (alignment-distances . (15)))
2111 \overrideProperty #"Score.NonMusicalPaperColumn"
2112 #'line-break-system-details #'((Y-offset . 60)
2113 (alignment-distances . (15)))
2115 \overrideProperty #"Score.NonMusicalPaperColumn"
2116 #'line-break-system-details #'((Y-offset . 100)
2117 (alignment-distances . (15)))
2120 \new Voice { \repeat unfold 15 { c'4 c' c' c' } }
2123 \repeat unfold 15 { d'4 d' d' d' }
2130 Note that here we assign two different values to the
2131 @code{line-break-system-details} attribute of the
2132 @code{NonMusicalPaperColumn} grob. Though the
2133 @code{line-break-system-details} attribute alist accepts many
2134 additional spacing parameters (including, for example, a corresponding
2135 @code{X-offset} pair), we need only set the @code{Y-offset} and
2136 @code{alignment-distances} pairs to control the vertical startpoint of
2137 every system and every staff. Finally, note that @code{alignment-distances}
2138 specifies the vertical positioning of staves but not of staff groups.
2141 \header { tagline = ##f }
2142 \paper { left-margin = 0\mm }
2148 \overrideProperty #"Score.NonMusicalPaperColumn"
2149 #'line-break-system-details #'((Y-offset . 0)
2150 (alignment-distances . (30 10)))
2152 \overrideProperty #"Score.NonMusicalPaperColumn"
2153 #'line-break-system-details #'((Y-offset . 60)
2154 (alignment-distances . (10 10)))
2156 \overrideProperty #"Score.NonMusicalPaperColumn"
2157 #'line-break-system-details #'((Y-offset . 100)
2158 (alignment-distances . (10 30)))
2161 \new Voice { \repeat unfold 15 { c'4 c' c' c' } }
2164 \new Staff { \repeat unfold 15 { d'4 d' d' d' } }
2165 \new Staff { \repeat unfold 15 { e'4 e' e' e' } }
2172 Some points to consider:
2175 @item When using @code{alignment-distances}, lyrics and other non-staff lines
2176 do not count as a staff.
2178 @item The units of the numbers passed to @code{X-offset},
2179 @code{Y-offset} and @code{alignment-distances} are interpreted as multiples
2180 of the distance between adjacent staff lines. Positive values move staves
2181 and lyrics up, negative values move staves and lyrics down.
2183 @item Because the @code{NonMusicalPaperColumn #'line-break-system-details}
2184 settings given here allow the positioning of staves and systems anywhere
2185 on the page, it is possible to violate paper or margin boundaries or even
2186 to print staves or systems on top of one another. Reasonable values
2187 passed to these different settings will avoid this.
2196 @node Vertical collision avoidance
2197 @subsection Vertical collision avoidance
2199 @funindex outside-staff-priority
2200 @funindex outside-staff-padding
2201 @funindex outside-staff-horizontal-padding
2203 Intuitively, there are some objects in musical notation that belong
2204 to the staff and there are other objects that should be placed outside
2205 the staff. Objects belonging outside the staff include things such as
2206 rehearsal marks, text and dynamic markings (from now on, these will
2207 be called outside-staff objects). LilyPond's rule for the
2208 vertical placement of outside-staff objects is to place them as close
2209 to the staff as possible but not so close that they collide with
2212 LilyPond uses the @code{outside-staff-priority} property to determine
2213 whether a grob is an outside-staff object: if @code{outside-staff-priority}
2214 is a number, the grob is an outside-staff object. In addition,
2215 @code{outside-staff-priority} tells LilyPond in which order the objects
2218 First, LilyPond places all the objects that do not belong outside
2219 the staff. Then it sorts the outside-staff objects according to their
2220 @code{outside-staff-priority} (in increasing order). One by one, LilyPond
2221 takes the outside-staff objects and places them so that they do
2222 not collide with any objects that have already been placed. That
2223 is, if two outside-staff grobs are competing for the same space, the one
2224 with the lower @code{outside-staff-priority} will be placed closer to
2227 @lilypond[quote,ragged-right,relative=2,verbatim]
2230 \once \override TextScript #'outside-staff-priority = #1
2231 c4_"Text"\pp % this time the text will be closer to the staff
2233 % by setting outside-staff-priority to a non-number,
2234 % we disable the automatic collision avoidance
2235 \once \override TextScript #'outside-staff-priority = ##f
2236 \once \override DynamicLineSpanner #'outside-staff-priority = ##f
2237 c4_"Text"\pp % now they will collide
2240 The vertical padding between an outside-staff object and the
2241 previously-positioned grobs can be controlled with
2242 @code{outside-staff-padding}.
2244 @lilypond[quote,ragged-right,relative=2,verbatim]
2245 \once \override TextScript #'outside-staff-padding = #0
2246 a'^"This text is placed very close to the note"
2247 \once \override TextScript #'outside-staff-padding = #3
2248 c^"This text is padded away from the previous text"
2249 c^"This text is placed close to the previous text"
2253 By default, outside-staff objects are placed only to avoid
2254 a horizontal collision with previously-positioned grobs. This
2255 can lead to situations in which objects are placed very close to each
2256 other horizontally. The vertical spacing between staves can
2257 also be set so that outside staff objects are interleaved.
2258 Setting @code{outside-staff-horizontal-padding}
2259 causes an object to be offset vertically so that such a situation
2262 @lilypond[quote,ragged-right,relative=2,verbatim]
2263 % the markup is too close to the following note
2267 % setting outside-staff-horizontal-padding fixes this
2269 \once \override TextScript #'outside-staff-horizontal-padding = #1
2281 @node Horizontal spacing
2282 @section Horizontal spacing
2284 @cindex horizontal spacing
2285 @cindex spacing, horizontal
2288 * Horizontal spacing overview::
2289 * New spacing area::
2290 * Changing horizontal spacing::
2292 * Proportional notation::
2296 @node Horizontal spacing overview
2297 @subsection Horizontal spacing overview
2299 The spacing engine translates differences in durations into stretchable
2300 distances (@q{springs}) of differing lengths. Longer durations get
2301 more space, shorter durations get less. The shortest durations get a
2302 fixed amount of space (which is controlled by
2303 @code{shortest-duration-space} in the @rinternals{SpacingSpanner}
2304 object). The longer the duration, the more space it gets: doubling a
2305 duration adds a fixed amount (this amount is controlled by
2306 @code{spacing-increment}) of space to the note.
2308 For example, the following piece contains lots of half, quarter, and
2309 8th notes; the eighth note is followed by 1 note head width (NHW).
2310 The quarter note is followed by 2 NHW, the half by 3 NHW, etc.
2312 @lilypond[quote,verbatim,relative=1]
2313 c2 c4. c8 c4. c8 c4. c8 c8
2317 Normally, @code{spacing-increment} is set to 1.2 staff space, which is
2318 approximately the width of a note head, and
2319 @code{shortest-duration-space} is set to 2.0, meaning that the
2320 shortest note gets 2.4 staff space (2.0 times the
2321 @code{spacing-increment}) of horizontal space. This space is counted
2322 from the left edge of the symbol, so the shortest notes are generally
2323 followed by one NHW of space.
2325 If one would follow the above procedure exactly, then adding a single
2326 32nd note to a score that uses 8th and 16th notes, would widen up the
2327 entire score a lot. The shortest note is no longer a 16th, but a 32nd,
2328 thus adding 1 NHW to every note. To prevent this, the shortest
2329 duration for spacing is not the shortest note in the score, but rather
2330 the one which occurs most frequently.
2333 The most common shortest duration is determined as follows: in every
2334 measure, the shortest duration is determined. The most common shortest
2335 duration is taken as the basis for the spacing, with the stipulation
2336 that this shortest duration should always be equal to or shorter than
2337 an 8th note. The shortest duration is printed when you run
2338 @code{lilypond} with the @code{--verbose} option.
2340 These durations may also be customized. If you set the
2341 @code{common-shortest-duration} in @rinternals{SpacingSpanner}, then
2342 this sets the base duration for spacing. The maximum duration for this
2343 base (normally an 8th), is set through @code{base-shortest-duration}.
2345 @funindex common-shortest-duration
2346 @funindex base-shortest-duration
2347 @funindex stem-spacing-correction
2350 Notes that are even shorter than the common shortest note are
2351 followed by a space that is proportional to their duration relative to
2352 the common shortest note. So if we were to add only a few 16th notes
2353 to the example above, they would be followed by half a NHW:
2355 @lilypond[quote,verbatim,relative=2]
2356 c2 c4. c8 c4. c16[ c] c4. c8 c8 c8 c4 c4 c4
2360 In the @emph{Essay on automated music engraving}, it was explained
2361 that stem directions influence spacing (see @ressay{Optical
2362 spacing}). This is controlled with the
2363 @code{stem-spacing-correction} property in the
2364 @rinternals{NoteSpacing}, object. These are generated for every
2365 @rinternals{Voice} context. The @code{StaffSpacing} object
2366 (generated in @rinternals{Staff} context) contains the same
2367 property for controlling the stem/bar line spacing. The following
2368 example shows these corrections, once with default settings, and
2369 once with exaggerated corrections:
2371 @lilypond[quote,ragged-right]
2375 \override Staff.NoteSpacing #'stem-spacing-correction = #1.5
2376 \override Staff.StaffSpacing #'stem-spacing-correction = #1.5
2382 Proportional notation is supported; see @ref{Proportional notation}.
2389 Internals Reference:
2390 @rinternals{SpacingSpanner},
2391 @rinternals{NoteSpacing},
2392 @rinternals{StaffSpacing},
2393 @rinternals{NonMusicalPaperColumn}.
2398 There is no convenient mechanism to manually override spacing. The
2399 following work-around may be used to insert extra space into a score,
2400 adjusting the padding value as necessary.
2402 \override Score.NonMusicalPaperColumn #'padding = #10
2405 No work-around exists for decreasing the amount of space.
2408 @node New spacing area
2409 @subsection New spacing area
2411 New sections with different spacing parameters can be started with
2412 @code{newSpacingSection}. This is useful when there are
2413 sections with a different notions of long and short notes.
2415 In the following example, the time signature change introduces a new
2416 section, and hence the 16ths notes are spaced wider.
2418 @lilypond[relative=1,verbatim,quote]
2421 c8 c c4 c16[ c c8] c4
2427 The @code{\newSpacingSection} command creates a new
2428 @code{SpacingSpanner} object, and hence new @code{\override}s
2429 may be used in that location.
2436 Internals Reference:
2437 @rinternals{SpacingSpanner}.
2440 @node Changing horizontal spacing
2441 @subsection Changing horizontal spacing
2443 Horizontal spacing may be altered with the
2444 @code{base-shortest-duration} property. Here
2445 we compare the same music; once without altering
2446 the property, and then altered. Larger values
2447 of @code{ly:make-moment} will produce smaller
2448 music. Note that @code{ly:make-moment} constructs
2449 a duration, so @code{1 4} is a longer duration
2452 @lilypond[verbatim,line-width=12\cm]
2455 g4 e e2 | f4 d d2 | c4 d e f | g4 g g2 |
2456 g4 e e2 | f4 d d2 | c4 e g g | c,1 |
2457 d4 d d d | d4 e f2 | e4 e e e | e4 f g2 |
2458 g4 e e2 | f4 d d2 | c4 e g g | c,1 |
2463 @lilypond[verbatim,line-width=12\cm]
2466 g4 e e2 | f4 d d2 | c4 d e f | g4 g g2 |
2467 g4 e e2 | f4 d d2 | c4 e g g | c,1 |
2468 d4 d d d | d4 e f2 | e4 e e e | e4 f g2 |
2469 g4 e e2 | f4 d d2 | c4 e g g | c,1 |
2474 \override SpacingSpanner
2475 #'base-shortest-duration = #(ly:make-moment 1 16)
2484 By default, spacing in tuplets depends on various non-duration
2485 factors (such as accidentals, clef changes, etc). To disregard
2486 such symbols and force uniform equal-duration spacing, use
2487 @code{Score.SpacingSpanner #'uniform-stretching}. This
2488 property can only be changed at the beginning of a score,
2490 @lilypond[quote,ragged-right,verbatim]
2509 \override SpacingSpanner #'uniform-stretching = ##t
2515 When @code{strict-note-spacing} is set, notes are spaced without
2516 regard for clefs, bar lines, and grace notes,
2518 @lilypond[quote,ragged-right,relative=2,verbatim]
2519 \override Score.SpacingSpanner #'strict-note-spacing = ##t
2520 \new Staff { c8[ c \clef alto c \grace { c16[ c] } c8 c c] c32[ c32] }
2530 @subsection Line length
2533 @cindex breaking pages
2536 @funindex line-width
2537 @funindex ragged-right
2538 @funindex ragged-last
2540 @c Although line-width can be set in \layout, it should be set in paper
2541 @c block, to get page layout right.
2542 @c Setting indent in \paper block makes not much sense, but it works.
2544 @c Bit verbose and vague, use examples?
2545 The most basic settings influencing the spacing are @code{indent} and
2546 @code{line-width}. They are set in the @code{\layout} block. They
2547 control the indentation of the first line of music, and the lengths of
2550 If @code{ragged-right} is set to true in the @code{\layout} block, then
2551 systems ends at their natural horizontal length, instead of being spread
2552 horizontally to fill the whole line. This is useful for
2553 short fragments, and for checking how tight the natural spacing is.
2554 The normal default setting is false, but if the score has only one
2555 system the default value is true.
2558 @cindex vertical spacing
2560 The option @code{ragged-last} is similar to @code{ragged-right}, but
2561 only affects the last line of the piece. No restrictions are put on
2562 that line. The result is similar to formatting text paragraphs. In a
2563 paragraph, the last line simply takes its natural horizontal length.
2564 @c Note that for text there are several options for the last line.
2565 @c While Knuth TeX uses natural length, lead typesetters use the same
2566 @c stretch as the previous line. eTeX uses \lastlinefit to
2567 @c interpolate between both these solutions.
2583 @node Proportional notation
2584 @subsection Proportional notation
2586 LilyPond supports proportional notation, a type of horizontal spacing
2587 in which each note consumes an amount of horizontal space exactly
2588 equivalent to its rhythmic duration. This type of proportional spacing
2589 is comparable to horizontal spacing on top of graph paper. Some late
2590 20th- and early 21st-century scores use proportional notation to
2591 clarify complex rhythmic relationships or to facilitate the placement
2592 of timelines or other graphics directly in the score.
2594 LilyPond supports five different settings for proportional notation,
2595 which may be used together or alone:
2598 @item @code{proportionalNotationDuration}
2599 @item @code{uniform-stretching}
2600 @item @code{strict-note-spacing}
2601 @item @code{\remove Separating_line_group_engraver}
2602 @item @code{\override PaperColumn #'used = ##t}
2605 In the examples that follow, we explore these five different
2606 proportional notation settings and examine how these settings interact.
2608 We start with the following one-measure example, which uses classical
2609 spacing with ragged-right turned on.
2611 @lilypond[quote,verbatim,ragged-right]
2614 \new RhythmicStaff {
2618 c'16 c'16 c'16 c'16 c'16
2625 Notice that the half note which begins the measure takes up far less
2626 than half of the horizontal space of the measure. Likewise, the
2627 sixteenth notes and sixteenth-note quintuplets (or twentieth notes)
2628 which end the measure together take up far more than half the
2629 horizontal space of the measure.
2631 In classical engraving, this spacing may be exactly what we want
2632 because we can borrow horizontal space from the half note and conserve
2633 horizontal space across the measure as a whole.
2635 On the other hand, if we want to insert a measured timeline or other
2636 graphic above or below our score, we need proportional notation. We
2637 turn proportional notation on with the proportionalNotationDuration
2640 @lilypond[quote,verbatim,ragged-right]
2643 \new RhythmicStaff {
2647 c'16 c'16 c'16 c'16 c'16
2654 proportionalNotationDuration = #(ly:make-moment 1 20)
2660 The half note at the beginning of the measure and the faster notes in
2661 the second half of the measure now occupy equal amounts of horizontal
2662 space. We could place a measured timeline or graphic above or below
2665 The @code{proportionalNotationDuration} setting is a context setting
2666 that lives in @code{Score}. Remember that context settings can appear
2667 in one of three locations within our input file -- in a @code{\with}
2668 block, in a @code{\context} block, or directly in music entry preceded
2669 by the @code{\set} command. As with all context settings, users can
2670 pick which of the three different locations they would like to
2671 set @code{proportionalNotationDuration} in to.
2673 The @code{proportionalNotationDuration} setting takes a single argument,
2674 which is the reference duration against that all music will be spaced.
2675 The LilyPond Scheme function @code{make-moment} takes two arguments
2676 -- a numerator and denominator which together express some fraction of
2677 a whole note. The call @code{#(ly:make-moment 1 20)} therefore produces
2678 a reference duration of a twentieth note. Values such as
2679 @code{#(ly:make-moment 1 16)}, @code{#(ly:make-moment 1 8)}, and
2680 @code{#(ly:make-moment 3 97)} are all possible as well.
2682 How do we select the right reference duration to pass to
2683 @code{proportionalNotationDuration}? Usually by a process of trial
2684 and error, beginning with a duration close to the fastest (or smallest)
2685 duration in the piece. Smaller reference durations space music loosely;
2686 larger reference durations space music tightly.
2688 @lilypond[quote,verbatim,ragged-right]
2691 \new RhythmicStaff {
2695 c'16 c'16 c'16 c'16 c'16
2702 proportionalNotationDuration = #(ly:make-moment 1 8)
2709 \new RhythmicStaff {
2713 c'16 c'16 c'16 c'16 c'16
2720 proportionalNotationDuration = #(ly:make-moment 1 16)
2727 \new RhythmicStaff {
2731 c'16 c'16 c'16 c'16 c'16
2738 proportionalNotationDuration = #(ly:make-moment 1 32)
2744 Note that too large a reference duration -- such as the eighth note,
2745 above -- spaces music too tightly and can cause note head collisions.
2746 Also that proportional notation in general takes up more horizontal
2747 space than classical spacing. Proportional spacing provides rhythmic
2748 clarity at the expense of horizontal space.
2750 Next we examine how to optimally space overlapping tuplets.
2752 We start by examining what happens to our original example, with
2753 classical spacing, when we add a second staff with a different type of
2756 @lilypond[quote,verbatim,ragged-right]
2759 \new RhythmicStaff {
2763 c'16 c'16 c'16 c'16 c'16
2766 \new RhythmicStaff {
2768 c'8 c'8 c'8 c'8 c'8 c'8 c'8 c'8 c'8
2775 The spacing is bad because the evenly spaced notes of the bottom staff
2776 do not stretch uniformly. Classical engravings include very few complex
2777 triplets and so classical engraving rules can generate this type of
2778 result. Setting @code{proportionalNotationDuration} fixes this.
2780 @lilypond[quote,verbatim,ragged-right]
2783 \new RhythmicStaff {
2787 c'16 c'16 c'16 c'16 c'16
2790 \new RhythmicStaff {
2792 c'8 c'8 c'8 c'8 c'8 c'8 c'8 c'8 c'8
2799 proportionalNotationDuration = #(ly:make-moment 1 20)
2805 But if we look very carefully we can see that notes of the second half
2806 of the 9-tuplet space ever so slightly more widely than the notes
2807 of the first half of the 9-tuplet. To ensure uniform stretching, we
2808 turn on @code{uniform-stretching}, which is a property of
2809 @code{SpacingSpanner}.
2811 @lilypond[quote,verbatim,ragged-right]
2814 \new RhythmicStaff {
2818 c'16 c'16 c'16 c'16 c'16
2821 \new RhythmicStaff {
2823 c'8 c'8 c'8 c'8 c'8 c'8 c'8 c'8 c'8
2830 proportionalNotationDuration = #(ly:make-moment 1 20)
2831 \override SpacingSpanner #'uniform-stretching = ##t
2837 Our two-staff example now spaces exactly, our rhythmic
2838 relationships are visually clear, and we can include a measured
2839 timeline or graphic if we want.
2841 Note that the LilyPond's proportional notation package expects
2842 that all proportional scores set the SpacingSpanner's
2843 'uniform-stretching attribute to ##t. Setting
2844 proportionalNotationDuration without also setting the
2845 SpacingSpanner's 'uniform-stretching attribute to ##t will, for
2846 example, cause Skips to consume an incorrect amount of horizontal
2849 The SpacingSpanner is an abstract grob that lives in the Score
2850 context. As with our settings of proportionalNotationDuration,
2851 overrides to the SpacingSpanner can occur in any of three
2852 different places in our input file – in the Score \with block, in
2853 a Score \context block, or in note entry directly.
2855 There is by default only one @code{SpacingSpanner} per @code{Score}. This
2856 means that, by default, @code{uniform-stretching} is either turned on for the
2857 entire score or turned off for the entire score. We can, however,
2858 override this behavior and turn on different spacing features at
2859 different places in the score. We do this with the command
2860 @code{\newSpacingSection}. See @ref{New spacing area}, for more info.
2862 Next we examine the effects of the @code{Separating_line_group_engraver} and
2863 see why proportional scores frequently remove this engraver. The following
2864 example shows that there is a small amount of @qq{preferatory} space
2865 just before the first note in each system.
2867 @lilypond[quote,verbatim,ragged-right]
2880 The amount of this preferatory space is the same whether after a time
2881 signature, a key signature or a clef. @code{Separating_line_group_engraver}
2882 is responsible for this space. Removing @code{Separating_line_group_engraver}
2883 reduces this space to zero.
2885 @lilypond[quote,verbatim,ragged-right]
2891 \remove Separating_line_group_engraver
2899 Nonmusical elements like time signatures, key signatures, clefs and
2900 accidentals are problematic in proportional notation. None of these
2901 elements has rhythmic duration. But all of these elements consume
2902 horizontal space. Different proportional scores approach these
2903 problems differently.
2905 It may be possible to avoid spacing problems with key signatures
2906 simply by not having any. This is a valid option since most
2907 proportional scores are contemporary music. The same may be true
2908 of time signatures, especially for those scores
2909 that include a measured timeline or other graphic. But these scores
2910 are exceptional and most proportional scores include at least some
2911 time signatures. Clefs and accidentals are even more essential.
2913 So what strategies exist for spacing nonmusical elements in a
2914 proportional context? One good option is the @code{strict-note-spacing}
2915 property of @code{SpacingSpanner}. Compare the two scores below:
2917 @lilypond[quote,verbatim,ragged-right]
2919 \set Score.proportionalNotationDuration = #(ly:make-moment 1 16)
2929 \set Score.proportionalNotationDuration = #(ly:make-moment 1 16)
2930 \override Score.SpacingSpanner #'strict-note-spacing = ##t
2940 Both scores are proportional, but the spacing in the first score
2941 is too loose because of the clef change. The spacing of the second
2942 score remains strict, however, because strict-note-spacing is
2943 turned on. Turning on strict-note-spacing causes the width of
2944 time signatures, key signatures, clefs and accidentals to play no
2945 part in the spacing algorithm.
2947 In addition to the settings given here, there are other settings
2948 that frequently appear in proportional scores. These include:
2951 @item @code{\override SpacingSpanner #'strict-grace-spacing = ##t}
2952 @item @code{tupletFullLength = ##t}
2953 @item @code{\override Beam #'breakable = ##t}
2954 @item @code{\override Glissando #'breakable = ##t}
2955 @item @code{\override TextSpanner #'breakable = ##t}
2956 @item @code{\remove Forbid_line_break_engraver in the Voice context}
2959 These settings space grace notes strictly, extend tuplet brackets to
2960 mark both rhythmic start- and stop-points, and allow spanning elements
2961 to break across systems and pages. See the respective parts of the manual
2962 for these related settings.
2967 @ref{New spacing area}.
2973 @node Fitting music onto fewer pages
2974 @section Fitting music onto fewer pages
2976 Sometimes you can end up with one or two staves on a second
2977 (or third, or fourth...) page. This is annoying, especially
2978 if you look at previous pages and it looks like there is plenty
2979 of room left on those.
2981 When investigating layout issues, @code{annotate-spacing} is an
2982 invaluable tool. This command prints the values of various layout
2983 spacing variables; for more details see the following section,
2984 @ref{Displaying spacing}.
2987 * Displaying spacing::
2988 * Changing spacing::
2992 @node Displaying spacing
2993 @subsection Displaying spacing
2995 @funindex annotate-spacing
2996 @cindex spacing, display of layout
2998 To graphically display the dimensions of vertical layout variables
2999 that may be altered for page formatting, set
3000 @code{annotate-spacing} in the @code{\paper} block:
3002 @c need to have \book{} otherwise we get the separate systems. -hwn
3003 @lilypond[verbatim,quote]
3004 #(set-default-paper-size "a6" 'landscape)
3007 \paper { annotate-spacing = ##t }
3013 All layout dimensions are displayed in staff-spaces, regardless
3014 of the units specified in the @code{\paper} or @code{\layout} block.
3015 In the above example, @code{paper-height} has a value of 59.75
3016 @code{staff-spaces}, and the @code{staff-size} is 20 points (the
3017 default value). Note that:
3019 @multitable {1 staff-space} {staff-size)/4 * (25.4/72.27) mm}
3022 @tab = (25.4/72.27) mm
3025 @tab = (@code{staff-size})/4 pts
3027 @tab = (@code{staff-size})/4 * (25.4/72.27) mm
3032 In this case, one @code{staff-space} is approximately equal to
3033 1.757mm. Thus the @code{paper-height} measurement of 59.75
3034 @code{staff-spaces} is equivalent to 105 millimeters, the height
3035 of @code{a6} paper in landscape orientation. The pairs
3036 (@var{a},@var{b}) are intervals, where @var{a} is the lower
3037 edge and @var{b} the upper edge of the interval.
3042 @ref{Setting the staff size}.
3048 @node Changing spacing
3049 @subsection Changing spacing
3051 The output of @code{annotate-spacing} reveals vertical dimensions
3052 in great detail. For details about modifying margins and other
3053 layout variables, see @ref{Page formatting}.
3055 Other than margins, there are a few other options to save space:
3059 Force systems to move as close together as possible (to fit as
3060 many systems as possible onto a page) while being spaced so that
3061 there is no blank space at the bottom of the page.
3065 system-system-spacing = #'((padding . 0) (space . 0.1))
3066 ragged-last-bottom = ##f
3072 Force the number of systems. This can help in two ways. Just
3073 setting a value, even the same value as the number of systems
3074 being typeset by default, will sometimes cause more systems to
3075 be fitted onto each page, as an estimation step is then bypassed,
3076 giving a more accurate fit to each page. Also, forcing an actual
3077 reduction in the number of systems may save a further page. For
3078 example, if the default layout has 11 systems, the following
3079 assignment will force a layout with 10 systems.
3088 Avoid (or reduce) objects that increase the vertical size of a
3089 system. For example, volta repeats (or alternate repeats) require
3090 extra space. If these repeats are spread over two systems, they
3091 will take up more space than one system with the volta repeats and
3092 another system without. For example, dynamics that @q{stick out} of
3093 a system can be moved closer to the staff:
3095 @lilypond[verbatim,quote,relative=1]
3097 e4 c g-\tweak #'X-offset #-2.7 -\tweak #'Y-offset #2.5 \f c
3101 Alter the horizontal spacing via @code{SpacingSpanner}. For more
3102 details, see @ref{Changing horizontal spacing}. The following
3103 example illustrates the default spacing:
3105 @lilypond[verbatim,quote]
3118 The next example modifies @code{common-shortest-duration} from a
3119 value of @code{1/4} to @code{1/2}. The quarter note is the most
3120 common and shortest duration in this example, so by making this
3121 duration longer, a @q{squeezing} effect occurs:
3123 @lilypond[verbatim,quote]
3135 \override SpacingSpanner
3136 #'common-shortest-duration = #(ly:make-moment 1 2)
3143 The @code{common-shortest-duration} property cannot be modified
3144 dynamically, so it must always be placed in a @code{\context}
3145 block so that it applies to the whole score.
3152 @ref{Page formatting},
3153 @ref{Changing horizontal spacing}.