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 Two types of blocks can contain layout settings:
72 @code{\paper @{@dots{}@}} and @code{\layout @{@dots{}@}}. The
73 @code{\paper} block contains page layout settings that are
74 expected to be the same for all scores in a book, such as the
75 paper height, or whether to print page numbers, etc. See
76 @ref{Page layout}. The @code{\layout} block contains score layout
77 settings, such as the number of systems to use, or the space
78 between staff-groups, etc. See @ref{Score layout}.
85 * Horizontal spacing::
86 * Fitting music onto fewer pages::
93 This section discusses page layout options for the @code{\paper}
98 * Paper size and automatic scaling::
99 * Fixed vertical spacing \paper variables::
100 * Flexible vertical spacing \paper variables::
101 * Horizontal spacing \paper variables::
102 * Other \paper variables::
106 @node The \paper block
107 @subsection The @code{\paper} block
109 The @code{\paper} block can appear within a @code{\book} block,
110 but not within a @code{\score} block. Settings in a @code{\paper}
111 block apply to the entire book, which may include multiple scores.
112 Settings that can appear in a @code{\paper} block include:
117 the @code{set-paper-size} scheme function,
120 @code{\paper} variables used for customizing page layout, and
123 markup definitions used for customizing the layout of headers,
128 The @code{set-paper-size} function is discussed in the next
129 section, @ref{Paper size and automatic scaling}. The
130 @code{\paper} variables that deal with page layout are discussed
131 in later sections. The markup definitions that deal with headers,
132 footers, and titles are discussed in
133 @ref{Custom headers footers and titles}.
135 Most @code{\paper} variables will only work in a @code{\paper}
136 block. The few that will also work in a @code{\layout} block are
137 listed in @ref{The \layout block}.
139 Except when specified otherwise, all @code{\paper} variables that
140 correspond to distances on the page are measured in millimeters,
141 unless a different unit is specified by the user. For example,
142 the following declaration sets @code{top-margin} to ten
151 To set it to @code{0.5} inches, use the @code{\in} unit suffix:
159 The available unit suffixes are @code{\mm}, @code{\cm},
160 @code{\in}, and @code{\pt}. These units are simple values for
161 converting from millimeters; they are defined in
162 @file{ly/paper-defaults-init.ly}. For the sake of clarity, when
163 using millimeters, the @code{\mm} is typically included in the
164 code, even though it is not technically necessary.
166 It is also possible to define @code{\paper} values using Scheme.
167 The Scheme equivalent of the above example is:
171 #(define top-margin (* 0.5 in))
177 @ref{Paper size and automatic scaling},
178 @ref{Custom headers footers and titles},
179 @ref{The \layout block}.
182 @file{ly/paper-defaults-init.ly}.
185 @node Paper size and automatic scaling
186 @subsection Paper size and automatic scaling
194 * Setting paper size::
195 * Automatic scaling to paper size::
199 @node Setting paper size
200 @unnumberedsubsubsec Setting paper size
202 Two functions are available for changing the paper size:
203 @code{set-default-paper-size} and @code{set-paper-size}.
204 @code{set-default-paper-size} must be placed in the toplevel
205 scope, and @code{set-paper-size} must be placed in a @code{\paper}
209 #(set-default-paper-size "a4")
214 #(set-paper-size "a4")
219 In the toplevel scope, the @code{set-default-paper-size} function
220 can safely be called anywhere before the first @code{\paper}
221 block. Within a @code{\paper} block, the safest place to call
222 @code{set-paper-size} is at the top, above the list of variable
223 declarations. The reasons for this are discussed in
224 @ref{Automatic scaling to paper size}.
226 @code{set-default-paper-size} sets the size of all pages, whereas
227 @code{set-paper-size} only sets the size of the pages that the
228 @code{\paper} block applies to. For example, if the @code{\paper}
229 block is at the top of the file, then it will apply the paper size
230 to all pages. If the @code{\paper} block is inside a
231 @code{\book}, then the paper size will only apply to that book.
233 Common paper sizes are available, including @code{a4},
234 @code{letter}, @code{legal}, and @code{11x17} (also known as
235 tabloid). Many more paper sizes are supported by default. For
236 details, see @file{scm/paper.scm}, and search for the
237 definition of @code{paper-alist}.
239 @c TODO add a new appendix for paper sizes (auto-generated) -pm
241 @warning{The default paper size is @code{a4}.}
243 Extra sizes may be added by editing the definition of
244 @code{paper-alist} in the initialization file
245 @file{scm/paper.scm}, however they will be overridden on a
251 If the symbol @code{'landscape} is supplied as an argument to
252 @code{set-default-paper-size}, pages will be rotated by 90
253 degrees, and wider line widths will be set accordingly.
256 #(set-default-paper-size "a6" 'landscape)
261 @ref{Automatic scaling to paper size}.
264 @file{scm/paper.scm}.
267 @node Automatic scaling to paper size
268 @unnumberedsubsubsec Automatic scaling to paper size
270 If the paper size is changed with one of the scheme functions
271 (@code{set-default-paper-size} or @code{set-paper-size}), the
272 values of several @code{\paper} variables are automatically scaled
273 to the new size. To bypass the automatic scaling for a particular
274 variable, set the variable after setting the paper size. Note
275 that the automatic scaling is not triggered by setting the
276 @code{paper-height} or @code{paper-width} variables, even though
277 @code{paper-width} can influence other values (this is separate
278 from scaling and is discussed below). The
279 @code{set-default-paper-size} and @code{set-paper-size} functions
280 are described in @ref{Setting paper size}.
282 The vertical dimensions affected by automatic scaling are
283 @code{top-margin} and @code{bottom-margin} (see
284 @ref{Fixed vertical spacing \paper variables}). The horizontal
285 dimensions affected by automatic scaling are @code{left-margin},
286 @code{right-margin}, @code{inner-margin}, @code{outer-margin},
287 @code{binding-offset}, @code{indent}, and @code{short-indent} (see
288 @ref{Horizontal spacing \paper variables}).
290 The default values for these dimensions are set in
291 @file{ly/paper-defaults-init.ly}, using internal variables named
292 @code{top-margin-default}, @code{bottom-margin-default}, etc.
293 These are the values that result at the default paper size
294 @code{a4}. For reference, with @code{a4} paper the
295 @code{paper-height} is @code{297\mm} and the @code{paper-width} is
300 @ref{Fixed vertical spacing \paper variables},
301 @ref{Horizontal spacing \paper variables}.
304 @file{ly/paper-defaults-init.ly},
305 @file{scm/paper.scm}.
308 @node Fixed vertical spacing \paper variables
309 @subsection Fixed vertical spacing @code{\paper} variables
311 @warning{Some @code{@bs{}paper} dimensions are automatically
312 scaled to the paper size, which may lead to unexpected behavior.
313 See @ref{Automatic scaling to paper size}.}
315 Default values (before scaling) are defined in
316 @file{ly/paper-defaults-init.ly}.
320 @funindex paper-height
322 The height of the page, unset by default. Note that the automatic
323 scaling of some vertical dimensions is not affected by this.
328 The margin between the top of the page and the top of the
329 printable area. If the paper size is modified, this dimension's
330 default value is scaled accordingly.
333 @funindex bottom-margin
335 The margin between the bottom of the printable area and the bottom
336 of the page. If the paper size is modified, this dimension's
337 default value is scaled accordingly.
340 @funindex ragged-bottom
342 If set to true, systems will not spread vertically down the page.
343 This does not affect the last page. This should be set to true
344 for pieces that have only two or three systems per page, for
345 example orchestral scores.
347 @item ragged-last-bottom
348 @funindex ragged-last-bottom
350 If set to false, systems will spread vertically down the last
351 page. Pieces that amply fill two pages or more should have this
352 set to false. It also affects the last page of book parts, i.e.
353 parts of a book created with @code{\bookpart} blocks.
359 @ref{Automatic scaling to paper size}.
362 @file{ly/paper-defaults-init.ly}.
369 The titles (from the @code{\header} block) are treated as a
370 system, so @code{ragged-bottom} and @code{ragged-last-bottom} will
371 add space between the titles and the first system of the score.
373 Explicitly defined paper-sizes will override any user-defined top or
374 bottom margin settings.
377 @node Flexible vertical spacing \paper variables
378 @subsection Flexible vertical spacing @code{\paper} variables
380 In most cases, it is preferable for the vertical distances between
381 certain items (such as margins, titles, systems, and separate
382 scores) to be flexible, so that they stretch and compress nicely
383 according to each situation. A number of @code{\paper} variables
384 (listed below) are available to fine-tune the stretching behavior
387 Note that the @code{\paper} variables discussed in this section do
388 not control the spacing of staves within individual systems.
389 Within-system spacing is controlled by grob properties, with
390 settings typically entered inside a @code{\score} or
391 @code{\layout} block, and not inside a @code{\paper} block. See
392 @ref{Flexible vertical spacing within systems}.
395 * Structure of flexible vertical spacing alists::
396 * List of flexible vertical spacing \paper variables::
400 @node Structure of flexible vertical spacing alists
401 @unnumberedsubsubsec Structure of flexible vertical spacing alists
403 Each of the flexible vertical spacing @code{\paper} variables is
404 an alist (association list) containing four @emph{keys}:
409 @code{basic-distance} -- the vertical distance, measured in
410 staff-spaces, between the @emph{reference points} of the two
411 items, when no collisions would result, and no stretching or
412 compressing is in effect. The reference point of a (title or
413 top-level) markup is its highest point, and the reference point of
414 a system is the vertical center of the nearest @code{StaffSymbol}
415 -- even if a non-staff line (such as a @code{Lyrics} context) is
416 in the way. Values for @code{basic-distance} that are less than
417 either @code{padding} or @code{minimum-distance} are not
418 meaningful, since the resulting distance will never be less than
419 either @code{padding} or @code{minimum-distance}.
422 @code{minimum-distance} -- the smallest allowable vertical
423 distance, measured in staff-spaces, between the reference points
424 of the two items, when compressing is in effect. Values for
425 @code{minimum-distance} that are less than @code{padding} are not
426 meaningful, since the resulting distance will never be less than
429 @c TODO: explain skylines somewhere and xref to it from here.
432 @code{padding} -- the minimum required amount of unobstructed
433 vertical whitespace between the bounding boxes (or skylines) of
434 the two items, measured in staff-spaces.
437 @code{stretchability} -- a unitless measure of the dimension's
438 relative propensity to stretch. If zero, the distance will not
439 stretch (unless collisions would result). When positive, the
440 significance of a particular dimension's @code{stretchability}
441 value lies only in its relation to the @code{stretchability}
442 values of the other dimensions. For example, if one dimension has
443 twice the @code{stretchability} of another, it will stretch twice
444 as easily. Values should be non-negative and finite. The value
445 @code{+inf.0} triggers a @code{programming_error} and is ignored,
446 but @code{1.0e7} can be used for an almost infinitely stretchable
447 spring. If unset, the default value is set to
448 @code{basic-distance}. Note that the dimension's propensity to
449 @emph{compress} cannot be directly set by the user and is equal to
450 (@code{basic-distance}@tie{}@minus{}@tie{}@code{minimum-distance}).
454 If a page has a ragged bottom, the resulting distance is the
460 @code{basic-distance},
463 @code{minimum-distance}, and
466 @code{padding} plus the smallest distance necessary to eliminate
471 Specific methods for modifying alists are discussed in
472 @ref{Modifying alists}. The following example demonstrates the
473 two ways these alists can be modified. The first declaration
474 updates one key-value individually, and the second completely
475 redefines the variable:
479 system-system-spacing #'basic-distance = #8
480 score-system-spacing =
481 #'((basic-distance . 12)
482 (minimum-distance . 6)
484 (stretchability . 12))
489 @node List of flexible vertical spacing \paper variables
490 @unnumberedsubsubsec List of flexible vertical spacing @code{\paper} variables
492 The names of these variables follow the format
493 @code{@var{upper}-@var{lower}-spacing}, where @code{@var{upper}}
494 and @code{@var{lower}} are the items to be spaced. Each distance
495 is measured between the reference points of the two items (see the
496 description of the alist structure above). Note that in these
497 variable names, the term @q{@code{markup}} refers to both
498 @emph{title markups} (@code{bookTitleMarkup} or
499 @code{scoreTitleMarkup}) and @emph{top-level markups} (see
500 @ref{File structure}). All distances are measured in
503 Default settings are defined in @file{ly/paper-defaults-init.ly}.
505 @c TODO: Where do headers/footers fit in? -mp
508 @item markup-system-spacing
509 @funindex markup-system-spacing
511 the distance between a (title or top-level) markup and the system
514 @item score-markup-spacing
515 @funindex score-markup-spacing
517 the distance between the last system of a score and the (title or
518 top-level) markup that follows it.
520 @item score-system-spacing
521 @funindex score-system-spacing
523 the distance between the last system of a score and the first
524 system of the score that follows it, when no (title or top-level)
525 markup exists between them.
527 @item system-system-spacing
528 @funindex system-system-spacing
530 the distance between two systems in the same score.
532 @item markup-markup-spacing
533 @funindex markup-markup-spacing
535 the distance between two (title or top-level) markups.
537 @item last-bottom-spacing
538 @funindex last-bottom-spacing
540 the distance from the last system or top-level markup on a page to
541 the bottom of the printable area (i.e. the top of the bottom
544 @item top-system-spacing
545 @funindex top-system-spacing
547 the distance from the top of the printable area (i.e. the bottom
548 of the top margin) to the first system on a page, when there is no
549 (title or top-level) markup between the two.
551 @item top-markup-spacing
552 @funindex top-markup-spacing
554 the distance from the top of the printable area (i.e. the bottom
555 of the top margin) to the first (title or top-level) markup on a
556 page, when there is no system between the two.
561 @ref{Flexible vertical spacing within systems}.
564 @file{ly/paper-defaults-init.ly}.
570 @node Horizontal spacing \paper variables
571 @subsection Horizontal spacing @code{\paper} variables
573 @warning{Some @code{@bs{}paper} dimensions are automatically
574 scaled to the paper size, which may lead to unexpected behavior.
575 See @ref{Automatic scaling to paper size}.}
578 * \paper variables for widths and margins::
579 * \paper variables for two-sided mode::
580 * \paper variables for shifts and indents::
584 @node \paper variables for widths and margins
585 @unnumberedsubsubsec @code{\paper} variables for widths and margins
587 Default values (before scaling) that are not listed here are
588 defined in @file{ly/paper-defaults-init.ly}.
593 @funindex paper-width
595 The width of the page, unset by default. While @code{paper-width}
596 has no effect on the automatic scaling of some horizontal
597 dimensions, it does influence the @code{line-width} variable. If
598 both @code{paper-width} and @code{line-width} are set, then
599 @code{left-margin} and @code{right-margin} will also be updated.
600 Also see @code{check-consistency}.
605 The horizontal extent of the staff lines in unindented, non-ragged
607 @code{(paper-width@tie{}@minus{}@tie{}left-margin@tie{}@minus{}@tie{}right-margin)}
608 when unset. If @code{line-width} is set, and both
609 @code{left-margin} and @code{right-margin} are unset, then the
610 margins will be updated to center the systems on the page
611 automatically. Also see @code{check-consistency}. This variable
612 can also be set in a @code{\layout} block.
615 @funindex left-margin
617 The margin between the left edge of the page and the start of the
618 staff lines in unindented systems. If the paper size is modified,
619 this dimension's default value is scaled accordingly. If
620 @code{left-margin} is unset, and both @code{line-width} and
621 @code{right-margin} are set, then @code{left-margin} is set to
622 @code{(paper-width@tie{}@minus{}@tie{}line-width@tie{}@minus{}@tie{}right-margin)}.
623 If only @code{line-width} is set, then both margins are set to
624 @code{((paper-width@tie{}@minus{}@tie{}line-width)@tie{}/@tie{}2)},
625 and the systems are consequently centered on the page. Also see
626 @code{check-consistency}.
629 @funindex right-margin
631 The margin between the right edge of the page and the end of the
632 staff lines in non-ragged systems. If the paper size is modified,
633 this dimension's default value is scaled accordingly. If
634 @code{right-margin} is unset, and both @code{line-width} and
635 @code{left-margin} are set, then @code{right-margin} is set to
636 @code{(paper-width@tie{}@minus{}@tie{}line-width@tie{}@minus{}@tie{}left-margin)}.
637 If only @code{line-width} is set, then both margins are set to
638 @code{((paper-width@tie{}@minus{}@tie{}line-width)@tie{}/@tie{}2)},
639 and the systems are consequently centered on the page. Also see
640 @code{check-consistency}.
642 @item check-consistency
643 @funindex check-consistency
645 If set to true, print a warning if @code{left-margin},
646 @code{line-width}, and @code{right-margin} do not exactly add up
647 to @code{paper-width}, and replace each of these (except
648 @code{paper-width}) with its default value (scaled to the paper
649 size if necessary). If set to false, ignore any inconsistencies
650 and allow systems to run off the edge of the page.
653 @funindex ragged-right
655 If set to true, systems will not fill the line width. Instead,
656 systems end at their natural horizontal length. Default:
657 @code{#t} for scores with only one system, and @code{#f} for
658 scores with two or more systems. This variable can also be set in
659 a @code{\layout} block.
662 @funindex ragged-last
664 If set to true, the last system in the score will not fill the
665 line width. Instead the last system ends at its natural
666 horizontal length. Default: @code{#f}. This variable can also be
667 set in a @code{\layout} block.
673 @ref{Automatic scaling to paper size}.
676 @file{ly/paper-defaults-init.ly}.
680 Explicitly defined paper-sizes will override any user-defined left or
681 right margin settings.
684 @node \paper variables for two-sided mode
685 @unnumberedsubsubsec @code{\paper} variables for two-sided mode
687 Default values (before scaling) are defined in
688 @file{ly/paper-defaults-init.ly}.
696 @cindex binding gutter
698 If set to true, use @code{inner-margin}, @code{outer-margin} and
699 @code{binding-offset} to determine margins depending on whether
700 the page number is odd or even. This overrides @code{left-margin}
701 and @code{right-margin}.
704 @funindex inner-margin
706 The margin all pages have at the inner side if they are part of a
707 book. If the paper size is modified, this dimension's default
708 value is scaled accordingly. Works only with @code{two-sided} set
712 @funindex outer-margin
714 The margin all pages have at the outer side if they are part of a
715 book. If the paper size is modified, this dimension's default
716 value is scaled accordingly. Works only with @code{two-sided} set
720 @funindex binding-offset
722 The amount @code{inner-margin} is increased to make sure nothing
723 will be hidden by the binding. If the paper size is modified,
724 this dimension's default value is scaled accordingly. Works only
725 with @code{two-sided} set to true.
731 @ref{Automatic scaling to paper size}.
734 @file{ly/paper-defaults-init.ly}.
737 @node \paper variables for shifts and indents
738 @unnumberedsubsubsec @code{\paper} variables for shifts and indents
740 Default values (before scaling) that are not listed here are
741 defined in @file{ly/paper-defaults-init.ly}.
745 @item horizontal-shift
746 @funindex horizontal-shift
748 @c This default value is buried in the middle of page.scm. -mp
750 The amount that all systems (including titles and system
751 separators) are shifted to the right. Default: @code{0.0\mm}.
756 The level of indentation for the first system in a score. If the
757 paper size is modified, this dimension's default value is scaled
758 accordingly. This variable can also be set in a @code{\layout}
762 @funindex short-indent
764 The level of indentation for all systems in a score besides the
765 first system. If the paper size is modified, this dimension's
766 default value is scaled accordingly. This variable can also be
767 set in a @code{\layout} block.
773 @ref{Automatic scaling to paper size}.
776 @file{ly/paper-defaults-init.ly}.
782 @node Other \paper variables
783 @subsection Other @code{\paper} variables
786 * \paper variables for line breaking::
787 * \paper variables for page breaking::
788 * \paper variables for page numbering::
789 * Miscellaneous \paper variables::
793 @node \paper variables for line breaking
794 @unnumberedsubsubsec @code{\paper} variables for line breaking
796 @c TODO: Mention that ly:optimal-breaking is on by default? -mp
800 @item max-systems-per-page
801 @funindex max-systems-per-page
803 The maximum number of systems that will be placed on a page. This
804 is currently supported only by the @code{ly:optimal-breaking} algorithm.
807 @item min-systems-per-page
808 @funindex min-systems-per-page
810 The minimum number of systems that will be placed on a page. This
811 may cause pages to be overfilled if it is made too large. This is
812 currently supported only by the @code{ly:optimal-breaking} algorithm.
815 @item systems-per-page
816 @funindex systems-per-page
818 The number of systems that should be placed on each page.
819 This is currently supported only by the @code{ly:optimal-breaking} algorithm.
823 @funindex system-count
825 The number of systems to be used for a score. Default: unset.
826 This variable can also be set in a @code{\layout} block.
835 @node \paper variables for page breaking
836 @unnumberedsubsubsec @code{\paper} variables for page breaking
838 Default values not listed here are defined in
839 @file{ly/paper-defaults-init.ly}
843 @item blank-after-score-page-force
844 @funindex blank-after-score-page-force
846 The penalty for having a blank page after the end of one score and
847 before the next. By default, this is smaller than
848 @code{blank-page-force}, so that we prefer blank pages after
849 scores to blank pages within a score.
851 @item blank-last-page-force
852 @funindex blank-last-page-force
854 The penalty for ending the score on an odd-numbered page.
856 @item blank-page-force
857 @funindex blank-page-force
859 The penalty for having a blank page in the middle of a
860 score. This is not used by @code{ly:optimal-breaking} since it will
861 never consider blank pages in the middle of a score.
864 @funindex page-breaking
866 The page-breaking algorithm to use. Choices are
867 @code{ly:minimal-breaking}, @code{ly:page-turn-breaking}, and
868 @code{ly:optimal-breaking}.
870 @item page-breaking-system-system-spacing
871 @funindex page-breaking-system-system-spacing
873 Tricks the page breaker into thinking that
874 @code{system-system-spacing} is set to something different than
875 it really is. For example, if
876 @code{page-breaking-system-system-spacing #'padding} is set to something
877 substantially larger than @code{system-system-spacing #'padding}, then the
878 page-breaker will put fewer systems on each page. Default: unset.
883 The number of pages to be used for a score, unset by default.
890 @ref{Optimal page breaking},
891 @ref{Optimal page turning},
892 @ref{Minimal page breaking}.
895 @file{ly/paper-defaults-init.ly}.
898 @node \paper variables for page numbering
899 @unnumberedsubsubsec @code{\paper} variables for page numbering
901 Default values not listed here are defined in
902 @file{ly/paper-defaults-init.ly}
906 @cindex page numbers, auto-numbering
907 @item auto-first-page-number
908 @funindex auto-first-page-number
910 The page breaking algorithm is affected by the first page number
911 being odd or even. If set to true, the page breaking algorithm
912 will decide whether to start with an odd or even number. This
913 will result in the first page number remaining as is or being
914 increased by one. Default: @code{#f}.
916 @cindex page numbers, specify the first
917 @item first-page-number
918 @funindex first-page-number
920 The value of the page number on the first page.
922 @item print-first-page-number
923 @funindex print-first-page-number
925 If set to true, a page number is printed on the first page.
927 @cindex page numbers, suppress
928 @item print-page-number
929 @funindex print-page-number
931 If set to false, page numbers are not printed.
937 @file{ly/paper-defaults-init.ly}.
940 Odd page numbers are always on the right. If you want the
941 music to start on page 1 there must be a blank page on the back
942 of the cover page so that page 1 is on the right hand side.
945 @node Miscellaneous \paper variables
946 @unnumberedsubsubsec Miscellaneous @code{\paper} variables
950 @item page-spacing-weight
951 @funindex page-spacing-weight
953 The relative importance of page (vertical) spacing and line
954 (horizontal) spacing. High values will make page spacing more
955 important. Default: @code{10}.
957 @item print-all-headers
958 @funindex print-all-headers
960 If set to true, this will print all headers for each @code{\score}
961 in the output. Normally only the @code{piece} and @code{opus}
962 header variables are printed. Default: @code{#f}.
964 @item system-separator-markup
965 @funindex system-separator-markup
967 A markup object that is inserted between systems, often used for
968 orchestral scores. Default: unset. The @code{\slashSeparator}
969 markup, defined in @file{ly/titling-init.ly}, is provided as a
970 sensible default, for example:
972 @lilypond[quote,verbatim,noragged-right,line-width=30\mm]
973 #(set-default-paper-size "a8")
977 system-separator-markup = \slashSeparator
983 \relative c'' { c1 \break c1 \break c1 }
993 @file{ly/titling-init.ly}.
1001 The default page header puts the page number and the @code{instrument}
1002 field from the @code{\header} block on a line.
1006 @section Score layout
1008 This section discusses score layout options for the @code{\layout}
1012 * The \layout block::
1013 * Setting the staff size::
1017 @node The \layout block
1018 @subsection The @code{\layout} block
1022 While the @code{\paper} block contains settings that relate to the
1023 page formatting of the whole document, the @code{\layout} block
1024 contains settings for score-specific layout. To set score layout
1025 options globally, enter them in a toplevel @code{\layout} block.
1026 To set layout options for an individual score, enter them in a
1027 @code{\layout} block inside the @code{\score} block, after the
1028 music. Settings that can appear in a @code{\layout} block
1032 @item the @code{layout-set-staff-size} scheme function,
1033 @item context modifications in @code{\context} blocks, and
1034 @item @code{\paper} variables that affect score layout.
1037 The @code{layout-set-staff-size} function is discussed in the next
1038 section, @ref{Setting the staff size}. Context modifications are
1039 discussed in a separate chapter; see
1040 @ref{Modifying context plug-ins} and
1041 @ref{Changing context default settings}. The @code{\paper}
1042 variables that can appear in a @code{\layout} block are:
1047 @code{line-width}, @code{ragged-right} and @code{ragged-last}
1048 (see @ref{\paper variables for widths and margins})
1051 @code{indent} and @code{short-indent}
1052 (see @ref{\paper variables for shifts and indents})
1056 (see @ref{\paper variables for line breaking})
1060 Here is an example @code{\layout} block:
1067 \override StaffGrouper #'staff-staff-spacing #'basic-distance = #8
1071 \override TextScript #'padding = #1
1072 \override Glissando #'thickness = #3
1080 @ref{Changing context default settings}.
1086 @node Setting the staff size
1087 @subsection Setting the staff size
1089 @cindex font size, setting
1090 @cindex staff size, setting
1091 @funindex layout file
1093 The default @strong{staff size} is set to 20 points.
1094 This may be changed in two ways:
1096 To set the staff size globally for all scores in a file (or
1097 in a @code{book} block, to be precise), use @code{set-global-staff-size}.
1100 #(set-global-staff-size 14)
1104 This sets the global default size to 14pt staff height and scales all
1107 To set the staff size individually for each score, use
1112 #(layout-set-staff-size 15)
1117 The Feta font provides musical symbols at eight different
1118 sizes. Each font is tuned for a different staff size: at a smaller size
1119 the font becomes heavier, to match the relatively heavier staff lines.
1120 The recommended font sizes are listed in the following table:
1123 @multitable @columnfractions .15 .2 .22 .2
1126 @tab @b{staff height (pt)}
1127 @tab @b{staff height (mm)}
1169 @c modern rental material?
1174 These fonts are available in any sizes. The context property
1175 @code{fontSize} and the layout property @code{staff-space} (in
1176 @rinternals{StaffSymbol}) can be used to tune the size for individual
1177 staves. The sizes of individual staves are relative to the global size.
1182 @ref{Selecting notation font size}.
1190 @code{layout-set-staff-size} does not change the distance between the
1200 * Optimal page breaking::
1201 * Optimal page turning::
1202 * Minimal page breaking::
1204 * Using an extra voice for breaks::
1209 @subsection Line breaking
1212 @cindex breaking lines
1214 Line breaks are normally determined automatically. They are chosen
1215 so that lines look neither cramped nor loose, and consecutive
1216 lines have similar density.
1218 To manually force a line break at a bar line, use the
1219 @code{\break} command:
1221 @lilypond[quote,ragged-right,relative=2,verbatim]
1226 By default, a @code{\break} in the middle of a measure is ignored,
1227 and a warning is printed. To force a line break in the middle of
1228 a measure, add an invisible bar line with @w{@samp{\bar ""}}:
1230 @lilypond[quote,ragged-right,relative=2,verbatim]
1237 A @code{\break} occurring at a bar line is also ignored if the
1238 previous measure ends in the middle of a note, such as when a
1239 tuplet begins and ends in different measures. To allow
1240 @code{\break} commands to work in these situations, remove the
1241 @code{Forbid_line_break_engraver} from the @code{Voice} context.
1242 Note that manually forced line breaks have to be added in parallel
1245 @lilypond[quote,ragged-right,verbatim]
1247 \remove Forbid_line_break_engraver
1250 { c2. \times 2/3 { c4 c c } c2. | }
1251 { s1 | \break s1 | }
1256 Similarly, line breaks are normally forbidden when beams cross bar
1257 lines. This behavior can be changed by setting
1258 @code{\override Beam #'breakable = ##t}:
1260 @lilypond[quote,ragged-right,relative=2,verbatim]
1261 \override Beam #'breakable = ##t
1266 The @code{\noBreak} command forbids a line break at the bar line
1267 where it is inserted.
1269 The most basic settings influencing line spacing are @code{indent}
1270 and @code{line-width}. They are set in the @code{\layout} block.
1271 They control the indentation of the first line of music, and the
1272 lengths of the lines.
1274 If @code{ragged-right} is set to true in the @code{\layout} block,
1275 then systems end at their natural horizontal length, instead of
1276 being spread horizontally to fill the whole line. This is useful
1277 for short fragments, and for checking how tight the natural
1280 @c TODO Check and add para on default for ragged-right
1282 The option @code{ragged-last} is similar to @code{ragged-right},
1283 but affects only the last line of the piece.
1295 @cindex regular line breaks
1296 @cindex four bar music.
1298 For line breaks at regular intervals use @code{\break} separated by
1299 skips and repeated with @code{\repeat}. For example, this would
1300 cause the following 28 measures (assuming 4/4 time) to be broken
1301 every 4 measures, and only there:
1306 s1 \noBreak s1 \noBreak
1307 s1 \noBreak s1 \break
1309 @{ @var{the actual music@dots{}} @}
1314 A linebreaking configuration can be saved as a @file{.ly} file
1315 automatically. This allows vertical alignments to be stretched to
1316 fit pages in a second formatting run. This is fairly new and
1317 complicated. More details are available in
1331 @ref{\paper variables for line breaking}.
1336 Internals Reference:
1337 @rinternals{LineBreakEvent}.
1341 @subsection Page breaking
1343 The default page breaking may be overridden by inserting
1344 @code{\pageBreak} or @code{\noPageBreak} commands. These commands are
1345 analogous to @code{\break} and @code{\noBreak}. They should be
1346 inserted at a bar line. These commands force and forbid a page-break
1347 from happening. Of course, the @code{\pageBreak} command also forces
1350 The @code{\pageBreak} and @code{\noPageBreak} commands may also be
1351 inserted at top-level, between scores and top-level markups.
1353 There are also analogous settings to @code{ragged-right} and
1354 @code{ragged-last} which have the same effect on vertical spacing:
1355 @code{ragged-bottom} and @code{ragged-last-bottom}. If set to
1356 @code{#t} the systems on all pages or just the last page
1357 respectively will not be justified vertically. See
1358 @ref{Fixed vertical spacing \paper variables}.
1360 Page breaks are computed by the @code{page-breaking} function. LilyPond
1361 provides three algorithms for computing page breaks,
1362 @code{ly:optimal-breaking}, @code{ly:page-turn-breaking} and
1363 @code{ly:minimal-breaking}. The default is @code{ly:optimal-breaking},
1364 but the value can be changed in the @code{\paper} block:
1368 page-breaking = #ly:page-turn-breaking
1374 When a book has many scores and pages, the page breaking problem may be
1375 difficult to solve, requiring large processing time and memory. To ease
1376 the page breaking process, @code{\bookpart} blocks are used to divide
1377 the book into several parts: the page breaking occurs separately on each
1378 part. Different page breaking functions may also be used in different
1384 subtitle = "Preface"
1387 %% In a part consisting mostly of text,
1388 %% ly:minimal-breaking may be preferred
1389 page-breaking = #ly:minimal-breaking
1391 \markup @{ @dots{} @}
1395 %% In this part, consisting of music, the default optimal
1396 %% page breaking function is used.
1398 subtitle = "First movement"
1400 \score @{ @dots{} @}
1407 @funindex \pageBreak
1409 @funindex \noPageBreak
1410 @code{\noPageBreak}.
1416 @ref{\paper variables for page breaking}.
1422 @node Optimal page breaking
1423 @subsection Optimal page breaking
1425 @funindex ly:optimal-breaking
1427 The @code{ly:optimal-breaking} function is LilyPond's default method of
1428 determining page breaks. It attempts to find a page breaking that minimizes
1429 cramping and stretching, both horizontally and vertically. Unlike
1430 @code{ly:page-turn-breaking}, it has no concept of page turns.
1438 @node Optimal page turning
1439 @subsection Optimal page turning
1441 @funindex ly:page-turn-breaking
1443 Often it is necessary to find a page breaking configuration so that there is
1444 a rest at the end of every second page. This way, the musician can turn the
1445 page without having to miss notes. The @code{ly:page-turn-breaking} function
1446 attempts to find a page breaking minimizing cramping and stretching, but with
1447 the additional restriction that it is only allowed to introduce page turns
1448 in specified places.
1450 There are two steps to using this page breaking function. First, you
1451 must enable it in the @code{\paper} block, as explained in @ref{Page
1452 breaking}. Then you must tell the function where you would like to allow
1455 There are two ways to achieve the second step. First, you can specify each
1456 potential page turn manually, by inserting @code{\allowPageTurn} into your
1457 input file at the appropriate places.
1459 If this is too tedious, you can add a @code{Page_turn_engraver} to a Staff or
1460 Voice context. The @code{Page_turn_engraver} will scan the context for
1461 sections without notes (note that it does not scan for rests; it scans for
1462 the absence of notes. This is so that single-staff polyphony with rests in one
1463 of the parts does not throw off the @code{Page_turn_engraver}). When it finds
1464 a sufficiently long section without notes, the @code{Page_turn_engraver} will
1465 insert an @code{\allowPageTurn} at the final bar line in that section, unless
1466 there is a @q{special} bar line (such as a double bar), in which case the
1467 @code{\allowPageTurn} will be inserted at the final @q{special} bar line in
1470 @funindex minimumPageTurnLength
1471 The @code{Page_turn_engraver} reads the context property
1472 @code{minimumPageTurnLength} to determine how long a note-free section must
1473 be before a page turn is considered. The default value for
1474 @code{minimumPageTurnLength} is @code{(ly:make-moment 1 1)}. If you want
1475 to disable page turns, you can set it to something very large.
1478 \new Staff \with @{ \consists "Page_turn_engraver" @}
1481 R1 | % a page turn will be allowed here
1483 \set Staff.minimumPageTurnLength = #(ly:make-moment 5 2)
1484 R1 | % a page turn will not be allowed here
1486 R1*2 | % a page turn will be allowed here
1491 @funindex minimumRepeatLengthForPageTurn
1492 The @code{Page_turn_engraver} detects volta repeats. It will only allow a page
1493 turn during the repeat if there is enough time at the beginning and end of the
1494 repeat to turn the page back. The @code{Page_turn_engraver} can also disable
1495 page turns if the repeat is very short. If you set the context property
1496 @code{minimumRepeatLengthForPageTurn} then the @code{Page_turn_engraver} will
1497 only allow turns in repeats whose duration is longer than this value.
1499 The page turning commands, @code{\pageTurn}, @code{\noPageTurn} and
1500 @code{\allowPageTurn}, may also be used at top-level, between scores and
1507 @funindex \noPageTurn
1509 @funindex \allowPageTurn
1510 @code{\allowPageTurn}.
1521 There should only be one @code{Page_turn_engraver} in a score. If there is more
1522 than one, they will interfere with each other.
1525 @node Minimal page breaking
1526 @subsection Minimal page breaking
1528 @funindex ly:minimal-breaking
1530 The @code{ly:minimal-breaking} function performs minimal computations to
1531 calculate the page breaking: it fills a page with as many systems as
1532 possible before moving to the next one. Thus, it may be preferred for
1533 scores with many pages, where the other page breaking functions could be
1534 too slow or memory demanding, or a lot of texts. It is enabled using:
1538 page-breaking = #ly:minimal-breaking
1548 @node Explicit breaks
1549 @subsection Explicit breaks
1551 Lily sometimes rejects explicit @code{\break} and @code{\pageBreak}
1552 commands. There are two commands to override this behavior:
1555 \override NonMusicalPaperColumn #'line-break-permission = ##f
1556 \override NonMusicalPaperColumn #'page-break-permission = ##f
1559 When @code{line-break-permission} is overridden to false, Lily will insert
1560 line breaks at explicit @code{\break} commands and nowhere else. When
1561 @code{page-break-permission} is overridden to false, Lily will insert
1562 page breaks at explicit @code{\pageBreak} commands and nowhere else.
1564 @lilypond[quote,verbatim]
1571 music = \relative c'' { c8 c c c }
1575 \repeat unfold 2 { \music } \break
1576 \repeat unfold 4 { \music } \break
1577 \repeat unfold 6 { \music } \break
1578 \repeat unfold 8 { \music } \pageBreak
1579 \repeat unfold 8 { \music } \break
1580 \repeat unfold 6 { \music } \break
1581 \repeat unfold 4 { \music } \break
1582 \repeat unfold 2 { \music }
1587 \override NonMusicalPaperColumn #'line-break-permission = ##f
1588 \override NonMusicalPaperColumn #'page-break-permission = ##f
1600 @node Using an extra voice for breaks
1601 @subsection Using an extra voice for breaks
1603 Line- and page-breaking information usually appears within note entry directly.
1606 music = \relative c'' @{ c4 c c c @}
1610 \repeat unfold 2 @{ \music @} \break
1611 \repeat unfold 3 @{ \music @}
1616 This makes @code{\break} and @code{\pageBreak} commands easy to enter but mixes
1617 music entry with information that specifies how music should lay out
1618 on the page. You can keep music entry and line- and page-breaking
1619 information in two separate places by introducing an extra voice to
1620 contain the breaks. This extra voice
1621 contains only skips together with @code{\break}, @code{pageBreak} and other
1622 breaking layout information.
1624 @lilypond[quote,verbatim]
1625 music = \relative c'' { c4 c c c }
1636 \repeat unfold 2 { \music }
1637 \repeat unfold 3 { \music }
1638 \repeat unfold 6 { \music }
1639 \repeat unfold 5 { \music }
1645 This pattern becomes especially helpful when overriding
1646 @code{line-break-system-details} and the other useful but long properties of
1647 @code{NonMusicalPaperColumnGrob}, as explained in @ref{Vertical spacing}.
1649 @lilypond[quote,verbatim]
1650 music = \relative c'' { c4 c c c }
1655 \overrideProperty "Score.NonMusicalPaperColumn"
1656 #'line-break-system-details #'((Y-offset . 0))
1659 \overrideProperty "Score.NonMusicalPaperColumn"
1660 #'line-break-system-details #'((Y-offset . 35))
1663 \overrideProperty "Score.NonMusicalPaperColumn"
1664 #'line-break-system-details #'((Y-offset . 70))
1667 \overrideProperty "Score.NonMusicalPaperColumn"
1668 #'line-break-system-details #'((Y-offset . 105))
1672 \repeat unfold 2 { \music }
1673 \repeat unfold 3 { \music }
1674 \repeat unfold 6 { \music }
1675 \repeat unfold 5 { \music }
1684 @ref{Vertical spacing}.
1690 @node Vertical spacing
1691 @section Vertical spacing
1693 @cindex vertical spacing
1694 @cindex spacing, vertical
1696 Vertical spacing is controlled by three things: the amount of
1697 space available (i.e., paper size and margins), the amount of
1698 space between systems, and the amount of space between
1699 staves inside a system.
1702 * Flexible vertical spacing within systems::
1703 * Explicit staff and system positioning::
1704 * Vertical collision avoidance::
1708 @node Flexible vertical spacing within systems
1709 @subsection Flexible vertical spacing within systems
1711 @cindex distance between staves
1712 @cindex staff distance
1713 @cindex space between staves
1714 @cindex space inside systems
1716 Three separate mechanisms control the flexible vertical spacing
1717 within systems, one for each of the following categories:
1722 @emph{ungrouped staves},
1725 @emph{grouped staves} (staves within a staff-group such as
1726 @code{ChoirStaff}, etc.), and
1729 @emph{non-staff lines} (such as @code{Lyrics}, @code{ChordNames},
1734 @c TODO: Clarify this. This almost implies that non-staff lines
1735 @c have NO effect on the spacing between staves. -mp
1737 The height of each system is determined in two steps. First, all
1738 of the staves are spaced according to the amount of space
1739 available. Then, the non-staff lines are distributed between the
1742 Note that the spacing mechanisms discussed in this section only
1743 control the vertical spacing of staves and non-staff lines within
1744 individual systems. The vertical spacing between separate
1745 systems, scores, markups, and margins is controlled by
1746 @code{\paper} variables, which are discussed in
1747 @ref{Flexible vertical spacing \paper variables}.
1750 * Within-system spacing properties::
1751 * Spacing of ungrouped staves::
1752 * Spacing of grouped staves::
1753 * Spacing of non-staff lines::
1757 @node Within-system spacing properties
1758 @unnumberedsubsubsec Within-system spacing properties
1760 @funindex staff-affinity
1761 @funindex staffgroup-staff-spacing
1762 @funindex staff-staff-spacing
1763 @funindex nonstaff-unrelatedstaff-spacing
1764 @funindex nonstaff-relatedstaff-spacing
1765 @funindex nonstaff-nonstaff-spacing
1766 @funindex default-staff-staff-spacing
1767 @funindex minimum-Y-extent
1768 @funindex extra-offset
1769 @funindex self-alignment-X
1771 @funindex VerticalAxisGroup
1773 The within-system vertical spacing mechanisms are controlled by
1774 two sets of grob properties. The first set is associated with the
1775 @code{VerticalAxisGroup} grob, which is created by all staves and
1776 non-staff lines. The second set is associated with the
1777 @code{StaffGrouper} grob, which can be created by staff-groups,
1778 but only if explicitly called. These properties are described
1779 individually at the end of this section.
1781 The names of these properties (except for @code{staff-affinity})
1782 follow the format @code{@var{item1}-@var{item2}-spacing}, where
1783 @code{@var{item1}} and @code{@var{item2}} are the items to be
1784 spaced. Note that @code{@var{item2}} is not necessarily below
1785 @code{@var{item1}}; for example,
1786 @code{nonstaff-relatedstaff-spacing} will measure upwards from the
1787 non-staff line if @code{staff-affinity} is @code{UP}.
1789 Each distance is measured between the @emph{reference points} of
1790 the two items. The reference point for a staff is the vertical
1791 center of its @code{StaffSymbol} (i.e. the middle line if
1792 @code{line-count} is odd; the middle space if @code{line-count} is
1793 even). The reference points for individual non-staff lines are
1794 given in the following table:
1796 @multitable {Non-staff line} {Reference point}
1797 @headitem Non-staff line @tab Reference point
1798 @item @code{ChordNames} @tab baseline
1799 @item @code{NoteNames} @tab baseline
1800 @item @code{Lyrics} @tab baseline
1801 @item @code{Dynamics} @tab vertical center
1802 @item @code{FiguredBass} @tab highest point
1803 @item @code{FretBoards} @tab top line
1806 In the following image, horizontal lines indicate the positions
1807 of these reference points:
1809 @lilypond[quote,noragged-right,line-width=110\mm]
1810 #(define zero-space '((padding . -inf.0) (basic-distance . 0)))
1812 alignToZero = \with {
1813 \override VerticalAxisGroup #'nonstaff-relatedstaff-spacing = #zero-space
1814 \override VerticalAxisGroup #'nonstaff-nonstaff-spacing = #zero-space
1816 lowerCaseChords = \with {
1817 chordNameLowercaseMinor = ##t
1819 staffAffinityDown = \with {
1820 \override VerticalAxisGroup #'staff-affinity = #DOWN
1823 #(define-music-function
1824 (parser location context)
1826 #{ s1*0^\markup { \typewriter #context } #})
1829 \context { \Dynamics \alignToZero }
1830 \context { \FiguredBass \alignToZero }
1831 \context { \Lyrics \alignToZero }
1832 \context { \NoteNames \alignToZero \staffAffinityDown }
1833 \context { \ChordNames \alignToZero
1836 \context { \FretBoards \alignToZero \staffAffinityDown }
1838 \override BarLine #'stencil = ##f
1839 \override DynamicText #'self-alignment-X = #-1
1840 \override FretBoard #'X-offset = #1.75
1841 \override InstrumentName #'minimum-Y-extent = #'(-2 . 2)
1842 \override InstrumentName #'extra-offset = #'(0 . -0.5)
1843 \override TextScript #'minimum-Y-extent = #'(-2 . 3)
1844 \override TimeSignature #'stencil = ##f
1848 %% These contexts have reference points at the baseline:
1849 %% ChordNames, NoteNames, and Lyrics
1851 \new ChordNames { \chords { g1:m } }
1852 \new NoteNames { s1 | g1 | }
1853 \new RhythmicStaff {
1854 \set RhythmicStaff.instrumentName = #"baseline "
1856 \labelContext "ChordNames " s1 |
1857 \labelContext "NoteNames " s1 |
1858 \labelContext "Lyrics" s1 |
1860 \new Lyrics { \lyrics { \skip 1*2 | ghijk1 | } }
1863 %% The reference point for Dynamics is its vertical center
1865 \new RhythmicStaff {
1866 \set RhythmicStaff.instrumentName = #"vertical center "
1867 \labelContext "Dynamics" s1*3
1869 \new Dynamics { s1\mp s\fp }
1872 %% The reference point for FiguredBass is its highest point
1874 \new RhythmicStaff {
1875 \set RhythmicStaff.instrumentName = #"highest point "
1876 \labelContext "FiguredBass" s1
1878 \new FiguredBass { \figuremode { <6 5>1 } }
1881 %% The reference point for FretBoards is the top line
1882 \include "predefined-guitar-fretboards.ly"
1884 \new FretBoards { \chordmode { e1 } }
1885 \new RhythmicStaff {
1886 \set RhythmicStaff.instrumentName = #"top line "
1887 \labelContext "FretBoards " s1
1892 Each of the vertical spacing grob properties (except
1893 @code{staff-affinity}) uses the same alist structure as the
1894 @code{\paper} spacing variables discussed in
1895 @ref{Flexible vertical spacing \paper variables}. Specific methods
1896 for modifying alists are discussed in @ref{Modifying alists}.
1897 Grob properties should be adjusted with an @code{\override} inside
1898 a @code{\score} or @code{\layout} block, and not inside a
1899 @code{\paper} block.
1901 The following example demonstrates the two ways these alists can
1902 be modified. The first declaration updates one key-value
1903 individually, and the second completely re-defines the property:
1907 \override VerticalAxisGroup #'default-staff-staff-spacing
1908 #'basic-distance = #10
1912 \override VerticalAxisGroup #'default-staff-staff-spacing =
1913 #'((basic-distance . 10)
1914 (minimum-distance . 9)
1916 (stretchability . 10))
1920 To change any spacing settings globally, put them in the
1921 @code{\layout} block:
1927 \override VerticalAxisGroup #'default-staff-staff-spacing
1928 #'basic-distance = #10
1933 Standard settings for the vertical spacing grob properties are
1934 listed in @rinternals{VerticalAxisGroup} and
1935 @rinternals{StaffGrouper}. Default overrides for specific types
1936 of non-staff lines are listed in the relevant context descriptions
1937 in @rinternals{Contexts}.
1940 @subsubheading Properties of the @code{VerticalAxisGroup} grob
1942 @code{VerticalAxisGroup} properties are typically adjusted with an
1943 @code{\override} at the @code{Staff} level (or equivalent).
1946 @item staff-staff-spacing
1948 Used to determine the distance between the current staff and the
1949 staff just below it in the same system, even if one or more
1950 non-staff lines (such as @code{Lyrics}) are placed between the two
1951 staves. Does not apply to the bottom staff of a system.
1953 Initially, the @code{staff-staff-spacing} of a
1954 @code{VerticalAxisGroup} is a Scheme function that applies the
1955 properties of the @code{StaffGrouper} if the staff is part of a
1956 group, or the @code{default-staff-staff-spacing} of the staff
1957 otherwise. This allows staves to be spaced differently when they
1958 are grouped. For uniform spacing regardless of grouping, this
1959 function may be replaced by a flexible-spacing alist, using the
1960 complete-redefinition form of override shown above.
1962 @item default-staff-staff-spacing
1963 A flexible-spacing alist defining the @code{staff-staff-spacing} used for
1964 ungrouped staves, unless @code{staff-staff-spacing} has been explicitly
1965 set with an @code{\override}.
1967 @item staff-affinity
1968 The direction of the staff to use for spacing the current
1969 non-staff line. Choices are @code{UP}, @code{DOWN}, and
1970 @code{CENTER}. If @code{CENTER}, the non-staff line will be
1971 placed equidistant between the two nearest staves on either side,
1972 unless collisions or other spacing constraints prevent this.
1973 Adjacent non-staff lines should have non-increasing
1974 @code{staff-affinity} from top to bottom, e.g. a non-staff line
1975 set to @code{UP} should not immediately follow one that is set to
1976 @code{DOWN}. Non-staff lines at the top of a system should use
1977 @code{DOWN}; those at the bottom should use @code{UP}. Setting
1978 @code{staff-affinity} for a staff causes it to be treated as a
1979 non-staff line. Setting @code{staff-affinity} to @code{#f} causes
1980 a non-staff line to be treated as a staff. Setting
1981 @code{staff-affinity} to @code{UP}, @code{CENTER}, or @code{DOWN}
1982 causes a staff to be spaced as a non-staff line.
1984 @item nonstaff-relatedstaff-spacing
1985 The distance between the current non-staff line and the nearest
1986 staff in the direction of @code{staff-affinity}, if there are no
1987 non-staff lines between the two, and @code{staff-affinity} is
1988 either @code{UP} or @code{DOWN}. If @code{staff-affinity} is
1989 @code{CENTER}, then @code{nonstaff-relatedstaff-spacing} is used
1990 for the nearest staves on @emph{both} sides, even if other
1991 non-staff lines appear between the current one and either of the
1992 staves. This means that the placement of a non-staff line depends
1993 on both the surrounding staves and the surrounding non-staff lines.
1994 Setting the @code{stretchability} of one of these types of spacing to
1995 a small value will make that spacing dominate. Setting the
1996 @code{stretchability} to a large value will make that spacing have
1999 @item nonstaff-nonstaff-spacing
2000 The distance between the current non-staff line and the next
2001 non-staff line in the direction of @code{staff-affinity}, if both
2002 are on the same side of the related staff, and
2003 @code{staff-affinity} is either @code{UP} or @code{DOWN}.
2005 @item nonstaff-unrelatedstaff-spacing
2006 The distance between the current non-staff line and the staff in
2007 the opposite direction from @code{staff-affinity}, if there are no
2008 other non-staff lines between the two, and @code{staff-affinity}
2009 is either @code{UP} or @code{DOWN}. This can be used, for
2010 example, to require a minimum amount of padding between a
2011 @code{Lyrics} line and the staff to which it does not belong.
2015 @subsubheading Properties of the @code{StaffGrouper} grob
2017 @code{StaffGrouper} properties are typically adjusted with an
2018 @code{\override} at the @code{StaffGroup} level (or equivalent).
2021 @item staff-staff-spacing
2022 The distance between consecutive staves within the current
2023 staff-group. The @code{staff-staff-spacing} property of an
2024 individual staff's @code{VerticalAxisGroup} grob can be
2025 overriden with different spacing settings for that staff.
2027 @item staffgroup-staff-spacing
2028 The distance between the last staff of the current staff-group and
2029 the staff just below it in the same system, even if one or more
2030 non-staff lines (such as @code{Lyrics}) exist between the two
2031 staves. Does not apply to the bottom staff of a system. The
2032 @code{staff-staff-spacing} property of an individual staff's
2033 @code{VerticalAxisGroup} grob can be overriden with different
2034 spacing settings for that staff.
2039 @ref{Flexible vertical spacing \paper variables},
2040 @ref{Modifying alists}.
2042 Internals Reference:
2043 @rinternals{Contexts},
2044 @rinternals{VerticalAxisGroup},
2045 @rinternals{StaffGrouper}.
2048 @file{ly/engraver-init.ly},
2049 @file{scm/define-grobs.scm}.
2052 @node Spacing of ungrouped staves
2053 @unnumberedsubsubsec Spacing of ungrouped staves
2055 @emph{Staves} (such as @code{Staff}, @code{DrumStaff},
2056 @code{TabStaff}, etc.) are contexts that can contain one or more
2057 voice contexts, but cannot contain any other staves.
2059 The following properties affect the spacing of @emph{ungrouped}
2063 @item @code{VerticalAxisGroup} properties:
2065 @item @code{default-staff-staff-spacing}
2066 @item @code{staff-staff-spacing}
2070 These grob properties are described individually above; see
2071 @ref{Within-system spacing properties}.
2073 Additional properties are involved for staves that are part of a
2074 staff-group; see @ref{Spacing of grouped staves}.
2076 The following example shows how the @code{default-staff-staff-spacing}
2077 property can affect the spacing of ungrouped staves.
2078 The same overrides applied to @code{staff-staff-spacing} would
2079 have the same effect, but would also apply in cases where the staves
2080 are combined in a group or groups.
2082 @lilypond[verbatim,quote,staffsize=16]
2086 \override VerticalAxisGroup #'default-staff-staff-spacing =
2087 #'((basic-distance . 8)
2088 (minimum-distance . 7)
2094 % The very low note here needs more room than 'basic-distance
2095 % can provide, so the distance between this staff and the next
2096 % is determined by 'padding.
2097 \new Staff { b,2 r | }
2099 % Here, 'basic-distance provides enough room, and there is no
2100 % need to compress the space (towards 'minimum-distance) to make
2101 % room for anything else on the page, so the distance between
2102 % this staff and the next is determined by 'basic-distance.
2103 \new Staff { \clef bass g2 r | }
2105 % By setting 'padding to a negative value, staves can be made to
2106 % collide. The lowest acceptable value for 'basic-distance is 0.
2108 \override VerticalAxisGroup #'default-staff-staff-spacing =
2109 #'((basic-distance . 3.5)
2111 } { \clef bass g2 r | }
2112 \new Staff { \clef bass g2 r | }
2118 @file{scm/define-grobs.scm}.
2123 Internals Reference:
2124 @rinternals{VerticalAxisGroup}.
2127 @node Spacing of grouped staves
2128 @unnumberedsubsubsec Spacing of grouped staves
2130 In orchestral and other large scores, it is common to place staves
2131 in groups. The space between groups is typically larger than the
2132 space between staves of the same group.
2134 @emph{Staff-groups} (such as @code{StaffGroup}, @code{ChoirStaff},
2135 etc.) are contexts that can contain one or more staves
2138 The following properties affect the spacing of staves inside
2142 @item @code{VerticalAxisGroup} properties:
2144 @item @code{staff-staff-spacing}
2146 @item @code{StaffGrouper} properties:
2148 @item @code{staff-staff-spacing}
2149 @item @code{staffgroup-staff-spacing}
2153 These grob properties are described individually above; see
2154 @ref{Within-system spacing properties}.
2156 The following example shows how properties of the
2157 @code{StaffGrouper} grob can affect the spacing of grouped staves:
2159 @lilypond[verbatim,quote,staffsize=16]
2163 \override StaffGrouper #'staff-staff-spacing #'padding = #0
2164 \override StaffGrouper #'staff-staff-spacing #'basic-distance = #1
2169 \new PianoStaff \with {
2170 \override StaffGrouper #'staffgroup-staff-spacing #'basic-distance = #20
2185 @file{scm/define-grobs.scm}.
2190 Internals Reference:
2191 @rinternals{VerticalAxisGroup},
2192 @rinternals{StaffGrouper}.
2195 @node Spacing of non-staff lines
2196 @unnumberedsubsubsec Spacing of non-staff lines
2198 @emph{Non-staff lines} (such as @code{Lyrics}, @code{ChordNames},
2199 etc.) are contexts whose layout objects are engraved like staves
2200 (i.e. in horizontal lines within systems). Specifically,
2201 non-staff lines are non-staff contexts that create the
2202 @code{VerticalAxisGroup} layout object.
2204 The following properties affect the spacing of non-staff lines:
2207 @item @code{VerticalAxisGroup} properties:
2209 @item @code{staff-affinity}
2210 @item @code{nonstaff-relatedstaff-spacing}
2211 @item @code{nonstaff-nonstaff-spacing}
2212 @item @code{nonstaff-unrelatedstaff-spacing}
2216 These grob properties are described individually above; see
2217 @ref{Within-system spacing properties}.
2219 The following example shows how the
2220 @code{nonstaff-nonstaff-spacing} property can affect the spacing
2221 of consecutive non-staff lines. Here, by setting the
2222 @code{stretchability} key to a very high value, the lyrics are
2223 able to stretch much more than usual:
2225 @lilypond[verbatim,quote,staffsize=16]
2229 \override VerticalAxisGroup
2230 #'nonstaff-nonstaff-spacing #'stretchability = #1000
2237 \override VerticalAxisGroup #'staff-staff-spacing = #'((basic-distance . 30))
2240 \override VerticalAxisGroup #'staff-affinity = #UP
2243 \override VerticalAxisGroup #'staff-affinity = #CENTER
2244 } \lyricmode { center }
2246 \override VerticalAxisGroup #'staff-affinity = #DOWN
2247 } \lyricmode { down }
2255 @file{ly/engraver-init.ly},
2256 @file{scm/define-grobs.scm}.
2261 @c @lsr{spacing,page-spacing.ly},
2262 @c @lsr{spacing,alignment-vertical-spacing.ly}.
2264 Internals Reference:
2265 @rinternals{Contexts},
2266 @rinternals{VerticalAxisGroup}.
2269 @node Explicit staff and system positioning
2270 @subsection Explicit staff and system positioning
2272 One way to understand the flexible vertical spacing mechanisms
2273 explained above is as a collection of settings that control the
2274 amount of vertical padding between staves and systems.
2276 It is possible to approach vertical spacing in a different way
2277 using @code{NonMusicalPaperColumn #'line-break-system-details}.
2278 While the flexible vertical spacing mechanisms specify vertical
2279 padding, @code{NonMusicalPaperColumn #'line-break-system-details}
2280 can specify exact vertical positions on the page.
2282 @code{NonMusicalPaperColumn #'line-break-system-details} accepts
2283 an associative list of three different settings:
2286 @item @code{X-offset}
2287 @item @code{Y-offset}
2288 @item @code{alignment-distances}
2291 Grob overrides, including the overrides for @code{NonMusicalPaperColumn}
2292 below, can occur in any of three different places in an input file:
2295 @item in the middle of note entry directly
2296 @item in a @code{\context} block
2297 @item in the @code{\with} block
2300 When we override @code{NonMusicalPaperColumn}, we use the usual
2301 @code{\override} command in @code{\context} blocks and in the
2302 @code{\with} block. On the other hand, when we override
2303 @code{NonMusicalPaperColumn} in the middle of note entry,
2304 use the special @code{\overrideProperty} command. Here are some
2305 example @code{NonMusicalPaperColumn} overrides with the special
2306 @code{\overrideProperty} command:
2309 \overrideProperty NonMusicalPaperColumn
2310 #'line-break-system-details #'((X-offset . 20))
2312 \overrideProperty NonMusicalPaperColumn
2313 #'line-break-system-details #'((Y-offset . 40))
2315 \overrideProperty NonMusicalPaperColumn
2316 #'line-break-system-details #'((X-offset . 20)
2319 \overrideProperty NonMusicalPaperColumn
2320 #'line-break-system-details #'((alignment-distances . (15)))
2322 \overrideProperty NonMusicalPaperColumn
2323 #'line-break-system-details #'((X-offset . 20)
2325 (alignment-distances . (15)))
2328 To understand how each of these different settings work, we begin
2329 by looking at an example that includes no overrides at all.
2331 @c \book { } is required in these examples to ensure the spacing
2332 @c overrides can be seen between systems. -np
2334 @lilypond[verbatim,quote,staffsize=16]
2335 \header { tagline = ##f }
2336 \paper { left-margin = 0\mm }
2346 \new Voice { \repeat unfold 15 { c'4 c' c' c' } }
2349 \repeat unfold 15 { d'4 d' d' d' }
2356 This score isolates line- and page-breaking information in a dedicated
2357 voice. This technique of creating a breaks voice will help keep layout
2358 separate from music entry as our example becomes more complicated.
2359 See @ref{Using an extra voice for breaks}.
2361 Explicit @code{\breaks} evenly divide the music into six measures per
2362 line. Vertical spacing results from LilyPond's defaults. To set
2363 the vertical startpoint of each system explicitly, we can set
2364 the @code{Y-offset} pair in the @code{line-break-system-details}
2365 attribute of the @code{NonMusicalPaperColumn} grob:
2367 @lilypond[verbatim,quote,staffsize=16]
2368 \header { tagline = ##f }
2369 \paper { left-margin = 0\mm }
2375 \overrideProperty #"Score.NonMusicalPaperColumn"
2376 #'line-break-system-details #'((Y-offset . 0))
2378 \overrideProperty #"Score.NonMusicalPaperColumn"
2379 #'line-break-system-details #'((Y-offset . 40))
2381 \overrideProperty #"Score.NonMusicalPaperColumn"
2382 #'line-break-system-details #'((Y-offset . 80))
2385 \new Voice { \repeat unfold 15 { c'4 c' c' c' } }
2388 \repeat unfold 15 { d'4 d' d' d' }
2395 Note that @code{line-break-system-details} takes an associative list of
2396 potentially many values, but that we set only one value here. Note,
2397 too, that the @code{Y-offset} property here determines the exact vertical
2398 position on the page at which each new system will render.
2400 Now that we have set the vertical startpoint of each system
2401 explicitly, we can also set the vertical distances between staves
2402 within each system manually. We do this using the @code{alignment-distances}
2403 subproperty of @code{line-break-system-details}.
2405 @lilypond[verbatim,quote,staffsize=16]
2406 \header { tagline = ##f }
2407 \paper { left-margin = 0\mm }
2413 \overrideProperty #"Score.NonMusicalPaperColumn"
2414 #'line-break-system-details #'((Y-offset . 20)
2415 (alignment-distances . (15)))
2417 \overrideProperty #"Score.NonMusicalPaperColumn"
2418 #'line-break-system-details #'((Y-offset . 60)
2419 (alignment-distances . (15)))
2421 \overrideProperty #"Score.NonMusicalPaperColumn"
2422 #'line-break-system-details #'((Y-offset . 100)
2423 (alignment-distances . (15)))
2426 \new Voice { \repeat unfold 15 { c'4 c' c' c' } }
2429 \repeat unfold 15 { d'4 d' d' d' }
2436 Note that here we assign two different values to the
2437 @code{line-break-system-details} attribute of the
2438 @code{NonMusicalPaperColumn} grob. Though the
2439 @code{line-break-system-details} attribute alist accepts many
2440 additional spacing parameters (including, for example, a corresponding
2441 @code{X-offset} pair), we need only set the @code{Y-offset} and
2442 @code{alignment-distances} pairs to control the vertical startpoint of
2443 every system and every staff. Finally, note that @code{alignment-distances}
2444 specifies the vertical positioning of staves but not of staff groups.
2446 @lilypond[verbatim,quote,staffsize=16]
2447 \header { tagline = ##f }
2448 \paper { left-margin = 0\mm }
2454 \overrideProperty #"Score.NonMusicalPaperColumn"
2455 #'line-break-system-details #'((Y-offset . 0)
2456 (alignment-distances . (30 10)))
2458 \overrideProperty #"Score.NonMusicalPaperColumn"
2459 #'line-break-system-details #'((Y-offset . 60)
2460 (alignment-distances . (10 10)))
2462 \overrideProperty #"Score.NonMusicalPaperColumn"
2463 #'line-break-system-details #'((Y-offset . 100)
2464 (alignment-distances . (10 30)))
2467 \new Voice { \repeat unfold 15 { c'4 c' c' c' } }
2470 \new Staff { \repeat unfold 15 { d'4 d' d' d' } }
2471 \new Staff { \repeat unfold 15 { e'4 e' e' e' } }
2478 Some points to consider:
2481 @item When using @code{alignment-distances}, lyrics and other non-staff lines
2482 do not count as a staff.
2484 @item The units of the numbers passed to @code{X-offset},
2485 @code{Y-offset} and @code{alignment-distances} are interpreted as multiples
2486 of the distance between adjacent staff lines. Positive values move staves
2487 and lyrics up, negative values move staves and lyrics down.
2489 @item Because the @code{NonMusicalPaperColumn #'line-break-system-details}
2490 settings given here allow the positioning of staves and systems anywhere
2491 on the page, it is possible to violate paper or margin boundaries or even
2492 to print staves or systems on top of one another. Reasonable values
2493 passed to these different settings will avoid this.
2502 @node Vertical collision avoidance
2503 @subsection Vertical collision avoidance
2505 @funindex outside-staff-priority
2506 @funindex outside-staff-padding
2507 @funindex outside-staff-horizontal-padding
2509 Intuitively, there are some objects in musical notation that belong
2510 to the staff and there are other objects that should be placed outside
2511 the staff. Objects belonging outside the staff include things such as
2512 rehearsal marks, text and dynamic markings (from now on, these will
2513 be called outside-staff objects). LilyPond's rule for the
2514 vertical placement of outside-staff objects is to place them as close
2515 to the staff as possible but not so close that they collide with
2518 LilyPond uses the @code{outside-staff-priority} property to determine
2519 whether a grob is an outside-staff object: if @code{outside-staff-priority}
2520 is a number, the grob is an outside-staff object. In addition,
2521 @code{outside-staff-priority} tells LilyPond in which order the objects
2524 First, LilyPond places all the objects that do not belong outside
2525 the staff. Then it sorts the outside-staff objects according to their
2526 @code{outside-staff-priority} (in increasing order). One by one, LilyPond
2527 takes the outside-staff objects and places them so that they do
2528 not collide with any objects that have already been placed. That
2529 is, if two outside-staff grobs are competing for the same space, the one
2530 with the lower @code{outside-staff-priority} will be placed closer to
2533 @lilypond[quote,ragged-right,relative=2,verbatim]
2536 \once \override TextScript #'outside-staff-priority = #1
2537 c4_"Text"\pp % this time the text will be closer to the staff
2539 % by setting outside-staff-priority to a non-number,
2540 % we disable the automatic collision avoidance
2541 \once \override TextScript #'outside-staff-priority = ##f
2542 \once \override DynamicLineSpanner #'outside-staff-priority = ##f
2543 c4_"Text"\pp % now they will collide
2546 The vertical padding between an outside-staff object and the
2547 previously-positioned grobs can be controlled with
2548 @code{outside-staff-padding}.
2550 @lilypond[quote,ragged-right,relative=2,verbatim]
2551 \once \override TextScript #'outside-staff-padding = #0
2552 a'^"This text is placed very close to the note"
2553 \once \override TextScript #'outside-staff-padding = #3
2554 c^"This text is padded away from the previous text"
2555 c^"This text is placed close to the previous text"
2559 By default, outside-staff objects are placed only to avoid
2560 a horizontal collision with previously-positioned grobs. This
2561 can lead to situations in which objects are placed very close to each
2562 other horizontally. The vertical spacing between staves can
2563 also be set so that outside staff objects are interleaved.
2564 Setting @code{outside-staff-horizontal-padding}
2565 causes an object to be offset vertically so that such a situation
2568 @lilypond[quote,ragged-right,relative=2,verbatim]
2569 % the markup is too close to the following note
2573 % setting outside-staff-horizontal-padding fixes this
2575 \once \override TextScript #'outside-staff-horizontal-padding = #1
2587 @node Horizontal spacing
2588 @section Horizontal spacing
2590 @cindex horizontal spacing
2591 @cindex spacing, horizontal
2594 * Horizontal spacing overview::
2595 * New spacing area::
2596 * Changing horizontal spacing::
2598 * Proportional notation::
2602 @node Horizontal spacing overview
2603 @subsection Horizontal spacing overview
2605 The spacing engine translates differences in durations into stretchable
2606 distances (@q{springs}) of differing lengths. Longer durations get
2607 more space, shorter durations get less. The shortest durations get a
2608 fixed amount of space (which is controlled by
2609 @code{shortest-duration-space} in the @rinternals{SpacingSpanner}
2610 object). The longer the duration, the more space it gets: doubling a
2611 duration adds a fixed amount (this amount is controlled by
2612 @code{spacing-increment}) of space to the note.
2614 For example, the following piece contains lots of half, quarter, and
2615 8th notes; the eighth note is followed by 1 note head width (NHW).
2616 The quarter note is followed by 2 NHW, the half by 3 NHW, etc.
2618 @lilypond[quote,verbatim,relative=1]
2619 c2 c4. c8 c4. c8 c4. c8 c8
2623 Normally, @code{spacing-increment} is set to 1.2 staff space, which is
2624 approximately the width of a note head, and
2625 @code{shortest-duration-space} is set to 2.0, meaning that the
2626 shortest note gets 2.4 staff space (2.0 times the
2627 @code{spacing-increment}) of horizontal space. This space is counted
2628 from the left edge of the symbol, so the shortest notes are generally
2629 followed by one NHW of space.
2631 If one would follow the above procedure exactly, then adding a single
2632 32nd note to a score that uses 8th and 16th notes, would widen up the
2633 entire score a lot. The shortest note is no longer a 16th, but a 32nd,
2634 thus adding 1 NHW to every note. To prevent this, the shortest
2635 duration for spacing is not the shortest note in the score, but rather
2636 the one which occurs most frequently.
2639 The most common shortest duration is determined as follows: in every
2640 measure, the shortest duration is determined. The most common shortest
2641 duration is taken as the basis for the spacing, with the stipulation
2642 that this shortest duration should always be equal to or shorter than
2643 an 8th note. The shortest duration is printed when you run
2644 @code{lilypond} with the @option{--verbose} option.
2646 These durations may also be customized. If you set the
2647 @code{common-shortest-duration} in @rinternals{SpacingSpanner}, then
2648 this sets the base duration for spacing. The maximum duration for this
2649 base (normally an 8th), is set through @code{base-shortest-duration}.
2651 @funindex common-shortest-duration
2652 @funindex base-shortest-duration
2653 @funindex stem-spacing-correction
2656 Notes that are even shorter than the common shortest note are
2657 followed by a space that is proportional to their duration relative to
2658 the common shortest note. So if we were to add only a few 16th notes
2659 to the example above, they would be followed by half a NHW:
2661 @lilypond[quote,verbatim,relative=2]
2662 c2 c4. c8 c4. c16[ c] c4. c8 c8 c8 c4 c4 c4
2666 In the @emph{Essay on automated music engraving}, it was explained
2667 that stem directions influence spacing (see
2668 @ressay{Optical spacing}). This is controlled with the
2669 @code{stem-spacing-correction} property in the
2670 @rinternals{NoteSpacing}, object. These are generated for every
2671 @rinternals{Voice} context. The @code{StaffSpacing} object
2672 (generated in @rinternals{Staff} context) contains the same
2673 property for controlling the stem/bar line spacing. The following
2674 example shows these corrections, once with default settings, and
2675 once with exaggerated corrections:
2677 @lilypond[quote,ragged-right]
2681 \override Staff.NoteSpacing #'stem-spacing-correction = #1.5
2682 \override Staff.StaffSpacing #'stem-spacing-correction = #1.5
2688 Proportional notation is supported; see @ref{Proportional notation}.
2695 Internals Reference:
2696 @rinternals{SpacingSpanner},
2697 @rinternals{NoteSpacing},
2698 @rinternals{StaffSpacing},
2699 @rinternals{NonMusicalPaperColumn}.
2701 Essay on automated music engraving:
2702 @ressay{Optical spacing}.
2707 There is no convenient mechanism to manually override spacing. The
2708 following work-around may be used to insert extra space into a score,
2709 adjusting the padding value as necessary.
2711 \override Score.NonMusicalPaperColumn #'padding = #10
2714 No work-around exists for decreasing the amount of space.
2717 @node New spacing area
2718 @subsection New spacing area
2720 New sections with different spacing parameters can be started with
2721 @code{newSpacingSection}. This is useful when there are
2722 sections with a different notions of long and short notes.
2724 In the following example, the time signature change introduces a new
2725 section, and hence the 16ths notes are spaced wider.
2727 @lilypond[relative=1,verbatim,quote]
2730 c8 c c4 c16[ c c8] c4
2736 The @code{\newSpacingSection} command creates a new
2737 @code{SpacingSpanner} object, and hence new @code{\override}s
2738 may be used in that location.
2745 Internals Reference:
2746 @rinternals{SpacingSpanner}.
2749 @node Changing horizontal spacing
2750 @subsection Changing horizontal spacing
2752 Horizontal spacing may be altered with the
2753 @code{base-shortest-duration} property. Here
2754 we compare the same music; once without altering
2755 the property, and then altered. Larger values
2756 of @code{ly:make-moment} will produce smaller
2757 music. Note that @code{ly:make-moment} constructs
2758 a duration, so @code{1 4} is a longer duration
2761 @lilypond[verbatim,line-width=12\cm]
2764 g4 e e2 | f4 d d2 | c4 d e f | g4 g g2 |
2765 g4 e e2 | f4 d d2 | c4 e g g | c,1 |
2766 d4 d d d | d4 e f2 | e4 e e e | e4 f g2 |
2767 g4 e e2 | f4 d d2 | c4 e g g | c,1 |
2772 @lilypond[verbatim,line-width=12\cm]
2775 g4 e e2 | f4 d d2 | c4 d e f | g4 g g2 |
2776 g4 e e2 | f4 d d2 | c4 e g g | c,1 |
2777 d4 d d d | d4 e f2 | e4 e e e | e4 f g2 |
2778 g4 e e2 | f4 d d2 | c4 e g g | c,1 |
2783 \override SpacingSpanner
2784 #'base-shortest-duration = #(ly:make-moment 1 16)
2793 By default, spacing in tuplets depends on various non-duration
2794 factors (such as accidentals, clef changes, etc). To disregard
2795 such symbols and force uniform equal-duration spacing, use
2796 @code{Score.SpacingSpanner #'uniform-stretching}. This
2797 property can only be changed at the beginning of a score,
2799 @lilypond[quote,ragged-right,verbatim]
2818 \override SpacingSpanner #'uniform-stretching = ##t
2824 When @code{strict-note-spacing} is set, notes are spaced without
2825 regard for clefs, bar lines, and grace notes,
2827 @lilypond[quote,ragged-right,relative=2,verbatim]
2828 \override Score.SpacingSpanner #'strict-note-spacing = ##t
2829 \new Staff { c8[ c \clef alto c \grace { c16[ c] } c8 c c] c32[ c32] }
2839 @subsection Line length
2842 @cindex breaking pages
2845 @funindex line-width
2846 @funindex ragged-right
2847 @funindex ragged-last
2849 @c Although line-width can be set in \layout, it should be set in paper
2850 @c block, to get page layout right.
2851 @c Setting indent in \paper block makes not much sense, but it works.
2853 @c Bit verbose and vague, use examples?
2854 The most basic settings influencing the spacing are @code{indent} and
2855 @code{line-width}. They are set in the @code{\layout} block. They
2856 control the indentation of the first line of music, and the lengths of
2859 If @code{ragged-right} is set to true in the @code{\layout} block, then
2860 systems ends at their natural horizontal length, instead of being spread
2861 horizontally to fill the whole line. This is useful for
2862 short fragments, and for checking how tight the natural spacing is.
2863 The normal default setting is false, but if the score has only one
2864 system the default value is true.
2867 @cindex vertical spacing
2869 The option @code{ragged-last} is similar to @code{ragged-right}, but
2870 only affects the last line of the piece. No restrictions are put on
2871 that line. The result is similar to formatting text paragraphs. In a
2872 paragraph, the last line simply takes its natural horizontal length.
2873 @c Note that for text there are several options for the last line.
2874 @c While Knuth TeX uses natural length, lead typesetters use the same
2875 @c stretch as the previous line. eTeX uses \lastlinefit to
2876 @c interpolate between both these solutions.
2892 @node Proportional notation
2893 @subsection Proportional notation
2895 LilyPond supports proportional notation, a type of horizontal spacing
2896 in which each note consumes an amount of horizontal space exactly
2897 equivalent to its rhythmic duration. This type of proportional spacing
2898 is comparable to horizontal spacing on top of graph paper. Some late
2899 20th- and early 21st-century scores use proportional notation to
2900 clarify complex rhythmic relationships or to facilitate the placement
2901 of timelines or other graphics directly in the score.
2903 LilyPond supports five different settings for proportional notation,
2904 which may be used together or alone:
2907 @item @code{proportionalNotationDuration}
2908 @item @code{uniform-stretching}
2909 @item @code{strict-note-spacing}
2910 @item @code{\remove Separating_line_group_engraver}
2911 @item @code{\override PaperColumn #'used = ##t}
2914 In the examples that follow, we explore these five different
2915 proportional notation settings and examine how these settings interact.
2917 We start with the following one-measure example, which uses classical
2918 spacing with ragged-right turned on.
2920 @lilypond[quote,verbatim,ragged-right]
2923 \new RhythmicStaff {
2927 c'16 c'16 c'16 c'16 c'16
2934 Notice that the half note which begins the measure takes up far less
2935 than half of the horizontal space of the measure. Likewise, the
2936 sixteenth notes and sixteenth-note quintuplets (or twentieth notes)
2937 which end the measure together take up far more than half the
2938 horizontal space of the measure.
2940 In classical engraving, this spacing may be exactly what we want
2941 because we can borrow horizontal space from the half note and conserve
2942 horizontal space across the measure as a whole.
2944 On the other hand, if we want to insert a measured timeline or other
2945 graphic above or below our score, we need proportional notation. We
2946 turn proportional notation on with the proportionalNotationDuration
2949 @lilypond[quote,verbatim,ragged-right]
2952 \new RhythmicStaff {
2956 c'16 c'16 c'16 c'16 c'16
2963 proportionalNotationDuration = #(ly:make-moment 1 20)
2969 The half note at the beginning of the measure and the faster notes in
2970 the second half of the measure now occupy equal amounts of horizontal
2971 space. We could place a measured timeline or graphic above or below
2974 The @code{proportionalNotationDuration} setting is a context setting
2975 that lives in @code{Score}. Remember that context settings can appear
2976 in one of three locations within our input file -- in a @code{\with}
2977 block, in a @code{\context} block, or directly in music entry preceded
2978 by the @code{\set} command. As with all context settings, users can
2979 pick which of the three different locations they would like to
2980 set @code{proportionalNotationDuration} in to.
2982 The @code{proportionalNotationDuration} setting takes a single argument,
2983 which is the reference duration against that all music will be spaced.
2984 The LilyPond Scheme function @code{make-moment} takes two arguments
2985 -- a numerator and denominator which together express some fraction of
2986 a whole note. The call @code{(ly:make-moment 1 20)} therefore produces
2987 a reference duration of a twentieth note. Values such as
2988 @code{(ly:make-moment 1 16)}, @code{(ly:make-moment 1 8)}, and
2989 @code{(ly:make-moment 3 97)} are all possible as well.
2991 How do we select the right reference duration to pass to
2992 @code{proportionalNotationDuration}? Usually by a process of trial
2993 and error, beginning with a duration close to the fastest (or smallest)
2994 duration in the piece. Smaller reference durations space music loosely;
2995 larger reference durations space music tightly.
2997 @lilypond[quote,verbatim,ragged-right]
3000 \new RhythmicStaff {
3004 c'16 c'16 c'16 c'16 c'16
3011 proportionalNotationDuration = #(ly:make-moment 1 8)
3018 \new RhythmicStaff {
3022 c'16 c'16 c'16 c'16 c'16
3029 proportionalNotationDuration = #(ly:make-moment 1 16)
3036 \new RhythmicStaff {
3040 c'16 c'16 c'16 c'16 c'16
3047 proportionalNotationDuration = #(ly:make-moment 1 32)
3053 Note that too large a reference duration -- such as the eighth note,
3054 above -- spaces music too tightly and can cause note head collisions.
3055 Also that proportional notation in general takes up more horizontal
3056 space than classical spacing. Proportional spacing provides rhythmic
3057 clarity at the expense of horizontal space.
3059 Next we examine how to optimally space overlapping tuplets.
3061 We start by examining what happens to our original example, with
3062 classical spacing, when we add a second staff with a different type of
3065 @lilypond[quote,verbatim,ragged-right]
3068 \new RhythmicStaff {
3072 c'16 c'16 c'16 c'16 c'16
3075 \new RhythmicStaff {
3077 c'8 c'8 c'8 c'8 c'8 c'8 c'8 c'8 c'8
3084 The spacing is bad because the evenly spaced notes of the bottom staff
3085 do not stretch uniformly. Classical engravings include very few complex
3086 triplets and so classical engraving rules can generate this type of
3087 result. Setting @code{proportionalNotationDuration} fixes this.
3089 @lilypond[quote,verbatim,ragged-right]
3092 \new RhythmicStaff {
3096 c'16 c'16 c'16 c'16 c'16
3099 \new RhythmicStaff {
3101 c'8 c'8 c'8 c'8 c'8 c'8 c'8 c'8 c'8
3108 proportionalNotationDuration = #(ly:make-moment 1 20)
3114 But if we look very carefully we can see that notes of the second half
3115 of the 9-tuplet space ever so slightly more widely than the notes
3116 of the first half of the 9-tuplet. To ensure uniform stretching, we
3117 turn on @code{uniform-stretching}, which is a property of
3118 @code{SpacingSpanner}.
3120 @lilypond[quote,verbatim,ragged-right]
3123 \new RhythmicStaff {
3127 c'16 c'16 c'16 c'16 c'16
3130 \new RhythmicStaff {
3132 c'8 c'8 c'8 c'8 c'8 c'8 c'8 c'8 c'8
3139 proportionalNotationDuration = #(ly:make-moment 1 20)
3140 \override SpacingSpanner #'uniform-stretching = ##t
3146 Our two-staff example now spaces exactly, our rhythmic
3147 relationships are visually clear, and we can include a measured
3148 timeline or graphic if we want.
3150 Note that the LilyPond's proportional notation package expects
3151 that all proportional scores set the SpacingSpanner's
3152 'uniform-stretching attribute to ##t. Setting
3153 proportionalNotationDuration without also setting the
3154 SpacingSpanner's 'uniform-stretching attribute to ##t will, for
3155 example, cause Skips to consume an incorrect amount of horizontal
3158 The SpacingSpanner is an abstract grob that lives in the Score
3159 context. As with our settings of proportionalNotationDuration,
3160 overrides to the SpacingSpanner can occur in any of three
3161 different places in our input file – in the Score \with block, in
3162 a Score \context block, or in note entry directly.
3164 There is by default only one @code{SpacingSpanner} per @code{Score}. This
3165 means that, by default, @code{uniform-stretching} is either turned on for the
3166 entire score or turned off for the entire score. We can, however,
3167 override this behavior and turn on different spacing features at
3168 different places in the score. We do this with the command
3169 @code{\newSpacingSection}. See @ref{New spacing area}, for more info.
3171 Next we examine the effects of the @code{Separating_line_group_engraver} and
3172 see why proportional scores frequently remove this engraver. The following
3173 example shows that there is a small amount of @qq{prefatory} space
3174 just before the first note in each system.
3176 @lilypond[quote,verbatim,ragged-right]
3189 The amount of this prefatory space is the same whether after a time
3190 signature, a key signature or a clef. @code{Separating_line_group_engraver}
3191 is responsible for this space. Removing @code{Separating_line_group_engraver}
3192 reduces this space to zero.
3194 @lilypond[quote,verbatim,ragged-right]
3200 \remove Separating_line_group_engraver
3208 non-musical elements like time signatures, key signatures, clefs and
3209 accidentals are problematic in proportional notation. None of these
3210 elements has rhythmic duration. But all of these elements consume
3211 horizontal space. Different proportional scores approach these
3212 problems differently.
3214 It may be possible to avoid spacing problems with key signatures
3215 simply by not having any. This is a valid option since most
3216 proportional scores are contemporary music. The same may be true
3217 of time signatures, especially for those scores
3218 that include a measured timeline or other graphic. But these scores
3219 are exceptional and most proportional scores include at least some
3220 time signatures. Clefs and accidentals are even more essential.
3222 So what strategies exist for spacing non-musical elements in a
3223 proportional context? One good option is the @code{strict-note-spacing}
3224 property of @code{SpacingSpanner}. Compare the two scores below:
3226 @lilypond[quote,verbatim,ragged-right]
3228 \set Score.proportionalNotationDuration = #(ly:make-moment 1 16)
3238 \set Score.proportionalNotationDuration = #(ly:make-moment 1 16)
3239 \override Score.SpacingSpanner #'strict-note-spacing = ##t
3249 Both scores are proportional, but the spacing in the first score
3250 is too loose because of the clef change. The spacing of the second
3251 score remains strict, however, because strict-note-spacing is
3252 turned on. Turning on strict-note-spacing causes the width of
3253 time signatures, key signatures, clefs and accidentals to play no
3254 part in the spacing algorithm.
3256 In addition to the settings given here, there are other settings
3257 that frequently appear in proportional scores. These include:
3260 @item @code{\override SpacingSpanner #'strict-grace-spacing = ##t}
3261 @item @code{tupletFullLength = ##t}
3262 @item @code{\override Beam #'breakable = ##t}
3263 @item @code{\override Glissando #'breakable = ##t}
3264 @item @code{\override TextSpanner #'breakable = ##t}
3265 @item @code{\remove Forbid_line_break_engraver in the Voice context}
3268 These settings space grace notes strictly, extend tuplet brackets to
3269 mark both rhythmic start- and stop-points, and allow spanning elements
3270 to break across systems and pages. See the respective parts of the manual
3271 for these related settings.
3276 @ref{New spacing area}.
3282 @node Fitting music onto fewer pages
3283 @section Fitting music onto fewer pages
3285 Sometimes you can end up with one or two staves on a second
3286 (or third, or fourth@dots{}) page. This is annoying, especially
3287 if you look at previous pages and it looks like there is plenty
3288 of room left on those.
3290 When investigating layout issues, @code{annotate-spacing} is an
3291 invaluable tool. This command prints the values of various layout
3292 spacing variables; for more details see the following section,
3293 @ref{Displaying spacing}.
3296 * Displaying spacing::
3297 * Changing spacing::
3301 @node Displaying spacing
3302 @subsection Displaying spacing
3304 @funindex annotate-spacing
3305 @cindex spacing, display of layout
3307 To graphically display the dimensions of vertical layout variables
3308 that may be altered for page formatting, set
3309 @code{annotate-spacing} in the @code{\paper} block:
3311 @c need to have \book{} otherwise we get the separate systems. -hwn
3312 @lilypond[verbatim,quote]
3313 #(set-default-paper-size "a6" 'landscape)
3316 \paper { annotate-spacing = ##t }
3322 All layout dimensions are displayed in staff-spaces, regardless
3323 of the units specified in the @code{\paper} or @code{\layout} block.
3324 In the above example, @code{paper-height} has a value of 59.75
3325 @code{staff-spaces}, and the @code{staff-size} is 20 points (the
3326 default value). Note that:
3328 @multitable {1 staff-space} {staff-size)/4 * (25.4/72.27) mm}
3331 @tab = (25.4/72.27) mm
3334 @tab = (@code{staff-size})/4 pts
3336 @tab = (@code{staff-size})/4 * (25.4/72.27) mm
3341 In this case, one @code{staff-space} is approximately equal to
3342 1.757mm. Thus the @code{paper-height} measurement of 59.75
3343 @code{staff-spaces} is equivalent to 105 millimeters, the height
3344 of @code{a6} paper in landscape orientation. The pairs
3345 (@var{a},@var{b}) are intervals, where @var{a} is the lower
3346 edge and @var{b} the upper edge of the interval.
3351 @ref{Setting the staff size}.
3357 @node Changing spacing
3358 @subsection Changing spacing
3360 The output of @code{annotate-spacing} reveals vertical dimensions
3361 in great detail. For details about modifying margins and other
3362 layout variables, see @ref{Page layout}.
3364 Other than margins, there are a few other options to save space:
3368 Force systems to move as close together as possible (to fit as
3369 many systems as possible onto a page) while being spaced so that
3370 there is no blank space at the bottom of the page.
3374 system-system-spacing = #'((basic-distance . 0.1) (padding . 0))
3375 ragged-last-bottom = ##f
3381 Force the number of systems. This can help in two ways. Just
3382 setting a value, even the same value as the number of systems
3383 being typeset by default, will sometimes cause more systems to
3384 be fitted onto each page, as an estimation step is then bypassed,
3385 giving a more accurate fit to each page. Also, forcing an actual
3386 reduction in the number of systems may save a further page. For
3387 example, if the default layout has 11 systems, the following
3388 assignment will force a layout with 10 systems.
3397 Avoid (or reduce) objects that increase the vertical size of a
3398 system. For example, volta repeats (or alternate repeats) require
3399 extra space. If these repeats are spread over two systems, they
3400 will take up more space than one system with the volta repeats and
3401 another system without. For example, dynamics that @q{stick out} of
3402 a system can be moved closer to the staff:
3404 @lilypond[verbatim,quote,relative=1]
3406 e4 c g-\tweak #'X-offset #-2.7 -\tweak #'Y-offset #2.5 \f c
3410 Alter the horizontal spacing via @code{SpacingSpanner}. For more
3411 details, see @ref{Changing horizontal spacing}. The following
3412 example illustrates the default spacing:
3414 @lilypond[verbatim,quote]
3427 The next example modifies @code{common-shortest-duration} from a
3428 value of @code{1/4} to @code{1/2}. The quarter note is the most
3429 common and shortest duration in this example, so by making this
3430 duration longer, a @q{squeezing} effect occurs:
3432 @lilypond[verbatim,quote]
3444 \override SpacingSpanner
3445 #'common-shortest-duration = #(ly:make-moment 1 2)
3452 The @code{common-shortest-duration} property cannot be modified
3453 dynamically, so it must always be placed in a @code{\context}
3454 block so that it applies to the whole score.
3462 @ref{Changing horizontal spacing}.