1 @c -*- coding: utf-8; mode: texinfo; -*-
2 @c This file is part of lilypond.tely
4 Translation of GIT committish: FILL-IN-HEAD-COMMITTISH
6 When revising a translation, copy the HEAD committish of the
7 version that you are working on. See TRANSLATION for details.
15 Negative numbers are allowed:
16 > Are you sure? The following works well
18 > first-page-number = -2
20 > and prints page number -1 on the second page, for example.
23 - default paper size is A4.
26 In 5.2.1 the @refbugs (line 495 in spacing.itely on master) it
29 "@code{layout-set-staff-size} does not change the distance between
33 Could we add a sentence:
34 "Use instead the pair fontSize = #@var{N}
35 \override StaffSymbol #'staff-space = #(magstep
37 inside the Staff context to change the size of the font and the
39 staff lines accordingly."
41 Actually I found, that the @internalsref{StaffSymbol} at line 481
42 sends to an uncomplete
43 documentation. The property staff-space is not explained here. I
44 thought Y-extent might be of
45 help, but it is in turn explained by x-space which again is
46 missing from the list. Who has the
47 knowledge to fix this?
51 http://code.google.com/p/lilypond/issues/detail?id=68
56 @chapter Spacing issues
58 The global paper layout is determined by three factors: the page layout, the
59 line breaks, and the spacing. These all influence each other. The
60 choice of spacing determines how densely each system of music is set.
61 This influences where line breaks are chosen, and thus ultimately, how
62 many pages a piece of music takes.
64 Globally speaking, this procedure happens in four steps: first,
65 flexible distances (@q{springs}) are chosen, based on durations. All
66 possible line breaking combinations are tried, and a @q{badness} score
67 is calculated for each. Then the height of each possible system is
68 estimated. Finally, a page breaking and line breaking combination is chosen
69 so that neither the horizontal nor the vertical spacing is too cramped
72 Settings which influence layout may be placed in two blocks.
73 The @code{\paper @{...@}} block is placed outside any
74 @code{\score @{...@}} blocks and contains settings that
75 relate to the entire document. The @code{\layout @{...@}}
76 block is placed within a @code{\score @{...@}} block and
77 contains settings for that particular score. If you have
78 only one @code{\score @{...@}} block the two have the same
79 effect. In general the commands shown in this chapter can
87 * Horizontal spacing::
88 * Fitting music onto fewer pages::
93 @section Paper and pages
95 This section deals with the boundaries that define the area
96 within which music can be printed.
105 @subsection Paper size
111 To change the paper size, there are two commands,
113 #(set-default-paper-size "a4")
117 #(set-paper-size "a4")
121 The first command sets the size of all pages. The second command sets the
123 of the pages that the @code{\paper} block applies to -- if the @code{\paper}
124 block is at the top of the file, then it will apply to all pages. If the
125 @code{\paper} block is inside a @code{\book}, then the paper size will only
128 Support for the following paper sizes are included by default,
129 @code{a6}, @code{a5}, @code{a4}, @code{a3}, @code{legal}, @code{letter},
130 @code{11x17} (also known as tabloid).
132 @c TODO Add new paper sizes -td
134 Extra sizes may be added by editing the definition for
135 @code{paper-alist} in the initialization file @file{scm/paper.scm}.
140 If the symbol @code{landscape} is supplied as an argument to
141 @code{set-default-paper-size}, the pages will be rotated by 90 degrees,
142 and wider line widths will be set correspondingly.
145 #(set-default-paper-size "a6" 'landscape)
148 Setting the paper size will adjust a number of @code{\paper} variables
149 (such as margins). To use a particular paper size with altered
150 @code{\paper} variables, set the paper size before setting the variables.
153 @node Page formatting
154 @subsection Page formatting
156 @cindex page formatting
161 LilyPond will do page layout, set margins, and add headers and
162 footers to each page.
164 The default layout responds to the following settings in the
171 @funindex first-page-number
172 @item first-page-number
173 The value of the page number of the first page. Default is@tie{}1.
175 @funindex print-first-page-number
176 @item print-first-page-number
177 If set to true, will print the page number in the first page. Default is
180 @funindex print-page-number
181 @item print-page-number
182 If set to false, page numbers will not be printed. Default is true.
184 @funindex paper-width
186 The width of the page. The default is taken from the current paper size,
187 see @ref{Paper size}.
189 @funindex paper-height
191 The height of the page. The default is taken from the current paper size,
192 see @ref{Paper size}.
196 Margin between header and top of the page. Default is@tie{}5mm.
198 @funindex bottom-margin
200 Margin between footer and bottom of the page. Default is@tie{}6mm.
202 @funindex left-margin
204 Margin between the left side of the page and the beginning of the
205 music. Unset by default, which means that the margins is determined
206 based on the @code{paper-width} and @code{line-width} to center the
211 The length of the systems. Default is @code{paper-width} minus @tie{}20mm.
213 @funindex head-separation
214 @item head-separation
215 Distance between the top-most music system and the page header. Default
218 @funindex foot-separation
219 @item foot-separation
220 Distance between the bottom-most music system and the page
221 footer. Default is@tie{}4mm.
223 @funindex page-top-space
225 Distance from the top of the printable area to the center of the first
226 staff. This only works for staves which are vertically small. Big staves
227 are set with the top of their bounding box aligned to the top of the
228 printable area. Default is@tie{}12mm.
230 @funindex ragged-bottom
232 If set to true, systems will not be spread vertically across the page. This
233 does not affect the last page. Default is false.
235 This should be set to true for pieces that have only two or three
236 systems per page, for example orchestral scores.
238 @funindex ragged-last-bottom
239 @item ragged-last-bottom
240 If set to false, systems will be spread vertically to fill the last
241 page. Default is true.
243 Pieces that amply fill two pages or more should have this set to
246 @funindex system-count
248 This variable, if set, specifies into how many lines a score should be
249 broken. Unset by default.
251 @funindex between-system-space
252 @item between-system-space
253 This dimensions determines the distance between systems. It is the
254 ideal distance between the center of the bottom staff of one system
255 and the center of the top staff of the next system. Default is@tie{}20mm.
257 Increasing this will provide a more even appearance of the page at the
258 cost of using more vertical space.
260 @funindex between-system-padding
261 @item between-system-padding
262 This dimension is the minimum amount of white space that will always
263 be present between the bottom-most symbol of one system, and the
264 top-most of the next system. Default is@tie{}4mm.
266 Increasing this will put systems whose bounding boxes almost touch
269 @funindex page-breaking-between-system-padding
270 @item page-breaking-between-system-padding
271 This variable tricks the page breaker into thinking that
272 @code{between-system-padding} is set to something different than it
273 really is. For example, if this variable is set to something substantially
274 larger than @code{between-system-padding}, then the page-breaker will put
275 fewer systems on each page.
277 @funindex horizontal-shift
278 @item horizontal-shift
279 All systems (including titles and system separators) are shifted by
280 this amount to the right. Page markup, such as headers and footers are
281 not affected by this. The purpose of this variable is to make space
282 for instrument names at the left. Default is@tie{}0.
284 @funindex after-title-space
285 @item after-title-space
286 Amount of space between the title and the first system. Default is@tie{}5mm.
288 @funindex before-title-space
289 @item before-title-space
290 Amount of space between the last system of the previous piece and the
291 title of the next. Default is@tie{}10mm.
293 @funindex between-title-space
294 @item between-title-space
295 Amount of space between consecutive titles (e.g., the title of the
296 book and the title of a piece). Default is@tie{}2mm.
298 @funindex printallheaders
299 @item printallheaders
300 Setting this to #t will print all headers for each \score in the
301 output. Normally only the piece and opus \headers are printed.
303 @funindex systemSeparatorMarkup
304 @item systemSeparatorMarkup
305 This contains a markup object, which will be inserted between
306 systems. This is often used for orchestral scores. Unset by default.
308 The markup command @code{\slashSeparator} is provided as a sensible
311 @lilypond[ragged-right]
312 #(set-default-paper-size "a6" 'landscape)
315 \relative { c1 \break c1 }
318 systemSeparatorMarkup = \slashSeparator
323 @funindex blank-page-force
324 @item blank-page-force
325 The penalty for having a blank page in the middle of a
326 score. This is not used by @code{ly:optimal-breaking} since it will
327 never consider blank pages in the middle of a score. Default value
330 @funindex blank-last-page-force
331 @item blank-last-page-force
332 The penalty for ending the score on an odd-numbered page.
335 @funindex page-spacing-weight
336 @item page-spacing-weight
337 The relative importance of page (vertical) spacing and line (horizontal)
338 spacing. High values will make page spacing more important. Default
341 @funindex auto-first-page-number
342 @item auto-first-page-number
343 The page breaking algorithm is affected by the first page number being
344 odd or even. If this variable is set to #t, the page breaking algorithm
345 will decide whether to start with an odd or even number. This will
346 result in the first page number remaining as is or being increased by one.
354 The header and footer are created by the functions make-footer and
355 make-header, defined in \paper. The default implementations are in
356 ly/paper-defaults.ly and ly/titling-init.ly.
358 The page layout itself is done by two functions in the \paper block,
359 page-music-height and page-make-stencil. The former tells the
360 line-breaking algorithm how much space can be spent on a page, the
361 latter creates the actual page given the system to put on it.
363 You can define paper block values in Scheme. In that case mm, in, pt,
364 and cm are variables defined in paper-defaults.ly with values in
365 millimeters. That is why the value 2 cm must be multiplied in the
370 #(define bottom-margin (* 2 cm))
382 ragged-last-bottom = ##t
386 This second example centers page numbers at the bottom of every page.
390 print-page-number = ##t
391 print-first-page-number = ##t
392 oddHeaderMarkup = \markup \fill-line @{ " " @}
393 evenHeaderMarkup = \markup \fill-line @{ " " @}
394 oddFooterMarkup = \markup @{ \fill-line @{
395 \bold \fontsize #3 \on-the-fly #print-page-number-check-first
396 \fromproperty #'page:page-number-string @} @}
397 evenFooterMarkup = \markup @{ \fill-line @{
398 \bold \fontsize #3 \on-the-fly #print-page-number-check-first
399 \fromproperty #'page:page-number-string @} @}
403 You can also define these values in Scheme. In that case @code{mm},
404 @code{in}, @code{pt}, and @code{cm} are variables defined in
405 @file{paper-defaults.ly} with values in millimeters. That is why the
406 value must be multiplied in the example
410 #(define bottom-margin (* 2 cm))
414 The header and footer are created by the functions @code{make-footer}
415 and @code{make-header}, defined in @code{\paper}. The default
416 implementations are in @file{ly/@/paper@/-defaults@/.ly} and
417 @file{ly/@/titling@/-init@/.ly}.
419 The page layout itself is done by two functions in the
420 @code{\paper} block, @code{page-music-height} and
421 @code{page-make-stencil}. The former tells the line-breaking algorithm
422 how much space can be spent on a page, the latter creates the actual
423 page given the system to put on it.
428 The option right-margin is defined but doesn't set the right margin
429 yet. The value for the right margin has to be defined adjusting the
430 values of @code{left-margin} and @code{line-width}.
432 The default page header puts the page number and the @code{instrument}
433 field from the @code{\header} block on a line.
435 The titles (from the @code{\header@{@}} section) are treated as a
436 system, so @code{ragged-bottom} and @code{ragged-last-bottom} will
437 add space between the titles and the first system of the score.
441 @section Music layout
444 * Setting the staff size::
449 @node Setting the staff size
450 @subsection Setting the staff size
452 @cindex font size, setting
453 @cindex staff size, setting
454 @funindex layout file
456 The default @strong{staff size} is set to 20 points.
457 This may be changed in two ways:
459 To set the staff size globally for all scores in a file (or
460 in a @code{book} block, to be precise), use @code{set-global-staff-size}.
463 #(set-global-staff-size 14)
467 This sets the global default size to 14pt staff height and scales all
470 To set the staff size individually for each score, use
475 #(layout-set-staff-size 15)
480 The Feta font provides musical symbols at eight different
481 sizes. Each font is tuned for a different staff size: at a smaller size
482 the font becomes heavier, to match the relatively heavier staff lines.
483 The recommended font sizes are listed in the following table:
486 @multitable @columnfractions .15 .2 .22 .2
489 @tab @b{staff height (pt)}
490 @tab @b{staff height (mm)}
532 @c modern rental material?
537 These fonts are available in any sizes. The context property
538 @code{fontSize} and the layout property @code{staff-space} (in
539 @rinternals{StaffSymbol}) can be used to tune the size for individual
540 staves. The sizes of individual staves are relative to the global size.
548 This manual: @ref{Selecting notation font size}.
553 @code{layout-set-staff-size} does not change the distance between the
558 @subsection Score layout
562 While @code{\paper} contains settings that relate to the page formatting
563 of the whole document, @code{\layout} contains settings for score-specific
570 \override VerticalAxisGroup #'minimum-Y-extent = #'(-6 . 6)
573 \override TextScript #'padding = #1.0
574 \override Glissando #'thickness = #3
582 This manual: @ref{Changing context default settings}.
591 * Optimal page breaking::
592 * Optimal page turning::
593 * Minimal page breaking::
595 * Using an extra voice for breaks::
599 @subsection Line breaking
602 @cindex breaking lines
604 Line breaks are normally determined automatically. They are chosen
605 so that lines look neither cramped nor loose, and consecutive
606 lines have similar density. Occasionally you might want to
607 override the automatic breaks; you can do this by specifying
608 @code{\break}. This will force a line break at this point. However,
609 line breaks can only occur at the end of @q{complete} bars, i.e.,
610 where there are no notes or tuplets left @q{hanging} over the bar
611 line. If you want to have a line break where there is no bar line,
612 you can force an invisible bar line by entering @code{\bar ""},
613 although again there must be no notes left hanging over in any of
614 the staves at this point, or it will be ignored.
616 The opposite command, @code{\noBreak}, forbids a line break at the
617 bar line where it is inserted.
619 The most basic settings influencing line spacing are @code{indent}
620 and @code{line-width}. They are set in the @code{\layout} block.
621 They control the indentation of the first line of music, and the
622 lengths of the lines.
624 If @code{ragged-right} is set to true in the @code{\layout} block,
625 then systems end at their natural horizontal length, instead of
626 being spread horizontally to fill the whole line. This is useful
627 for short fragments, and for checking how tight the natural
630 @c TODO Check and add para on default for ragged-right
632 The option @code{ragged-last} is similar to @code{ragged-right},
633 but affects only the last line of the piece.
645 @cindex regular line breaks
646 @cindex four bar music.
648 For line breaks at regular intervals use @code{\break} separated by
649 skips and repeated with @code{\repeat}. For example, this would
650 cause the following 28 measures (assuming 4/4 time) to be broken
651 every 4 measures, and only there:
654 << \repeat unfold 7 @{
655 s1 \noBreak s1 \noBreak
656 s1 \noBreak s1 \break @}
657 @emph{the real music}
663 @code{\break}, and @code{\noBreak}.
669 Internals: @rinternals{LineBreakEvent}.
672 A linebreaking configuration can be saved as a @code{.ly} file
673 automatically. This allows vertical alignments to be stretched to
674 fit pages in a second formatting run. This is fairly new and
675 complicated. More details are available in
680 Line breaks can only occur if there is a @q{proper} bar line. A note
681 which is hanging over a bar line is not proper, such as
683 @lilypond[quote,ragged-right,relative=2,fragment,verbatim]
684 c4 c2 << c2 {s4 \break } >> % this does nothing
685 c2 c4 | % a break here would work
686 c4 c2 c4 ~ \break % as does this break
690 This can be avoided by removing the @code{Forbid_line_break_engraver}.
691 Note that manually forced line breaks have to be added in parallel
694 @lilypond[quote,ragged-right,verbatim]
696 \remove Forbid_line_break_engraver
698 c4 c2 << c2 {s4 \break } >> % now the break is allowed
703 Similarly, line breaks are normally forbidden when beams cross bar
704 lines. This behavior can be changed by setting
705 @code{\override Beam #'breakable = ##t}.
709 @subsection Page breaking
711 The default page breaking may be overridden by inserting
712 @code{\pageBreak} or @code{\noPageBreak} commands. These commands are
713 analogous to @code{\break} and @code{\noBreak}. They should be
714 inserted at a bar line. These commands force and forbid a page-break
715 from happening. Of course, the @code{\pageBreak} command also forces
718 The @code{\pageBreak} and @code{\noPageBreak} commands may also be
719 inserted at top-level, between scores and top-level markups.
721 There are also analogous settings to @code{ragged-right} and
722 @code{ragged-last} which have the same effect on vertical spacing:
723 @code{ragged-bottom} and @code{ragged-last-bottom}. If set to
724 @code{##t} the systems on all pages or just the last page
725 respectively will not be justified vertically.
727 For more details see @ref{Vertical spacing}.
729 Page breaks are computed by the @code{page-breaking} function. LilyPond
730 provides three algorithms for computing page breaks,
731 @code{ly:optimal-breaking}, @code{ly:page-turn-breaking} and
732 @code{ly:minimal-breaking}. The default is @code{ly:optimal-breaking},
733 but the value can be changed in the @code{\paper} block:
737 #(define page-breaking ly:page-turn-breaking)
741 @c TODO Check this -td
742 The old page breaking algorithm is called
743 @code{optimal-page-breaks}. If you are having trouble with the new page
744 breakers, you can enable the old one as a workaround.
750 @funindex \noPageBreak
754 @node Optimal page breaking
755 @subsection Optimal page breaking
757 @funindex ly:optimal-breaking
759 The @code{ly:optimal-breaking} function is LilyPond's default method of
760 determining page breaks. It attempts to find a page breaking that minimizes
761 cramping and stretching, both horizontally and vertically. Unlike
762 @code{ly:page-turn-breaking}, it has no concept of page turns.
765 @node Optimal page turning
766 @subsection Optimal page turning
768 @funindex ly:page-turn-breaking
770 Often it is necessary to find a page breaking configuration so that there is
771 a rest at the end of every second page. This way, the musician can turn the
772 page without having to miss notes. The @code{ly:page-turn-breaking} function
773 attempts to find a page breaking minimizing cramping and stretching, but with
774 the additional restriction that it is only allowed to introduce page turns
777 There are two steps to using this page breaking function. First, you
778 must enable it in the @code{\paper} block, as explained in @ref{Page
779 breaking}. Then you must tell the function where you would like to allow
782 There are two ways to achieve the second step. First, you can specify each
783 potential page turn manually, by inserting @code{\allowPageTurn} into your
784 input file at the appropriate places.
786 If this is too tedious, you can add a @code{Page_turn_engraver} to a Staff or
787 Voice context. The @code{Page_turn_engraver} will scan the context for
788 sections without notes (note that it does not scan for rests; it scans for
789 the absence of notes. This is so that single-staff polyphony with rests in one
790 of the parts does not throw off the @code{Page_turn_engraver}). When it finds
791 a sufficiently long section without notes, the @code{Page_turn_engraver} will
792 insert an @code{\allowPageTurn} at the final bar line in that section, unless
793 there is a @q{special} bar line (such as a double bar), in which case the
794 @code{\allowPageTurn} will be inserted at the final @q{special} bar line in
797 @funindex minimumPageTurnLength
798 The @code{Page_turn_engraver} reads the context property
799 @code{minimumPageTurnLength} to determine how long a note-free section must
800 be before a page turn is considered. The default value for
801 @code{minimumPageTurnLength} is @code{#(ly:make-moment 1 1)}. If you want
802 to disable page turns, you can set it to something very large.
805 \new Staff \with @{ \consists "Page_turn_engraver" @}
808 R1 | % a page turn will be allowed here
810 \set Staff.minimumPageTurnLength = #(ly:make-moment 5 2)
811 R1 | % a page turn will not be allowed here
813 R1*2 | % a page turn will be allowed here
818 @funindex minimumRepeatLengthForPageTurn
819 The @code{Page_turn_engraver} detects volta repeats. It will only allow a page
820 turn during the repeat if there is enough time at the beginning and end of the
821 repeat to turn the page back. The @code{Page_turn_engraver} can also disable
822 page turns if the repeat is very short. If you set the context property
823 @code{minimumRepeatLengthForPageTurn} then the @code{Page_turn_engraver} will
824 only allow turns in repeats whose duration is longer than this value.
826 The page turning commands, @code{\pageTurn}, @code{\noPageTurn} and
827 @code{\allowPageTurn}, may also be used at top-level, between scores and
834 @funindex \noPageTurn
836 @funindex \allowPageTurn
837 @code{\allowPageTurn}
841 There should only be one @code{Page_turn_engraver} in a score. If there is more
842 than one, they will interfere with each other.
844 @node Minimal page breaking
845 @subsection Minimal page breaking
847 @funindex ly:minimal-breaking
849 The @code{ly:minimal-breaking} function performs minimal computations to
850 calculate the page breaking: it fills a page with as many systems as
851 possible before moving to the next one. Thus, it may be preferred for
852 scores with many pages, where the other page breaking functions could be
853 too slow or memory demanding, or a lot of texts. It is enabled using:
857 #(define page-breaking ly:minimal-breaking)
861 @node Explicit breaks
862 @subsection Explicit breaks
864 Lily sometimes rejects explicit @code{\break} and @code{\pageBreak}
865 commands. There are two commands to override this behavior:
868 \override NonMusicalPaperColumn #'line-break-permission = ##f
869 \override NonMusicalPaperColumn #'page-break-permission = ##f
872 When @code{line-break-permission} is overridden to false, Lily will insert
873 line breaks at explicit @code{\break} commands and nowhere else. When
874 @code{page-break-permission} is overridden to false, Lily will insert
875 page breaks at explicit @code{\pageBreak} commands and nowhere else.
877 @lilypond[quote,verbatim]
886 \override NonMusicalPaperColumn #'line-break-permission = ##f
887 \override NonMusicalPaperColumn #'page-break-permission = ##f
890 \repeat unfold 2 { c'8 c'8 c'8 c'8 } \break
891 \repeat unfold 4 { c'8 c'8 c'8 c'8 } \break
892 \repeat unfold 6 { c'8 c'8 c'8 c'8 } \break
893 \repeat unfold 8 { c'8 c'8 c'8 c'8 } \pageBreak
894 \repeat unfold 8 { c'8 c'8 c'8 c'8 } \break
895 \repeat unfold 6 { c'8 c'8 c'8 c'8 } \break
896 \repeat unfold 4 { c'8 c'8 c'8 c'8 } \break
897 \repeat unfold 2 { c'8 c'8 c'8 c'8 }
904 @node Using an extra voice for breaks
905 @subsection Using an extra voice for breaks
907 Line- and page-breaking information usually appears within note entry directly.
912 \repeat unfold 2 @{ c'4 c'4 c'4 c'4 @}
914 \repeat unfold 3 @{ c'4 c'4 c'4 c'4 @}
919 This makes @code{\break} and @code{\pageBreak} commands easy to enter but mixes
920 music entry with information that specifies how music should lay out
921 on the page. You can keep music entry and line- and page-breaking
922 information in two separate places by introducing an extra voice to
923 contain the breaks. This extra voice
924 contains only skips together with @code{\break}, @code{pageBreak} and other
925 breaking layout information.
927 @lilypond[quote,verbatim]
937 \repeat unfold 2 { c'4 c'4 c'4 c'4 }
938 \repeat unfold 3 { c'4 c'4 c'4 c'4 }
939 \repeat unfold 6 { c'4 c'4 c'4 c'4 }
940 \repeat unfold 5 { c'4 c'4 c'4 c'4 }
946 This pattern becomes especially helpful when overriding
947 @code{line-break-system-details} and the other useful but long properties of
948 @code{NonMusicalPaperColumnGrob}, as explained in @ref{Vertical spacing}.
950 @lilypond[quote,verbatim]
955 \overrideProperty "Score.NonMusicalPaperColumn"
956 #'line-break-system-details #'((Y-offset . 0))
959 \overrideProperty "Score.NonMusicalPaperColumn"
960 #'line-break-system-details #'((Y-offset . 35))
963 \overrideProperty "Score.NonMusicalPaperColumn"
964 #'line-break-system-details #'((Y-offset . 70))
967 \overrideProperty "Score.NonMusicalPaperColumn"
968 #'line-break-system-details #'((Y-offset . 105))
972 \repeat unfold 2 { c'4 c'4 c'4 c'4 }
973 \repeat unfold 3 { c'4 c'4 c'4 c'4 }
974 \repeat unfold 6 { c'4 c'4 c'4 c'4 }
975 \repeat unfold 5 { c'4 c'4 c'4 c'4 }
982 @node Vertical spacing
983 @section Vertical spacing
985 @cindex vertical spacing
986 @cindex spacing, vertical
988 Vertical spacing is controlled by three things: the amount of
989 space available (i.e., paper size and margins), the amount of
990 space between systems, and the amount of space between
991 staves inside a system.
994 * Vertical spacing inside a system::
995 * Vertical spacing between systems::
996 * Explicit staff and system positioning::
997 * Two-pass vertical spacing::
998 * Vertical collision avoidance::
1002 @node Vertical spacing inside a system
1003 @subsection Vertical spacing inside a system
1005 @cindex distance between staves
1006 @cindex staff distance
1007 @cindex space between staves
1008 @cindex space inside systems
1010 The height of each system is determined automatically. To prevent
1011 staves from bumping into each other, some minimum distances are set.
1012 By changing these, you can put staves closer together. This
1013 reduces the amount of space each system requires, and may result
1014 in having more systems per page.
1016 Normally staves are stacked vertically. To make staves maintain a
1017 distance, their vertical size is padded. This is done with the
1018 property @code{minimum-Y-extent}. When applied to a
1019 @rinternals{VerticalAxisGroup}, it controls the size of a horizontal
1020 line, such as a staff or a line of lyrics. @code{minimum-Y-extent}
1021 takes a pair of numbers, so
1022 if you want to make it smaller than its default @code{#'(-4 . 4)}
1026 \override Staff.VerticalAxisGroup #'minimum-Y-extent = #'(-3 . 3)
1030 This sets the vertical size of the current staff to 3 staff spaces on
1031 either side of the center staff line. The value @code{(-3 . 3)} is
1032 interpreted as an interval, where the center line is the 0, so the
1033 first number is generally negative. The numbers need not match;
1034 for example, the staff can be made larger at the bottom by setting
1035 it to @code{(-6 . 4)}.
1037 After page breaks are determined, the vertical spacing within each
1038 system is reevaluated in order to fill the page more evenly; if a page
1039 has space left over, systems are stretched in order to fill that space.
1040 The amount of stretching can be configured though the @code{max-stretch}
1041 property of the @rinternals{VerticalAlignment} grob. By default,
1042 @code{max-stretch} is set to zero, disabling stretching. To enable
1043 stretching, a sane value for @code{max-stretch}
1044 is @code{ly:align-interface::calc-max-stretch}.
1046 In some situations, you may want to stretch most of a system while
1047 leaving some parts fixed. For example, if a piano part occurs in the
1048 middle of an orchestral score, you may want to leave the piano staves
1049 close to each other while stretching the rest of the score. The
1050 @code{keep-fixed-while-stretching} property of
1051 @rinternals{VerticalAxisGroup} can be used to achieve this. When set
1052 to @code{##t}, this property keeps its staff (or line of lyrics) from
1053 moving relative to the one directly above it. In the example above,
1054 you would override @code{keep-fixed-while-stretching} to @code{##t} in
1055 the second piano staff:
1058 #(set-default-paper-size "a6")
1059 #(set-global-staff-size 14.0)
1063 ragged-last-bottom = ##f
1068 \override VerticalAlignment #'max-stretch = #ly:align-interface::calc-max-stretch
1075 \new Staff {c' d' e' f'}
1076 \new Staff {c' d' e' f'}
1077 \new Staff {c' d' e' f'}
1082 \new Staff {c' d' e' f'}
1084 \override VerticalAxisGroup #'keep-fixed-while-stretching = ##t
1091 \new Staff {c' d' e' f'}
1092 \new Staff {c' d' e' f'}
1101 Internals: Vertical alignment of staves is handled by the
1102 @rinternals{VerticalAlignment} object. The context parameters
1103 specifying the vertical extent are described in connection with
1104 the @rinternals{Axis_group_engraver}.
1106 Example files: @c @lsr{spacing,page-spacing.ly},
1107 @c @lsr{spacing,alignment-vertical-spacing.ly}.
1110 @node Vertical spacing between systems
1111 @subsection Vertical spacing between systems
1113 Space between systems are controlled by four @code{\paper} variables,
1117 between-system-space = 1.5\cm
1118 between-system-padding = #1
1120 ragged-last-bottom=##f
1124 When only a couple of flat systems are placed on a page, the resulting
1125 vertical spacing may be non-elegant: one system at the top of the page,
1126 and the other at the bottom, with a huge gap between them. To avoid this
1127 situation, the space added between the systems can be limited. This
1128 feature is activated by setting to @code{#t} the
1129 @code{page-limit-inter-system-space} variable in the @code{\paper}
1130 block. The paper variable @code{page-limit-inter-system-space-factor}
1131 determines how much the space can be increased: for instance, the value
1132 @code{1.3} means that the space can be 30% larger than what it would be
1133 on a ragged-bottom page.
1135 In the following example, if the inter system space were not limited,
1136 the second system of page 1 would be placed at the page bottom. By
1137 activating the space limitation, the second system is placed closer to
1138 the first one. By setting @code{page-limit-inter-system-space-factor} to
1139 @code{1}, the spacing would the same as on a ragged-bottom page, like
1143 #(set-default-paper-size "a6")
1146 page-limit-inter-system-space = ##t
1147 page-limit-inter-system-space-factor = 1.3
1149 oddFooterMarkup = \markup "page bottom"
1150 evenFooterMarkup = \markup "page bottom"
1151 oddHeaderMarkup = \markup \fill-line {
1152 "page top" \fromproperty #'page:page-number-string }
1153 evenHeaderMarkup = \markup \fill-line {
1154 "page top" \fromproperty #'page:page-number-string }
1156 \new Staff << \repeat unfold 4 { g'4 g' g' g' \break }
1157 { s1*2 \pageBreak } >>
1161 @node Explicit staff and system positioning
1162 @subsection Explicit staff and system positioning
1164 One way to understand the @code{VerticalAxisGroup} and @code{\paper}
1165 settings explained in the previous two sections is as a collection of
1166 different settings that primarily concern the amount of vertical padding
1167 different staves and systems running down the page.
1169 It is possible to approach vertical spacing in a different way using
1170 @code{NonMusicalPaperColumn #'line-break-system-details}. Where
1171 @code{VerticalAxisGroup} and @code{\paper} settings specify vertical padding,
1172 @code{NonMusicalPaperColumn #'line-break-system-details} specifies exact
1173 vertical positions on the page.
1175 @code{NonMusicalPaperColumn #'line-break-system-details} accepts an associative
1176 list of five different settings:
1179 @item @code{X-offset}
1180 @item @code{Y-offset}
1181 @item @code{alignment-offsets}
1182 @item @code{alignment-extra-space}
1183 @item @code{fixed-alignment-extra-space}
1186 Grob overrides, including the overrides for @code{NonMusicalPaperColumn}
1187 below, can occur in any of three different places in an input file:
1190 @item in the middle of note entry directly
1191 @item in a @code{\context} block
1192 @item in the @code{\with} block
1195 When we override @code{NonMusicalPaperColumn}, we use the usual
1196 @code{\override} command in @code{\context} blocks and in the
1197 @code{\with} block. On the other hand, when we override
1198 @code{NonMusicalPaperColumn} in the middle of note entry,
1199 use the special @code{\overrideProperty} command. Here are some
1200 example @code{NonMusicalPaperColumn} overrides with the special
1201 @code{\overrideProperty} command:
1204 \overrideProperty NonMusicalPaperColumn
1205 #'line-break-system-details #'((X-offset . 20))
1207 \overrideProperty NonMusicalPaperColumn
1208 #'line-break-system-details #'((Y-offset . 40))
1210 \overrideProperty NonMusicalPaperColumn
1211 #'line-break-system-details #'((X-offset . 20) (Y-offset . 40))
1213 \override NonMusicalPaperColumn
1214 #'line-break-system-details #'((alignment-offsets . (0 -15)))
1216 \override NonMusicalPaperColumn
1217 #'line-break-system-details #'((X-offset . 20) (Y-offset . 40)
1218 (alignment-offsets . (0 -15)))
1221 To understand how each of these different settings work, we begin
1222 by looking at an example that includes no overrides at all.
1224 @lilypond[quote,ragged-right]
1232 \new Voice { \repeat unfold 18 { c'4 c'4 c'4 c'4 } }
1235 \repeat unfold 18 { d'4 d'4 d'4 d'4 }
1240 This score isolates line- and page-breaking information in a dedicated
1241 voice. This technique of creating a breaks voice will help keep layout
1242 separate from music entry as our example becomes more complicated.
1243 See @ref{Using an extra voice for breaks}.
1245 Explicit @code{\breaks} evenly divide the music into six measures per
1246 line. Vertical spacing results from LilyPond's defaults. To set
1247 the vertical startpoint of each system explicitly, we can set
1248 the @code{Y-offset} pair in the @code{line-break-system-details}
1249 attribute of the @code{NonMusicalPaperColumn} grob:
1251 @lilypond[quote,ragged-right]
1255 \overrideProperty #"Score.NonMusicalPaperColumn"
1256 #'line-break-system-details #'((Y-offset . 0))
1258 \overrideProperty #"Score.NonMusicalPaperColumn"
1259 #'line-break-system-details #'((Y-offset . 40))
1261 \overrideProperty #"Score.NonMusicalPaperColumn"
1262 #'line-break-system-details #'((Y-offset . 80))
1265 \new Voice { \repeat unfold 18 { c'4 c'4 c'4 c'4 } }
1268 \repeat unfold 18 { d'4 d'4 d'4 d'4 }
1273 Note that @code{line-break-system-details} takes an associative list of
1274 potentially many values, but that we set only one value here. Note,
1275 too, that the @code{Y-offset} property here determines the exact vertical
1276 position on the page at which each new system will render.
1278 Now that we have set the vertical startpoint of each system
1279 explicitly, we can also set the vertical startpoint of each staff
1280 within each system manually. We do this using the @code{alignment-offsets}
1281 subproperty of @code{line-break-system-details}.
1283 @lilypond[quote,ragged-right]
1287 \overrideProperty #"Score.NonMusicalPaperColumn"
1288 #'line-break-system-details #'((Y-offset . 20)
1289 (alignment-offsets . (0 -15)))
1291 \overrideProperty #"Score.NonMusicalPaperColumn"
1292 #'line-break-system-details #'((Y-offset . 60)
1293 (alignment-offsets . (0 -15)))
1295 \overrideProperty #"Score.NonMusicalPaperColumn"
1296 #'line-break-system-details #'((Y-offset . 100)
1297 (alignment-offsets . (0 -15)))
1300 \new Voice { \repeat unfold 18 { c'4 c'4 c'4 c'4 } }
1303 \repeat unfold 18 { d'4 d'4 d'4 d'4 }
1308 Note that here we assign two different values to the
1309 @code{line-break-system-details} attribute of the
1310 @code{NonMusicalPaperColumn} grob. Though the
1311 @code{line-break-system-details} attribute alist accepts many
1312 additional spacing parameters (including, for example, a corresponding
1313 @code{X-offset} pair), we need only set the @code{Y-offset} and
1314 @code{alignment-offsets} pairs to control the vertical startpoint of
1315 every system and every staff. Finally, note that @code{alignment-offsets}
1316 specifies the vertical positioning of staves but not of staff groups.
1318 @lilypond[quote,ragged-right]
1322 \overrideProperty #"Score.NonMusicalPaperColumn"
1323 #'line-break-system-details #'((Y-offset . 0)
1324 (alignment-offsets . (0 -30 -40)))
1326 \overrideProperty #"Score.NonMusicalPaperColumn"
1327 #'line-break-system-details #'((Y-offset . 60)
1328 (alignment-offsets . (0 -10 -20)))
1330 \overrideProperty #"Score.NonMusicalPaperColumn"
1331 #'line-break-system-details #'((Y-offset . 100)
1332 (alignment-offsets . (0 -10, -40)))
1335 \new Voice { \repeat unfold 18 { c'4 c'4 c'4 c'4 } }
1339 \repeat unfold 18 { d'4 d'4 d'4 d'4 }
1342 \repeat unfold 18 { e'4 e'4 e'4 e'4 }
1348 Some points to consider:
1351 @item When using @code{alignment-offsets}, lyrics count as a staff.
1353 @item The units of the numbers passed to @code{X-offset},
1354 @code{Y-offset} and @code{alignment-offsets} are interpreted as multiples
1355 of the distance between adjacent staff lines. Positive values move staves
1356 and lyrics up, negative values move staves and lyrics down.
1358 @item Because the @code{NonMusicalPaperColumn #'line-break-system-details}
1359 settings given here allow the positioning of staves and systems anywhere
1360 on the page, it is possible to violate paper or margin boundaries or even
1361 to print staves or systems on top of one another. Reasonable values
1362 passed to these different settings will avoid this.
1366 @node Two-pass vertical spacing
1367 @subsection Two-pass vertical spacing
1369 Warning: two-pass vertical spacing is deprecated and will be removed in
1370 a future version of LilyPond. Systems are now stretched automatically
1371 in a single pass. See @ref{Vertical spacing inside a system}.
1373 In order to automatically stretch systems so that they should fill the
1374 space left on a page, a two-pass technique can be used:
1377 @item In the first pass, the amount of vertical space used to increase
1378 the height of each system is computed and dumped to a file.
1379 @item In the second pass, spacing inside the systems are
1380 stretched according to the data in the page layout file.
1383 The @code{ragged-bottom} property adds space between systems, while
1384 the two-pass technique adds space between staves inside a system.
1386 To allow this behavior, a @code{tweak-key} variable has to be set in
1387 each score @code{\layout} block, and the tweaks included in each score
1388 music, using the @code{\scoreTweak} music function.
1392 %% include the generated page layout file:
1393 \includePageLayoutFile
1398 %% Include this score tweaks:
1399 \scoreTweak "scoreA"
1400 { \clef french c''1 \break c''1 }
1402 \new Staff { \clef soprano g'1 g'1 }
1403 \new Staff { \clef mezzosoprano e'1 e'1 }
1404 \new Staff { \clef alto g1 g1 }
1405 \new Staff { \clef bass c1 c1 }
1408 piece = "Score with tweaks"
1410 %% Define how to name the tweaks for this score:
1411 \layout { #(define tweak-key "scoreA") }
1416 For the first pass, the @code{dump-tweaks} option should be set to
1417 generate the page layout file.
1420 lilypond -dbackend=null -d dump-tweaks <file>.ly
1425 @node Vertical collision avoidance
1426 @subsection Vertical collision avoidance
1428 @funindex outside-staff-priority
1429 @funindex outside-staff-padding
1430 @funindex outside-staff-horizontal-padding
1432 Intuitively, there are some objects in musical notation that belong
1433 to the staff and there are other objects that should be placed outside
1434 the staff. Objects belonging outside the staff include things such as
1435 rehearsal marks, text and dynamic markings (from now on, these will
1436 be called outside-staff objects). LilyPond's rule for the
1437 vertical placement of outside-staff objects is to place them as close
1438 to the staff as possible but not so close that they collide with
1441 LilyPond uses the @code{outside-staff-priority} property to determine
1442 whether a grob is an outside-staff object: if @code{outside-staff-priority}
1443 is a number, the grob is an outside-staff object. In addition,
1444 @code{outside-staff-priority} tells LilyPond in which order the objects
1447 First, LilyPond places all the objects that do not belong outside
1448 the staff. Then it sorts the outside-staff objects according to their
1449 @code{outside-staff-priority} (in increasing order). One by one, LilyPond
1450 takes the outside-staff objects and places them so that they do
1451 not collide with any objects that have already been placed. That
1452 is, if two outside-staff grobs are competing for the same space, the one
1453 with the lower @code{outside-staff-priority} will be placed closer to
1456 @lilypond[quote,ragged-right,relative=2,fragment,verbatim]
1459 \once \override TextScript #'outside-staff-priority = #1
1460 c4_"Text"\pp % this time the text will be closer to the staff
1462 % by setting outside-staff-priority to a non-number,
1463 % we disable the automatic collision avoidance
1464 \once \override TextScript #'outside-staff-priority = ##f
1465 \once \override DynamicLineSpanner #'outside-staff-priority = ##f
1466 c4_"Text"\pp % now they will collide
1469 The vertical padding between an outside-staff object and the
1470 previously-positioned grobs can be controlled with
1471 @code{outside-staff-padding}.
1473 @lilypond[quote,ragged-right,relative=2,fragment,verbatim]
1474 \once \override TextScript #'outside-staff-padding = #0
1475 a'^"This text is placed very close to the note"
1476 \once \override TextScript #'outside-staff-padding = #3
1477 c^"This text is padded away from the previous text"
1478 c^"This text is placed close to the previous text"
1481 TODO: this example doesn't work any more ?
1483 By default, outside-staff objects are placed without regard to
1484 their horizontal distance from the previously-positioned grobs. This
1485 can lead to situations in which objects are placed very close to each
1486 other horizontally. Setting @code{outside-staff-horizontal-padding}
1487 causes an object to be offset vertically so that such a situation
1490 @lilypond[quote,ragged-right,relative=2,fragment,verbatim]
1491 % the markup is too close to the following note
1494 % setting outside-staff-horizontal-padding fixes this
1496 \once \override TextScript #'outside-staff-horizontal-padding = #1
1503 @node Horizontal spacing
1504 @section Horizontal Spacing
1506 @cindex horizontal spacing
1507 @cindex spacing, horizontal
1510 * Horizontal spacing overview::
1511 * New spacing area::
1512 * Changing horizontal spacing::
1514 * Proportional notation::
1518 @node Horizontal spacing overview
1519 @subsection Horizontal spacing overview
1521 The spacing engine translates differences in durations into stretchable
1522 distances (@q{springs}) of differing lengths. Longer durations get
1523 more space, shorter durations get less. The shortest durations get a
1524 fixed amount of space (which is controlled by
1525 @code{shortest-duration-space} in the @rinternals{SpacingSpanner}
1526 object). The longer the duration, the more space it gets: doubling a
1527 duration adds a fixed amount (this amount is controlled by
1528 @code{spacing-increment}) of space to the note.
1530 For example, the following piece contains lots of half, quarter, and
1531 8th notes; the eighth note is followed by 1 note head width (NHW).
1532 The quarter note is followed by 2 NHW, the half by 3 NHW, etc.
1534 @lilypond[quote,fragment,verbatim,relative=1]
1535 c2 c4. c8 c4. c8 c4. c8 c8
1539 Normally, @code{spacing-increment} is set to 1.2 staff space, which is
1540 approximately the width of a note head, and
1541 @code{shortest-duration-space} is set to 2.0, meaning that the
1542 shortest note gets 2.4 staff space (2.0 times the
1543 @code{spacing-increment}) of horizontal space. This space is counted
1544 from the left edge of the symbol, so the shortest notes are generally
1545 followed by one NHW of space.
1547 If one would follow the above procedure exactly, then adding a single
1548 32nd note to a score that uses 8th and 16th notes, would widen up the
1549 entire score a lot. The shortest note is no longer a 16th, but a 32nd,
1550 thus adding 1 NHW to every note. To prevent this, the shortest
1551 duration for spacing is not the shortest note in the score, but rather
1552 the one which occurs most frequently.
1555 The most common shortest duration is determined as follows: in every
1556 measure, the shortest duration is determined. The most common shortest
1557 duration is taken as the basis for the spacing, with the stipulation
1558 that this shortest duration should always be equal to or shorter than
1559 an 8th note. The shortest duration is printed when you run
1560 @code{lilypond} with the @code{--verbose} option.
1562 These durations may also be customized. If you set the
1563 @code{common-shortest-duration} in @rinternals{SpacingSpanner}, then
1564 this sets the base duration for spacing. The maximum duration for this
1565 base (normally an 8th), is set through @code{base-shortest-duration}.
1567 @funindex common-shortest-duration
1568 @funindex base-shortest-duration
1569 @funindex stem-spacing-correction
1572 Notes that are even shorter than the common shortest note are
1573 followed by a space that is proportional to their duration relative to
1574 the common shortest note. So if we were to add only a few 16th notes
1575 to the example above, they would be followed by half a NHW:
1577 @lilypond[quote,fragment,verbatim,relative=2]
1578 c2 c4. c8 c4. c16[ c] c4. c8 c8 c8 c4 c4 c4
1582 In the introduction (see @rlearning{Engraving}), it was explained that stem
1583 directions influence spacing. This is controlled with the
1584 @code{stem-spacing-correction} property in the
1585 @rinternals{NoteSpacing}, object. These are generated for every
1586 @rinternals{Voice} context. The @code{StaffSpacing} object
1587 (generated in @rinternals{Staff} context) contains the same property
1588 for controlling the stem/bar line spacing. The following example shows
1589 these corrections, once with default settings, and once with
1590 exaggerated corrections:
1592 @lilypond[quote,ragged-right]
1596 \override Staff.NoteSpacing #'stem-spacing-correction = #1.5
1597 \override Staff.StaffSpacing #'stem-spacing-correction = #1.5
1603 Proportional notation is supported; see @ref{Proportional notation}.
1608 Internals: @rinternals{SpacingSpanner}, @rinternals{NoteSpacing},
1609 @rinternals{StaffSpacing}, and @rinternals{SeparationItem}.
1614 There is no convenient mechanism to manually override spacing. The
1615 following work-around may be used to insert extra space into a score.
1617 \once \override Score.SeparationItem #'padding = #1
1620 No work-around exists for decreasing the amount of space.
1623 @node New spacing area
1624 @subsection New spacing area
1626 New sections with different spacing parameters can be started with
1627 @code{newSpacingSection}. This is useful when there are
1628 sections with a different notions of long and short notes.
1630 In the following example, the time signature change introduces a new
1631 section, and hence the 16ths notes are spaced wider.
1633 @lilypond[relative,fragment,verbatim,quote]
1636 c8 c c4 c16[ c c8] c4
1643 The @code{\newSpacingSection} command creates a new
1644 @rinternals{SpacingSpanner} object, and hence new @code{\override}s
1645 may be used in that location.
1648 @node Changing horizontal spacing
1649 @subsection Changing horizontal spacing
1651 Horizontal spacing may be altered with the
1652 @code{base-shortest-duration} property. Here
1653 we compare the same music; once without altering
1654 the property, and then altered. Larger values
1655 of @code{ly:make-moment} will produce smaller
1656 music. Note that @code{ly:make-moment} constructs
1657 a duration, so @code{1 4} is a longer duration
1660 @lilypond[verbatim,line-width=12\cm]
1663 g4 e e2 | f4 d d2 | c4 d e f | g4 g g2 |
1664 g4 e e2 | f4 d d2 | c4 e g g | c,1 |
1665 d4 d d d | d4 e f2 | e4 e e e | e4 f g2 |
1666 g4 e e2 | f4 d d2 | c4 e g g | c,1 |
1671 @lilypond[verbatim,line-width=12\cm]
1674 g4 e e2 | f4 d d2 | c4 d e f | g4 g g2 |
1675 g4 e e2 | f4 d d2 | c4 e g g | c,1 |
1676 d4 d d d | d4 e f2 | e4 e e e | e4 f g2 |
1677 g4 e e2 | f4 d d2 | c4 e g g | c,1 |
1682 \override SpacingSpanner
1683 #'base-shortest-duration = #(ly:make-moment 1 16)
1692 By default, spacing in tuplets depends on various non-duration
1693 factors (such as accidentals, clef changes, etc). To disregard
1694 such symbols and force uniform equal-duration spacing, use
1695 @code{Score.SpacingSpanner #'uniform-stretching}. This
1696 property can only be changed at the beginning of a score,
1698 @lilypond[quote,ragged-right,relative=2,fragment,verbatim]
1700 \override SpacingSpanner #'uniform-stretching = ##t
1718 When @code{strict-note-spacing} is set, notes are spaced without
1719 regard for clefs, bar lines, and grace notes,
1721 @lilypond[quote,ragged-right,relative=2,fragment,verbatim]
1722 \override Score.SpacingSpanner #'strict-note-spacing = ##t
1723 \new Staff { c8[ c \clef alto c \grace { c16[ c] } c8 c c] c32[ c32] }
1728 @subsection Line length
1731 @cindex breaking pages
1734 @funindex line-width
1735 @funindex ragged-right
1736 @funindex ragged-last
1738 @c Although line-width can be set in \layout, it should be set in paper
1739 @c block, to get page layout right.
1740 @c Setting indent in \paper block makes not much sense, but it works.
1742 @c Bit verbose and vague, use examples?
1743 The most basic settings influencing the spacing are @code{indent} and
1744 @code{line-width}. They are set in the @code{\layout} block. They
1745 control the indentation of the first line of music, and the lengths of
1748 If @code{ragged-right} is set to true in the @code{\layout} block, then
1749 systems ends at their natural horizontal length, instead of being spread
1750 horizontally to fill the whole line. This is useful for
1751 short fragments, and for checking how tight the natural spacing is.
1754 @cindex vertical spacing
1756 The option @code{ragged-last} is similar to @code{ragged-right}, but
1757 only affects the last line of the piece. No restrictions are put on
1758 that line. The result is similar to formatting text paragraphs. In a
1759 paragraph, the last line simply takes its natural horizontal length.
1760 @c Note that for text there are several options for the last line.
1761 @c While Knuth TeX uses natural length, lead typesetters use the same
1762 @c stretch as the previous line. eTeX uses \lastlinefit to
1763 @c interpolate between both these solutions.
1774 @node Proportional notation
1775 @subsection Proportional notation
1777 LilyPond supports proportional notation, a type of horizontal spacing
1778 in which each note consumes an amount of horizontal space exactly
1779 equivalent to its rhythmic duration. This type of proportional spacing
1780 is comparable to horizontal spacing on top of graph paper. Some late
1781 20th- and early 21st-century scores use proportional notation to
1782 clarify complex rhythmic relationships or to facilitate the placement
1783 of timelines or other graphics directly in the score.
1785 LilyPond supports five different settings for proportional notation,
1786 which may be used together or alone:
1789 @item @code{proportionalNotationDuration}
1790 @item @code{uniform-stretching}
1791 @item @code{strict-note-spacing}
1792 @item @code{\remove Separating_line_group_engraver}
1793 @item @code{\override PaperColumn #'used = ##t}
1796 In the examples that follow, we explore these five different
1797 proportional notation settings and examine how these settings interact.
1799 We start with the following one-measure example, which uses classical
1800 spacing with ragged-right turned on.
1802 @lilypond[quote,verbatim,ragged-right]
1804 \new RhythmicStaff {
1808 c'16 c'16 c'16 c'16 c'16
1814 Notice that the half note which begins the measure takes up far less
1815 than half of the horizontal space of the measure. Likewise, the
1816 sixteenth notes and sixteenth-note quintuplets (or twentieth notes)
1817 which end the measure together take up far more than half the
1818 horizontal space of the measure.
1820 In classical engraving, this spacing may be exactly what we want
1821 because we can borrow horizontal space from the half note and conserve
1822 horizontal space across the measure as a whole.
1824 On the other hand, if we want to insert a measured timeline or other
1825 graphic above or below our score, we need proportional notation. We
1826 turn proportional notation on with the proportionalNotationDuration
1829 @lilypond[quote,verbatim,ragged-right]
1831 proportionalNotationDuration = #(ly:make-moment 1 20)
1833 \new RhythmicStaff {
1837 c'16 c'16 c'16 c'16 c'16
1843 The half note at the beginning of the measure and the faster notes in
1844 the second half of the measure now occupy equal amounts of horizontal
1845 space. We could place a measured timeline or graphic above or below
1848 The @code{proportionalNotationDuration} setting is a context setting that
1849 lives in @code{Score}. Recall that context settings appear in one of
1850 three locations in our input file -- in a @code{\with} block, in a
1851 @code{\context} block, or directly in music entry
1852 preceded by the @code{\set} command. As with all
1853 context settings, users can pick which of the three different
1854 locations they would like to set @code{proportionalNotationDuration}.
1856 The @code{proportionalNotationDuration} setting takes a single argument,
1857 which is the reference duration against which all music will be
1858 spaced. The LilyPond Scheme function make-moment takes two arguments
1859 -- a numerator and denominator which together express some fraction of
1860 a whole note. The call @code{#(ly:make-moment 1 20)} therefore produces a
1861 reference duration of a twentieth note. The values
1862 @code{#(ly:make-moment 1 16)}, @code{#(ly:make-moment 1 8)}, and
1863 @code{#(ly:make-moment 3 97)} are all possible as well.
1865 How do we select the right reference duration to pass to
1866 @code{proportionalNotationDuration}? Usually by a process of trial and error,
1867 beginning with a duration close to the fastest (or smallest) duration
1868 in the piece. Smaller reference durations space music loosely; larger
1869 reference durations space music tightly.
1871 @lilypond[quote,verbatim,ragged-right]
1873 proportionalNotationDuration = #(ly:make-moment 1 8)
1875 \new RhythmicStaff {
1879 c'16 c'16 c'16 c'16 c'16
1885 proportionalNotationDuration = #(ly:make-moment 1 16)
1887 \new RhythmicStaff {
1891 c'16 c'16 c'16 c'16 c'16
1897 proportionalNotationDuration = #(ly:make-moment 1 32)
1899 \new RhythmicStaff {
1903 c'16 c'16 c'16 c'16 c'16
1909 Note that too large a reference duration -- such as the eighth note,
1910 above -- spaces music too tightly and can cause note head collisions.
1911 Note also that proportional notation in general takes up more
1912 horizontal space that does classical spacing. Proportional spacing
1913 provides rhythmic clarity at the expense of horizontal space.
1915 Next we examine how to optimally space overlapping tuplets.
1917 We start by examining what happens to our original example, with
1918 classical spacing, when we add a second staff with a different type of
1921 @lilypond[quote,verbatim,ragged-right]
1923 \new RhythmicStaff {
1927 c'16 c'16 c'16 c'16 c'16
1930 \new RhythmicStaff {
1932 c'8 c'8 c'8 c'8 c'8 c'8 c'8 c'8 c'8
1938 The spacing is bad because the evenly notes of the bottom staff do not
1939 stretch uniformly. Classical engraving includes very few complex
1940 triplets and so classical engraving rules can generate this type of
1941 result. Setting @code{proportionalNotationDuration} remedies this
1942 situation considerably.
1944 @lilypond[quote,verbatim,ragged-right]
1946 proportionalNotationDuration = #(ly:make-moment 1 20)
1948 \new RhythmicStaff {
1952 c'16 c'16 c'16 c'16 c'16
1955 \new RhythmicStaff {
1957 c'8 c'8 c'8 c'8 c'8 c'8 c'8 c'8 c'8
1963 But if we look very carefully we can see that notes of the second half
1964 of the 9-tuplet space ever so slightly more widely than do the notes
1965 of the first half of the 9-tuplet. To ensure uniform stretching, we
1966 turn on @code{uniform-stretching}, which is a property of
1967 @code{SpacingSpanner}.
1969 @lilypond[quote,verbatim,ragged-right]
1971 proportionalNotationDuration = #(ly:make-moment 1 20)
1972 \override SpacingSpanner #'uniform-stretching = ##t
1974 \new RhythmicStaff {
1978 c'16 c'16 c'16 c'16 c'16
1981 \new RhythmicStaff {
1983 c'8 c'8 c'8 c'8 c'8 c'8 c'8 c'8 c'8
1989 Our two-staff example now spaces exactly, our rhythmic
1990 relationships are visually clear, and we can include a measured
1991 timeline or graphic if we want.
1993 Note that the LilyPond's proportional notation package expects
1994 that all proportional scores set the SpacingSpanner's
1995 'uniform-stretching attribute to ##t. Setting
1996 proportionalNotationDuration without also setting the
1997 SpacingSpanner's 'uniform-stretching attribute to ##t will, for
1998 example, cause Skips to consume an incorrect amount of horizontal
2001 The SpacingSpanner is an abstract grob that lives in the Score
2002 context. As with our settings of proportionalNotationDuration,
2003 overrides to the SpacingSpanner can occur in any of three
2004 different places in our input file – in the Score \with block, in
2005 a Score \context block, or in note entry directly.
2007 There is by default only one @code{SpacingSpanner} per @code{Score}. This
2008 means that, by default, @code{uniform-stretching} is either turned on for the
2009 entire score or turned off for the entire score. We can, however,
2010 override this behavior and turn on different spacing features at
2011 different places in the score. We do this with the command
2012 @code{\newSpacingSection}. See @ref{New spacing area}, for more info.
2014 Next we examine the effects of the @code{Separating_line_group_engraver} and
2015 see why proportional scores frequently remove this engraver. The following
2016 example shows that there is a small amount of @qq{preferatory} space
2017 just before the first note in each system.
2019 @lilypond[quote,verbatim,ragged-right]
2032 The amount of this preferatory space is the same whether after a time
2033 signature, a key signature or a clef. @code{Separating_line_group_engraver}
2034 is responsible for this space. Removing @code{Separating_line_group_engraver}
2035 reduces this space to zero.
2037 @lilypond[quote,verbatim,ragged-right]
2043 \remove Separating_line_group_engraver
2051 Nonmusical elements like time signatures, key signatures, clefs and
2052 accidentals are problematic in proportional notation. None of these
2053 elements has rhythmic duration. But all of these elements consume
2054 horizontal space. Different proportional scores approach these
2055 problems differently.
2057 It may be possible to avoid spacing problems with key signatures
2058 simply by not having any. This is a valid option since most
2059 proportional scores are contemporary music. The same may be true
2060 of time signatures, especially for those scores
2061 that include a measured timeline or other graphic. But these scores
2062 are exceptional and most proportional scores include at least some
2063 time signatures. Clefs and accidentals are even more essential.
2065 So what strategies exist for spacing nonmusical elements in a
2066 proportional context? One good option is the @code{strict-note-spacing}
2067 property of @code{SpacingSpanner}. Compare the two scores below:
2069 @lilypond[quote,verbatim,ragged-right]
2071 \set Score.proportionalNotationDuration = #(ly:make-moment 1 16)
2081 \set Score.proportionalNotationDuration = #(ly:make-moment 1 16)
2082 \override Score.SpacingSpanner #'strict-note-spacing = ##t
2092 Both scores are proportional, but the spacing in the first score
2093 is too loose because of the clef change. The spacing of the second
2094 score remains strict, however, because strict-note-spacing is
2095 turned on. Turning on strict-note-spacing causes the width of
2096 time signatures, key signatures, clefs and accidentals to play no
2097 part in the spacing algorithm.
2099 In addition to the settings given here, there are other settings
2100 that frequently appear in proportional scores. These include:
2103 @item @code{\override SpacingSpanner #'strict-grace-spacing = ##t}
2104 @item @code{tupletFullLength = ##t}
2105 @item @code{\override Beam #'breakable = ##t}
2106 @item @code{\override Glissando #'breakable = ##t}
2107 @item @code{\override TextSpanner #'breakable = ##t}
2108 @item @code{\remove Forbid_line_break_engraver in the Voice context}
2111 These settings space grace notes strictly, extend tuplet brackets to
2112 mark both rhythmic start- and stop-points, and allow spanning elements
2113 to break across systems and pages. See the respective parts of the manual
2114 for these related settings.
2117 @node Fitting music onto fewer pages
2118 @section Fitting music onto fewer pages
2120 Sometimes you can end up with one or two staves on a second
2121 (or third, or fourth...) page. This is annoying, especially
2122 if you look at previous pages and it looks like there is plenty
2123 of room left on those.
2125 When investigating layout issues, @code{annotate-spacing} is
2126 an invaluable tool. This command prints the values of various
2127 layout spacing commands; for more details see the following
2128 section, @ref{Displaying spacing}.
2131 * Displaying spacing::
2132 * Changing spacing::
2135 @node Displaying spacing
2136 @subsection Displaying spacing
2138 @funindex annotate-spacing
2139 @cindex Spacing, display of properties
2141 To graphically display the dimensions of vertical properties that may
2142 be altered for page formatting, set @code{annotate-spacing} in the
2143 @code{\paper} block, like this:
2145 @c need to have \book{} otherwise we get the separate systems. -hwn
2147 #(set-default-paper-size "a6" 'landscape)
2150 \paper { annotate-spacing = ##t }
2155 @c TODO: really bad vagueness due to bug in annotate-spacing. -gp
2157 Some unit dimensions are measured in staff spaces, while others
2158 are measured in millimeters.
2160 (@var{a},@var{b}) are intervals, where @var{a} is the lower edge and
2161 @var{b} the upper edge of the interval.
2163 @node Changing spacing
2164 @subsection Changing spacing
2166 From the output of @code{annotate-spacing}, we can
2167 see which margins we may wish to alter.
2169 @c TODO add info about or pointers to margin settings
2171 Other than margins, there are a few other options to save space:
2175 You may tell LilyPond to place systems as close together as
2176 possible (to fit as many systems as possible onto a page), but
2177 then to space those systems out so that there is no blank
2178 space at the bottom of the page.
2182 between-system-padding = #0.1
2183 between-system-space = #0.1
2184 ragged-last-bottom = ##f
2190 You may force the number of systems (i.e., if LilyPond wants
2191 to typeset some music with 11 systems, you could force it to
2201 Avoid (or reduce) objects which increase the vertical size of
2202 a system. For example, volta repeats (or alternate repeats)
2203 require extra space. If these repeats are spread over two
2204 systems, they will take up more space than one system with
2205 the volta repeats and another system without.
2207 Another example is moving dynamics which @q{stick out} of
2208 a system, as in the second bar here:
2210 @lilypond[verbatim,quote,fragment,ragged-right,relative=1]
2212 \override DynamicText #'extra-offset = #'( -2.2 . 2.0)
2217 Alter the horizontal spacing via @code{SpacingSpanner}. See
2218 @ref{Changing horizontal spacing}, for more details. Here's
2219 an example first showing the default behavior:
2221 @lilypond[verbatim,quote,ragged-right]
2234 and now with @code{common-shortest-duration} increased from the
2235 value of @code{1/4} (a quarter note is the most common in this
2236 example) to @code{1/2}:
2238 @lilypond[verbatim,quote,ragged-right]
2250 \override SpacingSpanner
2251 #'common-shortest-duration = #(ly:make-moment 1 2)
2258 Note that this override cannot be modified dynamically, so it must
2259 always be placed in a @code{\context@{..@}} block so that it applies