1 @c -*- coding: utf-8; mode: texinfo; -*-
2 @c This file is part of lilypond.tely
4 Translation of GIT committish: FILL-IN-HEAD-COMMITTISH
6 When revising a translation, copy the HEAD committish of the
7 version that you are working on. See TRANSLATION for details.
10 @c A menu is needed before every deeper *section nesting of @node's; run
11 @c M-x texinfo-all-menus-update
12 @c to automatically fill in these menus before saving changes
15 @chapter Spacing issues
17 The global paper layout is determined by three factors: the page layout, the
18 line breaks, and the spacing. These all influence each other. The
19 choice of spacing determines how densely each system of music is set.
20 This influences where line breaks are chosen, and thus ultimately, how
21 many pages a piece of music takes.
23 Globally speaking, this procedure happens in four steps: first,
24 flexible distances (@q{springs}) are chosen, based on durations. All
25 possible line breaking combinations are tried, and a @q{badness} score
26 is calculated for each. Then the height of each possible system is
27 estimated. Finally, a page breaking and line breaking combination is chosen
28 so that neither the horizontal nor the vertical spacing is too cramped
36 * Horizontal spacing::
37 * Displaying spacing::
38 * Vertical collision avoidance::
43 @section Paper and pages
45 This section deals with the boundaries that define the area
46 that music can be printed inside.
55 @subsection Paper size
61 To change the paper size, there are two commands,
63 #(set-default-paper-size "a4")
65 #(set-paper-size "a4")
69 The first command sets the size of all pages. The second command sets the
71 of the pages that the @code{\paper} block applies to -- if the @code{\paper}
72 block is at the top of the file, then it will apply to all pages. If the
73 @code{\paper} block is inside a @code{\book}, then the paper size will only
76 Support for the following paper sizes are included by default,
77 @code{a6}, @code{a5}, @code{a4}, @code{a3}, @code{legal}, @code{letter},
78 @code{11x17} (also known as tabloid).
80 Extra sizes may be added by editing the definition for
81 @code{paper-alist} in the initialization file @file{scm/paper.scm}.
86 If the symbol @code{landscape} is supplied as an argument to
87 @code{set-default-paper-size}, the pages will be rotated by 90 degrees,
88 and wider line widths will be set correspondingly.
91 #(set-default-paper-size "a6" 'landscape)
94 Setting the paper size will adjust a number of @code{\paper} variables
95 (such as margins). To use a particular paper size with altered
96 @code{\paper} variables, set the paper size before setting the variables.
100 @subsection Page formatting
102 @cindex page formatting
107 LilyPond will do page layout, set margins, and add headers and
108 footers to each page.
110 The default layout responds to the following settings in the
117 @funindex first-page-number
118 @item first-page-number
119 The value of the page number of the first page. Default is@tie{}1.
121 @funindex print-first-page-number
122 @item print-first-page-number
123 If set to true, will print the page number in the first page. Default is
126 @funindex print-page-number
127 @item print-page-number
128 If set to false, page numbers will not be printed. Default is true.
130 @funindex paper-width
132 The width of the page. The default is taken from the current paper size,
133 see @ref{Paper size}.
135 @funindex paper-height
137 The height of the page. The default is taken from the current paper size,
138 see @ref{Paper size}.
142 Margin between header and top of the page. Default is@tie{}5mm.
144 @funindex bottom-margin
146 Margin between footer and bottom of the page. Default is@tie{}6mm.
148 @funindex left-margin
150 Margin between the left side of the page and the beginning of the
151 music. Unset by default, which means that the margins is determined
152 based on the @code{paper-width} and @code{line-width} to center the
157 The length of the systems. Default is @code{paper-width} minus @tie{}20mm.
159 @funindex head-separation
160 @item head-separation
161 Distance between the top-most music system and the page header. Default
164 @funindex foot-separation
165 @item foot-separation
166 Distance between the bottom-most music system and the page
167 footer. Default is@tie{}4mm.
169 @funindex page-top-space
171 Distance from the top of the printable area to the center of the first
172 staff. This only works for staves which are vertically small. Big staves
173 are set with the top of their bounding box aligned to the top of the
174 printable area. Default is@tie{}12mm.
176 @funindex ragged-bottom
178 If set to true, systems will not be spread vertically across the page. This
179 does not affect the last page. Default is false.
181 This should be set to true for pieces that have only two or three
182 systems per page, for example orchestral scores.
184 @funindex ragged-last-bottom
185 @item ragged-last-bottom
186 If set to false, systems will be spread vertically to fill the last
187 page. Default is true.
189 Pieces that amply fill two pages or more should have this set to
192 @funindex system-count
194 This variable, if set, specifies into how many lines a score should be
195 broken. Unset by default.
197 @funindex between-system-space
198 @item between-system-space
199 This dimensions determines the distance between systems. It is the
200 ideal distance between the center of the bottom staff of one system
201 and the center of the top staff of the next system. Default is@tie{}20mm.
203 Increasing this will provide a more even appearance of the page at the
204 cost of using more vertical space.
206 @funindex between-system-padding
207 @item between-system-padding
208 This dimension is the minimum amount of white space that will always
209 be present between the bottom-most symbol of one system, and the
210 top-most of the next system. Default is@tie{}4mm.
212 Increasing this will put systems whose bounding boxes almost touch
216 @funindex horizontal-shift
217 @item horizontal-shift
218 All systems (including titles and system separators) are shifted by
219 this amount to the right. Page markup, such as headers and footers are
220 not affected by this. The purpose of this variable is to make space
221 for instrument names at the left. Default is@tie{}0.
223 @funindex after-title-space
224 @item after-title-space
225 Amount of space between the title and the first system. Default is@tie{}5mm.
227 @funindex before-title-space
228 @item before-title-space
229 Amount of space between the last system of the previous piece and the
230 title of the next. Default is@tie{}10mm.
232 @funindex between-title-space
233 @item between-title-space
234 Amount of space between consecutive titles (e.g., the title of the
235 book and the title of a piece). Default is@tie{}2mm.
237 @funindex printallheaders
238 @item printallheaders
239 Setting this to #t will print all headers for each \score in the
240 output. Normally only the piece and opus \headers are printed.
242 @funindex systemSeparatorMarkup
243 @item systemSeparatorMarkup
244 This contains a markup object, which will be inserted between
245 systems. This is often used for orchestral scores. Unset by default.
247 The markup command @code{\slashSeparator} is provided as a sensible
250 @lilypond[ragged-right]
251 #(set-default-paper-size "a6" 'landscape)
254 \relative { c1 \break c1 }
257 systemSeparatorMarkup = \slashSeparator
262 @funindex blank-page-force
263 @item blank-page-force
264 The penalty for having a blank page in the middle of a
265 score. This is not used by @code{ly:optimal-breaking} since it will
266 never consider blank pages in the middle of a score. Default value
269 @funindex blank-last-page-force
270 @item blank-last-page-force
271 The penalty for ending the score on an odd-numbered page.
274 @funindex page-spacing-weight
275 @item page-spacing-weight
276 The relative importance of page (vertical) spacing and line (horizontal)
277 spacing. High values will make page spacing more important. Default
280 @funindex auto-first-page-number
281 @item auto-first-page-number
282 The page breaking algorithm is affected by the first page number being
283 odd or even. If this variable is set to #t, the page breaking algorithm
284 will decide whether to start with an odd or even number. This will
285 result in the first page number remaining as is or being increased by one.
297 ragged-last-bottom = ##t
301 You can also define these values in Scheme. In that case @code{mm},
302 @code{in}, @code{pt}, and @code{cm} are variables defined in
303 @file{paper-defaults.ly} with values in millimeters. That is why the
304 value must be multiplied in the example
308 #(define bottom-margin (* 2 cm))
312 The header and footer are created by the functions @code{make-footer}
313 and @code{make-header}, defined in @code{\paper}. The default
314 implementations are in @file{ly/@/paper@/-defaults@/.ly} and
315 @file{ly/@/titling@/-init@/.ly}.
317 The page layout itself is done by two functions in the
318 @code{\paper} block, @code{page-music-height} and
319 @code{page-make-stencil}. The former tells the line-breaking algorithm
320 how much space can be spent on a page, the latter creates the actual
321 page given the system to put on it.
326 The option right-margin is defined but doesn't set the right margin
327 yet. The value for the right margin has to be defined adjusting the
328 values of @code{left-margin} and @code{line-width}.
330 The default page header puts the page number and the @code{instrument}
331 field from the @code{\header} block on a line.
333 The titles (from the @code{\header@{@}} section) are treated as a
334 system, so @code{ragged-bottom} and @code{ragged-last-bottom} will
335 add space between the titles and the first system of the score.
339 @section Music layout
342 * Setting the staff size::
347 @node Setting the staff size
348 @subsection Setting the staff size
350 @cindex font size, setting
351 @cindex staff size, setting
352 @funindex layout file
354 To set the staff size globally for all scores in a file (or
355 in a @code{book} block, to be precise), use @code{set-global-staff-size}.
358 #(set-global-staff-size 14)
362 This sets the global default size to 14pt staff height and scales all
365 To set the staff size individually for each score, use
370 #(layout-set-staff-size 15)
375 The Feta font provides musical symbols at eight different
376 sizes. Each font is tuned for a different staff size: at a smaller size
377 the font becomes heavier, to match the relatively heavier staff lines.
378 The recommended font sizes are listed in the following table:
381 @multitable @columnfractions .15 .2 .22 .2
384 @tab @b{staff height (pt)}
385 @tab @b{staff height (mm)}
427 @c modern rental material?
432 These fonts are available in any sizes. The context property
433 @code{fontSize} and the layout property @code{staff-space} (in
434 @internalsref{StaffSymbol}) can be used to tune the size for individual
435 staves. The sizes of individual staves are relative to the global size.
443 This manual: @ref{Selecting notation font size}.
447 @subsection Score layout
451 While @code{\paper} contains settings that relate to the page formatting
452 of the whole document, @code{\layout} contains settings for score-specific
459 \override VerticalAxisGroup #'minimum-Y-extent = #'(-6 . 6)
462 \override TextScript #'padding = #1.0
463 \override Glissando #'thickness = #3
471 This manual: @ref{Changing context default settings}
480 * Optimal page breaking::
481 * Optimal page turning::
486 @subsection Line breaking
489 @cindex breaking lines
491 Line breaks are normally computed automatically. They are chosen so
492 that lines look neither cramped nor loose, and that consecutive lines
493 have similar density.
495 Occasionally you might want to override the automatic breaks; you can
496 do this by specifying @code{\break}. This will force a line break at
497 this point. Line breaks can only occur at places where there are bar
498 lines. If you want to have a line break where there is no bar line,
499 you can force an invisible bar line by entering @code{\bar
500 ""}. Similarly, @code{\noBreak} forbids a line break at a
504 @cindex regular line breaks
505 @cindex four bar music.
507 For line breaks at regular intervals use @code{\break} separated by
508 skips and repeated with @code{\repeat}:
510 << \repeat unfold 7 @{
511 s1 \noBreak s1 \noBreak
512 s1 \noBreak s1 \break @}
513 @emph{the real music}
518 This makes the following 28 measures (assuming 4/4 time) be broken every
519 4 measures, and only there.
523 @code{\break}, and @code{\noBreak}.
529 Internals: @internalsref{LineBreakEvent}.
531 A linebreaking configuration can now be saved as a @code{.ly} file
532 automatically. This allows vertical alignments to be stretched to
533 fit pages in a second formatting run. This is fairly new and
534 complicated. More details are available in
540 Line breaks can only occur if there is a @q{proper} bar line. A note
541 which is hanging over a bar line is not proper, such as
543 @lilypond[quote,ragged-right,relative=2,fragment,verbatim]
544 c4 c2 c2 \break % this does nothing
545 c2 c4 | % a break here would work
546 c4 c2 c4 ~ \break % as does this break
550 To allow line breaks on such bar lines, the
551 @code{Forbid_line_break_engraver} can be removed from @code{Voice}
555 @lilypond[quote,ragged-right,relative=2,fragment,verbatim]
557 \remove "Forbid_line_break_engraver"
559 c4 c2 c2 \break % now the break is allowed
567 @subsection Page breaking
569 The default page breaking may be overriden by inserting
570 @code{\pageBreak} or @code{\noPageBreak} commands. These commands are
571 analogous to @code{\break} and @code{\noBreak}. They should be
572 inserted at a bar line. These commands force and forbid a page-break
573 from happening. Of course, the @code{\pageBreak} command also forces
576 Page breaks are computed by the @code{page-breaking} function.
577 LilyPond provides two algorithms for computing page
578 breaks, @code{ly:optimal-breaking} and @code{ly:page-turn-breaking}. The
579 default is @code{ly:optimal-breaking}, but the value can be changed in
580 the @code{\paper} block:
584 #(define page-breaking ly:page-turn-breaking)
588 The old page breaking algorithm is called
589 @code{optimal-page-breaks}. If you are having trouble with the new page
590 breakers, you can enable the old one as a workaround.
596 @funindex \noPageBreak
600 @node Optimal page breaking
601 @subsection Optimal page breaking
603 @funindex ly:optimal-breaking
605 The @code{ly:optimal-breaking} function is LilyPond's default method of
606 determining page breaks. It attempts to find a page breaking that minimizes
607 cramping and stretching, both horizontally and vertically. Unlike
608 @code{ly:page-turn-breaking}, it has no concept of page turns.
611 @node Optimal page turning
612 @subsection Optimal page turning
614 @funindex ly:page-turn-breaking
616 Often it is necessary to find a page breaking configuration so that there is
617 a rest at the end of every second page. This way, the musician can turn the
618 page without having to miss notes. The @code{ly:page-turn-breaking} function
619 attempts to find a page breaking minimizing cramping and stretching, but with
620 the additional restriction that it is only allowed to introduce page turns
623 There are two steps to using this page breaking function. First, you must
624 enable it in the @code{\paper} block. Then, you must tell the function
625 where you would like to allow page breaks.
627 There are two ways to achieve the second step. First, you can specify each
628 potential page turn manually, by inserting @code{\allowPageTurn} into your
629 input file at the appropriate places.
631 If this is too tedious, you can add a @code{Page_turn_engraver} to a Staff or
632 Voice context. The @code{Page_turn_engraver} will scan the context for
633 sections without notes (note that it does not scan for rests; it scans for
634 the absence of notes. This is so that single-staff polyphony with rests in one
635 of the parts does not throw off the @code{Page_turn_engraver}). When it finds
636 a sufficiently long section without notes, the @code{Page_turn_engraver} will
637 insert an @code{\allowPageTurn} at the final barline in that section, unless
638 there is a @q{special} barline (such as a double bar), in which case the
639 @code{\allowPageTurn} will be inserted at the final @q{special} barline in
642 @funindex minimumPageTurnLength
643 The @code{Page_turn_engraver} reads the context property
644 @code{minimumPageTurnLength} to determine how long a note-free section must
645 be before a page turn is considered. The default value for
646 @code{minimumPageTurnLength} is @code{#(ly:make-moment 1 1)}. If you want
647 to disable page turns, you can set it to something very large.
650 \new Staff \with @{ \consists "Page_turn_engraver" @}
653 R1 | % a page turn will be allowed here
655 \set Staff.minimumPageTurnLength = #(ly:make-moment 5 2)
656 R1 | % a page turn will not be allowed here
658 R1*2 | % a page turn will be allowed here
663 @funindex minimumRepeatLengthForPageTurn
664 The @code{Page_turn_engraver} detects volta repeats. It will only allow a page
665 turn during the repeat if there is enough time at the beginning and end of the
666 repeat to turn the page back. The @code{Page_turn_engraver} can also disable
667 page turns if the repeat is very short. If you set the context property
668 @code{minimumRepeatLengthForPageTurn} then the @code{Page_turn_engraver} will
669 only allow turns in repeats whose duration is longer than this value.
673 There should only be one @code{Page_turn_engraver} in a score. If there is more
674 than one, they will interfere with each other.
677 @node Explicit breaks
678 @subsection Explicit breaks
680 Lily sometimes rejects explicit @code{\break} and @code{\pageBreak}
681 commands. There are two commands to override this behavior:
684 \override NonMusicalPaperColumn #'line-break-permission = ##f
685 \override NonMusicalPaperColumn #'page-break-permission = ##f
688 When @code{line-break-permission} is overriden to false, Lily will insert
689 line breaks at explicit @code{\break} commands and nowhere else. When
690 @code{page-break-permission} is overriden to false, Lily will insert
691 page breaks at explicit @code{\pageBreak} commands and nowhere else.
693 @lilypond[quote,verbatim]
702 \override NonMusicalPaperColumn #'line-break-permission = ##f
703 \override NonMusicalPaperColumn #'page-break-permission = ##f
706 \repeat unfold 2 { c'8 c'8 c'8 c'8 } \break
707 \repeat unfold 4 { c'8 c'8 c'8 c'8 } \break
708 \repeat unfold 6 { c'8 c'8 c'8 c'8 } \break
709 \repeat unfold 8 { c'8 c'8 c'8 c'8 } \pageBreak
710 \repeat unfold 8 { c'8 c'8 c'8 c'8 } \break
711 \repeat unfold 6 { c'8 c'8 c'8 c'8 } \break
712 \repeat unfold 4 { c'8 c'8 c'8 c'8 } \break
713 \repeat unfold 2 { c'8 c'8 c'8 c'8 }
720 @node Vertical spacing
721 @section Vertical spacing
723 @cindex vertical spacing
724 @cindex spacing, vertical
726 Vertical spacing is controlled by three things: the amount of
727 space available (i.e., paper size and margins), the amount of
728 space between systems, and the amount of space between
729 staves inside a system.
732 * Vertical spacing inside a system::
733 * Vertical spacing between systems::
734 * Controlling spacing of individual systems::
735 * Two-pass vertical spacing::
739 @node Vertical spacing inside a system
740 @subsection Vertical spacing inside a system
742 @cindex distance between staves
743 @cindex staff distance
744 @cindex space between staves
745 @cindex space inside systems
747 The height of each system is determined automatically. To prevent
748 staves from bumping into each other, some minimum distances are set.
749 By changing these, you can put staves closer together. This
750 reduces the amount of space each system requires, and may result
751 in having more systems per page.
753 Normally staves are stacked vertically. To make staves maintain a
754 distance, their vertical size is padded. This is done with the
755 property @code{minimum-Y-extent}. When applied to a
756 @internalsref{VerticalAxisGroup}, it controls the size of a horizontal
757 line, such as a staff or a line of lyrics. @code{minimum-Y-extent}
758 takes a pair of numbers, so
759 if you want to make it smaller than its default @code{#'(-4 . 4)}
763 \override Staff.VerticalAxisGroup #'minimum-Y-extent = #'(-3 . 3)
767 This sets the vertical size of the current staff to 3 staff spaces on
768 either side of the center staff line. The value @code{(-3 . 3)} is
769 interpreted as an interval, where the center line is the 0, so the
770 first number is generally negative. The numbers need not match;
771 for example, the staff can be made larger at the bottom by setting
772 it to @code{(-6 . 4)}.
777 Internals: Vertical alignment of staves is handled by the
778 @internalsref{VerticalAlignment} object. The context parameters
779 specifying the vertical extent are described in connection with
780 the @internalsref{Axis_group_engraver}.
782 Example files: @lsr{spacing,page-spacing.ly},
783 @lsr{spacing,alignment-vertical-spacing.ly}.
786 @node Vertical spacing between systems
787 @subsection Vertical spacing between systems
789 Space between systems are controlled by four @code{\paper} variables,
793 between-system-space = 1.5\cm
794 between-system-padding = #1
796 ragged-last-bottom=##f
801 @node Controlling spacing of individual systems
802 @subsection Controlling spacing of individual systems
804 It is also possible to change the distance between for each system
805 individually. This is done by including the command
809 #"Score.NonMusicalPaperColumn"
810 #'line-break-system-details
811 #'((fixed-alignment-extra-space . 15))
815 at the line break before the system to be changed. The distance
816 @code{15} is distributed over all staves that have a fixed distance
817 alignment. For example,
819 @lilypond[ragged-right, fragment, relative=2, staffsize=13]
825 #"Score.NonMusicalPaperColumn"
826 #'line-break-system-details
827 #'((fixed-alignment-extra-space . 15))
835 The distance for @code{fixed-alignment-extra-space} may also be
839 @node Two-pass vertical spacing
840 @subsection Two-pass vertical spacing
842 In order to automatically stretch systems so that they should fill the
843 space left on a page, a two-pass technique can be used:
846 @item In the first pass, the amount of vertical space used to increase
847 the height of each system is computed and dumped to a file.
848 @item In the second pass, spacing inside the systems are
849 stretched according to the data in the page layout file.
852 The @code{ragged-bottom} property adds space between systems, while
853 the two-pass technique adds space between staffs inside a system.
855 To allow this behaviour, a @code{tweak-key} variable has to be set in
856 each score @code{\layout} block, and the tweaks included in each score
857 music, using the @code{\scoreTweak} music function.
861 %% include the generated page layout file:
862 \includePageLayoutFile
867 %% Include this score tweaks:
869 { \clef french c''1 \break c''1 }
871 \new Staff { \clef soprano g'1 g'1 }
872 \new Staff { \clef mezzosoprano e'1 e'1 }
873 \new Staff { \clef alto g1 g1 }
874 \new Staff { \clef bass c1 c1 }
877 piece = "Score with tweaks"
879 %% Define how to name the tweaks for this score:
880 \layout { #(define tweak-key "scoreA") }
885 For the first pass, the @code{dump-tweaks} option should be set to
886 generate the page layout file.
889 lilypond -dbackend=null -d dump-tweaks <file>.ly
893 @node Horizontal spacing
894 @section Horizontal Spacing
896 @cindex horizontal spacing
897 @cindex spacing, horizontal
900 * Horizontal spacing overview::
902 * Changing horizontal spacing::
907 @node Horizontal spacing overview
908 @subsection Horizontal spacing overview
910 The spacing engine translates differences in durations into stretchable
911 distances (@q{springs}) of differring lengths. Longer durations get
912 more space, shorter durations get less. The shortest durations get a
913 fixed amount of space (which is controlled by
914 @code{shortest-duration-space} in the @internalsref{SpacingSpanner}
915 object). The longer the duration, the more space it gets: doubling a
916 duration adds a fixed amount (this amount is controlled by
917 @code{spacing-increment}) of space to the note.
919 For example, the following piece contains lots of half, quarter, and
920 8th notes; the eighth note is followed by 1 note head width (NHW).
921 The quarter note is followed by 2 NHW, the half by 3 NHW, etc.
923 @lilypond[quote,fragment,verbatim,relative=1]
924 c2 c4. c8 c4. c8 c4. c8 c8
928 Normally, @code{spacing-increment} is set to 1.2 staff space, which is
929 approximately the width of a note head, and
930 @code{shortest-duration-space} is set to 2.0, meaning that the
931 shortest note gets 2.4 staff space (2.0 times the
932 @code{spacing-increment}) of horizontal space. This space is counted
933 from the left edge of the symbol, so the shortest notes are generally
934 followed by one NHW of space.
936 If one would follow the above procedure exactly, then adding a single
937 32nd note to a score that uses 8th and 16th notes, would widen up the
938 entire score a lot. The shortest note is no longer a 16th, but a 32nd,
939 thus adding 1 NHW to every note. To prevent this, the shortest
940 duration for spacing is not the shortest note in the score, but rather
941 the one which occurs most frequently.
944 The most common shortest duration is determined as follows: in every
945 measure, the shortest duration is determined. The most common shortest
946 duration is taken as the basis for the spacing, with the stipulation
947 that this shortest duration should always be equal to or shorter than
948 an 8th note. The shortest duration is printed when you run
949 @code{lilypond} with the @code{--verbose} option.
951 These durations may also be customized. If you set the
952 @code{common-shortest-duration} in @internalsref{SpacingSpanner}, then
953 this sets the base duration for spacing. The maximum duration for this
954 base (normally an 8th), is set through @code{base-shortest-duration}.
956 @funindex common-shortest-duration
957 @funindex base-shortest-duration
958 @funindex stem-spacing-correction
961 Notes that are even shorter than the common shortest note are
962 followed by a space that is proportional to their duration relative to
963 the common shortest note. So if we were to add only a few 16th notes
964 to the example above, they would be followed by half a NHW:
966 @lilypond[quote,fragment,verbatim,relative=2]
967 c2 c4. c8 c4. c16[ c] c4. c8 c8 c8 c4 c4 c4
971 In the introduction (see @ref{Engraving}), it was explained that stem
972 directions influence spacing. This is controlled with the
973 @code{stem-spacing-correction} property in the
974 @internalsref{NoteSpacing}, object. These are generated for every
975 @internalsref{Voice} context. The @code{StaffSpacing} object
976 (generated in @internalsref{Staff} context) contains the same property
977 for controlling the stem/bar line spacing. The following example shows
978 these corrections, once with default settings, and once with
979 exaggerated corrections:
981 @lilypond[quote,ragged-right]
985 \override Staff.NoteSpacing #'stem-spacing-correction = #1.5
986 \override Staff.StaffSpacing #'stem-spacing-correction = #1.5
992 Proportional notation is supported; see @ref{Proportional notation}.
997 Internals: @internalsref{SpacingSpanner}, @internalsref{NoteSpacing},
998 @internalsref{StaffSpacing}, @internalsref{SeparationItem}, and
999 @internalsref{SeparatingGroupSpanner}.
1004 There is no convenient mechanism to manually override spacing. The
1005 following work-around may be used to insert extra space into a score.
1007 \once \override Score.SeparationItem #'padding = #1
1010 No work-around exists for decreasing the amount of space.
1013 @node New spacing area
1014 @subsection New spacing area
1016 New sections with different spacing parameters can be started with
1017 @code{newSpacingSection}. This is useful when there are
1018 sections with a different notions of long and short notes.
1020 In the following example, the time signature change introduces a new
1021 section, and hence the 16ths notes are spaced wider.
1023 @lilypond[relative,fragment,verbatim,quote]
1026 c8 c c4 c16[ c c8] c4
1033 The @code{\newSpacingSection} command creates a new
1034 @internalsref{SpacingSpanner} object, and hence new @code{\override}s
1035 may be used in that location.
1038 @node Changing horizontal spacing
1039 @subsection Changing horizontal spacing
1041 Horizontal spacing may be altered with the
1042 @code{base-shortest-duration} property. Here
1043 we compare the same music; once without altering
1044 the property, and then altered. Larger values
1045 of @code{ly:make-moment} will produce smaller
1046 music. Note that @code{ly:make-moment} constructs
1047 a duration, so @code{1 4} is a longer duration
1050 @lilypond[relative,verbatim,line-width=12\cm]
1053 g4 e e2 | f4 d d2 | c4 d e f | g4 g g2 |
1054 g4 e e2 | f4 d d2 | c4 e g g | c,1 |
1055 d4 d d d | d4 e f2 | e4 e e e | e4 f g2 |
1056 g4 e e2 | f4 d d2 | c4 e g g | c,1 |
1061 @lilypond[relative,verbatim,line-width=12\cm]
1064 g4 e e2 | f4 d d2 | c4 d e f | g4 g g2 |
1065 g4 e e2 | f4 d d2 | c4 e g g | c,1 |
1066 d4 d d d | d4 e f2 | e4 e e e | e4 f g2 |
1067 g4 e e2 | f4 d d2 | c4 e g g | c,1 |
1072 \override SpacingSpanner
1073 #'base-shortest-duration = #(ly:make-moment 1 16)
1082 By default, spacing in tuplets depends on various non-duration
1083 factors (such as accidentals, clef changes, etc). To disregard
1084 such symbols and force uniform equal-duration spacing, use
1085 @code{Score.SpacingSpanner #'uniform-stretching}. This
1086 property can only be changed at the beginning of a score,
1088 @lilypond[quote,ragged-right,relative=2,fragment,verbatim]
1090 \override SpacingSpanner #'uniform-stretching = ##t
1108 When @code{strict-note-spacing} is set, notes are spaced without
1109 regard for clefs, bar lines, and grace notes,
1111 @lilypond[quote,ragged-right,relative=2,fragment,verbatim]
1112 \override Score.SpacingSpanner #'strict-note-spacing = ##t
1113 \new Staff { c8[ c \clef alto c \grace { c16[ c] } c8 c c] c32[ c32] }
1118 @subsection Line length
1121 @cindex breaking pages
1124 @funindex line-width
1125 @funindex ragged-right
1126 @funindex ragged-last
1128 @c Although line-width can be set in \layout, it should be set in paper
1129 @c block, to get page layout right.
1130 @c Setting indent in \paper block makes not much sense, but it works.
1132 @c Bit verbose and vague, use examples?
1133 The most basic settings influencing the spacing are @code{indent} and
1134 @code{line-width}. They are set in the @code{\layout} block. They
1135 control the indentation of the first line of music, and the lengths of
1138 If @code{ragged-right} is set to true in the @code{\layout} block, then
1139 systems ends at their natural horizontal length, instead of being spread
1140 horizontally to fill the whole line. This is useful for
1141 short fragments, and for checking how tight the natural spacing is.
1144 @cindex vertical spacing
1146 The option @code{ragged-last} is similar to @code{ragged-right}, but
1147 only affects the last line of the piece. No restrictions are put on
1148 that line. The result is similar to formatting text paragraphs. In a
1149 paragraph, the last line simply takes its natural horizontal length.
1150 @c Note that for text there are several options for the last line.
1151 @c While Knuth TeX uses natural length, lead typesetters use the same
1152 @c stretch as the previous line. eTeX uses \lastlinefit to
1153 @c interpolate between both these solutions.
1164 @node Displaying spacing
1165 @section Displaying spacing
1167 @funindex annotate-spacing
1168 @cindex Spacing, display of properties
1170 To graphically display the dimensions of vertical properties that may
1171 be altered for page formatting, set @code{annotate-spacing} in the
1172 @code{\paper} block, like this
1176 #(set-default-paper-size "a6" 'landscape)
1180 \paper { annotate-spacing = ##t }
1184 @c need to have \book{} otherwise we get the separate systems. -hwn
1187 @c FIXME: really bad vagueness due to bug in annotate-spacing. -gp
1188 Some unit dimensions are measured in staff spaces, while others
1189 are measured in millimeters.
1191 (@var{a},@var{b}) are intervals, where @var{a} is the lower edge and
1192 @var{b} the upper edge of the interval.
1195 @node Vertical collision avoidance
1196 @section Vertical collision avoidance
1198 @funindex outside-staff-priority
1199 @funindex outside-staff-padding
1200 @funindex outside-staff-horizontal-padding
1202 Intuitively, there are some objects in musical notation that belong
1203 to the staff and there are other objects that should be placed outside
1204 the staff. Objects belonging outside the staff include things such as
1205 rehearsal marks, text and dynamic markings (from now on, these will
1206 be called outside-staff objects). LilyPond's rule for the
1207 vertical placement of outside-staff objects is to place them as close
1208 to the staff as possible but not so close that they collide with
1211 LilyPond uses the @code{outside-staff-priority} property to determine
1212 whether a grob is an outside-staff object: if @code{outside-staff-priority}
1213 is a number, the grob is an outside-staff object. In addition,
1214 @code{outside-staff-priority} tells LilyPond in which order the objects
1217 First, LilyPond places all the objects that do not belong outside
1218 the staff. Then it sorts the outside-staff objects according to their
1219 @code{outside-staff-priority} (in increasing order). One by one, LilyPond
1220 takes the outside-staff objects and places them so that they do
1221 not collide with any objects that have already been placed. That
1222 is, if two outside-staff grobs are competing for the same space, the one
1223 with the lower @code{outside-staff-priority} will be placed closer to
1226 @lilypond[quote,ragged-right,relative=2,fragment,verbatim]
1229 \once \override TextScript #'outside-staff-priority = #1
1230 c4_"Text"\pp % this time the text will be closer to the staff
1232 % by setting outside-staff-priority to a non-number, we
1233 % disable the automatic collision avoidance
1234 \once \override TextScript #'outside-staff-priority = ##f
1235 \once \override DynamicLineSpanner #'outside-staff-priority = ##f
1236 c4_"Text"\pp % now they will collide
1239 The vertical padding between an outside-staff object and the
1240 previously-positioned grobs can be controlled with
1241 @code{outside-staff-padding}.
1243 @lilypond[quote,ragged-right,relative=2,fragment,verbatim]
1244 \once \override TextScript #'outside-staff-padding = #0
1245 a'^"This text is placed very close to the note"
1246 \once \override TextScript #'outside-staff-padding = #3
1247 c^"This text is padded away from the previous text"
1248 c^"This text is placed close to the previous text"
1251 By default, outside-staff objects are placed without regard to
1252 their horizontal distance from the previously-posititioned grobs. This
1253 can lead to situations in which objects are placed very close to each
1254 other horizontally. Setting @code{outside-staff-horizontal-padding}
1255 causes an object to be offset vertically so that such a situation
1258 @lilypond[quote,ragged-right,relative=2,fragment,verbatim]
1259 % the markup is too close to the following note
1262 % setting outside-staff-horizontal-padding fixes this
1264 \once \override TextScript #'outside-staff-horizontal-padding = #1