Revert "update fret diagrams regression test"
[lilypond/csorensen.git] / Documentation / user / spacing.itely
blob7aa0dd62645c3822d48e8f967d812f5b06ded703
1 @c -*- coding: utf-8; mode: texinfo; -*-
2 @c This file is part of lilypond.tely
3 @ignore
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.
8 @end ignore
10 @c \version "2.11.38"
12 @ignore
13 GDP TODO list
15 Negative numbers are allowed:
16 > Are you sure? The following works well
17 > \paper{
18 >   first-page-number = -2
19 > }
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
27 states:
29 "@code{layout-set-staff-size} does not change the distance between
30 the
31 staff lines."
33 Could we add a sentence:
34 "Use instead the pair               fontSize = #@var{N}
35             \override StaffSymbol #'staff-space = #(magstep
36 @var{N})
37 inside the Staff context to change the size of the font and the
38 distance between
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?
50 Clarify
51 http://code.google.com/p/lilypond/issues/detail?id=68
53 @end ignore
55 @node Spacing issues
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
70 or stretched.
72 @menu
73 * Paper and pages::             
74 * Music layout::                
75 * Displaying spacing::          
76 * Breaks::                      
77 * Vertical spacing::            
78 * Horizontal spacing::          
79 * Page layout MOVED FROM LM::   
80 @end menu
83 @node Paper and pages
84 @section Paper and pages
86 This section deals with the boundaries that define the area
87 that music can be printed inside.
89 @menu
90 * Paper size::                  
91 * Page formatting::             
92 @end menu
95 @node Paper size
96 @subsection Paper size
98 @cindex paper size
99 @cindex page size
100 @funindex papersize
102 To change the paper size, there are two commands,
103 @example
104 #(set-default-paper-size "a4")
105 \paper @{
106   #(set-paper-size "a4")
108 @end example
110 The first command sets the size of all pages.  The second command sets the
111 size
112 of the pages that the @code{\paper} block applies to -- if the @code{\paper}
113 block is at the top of the file, then it will apply to all pages.  If the
114 @code{\paper} block is inside a @code{\book}, then the paper size will only
115 apply to that book.
117 Support for the following paper sizes are included by default,
118 @code{a6}, @code{a5}, @code{a4}, @code{a3}, @code{legal}, @code{letter},
119 @code{11x17} (also known as tabloid).
121 Extra sizes may be added by editing the definition for
122 @code{paper-alist} in the initialization file @file{scm/paper.scm}.
124 @cindex orientation
125 @cindex landscape
127 If the symbol @code{landscape} is supplied as an argument to
128 @code{set-default-paper-size}, the pages will be rotated by 90 degrees,
129 and wider line widths will be set correspondingly.
131 @example
132 #(set-default-paper-size "a6" 'landscape)
133 @end example
135 Setting the paper size will adjust a number of @code{\paper} variables
136 (such as margins).  To use a particular paper size with altered
137 @code{\paper} variables, set the paper size before setting the variables.
140 @node Page formatting
141 @subsection Page formatting
143 @cindex page formatting
144 @cindex margins
145 @cindex header, page
146 @cindex footer, page
148 LilyPond will do page layout, set margins, and add headers and
149 footers to each page.
151 The default layout responds to the following settings in the
152 @code{\paper} block.
154 @funindex \paper
156 @quotation
157 @table @code
158 @funindex first-page-number
159 @item first-page-number
160 The value of the page number of the first page.  Default is@tie{}1.
162 @funindex print-first-page-number
163 @item print-first-page-number
164 If set to true, will print the page number in the first page.  Default is
165 false.
167 @funindex print-page-number
168 @item print-page-number
169 If set to false, page numbers will not be printed.  Default is true.
171 @funindex paper-width
172 @item paper-width
173 The width of the page.  The default is taken from the current paper size,
174 see @ref{Paper size}. 
176 @funindex paper-height
177 @item paper-height
178 The height of the page.  The default is taken from the current paper size,
179 see @ref{Paper size}. 
181 @funindex top-margin
182 @item top-margin
183 Margin between header and top of the page.  Default is@tie{}5mm.
185 @funindex bottom-margin
186 @item bottom-margin
187 Margin between footer and bottom of the page.  Default is@tie{}6mm.
189 @funindex left-margin
190 @item left-margin
191 Margin between the left side of the page and the beginning of the
192 music.  Unset by default, which means that the margins is determined
193 based on the @code{paper-width} and @code{line-width} to center the
194 score on the paper. 
196 @funindex line-width
197 @item line-width
198 The length of the systems.  Default is @code{paper-width} minus @tie{}20mm.
200 @funindex head-separation
201 @item head-separation
202 Distance between the top-most music system and the page header.  Default
203 is@tie{}4mm. 
205 @funindex foot-separation
206 @item foot-separation
207 Distance between the bottom-most music system and the page
208 footer.  Default is@tie{}4mm.
210 @funindex page-top-space
211 @item page-top-space
212 Distance from the top of the printable area to the center of the first
213 staff.  This only works for staves which are vertically small.  Big staves
214 are set with the top of their bounding box aligned to the top of the
215 printable area.  Default is@tie{}12mm.
217 @funindex ragged-bottom
218 @item ragged-bottom
219 If set to true, systems will not be spread vertically across the page.  This
220 does not affect the last page.  Default is false.
222 This should be set to true for pieces that have only two or three
223 systems per page, for example orchestral scores.
225 @funindex ragged-last-bottom
226 @item ragged-last-bottom
227 If set to false, systems will be spread vertically to fill the last
228 page.  Default is true.
230 Pieces that amply fill two pages or more should have this set to
231 true.
233 @funindex system-count
234 @item system-count
235 This variable, if set, specifies into how many lines a score should be
236 broken.  Unset by default.
238 @funindex between-system-space
239 @item between-system-space
240 This dimensions determines the distance between systems.  It is the
241 ideal distance between the center of the bottom staff of one system
242 and the center of the top staff of the next system.  Default is@tie{}20mm.
244 Increasing this will provide a more even appearance of the page at the
245 cost of using more vertical space.
247 @funindex between-system-padding
248 @item between-system-padding
249 This dimension is the minimum amount of white space that will always
250 be present between the bottom-most symbol of one system, and the
251 top-most of the next system.  Default is@tie{}4mm.
253 Increasing this will put systems whose bounding boxes almost touch
254 farther apart.
256 @funindex page-breaking-between-system-padding
257 @item page-breaking-between-system-padding
258 This variable tricks the page breaker into thinking that
259 @code{between-system-padding} is set to something different than it
260 really is.  For example, if this variable is set to something substantially
261 larger than @code{between-system-padding}, then the page-breaker will put
262 fewer systems on each page.
264 @funindex horizontal-shift
265 @item horizontal-shift
266 All systems (including titles and system separators) are shifted by
267 this amount to the right.  Page markup, such as headers and footers are
268 not affected by this.  The purpose of this variable is to make space
269 for instrument names at the left.  Default is@tie{}0.
271 @funindex after-title-space
272 @item after-title-space
273 Amount of space between the title and the first system.  Default is@tie{}5mm.
275 @funindex before-title-space
276 @item before-title-space
277 Amount of space between the last system of the previous piece and the
278 title of the next.  Default is@tie{}10mm.
280 @funindex between-title-space
281 @item between-title-space
282 Amount of space between consecutive titles (e.g., the title of the
283 book and the title of a piece).  Default is@tie{}2mm.
285 @funindex printallheaders
286 @item printallheaders
287 Setting this to #t will print all headers for each \score in the
288 output.  Normally only the piece and opus \headers are printed.
290 @funindex systemSeparatorMarkup
291 @item systemSeparatorMarkup
292 This contains a markup object, which will be inserted between
293 systems.  This is often used for orchestral scores.  Unset by default.
295 The markup command @code{\slashSeparator} is provided as a sensible
296 default,  for example
298 @lilypond[ragged-right]
299 #(set-default-paper-size "a6" 'landscape)
300 \book {
301   \score {
302     \relative { c1 \break c1 }
303   }
304   \paper {
305     systemSeparatorMarkup = \slashSeparator
306   }
308 @end lilypond
310 @funindex blank-page-force
311 @item blank-page-force
312 The penalty for having a blank page in the middle of a
313 score.  This is not used by @code{ly:optimal-breaking} since it will
314 never consider blank pages in the middle of a score.  Default value
315 is 10.
317 @funindex blank-last-page-force
318 @item blank-last-page-force
319 The penalty for ending the score on an odd-numbered page.
320 Default value is 0.
322 @funindex page-spacing-weight
323 @item page-spacing-weight
324 The relative importance of page (vertical) spacing and line (horizontal)
325 spacing.  High values will make page spacing more important.  Default
326 value is 10.
328 @funindex auto-first-page-number
329 @item auto-first-page-number
330 The page breaking algorithm is affected by the first page number being
331 odd or even.  If this variable is set to #t, the page breaking algorithm
332 will decide whether to start with an odd or even number.  This will 
333 result in the first page number remaining as is or being increased by one.
335 @end table
336 @end quotation
339 @snippets
341 The header and footer are created by the functions make-footer and
342 make-header, defined in \paper.  The default implementations are in
343 ly/paper-defaults.ly and ly/titling-init.ly.
345 The page layout itself is done by two functions in the \paper block,
346 page-music-height and page-make-stencil.  The former tells the
347 line-breaking algorithm how much space can be spent on a page, the
348 latter creates the actual page given the system to put on it.
350 You can define paper block values in Scheme.  In that case mm, in, pt,
351 and cm are variables defined in paper-defaults.ly with values in
352 millimeters.  That is why the value 2 cm must be multiplied in the
353 example
355 @example
356 \paper @{
357  #(define bottom-margin (* 2 cm))
359 @end example
362 Example:
364 @example
365 \paper@{
366   paper-width = 2\cm
367   top-margin = 3\cm
368   bottom-margin = 3\cm
369   ragged-last-bottom = ##t
371 @end example
373 This second example centers page numbers at the bottom of every page. 
375 @example
376 \paper @{
377   print-page-number = ##t
378   print-first-page-number = ##t
379   oddHeaderMarkup = \markup \fill-line @{ " " @}
380   evenHeaderMarkup = \markup \fill-line @{ " " @}
381   oddFooterMarkup = \markup @{ \fill-line @{
382      \bold \fontsize #3 \on-the-fly #print-page-number-check-first
383      \fromproperty #'page:page-number-string @} @}
384   evenFooterMarkup = \markup @{ \fill-line @{
385      \bold \fontsize #3 \on-the-fly #print-page-number-check-first
386      \fromproperty #'page:page-number-string @} @}
387 @} 
388 @end example
390 You can also define these values in Scheme.  In that case @code{mm},
391 @code{in}, @code{pt}, and @code{cm} are variables defined in
392 @file{paper-defaults.ly} with values in millimeters.  That is why the
393 value must be multiplied in the example
395 @example
396 \paper @{
397   #(define bottom-margin (* 2 cm))
399 @end example
401 The header and footer are created by the functions @code{make-footer}
402 and @code{make-header}, defined in @code{\paper}.  The default
403 implementations are in @file{ly/@/paper@/-defaults@/.ly} and
404 @file{ly/@/titling@/-init@/.ly}.
406 The page layout itself is done by two functions in the
407 @code{\paper} block, @code{page-music-height} and
408 @code{page-make-stencil}.  The former tells the line-breaking algorithm
409 how much space can be spent on a page, the latter creates the actual
410 page given the system to put on it.
413 @knownissues
415 The option right-margin is defined but doesn't set the right margin
416 yet.  The value for the right margin has to be defined adjusting the
417 values of @code{left-margin} and @code{line-width}.
419 The default page header puts the page number and the @code{instrument}
420 field from the @code{\header} block on a line.
422 The titles (from the @code{\header@{@}} section) are treated as a
423 system, so @code{ragged-bottom} and @code{ragged-last-bottom} will
424 add space between the titles and the first system of the score.
427 @node Music layout
428 @section Music layout
430 @menu
431 * Setting the staff size::      
432 * Score layout::                
433 @end menu
436 @node Setting the staff size
437 @subsection Setting the staff size
439 @cindex font size, setting
440 @cindex staff size, setting
441 @funindex layout file
443 To set the staff size globally for all scores in a file (or
444 in a @code{book} block, to be precise), use @code{set-global-staff-size}.
446 @example
447 #(set-global-staff-size 14)
448 @end example
450 @noindent
451 This sets the global default size to 14pt staff height and scales all
452 fonts accordingly.
454 To set the staff size individually for each score, use 
455 @example
456 \score@{
457   ...
458   \layout@{
459   #(layout-set-staff-size 15)
460   @}
462 @end example
464 The Feta font provides musical symbols at eight different
465 sizes.  Each font is tuned for a different staff size: at a smaller size
466 the font becomes heavier, to match the relatively heavier staff lines.
467 The recommended font sizes are listed in the following table:
469 @quotation
470 @multitable @columnfractions .15 .2 .22 .2
472 @item @b{font name}
473 @tab @b{staff height (pt)}
474 @tab @b{staff height (mm)}
475 @tab @b{use}
477 @item feta11
478 @tab 11.22
479 @tab 3.9
480 @tab pocket scores
482 @item feta13
483 @tab 12.60
484 @tab 4.4
485 @tab
487 @item feta14
488 @tab 14.14
489 @tab 5.0
490 @tab
492 @item feta16
493 @tab 15.87
494 @tab 5.6
495 @tab
497 @item feta18
498 @tab 17.82
499 @tab 6.3
500 @tab song books
502 @item feta20
503 @tab 20
504 @tab 7.0
505 @tab standard parts
507 @item feta23
508 @tab 22.45
509 @tab 7.9
510 @tab
512 @item feta26
513 @tab 25.2
514 @tab 8.9
515 @tab
516 @c modern rental material?
518 @end multitable
519 @end quotation
521 These fonts are available in any sizes.  The context property
522 @code{fontSize} and the layout property @code{staff-space} (in
523 @rinternals{StaffSymbol}) can be used to tune the size for individual
524 staves.  The sizes of individual staves are relative to the global size.
526 @example
528 @end example
530 @seealso
532 This manual: @ref{Selecting notation font size}.
535 @knownissues
537 @code{layout-set-staff-size} does not change the distance between the
538 staff lines.
541 @node Score layout
542 @subsection Score layout
544 @funindex \layout
546 While @code{\paper} contains settings that relate to the page formatting
547 of the whole document, @code{\layout} contains settings for score-specific
548 layout.
550 @example
551 \layout @{
552   indent = 2.0\cm
553   \context @{ \Staff
554     \override VerticalAxisGroup #'minimum-Y-extent = #'(-6 . 6)
555   @}
556   \context @{ \Voice
557     \override TextScript #'padding = #1.0
558     \override Glissando #'thickness = #3
559   @}
561 @end example
564 @seealso
566 This manual: @ref{Changing context default settings}.
569 @node Displaying spacing
570 @section Displaying spacing
572 @funindex annotate-spacing
573 @cindex Spacing, display of properties
575 To graphically display the dimensions of vertical properties that may
576 be altered for page formatting, set @code{annotate-spacing} in the
577 @code{\paper} block, like this
580 @c need to have \book{} otherwise we get  the separate systems. -hwn
581 @lilypond[verbatim]
582 #(set-default-paper-size "a6" 'landscape)
584 \book {
585   \score { { c4 } }
586   \paper { annotate-spacing = ##t }
588 @end lilypond
591 @c  TODO: really bad vagueness due to bug in annotate-spacing.  -gp
592 @noindent
593 Some unit dimensions are measured in staff spaces, while others
594 are measured in millimeters.
595 The pairs
596 (@var{a},@var{b}) are intervals, where @var{a} is the lower edge and
597 @var{b} the upper edge of the interval.
600 @node Breaks
601 @section Breaks
603 @menu
604 * Line breaking::               
605 * Page breaking::               
606 * Optimal page breaking::       
607 * Optimal page turning::        
608 * Minimal page breaking::       
609 * Explicit breaks::             
610 * Using an extra voice for breaks::  
611 @end menu
613 @node Line breaking
614 @subsection Line breaking
616 @cindex line breaks
617 @cindex breaking lines
619 Line breaks are normally computed automatically.  They are chosen so
620 that lines look neither cramped nor loose, and that consecutive lines
621 have similar density.
623 Occasionally you might want to override the automatic breaks; you can
624 do this by specifying @code{\break}.  This will force a line break at
625 this point.  Line breaks can only occur at places where there are bar
626 lines.  If you want to have a line break where there is no bar line,
627 you can force an invisible bar line by entering @code{\bar
628 ""}.  Similarly, @code{\noBreak} forbids a line break at a
629 point.
632 @cindex regular line breaks
633 @cindex four bar music.
635 For line breaks at regular intervals use @code{\break} separated by
636 skips and repeated with @code{\repeat}:
637 @example
638 << \repeat unfold 7 @{
639          s1 \noBreak s1 \noBreak
640          s1 \noBreak s1 \break @}
641    @emph{the real music}
643 @end example
645 @noindent
646 This makes the following 28 measures (assuming 4/4 time) be broken every
647 4 measures, and only there.
649 @predefined
651 @code{\break}, and @code{\noBreak}.
652 @funindex \break
653 @funindex \noBreak
655 @seealso
657 Internals: @rinternals{LineBreakEvent}.
659 A linebreaking configuration can be saved as a @code{.ly} file
660 automatically.  This allows vertical alignments to be stretched to
661 fit pages in a second formatting run.  This is fairly new and
662 complicated.  More details are available in
663 @rlsr{Spacing}.
665 @knownissues
667 Line breaks can only occur if there is a @q{proper} bar line.  A note
668 which is hanging over a bar line is not proper, such as
670 @lilypond[quote,ragged-right,relative=2,fragment,verbatim]
671 c4 c2 << c2 {s4 \break } >>  % this does nothing
672 c2 c4 |           % a break here would work
673 c4 c2 c4 ~ \break % as does this break
674 c4 c2 c4
675 @end lilypond
677 This can be avoided by removing the @code{Forbid_line_break_engraver}.
678 Note that manually forced line breaks have to be added in parallel
679 with the music.
681 @lilypond[quote,ragged-right,verbatim]
682 \new Voice \with {
683   \remove Forbid_line_break_engraver
684 } {
685   c4 c2 << c2 {s4 \break } >>  % now the break is allowed
686   c2 c4 
688 @end lilypond
690 Similarly, line breaks are normally forbidden when beams cross bar
691 lines.  This behavior can be changed by setting 
692 @code{\override Beam #'breakable = ##t}.
695 @node Page breaking
696 @subsection Page breaking
698 The default page breaking may be overridden by inserting
699 @code{\pageBreak} or @code{\noPageBreak} commands.  These commands are
700 analogous to @code{\break} and @code{\noBreak}.  They should be
701 inserted at a bar line.  These commands force and forbid a page-break
702 from happening.  Of course, the @code{\pageBreak} command also forces
703 a line break.
705 The @code{\pageBreak} and @code{\noPageBreak} commands may also be
706 inserted at top-level, between scores and top-level markups.
708 Page breaks are computed by the @code{page-breaking} function.  LilyPond
709 provides three algorithms for computing page breaks,
710 @code{ly:optimal-breaking}, @code{ly:page-turn-breaking} and
711 @code{ly:minimal-breaking}.  The default is @code{ly:optimal-breaking},
712 but the value can be changed in the @code{\paper} block:
714 @example
715 \paper@{
716   #(define page-breaking ly:page-turn-breaking)
718 @end example
720 The old page breaking algorithm is called
721 @code{optimal-page-breaks}.  If you are having trouble with the new page
722 breakers, you can enable the old one as a workaround.
724 @predefined
726 @funindex \pageBreak
727 @code{\pageBreak}
728 @funindex \noPageBreak
729 @code{\noPageBreak}
732 @node Optimal page breaking
733 @subsection Optimal page breaking
735 @funindex ly:optimal-breaking
737 The @code{ly:optimal-breaking} function is LilyPond's default method of
738 determining page breaks.  It attempts to find a page breaking that minimizes
739 cramping and stretching, both horizontally and vertically.  Unlike
740 @code{ly:page-turn-breaking}, it has no concept of page turns.
743 @node Optimal page turning
744 @subsection Optimal page turning
746 @funindex ly:page-turn-breaking
748 Often it is necessary to find a page breaking configuration so that there is
749 a rest at the end of every second page.  This way, the musician can turn the
750 page without having to miss notes.  The @code{ly:page-turn-breaking} function
751 attempts to find a page breaking minimizing cramping and stretching, but with
752 the additional restriction that it is only allowed to introduce page turns
753 in specified places.
755 There are two steps to using this page breaking function.  First, you
756 must enable it in the @code{\paper} block, as explained in @ref{Page
757 breaking}.  Then you must tell the function where you would like to allow
758 page breaks.
760 There are two ways to achieve the second step.  First, you can specify each
761 potential page turn manually, by inserting @code{\allowPageTurn} into your
762 input file at the appropriate places.
764 If this is too tedious, you can add a @code{Page_turn_engraver} to a Staff or
765 Voice context.  The @code{Page_turn_engraver} will scan the context for
766 sections without notes (note that it does not scan for rests; it scans for
767 the absence of notes.  This is so that single-staff polyphony with rests in one
768 of the parts does not throw off the @code{Page_turn_engraver}).  When it finds
769 a sufficiently long section without notes, the @code{Page_turn_engraver} will
770 insert an @code{\allowPageTurn} at the final bar line in that section, unless
771 there is a @q{special} bar line (such as a double bar), in which case the
772 @code{\allowPageTurn} will be inserted at the final @q{special} bar line in
773 the section.
775 @funindex minimumPageTurnLength
776 The @code{Page_turn_engraver} reads the context property
777 @code{minimumPageTurnLength} to determine how long a note-free section must
778 be before a page turn is considered.  The default value for
779 @code{minimumPageTurnLength} is @code{#(ly:make-moment 1 1)}.  If you want
780 to disable page turns, you can set it to something very large.
782 @example
783 \new Staff \with @{ \consists "Page_turn_engraver" @}
785   a4 b c d |
786   R1 | % a page turn will be allowed here
787   a4 b c d |
788   \set Staff.minimumPageTurnLength = #(ly:make-moment 5 2)
789   R1 | % a page turn will not be allowed here
790   a4 b r2 |
791   R1*2 | % a page turn will be allowed here
792   a1
794 @end example
796 @funindex minimumRepeatLengthForPageTurn
797 The @code{Page_turn_engraver} detects volta repeats.  It will only allow a page
798 turn during the repeat if there is enough time at the beginning and end of the
799 repeat to turn the page back.  The @code{Page_turn_engraver} can also disable
800 page turns if the repeat is very short.  If you set the context property
801 @code{minimumRepeatLengthForPageTurn} then the @code{Page_turn_engraver} will
802 only allow turns in repeats whose duration is longer than this value.
804 The page turning commands, @code{\pageTurn}, @code{\noPageTurn} and
805 @code{\allowPageTurn}, may also be used at top-level, between scores and
806 top-level markups.
808 @predefined
810 @funindex \pageTurn
811 @code{\pageTurn}
812 @funindex \noPageTurn
813 @code{\noPageTurn}
814 @funindex \allowPageTurn
815 @code{\allowPageTurn}
817 @knownissues
819 There should only be one @code{Page_turn_engraver} in a score.  If there is more
820 than one, they will interfere with each other.
822 @node Minimal page breaking
823 @subsection Minimal page breaking
825 @funindex ly:minimal-breaking
827 The @code{ly:minimal-breaking} function performs minimal computations to
828 calculate the page breaking: it fills a page with as many systems as
829 possible before moving to the next one.  Thus, it may be preferred for
830 scores with many pages, where the other page breaking functions could be
831 too slow or memory demanding, or a lot of texts.  It is enabled using:
833 @example
834 \paper @{
835   #(define page-breaking ly:minimal-breaking)
837 @end example
839 @node Explicit breaks
840 @subsection Explicit breaks
842 Lily sometimes rejects explicit @code{\break} and @code{\pageBreak}
843 commands.  There are two commands to override this behavior:
845 @example
846 \override NonMusicalPaperColumn #'line-break-permission = ##f
847 \override NonMusicalPaperColumn #'page-break-permission = ##f
848 @end example
850 When @code{line-break-permission} is overridden to false, Lily will insert
851 line breaks at explicit @code{\break} commands and nowhere else.  When
852 @code{page-break-permission} is overridden to false, Lily will insert
853 page breaks at explicit @code{\pageBreak} commands and nowhere else.
855 @lilypond[quote,verbatim]
856 \paper {
857   indent = #0
858   ragged-right = ##t
859   ragged-bottom = ##t
862 \score {
863   \new Score \with {
864     \override NonMusicalPaperColumn #'line-break-permission = ##f
865     \override NonMusicalPaperColumn #'page-break-permission = ##f
866   } {
867     \new Staff {
868       \repeat unfold 2 { c'8 c'8 c'8 c'8 } \break
869       \repeat unfold 4 { c'8 c'8 c'8 c'8 } \break
870       \repeat unfold 6 { c'8 c'8 c'8 c'8 } \break
871       \repeat unfold 8 { c'8 c'8 c'8 c'8 } \pageBreak
872       \repeat unfold 8 { c'8 c'8 c'8 c'8 } \break
873       \repeat unfold 6 { c'8 c'8 c'8 c'8 } \break
874       \repeat unfold 4 { c'8 c'8 c'8 c'8 } \break
875       \repeat unfold 2 { c'8 c'8 c'8 c'8 }
876     }
877   }
879 @end lilypond
882 @node Using an extra voice for breaks
883 @subsection Using an extra voice for breaks
885 Line- and page-breaking information usually appears within note entry directly.
887 @example
888 \new Score @{
889   \new Staff @{
890     \repeat unfold 2 @{ c'4 c'4 c'4 c'4 @}
891     \break
892     \repeat unfold 3 @{ c'4 c'4 c'4 c'4 @}
893   @}
895 @end example
897 This makes @code{\break} and @code{\pageBreak} commands easy to enter but mixes
898 music entry with information that specifies how music should lay out
899 on the page.  You can keep music entry and line- and page-breaking
900 information in two separate places by introducing an extra voice to 
901 contain the  breaks.  This extra voice
902 contains only skips together with @code{\break}, @code{pageBreak} and other
903 breaking layout information.
905 @lilypond[quote,verbatim]
906 \new Score {
907   \new Staff <<
908      \new Voice {
909         s1 * 2 \break
910         s1 * 3 \break
911         s1 * 6 \break
912         s1 * 5 \break
913      }
914      \new Voice {
915         \repeat unfold 2 { c'4 c'4 c'4 c'4 }
916         \repeat unfold 3 { c'4 c'4 c'4 c'4 }
917         \repeat unfold 6 { c'4 c'4 c'4 c'4 }
918         \repeat unfold 5 { c'4 c'4 c'4 c'4 }
919      }
920   >>
922 @end lilypond
924 This pattern becomes especially helpful when overriding
925 @code{line-break-system-details} and the other useful but long properties of
926 @code{NonMusicalPaperColumnGrob}, as explained in @ref{Vertical spacing}.
928 @lilypond[quote,verbatim]
929 \new Score {
930   \new Staff <<
931      \new Voice {
933         \overrideProperty "Score.NonMusicalPaperColumn"
934         #'line-break-system-details #'((Y-offset . 0))
935         s1 * 2 \break
937         \overrideProperty "Score.NonMusicalPaperColumn"
938         #'line-break-system-details #'((Y-offset . 35))
939         s1 * 3 \break
941         \overrideProperty "Score.NonMusicalPaperColumn"
942         #'line-break-system-details #'((Y-offset . 70))
943         s1 * 6 \break
945         \overrideProperty "Score.NonMusicalPaperColumn"
946         #'line-break-system-details #'((Y-offset . 105))
947         s1 * 5 \break
948      }
949      \new Voice {
950         \repeat unfold 2 { c'4 c'4 c'4 c'4 }
951         \repeat unfold 3 { c'4 c'4 c'4 c'4 }
952         \repeat unfold 6 { c'4 c'4 c'4 c'4 }
953         \repeat unfold 5 { c'4 c'4 c'4 c'4 }
954      }
955   >>
957 @end lilypond
960 @node Vertical spacing
961 @section Vertical spacing
963 @cindex vertical spacing
964 @cindex spacing, vertical
966 Vertical spacing is controlled by three things: the amount of
967 space available (i.e., paper size and margins), the amount of
968 space between systems, and the amount of space between
969 staves inside a system.
971 @menu
972 * Vertical spacing inside a system::  
973 * Vertical spacing between systems::  
974 * Explicit staff and system positioning::  
975 * Two-pass vertical spacing::   
976 * Vertical collision avoidance::  
977 @end menu
980 @node Vertical spacing inside a system
981 @subsection Vertical spacing inside a system
983 @cindex distance between staves
984 @cindex staff distance
985 @cindex space between staves
986 @cindex space inside systems
988 The height of each system is determined automatically.  To prevent
989 staves from bumping into each other, some minimum distances are set.
990 By changing these, you can put staves closer together.  This
991 reduces the amount of space each system requires, and may result
992 in having more systems per page.
994 Normally staves are stacked vertically.  To make staves maintain a
995 distance, their vertical size is padded.  This is done with the
996 property @code{minimum-Y-extent}.  When applied to a
997 @rinternals{VerticalAxisGroup}, it controls the size of a horizontal
998 line, such as a staff or a line of lyrics.  @code{minimum-Y-extent}
999 takes a pair of numbers, so
1000 if you want to make it smaller than its default @code{#'(-4 . 4)}
1001 then you could set
1003 @example
1004 \override Staff.VerticalAxisGroup #'minimum-Y-extent = #'(-3 . 3)
1005 @end example
1007 @noindent
1008 This sets the vertical size of the current staff to 3 staff spaces on
1009 either side of the center staff line.  The value @code{(-3 . 3)} is
1010 interpreted as an interval, where the center line is the 0, so the
1011 first number is generally negative.  The numbers need not match;
1012 for example, the staff can be made larger at the bottom by setting
1013 it to @code{(-6 . 4)}.
1015 After page breaks are determined, the vertical spacing within each
1016 system is reevaluated in order to fill the page more evenly; if a page
1017 has space left over, systems are stretched in order to fill that space.
1018 The amount of stretching can be configured though the @code{max-stretch}
1019 property of the @rinternals{VerticalAlignment} grob. By default,
1020 @code{max-stretch} is set to zero, disabling stretching. To enable
1021 stretching, a sane value for @code{max-stretch}
1022 is @code{ly:align-interface::calc-max-stretch}.
1024 In some situations, you may want to stretch most of a system while
1025 leaving some parts fixed.  For example, if a piano part occurs in the
1026 middle of an orchestral score, you may want to leave the piano staves
1027 close to each other while stretching the rest of the score.  The
1028 @code{keep-fixed-while-stretching} property of
1029 @rinternals{VerticalAxisGroup} can be used to achieve this.  When set
1030 to @code{##t}, this property keeps its staff (or line of lyrics) from
1031 moving relative to the one directly above it.  In the example above,
1032 you would override @code{keep-fixed-while-stretching} to @code{##t} in
1033 the second piano staff:
1035 @lilypond[verbatim]
1036 #(set-default-paper-size "a6")
1037 #(set-global-staff-size 14.0)
1039 \book {
1040 \paper {
1041   ragged-last-bottom = ##f
1044 \new Score \with
1046   \override VerticalAlignment #'max-stretch = #ly:align-interface::calc-max-stretch
1049 \new GrandStaff
1051   \new StaffGroup
1052   <<
1053     \new Staff {c' d' e' f'}
1054     \new Staff {c' d' e' f'}
1055     \new Staff {c' d' e' f'}
1056   >>
1058   \new PianoStaff
1059   <<
1060     \new Staff {c' d' e' f'}
1061     \new Staff \with {
1062       \override VerticalAxisGroup #'keep-fixed-while-stretching = ##t
1063     }
1064     {c' d' e' f'}
1065   >>
1067   \new StaffGroup
1068   <<
1069     \new Staff {c' d' e' f'}
1070     \new Staff {c' d' e' f'}
1071   >>
1075 @end lilypond
1077 @seealso
1079 Internals: Vertical alignment of staves is handled by the
1080 @rinternals{VerticalAlignment} object.  The context parameters
1081 specifying the vertical extent are described in connection with
1082 the @rinternals{Axis_group_engraver}.
1084 Example files: @c @lsr{spacing,page-spacing.ly},
1085 @c @lsr{spacing,alignment-vertical-spacing.ly}.
1088 @node Vertical spacing between systems
1089 @subsection Vertical spacing between systems
1091 Space between systems are controlled by four @code{\paper} variables,
1093 @example
1094 \paper @{
1095   between-system-space = 1.5\cm
1096   between-system-padding = #1
1097   ragged-bottom=##f
1098   ragged-last-bottom=##f
1100 @end example
1102 When only a couple of flat systems are placed on a page, the resulting
1103 vertical spacing may be non-elegant: one system at the top of the page,
1104 and the other at the bottom, with a huge gap between them.  To avoid this
1105 situation, the space added between the systems can be limited.  This
1106 feature is activated by setting to @code{#t} the
1107 @code{page-limit-inter-system-space} variable in the @code{\paper}
1108 block.  The paper variable @code{page-limit-inter-system-space-factor}
1109 determines how much the space can be increased: for instance, the value
1110 @code{1.3} means that the space can be 30% larger than what it would be
1111 on a ragged-bottom page.
1113 In the following example, if the inter system space were not limited,
1114 the second system of page 1 would be placed at the page bottom.  By
1115 activating the space limitation, the second system is placed closer to
1116 the first one.  By setting @code{page-limit-inter-system-space-factor} to
1117 @code{1}, the spacing would the same as on a ragged-bottom page, like
1118 the last one.
1120 @lilypond[verbatim]
1121 #(set-default-paper-size "a6")
1122 \book {
1123   \paper {
1124     page-limit-inter-system-space = ##t
1125     page-limit-inter-system-space-factor = 1.3
1127     oddFooterMarkup = \markup "page bottom"
1128     evenFooterMarkup = \markup "page bottom"
1129     oddHeaderMarkup = \markup \fill-line {
1130       "page top" \fromproperty #'page:page-number-string }
1131     evenHeaderMarkup = \markup \fill-line {
1132       "page top" \fromproperty #'page:page-number-string }
1133   }
1134   \new Staff << \repeat unfold 4 { g'4 g' g' g' \break }
1135                 { s1*2 \pageBreak } >>
1137 @end lilypond
1139 @node Explicit staff and system positioning
1140 @subsection Explicit staff and system positioning
1142 One way to understand the @code{VerticalAxisGroup} and @code{\paper}
1143 settings explained in the previous two sections is as a collection of
1144 different settings that primarily concern the amount of vertical padding
1145 different staves and systems running down the page.
1147 It is possible to approach vertical spacing in a different way using
1148 @code{NonMusicalPaperColumn #'line-break-system-details}.  Where
1149 @code{VerticalAxisGroup} and @code{\paper} settings specify vertical padding,
1150 @code{NonMusicalPaperColumn #'line-break-system-details} specifies exact
1151 vertical positions on the page.
1153 @code{NonMusicalPaperColumn #'line-break-system-details} accepts an associative
1154 list of five different settings:
1156 @itemize 
1157 @item @code{X-offset}
1158 @item @code{Y-offset}
1159 @item @code{alignment-offsets}
1160 @item @code{alignment-extra-space}
1161 @item @code{fixed-alignment-extra-space}
1162 @end itemize
1164 Grob overrides, including the overrides for @code{NonMusicalPaperColumn}
1165 below, can occur in any of three different places in an input file:
1167 @itemize
1168 @item in the middle of note entry directly
1169 @item in a @code{\context} block
1170 @item in the @code{\with} block
1171 @end itemize
1173 When we override @code{NonMusicalPaperColumn}, we use the usual
1174 @code{\override} command in @code{\context} blocks and in the
1175 @code{\with} block.  On the other hand, when we override
1176 @code{NonMusicalPaperColumn} in the middle of note entry,
1177 use the special @code{\overrideProperty} command.  Here are some
1178 example @code{NonMusicalPaperColumn} overrides with the special
1179 @code{\overrideProperty} command:
1181 @example
1182 \overrideProperty NonMusicalPaperColumn
1183   #'line-break-system-details #'((X-offset . 20))
1185 \overrideProperty NonMusicalPaperColumn
1186   #'line-break-system-details #'((Y-offset . 40))
1188 \overrideProperty NonMusicalPaperColumn
1189   #'line-break-system-details #'((X-offset . 20) (Y-offset . 40))
1191 \override NonMusicalPaperColumn
1192   #'line-break-system-details #'((alignment-offsets . (0 -15)))
1194 \override NonMusicalPaperColumn
1195   #'line-break-system-details #'((X-offset . 20) (Y-offset . 40)
1196                                  (alignment-offsets . (0 -15)))
1197 @end example
1199 To understand how each of these different settings work, we begin
1200 by looking at an example that includes no overrides at all.
1202 @lilypond[quote,ragged-right]
1203 \new Score <<
1204   \new Staff <<
1205     \new Voice {
1206       s1 * 6 \break
1207       s1 * 6 \break
1208       s1 * 6 \break
1209     }
1210     \new Voice { \repeat unfold 18 { c'4 c'4 c'4 c'4 } }
1211   >>
1212   \new Staff {
1213     \repeat unfold 18 { d'4 d'4 d'4 d'4 }
1214   }
1216 @end lilypond
1218 This score isolates line- and page-breaking information in a dedicated
1219 voice.  This technique of creating a breaks voice will help keep layout
1220 separate from music entry as our example becomes more complicated.
1221 See @ref{Using an extra voice for breaks}.
1223 Explicit @code{\breaks} evenly divide the music into six measures per
1224 line.  Vertical spacing results from LilyPond's defaults.  To set
1225 the vertical startpoint of each system explicitly, we can set
1226 the @code{Y-offset} pair in the @code{line-break-system-details}
1227 attribute of the @code{NonMusicalPaperColumn} grob:
1229 @lilypond[quote,ragged-right]
1230 \new Score <<
1231   \new Staff <<
1232     \new Voice {
1233       \overrideProperty #"Score.NonMusicalPaperColumn"
1234         #'line-break-system-details #'((Y-offset . 0))
1235       s1 * 6 \break
1236       \overrideProperty #"Score.NonMusicalPaperColumn"
1237         #'line-break-system-details #'((Y-offset . 40))
1238       s1 * 6 \break
1239       \overrideProperty #"Score.NonMusicalPaperColumn"
1240         #'line-break-system-details #'((Y-offset . 80))
1241       s1 * 6 \break
1242     }
1243     \new Voice { \repeat unfold 18 { c'4 c'4 c'4 c'4 } }
1244   >>
1245   \new Staff {
1246     \repeat unfold 18 { d'4 d'4 d'4 d'4 }
1247   }
1249 @end lilypond
1251 Note that @code{line-break-system-details} takes an associative list of
1252 potentially many values, but that we set only one value here.  Note,
1253 too, that the @code{Y-offset} property here determines the exact vertical
1254 position on the page at which each new system will render.
1256 Now that we have set the vertical startpoint of each system
1257 explicitly, we can also set the vertical startpoint of each staff
1258 within each system manually.  We do this using the @code{alignment-offsets}
1259 subproperty of @code{line-break-system-details}.
1261 @lilypond[quote,ragged-right]
1262 \new Score <<
1263   \new Staff <<
1264     \new Voice {
1265       \overrideProperty #"Score.NonMusicalPaperColumn"
1266         #'line-break-system-details #'((Y-offset . 20)
1267           (alignment-offsets . (0 -15)))
1268       s1 * 6 \break
1269       \overrideProperty #"Score.NonMusicalPaperColumn"
1270         #'line-break-system-details #'((Y-offset . 60)
1271           (alignment-offsets . (0 -15)))
1272       s1 * 6 \break
1273       \overrideProperty #"Score.NonMusicalPaperColumn"
1274         #'line-break-system-details #'((Y-offset . 100)
1275           (alignment-offsets . (0 -15)))
1276       s1 * 6 \break
1277     }
1278     \new Voice { \repeat unfold 18 { c'4 c'4 c'4 c'4 } }
1279   >>
1280   \new Staff {
1281     \repeat unfold 18 { d'4 d'4 d'4 d'4 }
1282   }
1284 @end lilypond
1286 Note that here we assign two different values to the
1287 @code{line-break-system-details} attribute of the
1288 @code{NonMusicalPaperColumn} grob.  Though the
1289 @code{line-break-system-details} attribute alist accepts many
1290 additional spacing parameters (including, for example, a corresponding
1291 @code{X-offset} pair), we need only set the @code{Y-offset} and
1292 @code{alignment-offsets} pairs to control the vertical startpoint of
1293 every system and every staff.  Finally, note that @code{alignment-offsets}
1294 specifies the vertical positioning of staves but not of staff groups.
1296 @lilypond[quote,ragged-right]
1297 \new Score <<
1298   \new Staff <<
1299     \new Voice {
1300       \overrideProperty #"Score.NonMusicalPaperColumn"
1301       #'line-break-system-details #'((Y-offset . 0)
1302         (alignment-offsets . (0 -30 -40)))
1303       s1 * 6 \break
1304       \overrideProperty #"Score.NonMusicalPaperColumn"
1305       #'line-break-system-details #'((Y-offset . 60)
1306         (alignment-offsets . (0 -10 -20)))
1307       s1 * 6 \break
1308       \overrideProperty #"Score.NonMusicalPaperColumn"
1309       #'line-break-system-details #'((Y-offset . 100)
1310         (alignment-offsets . (0 -10, -40)))
1311       s1 * 6 \break
1312     }
1313     \new Voice { \repeat unfold 18 { c'4 c'4 c'4 c'4 } }
1314   >>
1315   \new StaffGroup <<
1316     \new Staff {
1317       \repeat unfold 18 { d'4 d'4 d'4 d'4 }
1318     }
1319     \new Staff {
1320       \repeat unfold 18 { e'4 e'4 e'4 e'4 }
1321     }
1322   >>
1324 @end lilypond
1326 Some points to consider:
1328 @itemize
1329 @item When using @code{alignment-offsets}, lyrics count as a staff.
1331 @item The units of the numbers passed to @code{X-offset},
1332 @code{Y-offset} and @code{alignment-offsets} are interpreted as multiples
1333 of the distance between adjacent staff lines.  Positive values move staves
1334 and lyrics up, negative values move staves and lyrics down.
1336 @item Because the @code{NonMusicalPaperColumn #'line-break-system-details}
1337 settings given here allow the positioning of staves and systems anywhere
1338 on the page, it is possible to violate paper or margin boundaries or even
1339 to print staves or systems on top of one another.  Reasonable values
1340 passed to these different settings will avoid this.
1341 @end itemize
1344 @node Two-pass vertical spacing
1345 @subsection Two-pass vertical spacing
1347 Warning: two-pass vertical spacing is deprecated and will be removed in
1348 a future version of LilyPond.  Systems are now stretched automatically
1349 in a single pass.  See @ref{Vertical spacing inside a system}.
1351 In order to automatically stretch systems so that they should fill the
1352 space left on a page, a two-pass technique can be used:
1354 @enumerate
1355 @item In the first pass, the amount of vertical space used to increase
1356 the height of each system is computed and dumped to a file.
1357 @item In the second pass, spacing inside the systems are
1358 stretched according to the data in the page layout file.
1359 @end enumerate
1361 The @code{ragged-bottom} property adds space between systems, while
1362 the two-pass technique adds space between staves inside a system.
1364 To allow this behavior, a @code{tweak-key} variable has to be set in
1365 each score @code{\layout} block, and the tweaks included in each score
1366 music, using the @code{\scoreTweak} music function.
1368 @quotation
1369 @verbatim
1370 %% include the generated page layout file:
1371 \includePageLayoutFile
1373 \score {
1374   \new StaffGroup <<
1375     \new Staff <<
1376       %% Include this score tweaks:
1377       \scoreTweak "scoreA"
1378       { \clef french c''1 \break c''1 }
1379     >>
1380     \new Staff { \clef soprano g'1 g'1 }
1381     \new Staff { \clef mezzosoprano e'1 e'1 }
1382     \new Staff { \clef alto g1 g1 }
1383     \new Staff { \clef bass c1 c1 }
1384   >>
1385   \header {
1386     piece = "Score with tweaks"
1387   }
1388   %% Define how to name the tweaks for this score:
1389   \layout { #(define tweak-key "scoreA") }
1391 @end verbatim
1392 @end quotation
1394 For the first pass, the @code{dump-tweaks} option should be set to
1395 generate the page layout file.
1397 @example
1398 lilypond -dbackend=null -d dump-tweaks <file>.ly
1399 lilypond <file>.ly
1400 @end example
1403 @node Vertical collision avoidance
1404 @subsection Vertical collision avoidance
1406 @funindex outside-staff-priority
1407 @funindex outside-staff-padding
1408 @funindex outside-staff-horizontal-padding
1410 Intuitively, there are some objects in musical notation that belong
1411 to the staff and there are other objects that should be placed outside
1412 the staff.  Objects belonging outside the staff include things such as
1413 rehearsal marks, text and dynamic markings (from now on, these will
1414 be called outside-staff objects).  LilyPond's rule for the
1415 vertical placement of outside-staff objects is to place them as close
1416 to the staff as possible but not so close that they collide with
1417 another object.
1419 LilyPond uses the @code{outside-staff-priority} property to determine
1420 whether a grob is an outside-staff object: if @code{outside-staff-priority}
1421 is a number, the grob is an outside-staff object.  In addition,
1422 @code{outside-staff-priority} tells LilyPond in which order the objects
1423 should be placed.
1425 First, LilyPond places all the objects that do not belong outside
1426 the staff.  Then it sorts the outside-staff objects according to their
1427 @code{outside-staff-priority} (in increasing order).  One by one, LilyPond
1428 takes the outside-staff objects and places them so that they do
1429 not collide with any objects that have already been placed.  That
1430 is, if two outside-staff grobs are competing for the same space, the one
1431 with the lower @code{outside-staff-priority} will be placed closer to
1432 the staff.
1434 @lilypond[quote,ragged-right,relative=2,fragment,verbatim]
1435 c4_"Text"\pp
1437 \once \override TextScript #'outside-staff-priority = #1
1438 c4_"Text"\pp % this time the text will be closer to the staff
1440 % by setting outside-staff-priority to a non-number, we
1441 % disable the automatic collision avoidance
1442 \once \override TextScript #'outside-staff-priority = ##f
1443 \once \override DynamicLineSpanner #'outside-staff-priority = ##f
1444 c4_"Text"\pp % now they will collide
1445 @end lilypond
1447 The vertical padding between an outside-staff object and the
1448 previously-positioned grobs can be controlled with
1449 @code{outside-staff-padding}.
1451 @lilypond[quote,ragged-right,relative=2,fragment,verbatim]
1452 \once \override TextScript #'outside-staff-padding = #0
1453 a'^"This text is placed very close to the note"
1454 \once \override TextScript #'outside-staff-padding = #3
1455 c^"This text is padded away from the previous text"
1456 c^"This text is placed close to the previous text"
1457 @end lilypond
1459 TODO: this example doesn't work any more ?
1461 By default, outside-staff objects are placed without regard to
1462 their horizontal distance from the previously-positioned grobs.  This
1463 can lead to situations in which objects are placed very close to each
1464 other horizontally.  Setting @code{outside-staff-horizontal-padding}
1465 causes an object to be offset vertically so that such a situation
1466 doesn't occur.
1468 @lilypond[quote,ragged-right,relative=2,fragment,verbatim]
1469 % the markup is too close to the following note
1470 c2^"Text"
1471 c''2
1472 % setting outside-staff-horizontal-padding fixes this
1474 \once \override TextScript #'outside-staff-horizontal-padding = #1
1475 c,,2^"Text"
1476 c''2
1477 @end lilypond
1481 @node Horizontal spacing
1482 @section Horizontal Spacing
1484 @cindex horizontal spacing
1485 @cindex spacing, horizontal
1487 @menu
1488 * Horizontal spacing overview::  
1489 * New spacing area::            
1490 * Changing horizontal spacing::  
1491 * Line length::                 
1492 * Proportional notation::       
1493 @end menu
1496 @node Horizontal spacing overview
1497 @subsection Horizontal spacing overview
1499 The spacing engine translates differences in durations into stretchable
1500 distances (@q{springs}) of differing lengths.  Longer durations get
1501 more space, shorter durations get less.  The shortest durations get a
1502 fixed amount of space (which is controlled by
1503 @code{shortest-duration-space} in the @rinternals{SpacingSpanner}
1504 object).  The longer the duration, the more space it gets: doubling a
1505 duration adds a fixed amount (this amount is controlled by
1506 @code{spacing-increment}) of space to the note.
1508 For example, the following piece contains lots of half, quarter, and
1509 8th notes; the eighth note is followed by 1 note head width (NHW).
1510 The quarter note is followed by 2 NHW, the half by 3 NHW, etc.
1512 @lilypond[quote,fragment,verbatim,relative=1]
1513 c2 c4. c8 c4. c8 c4. c8 c8
1514 c8 c4 c4 c4
1515 @end lilypond
1517 Normally, @code{spacing-increment} is set to 1.2 staff space, which is
1518 approximately the width of a note head, and
1519 @code{shortest-duration-space} is set to 2.0, meaning that the
1520 shortest note gets 2.4 staff space (2.0 times the
1521 @code{spacing-increment}) of horizontal space.  This space is counted
1522 from the left edge of the symbol, so the shortest notes are generally
1523 followed by one NHW of space.
1525 If one would follow the above procedure exactly, then adding a single
1526 32nd note to a score that uses 8th and 16th notes, would widen up the
1527 entire score a lot.  The shortest note is no longer a 16th, but a 32nd,
1528 thus adding 1 NHW to every note.  To prevent this, the shortest
1529 duration for spacing is not the shortest note in the score, but rather
1530 the one which occurs most frequently.
1533 The most common shortest duration is determined as follows: in every
1534 measure, the shortest duration is determined.  The most common shortest
1535 duration is taken as the basis for the spacing, with the stipulation
1536 that this shortest duration should always be equal to or shorter than
1537 an 8th note.  The shortest duration is printed when you run
1538 @code{lilypond} with the @code{--verbose} option.
1540 These durations may also be customized.  If you set the
1541 @code{common-shortest-duration} in @rinternals{SpacingSpanner}, then
1542 this sets the base duration for spacing.  The maximum duration for this
1543 base (normally an 8th), is set through @code{base-shortest-duration}.
1545 @funindex common-shortest-duration
1546 @funindex base-shortest-duration
1547 @funindex stem-spacing-correction
1548 @funindex spacing
1550 Notes that are even shorter than the common shortest note are
1551 followed by a space that is proportional to their duration relative to
1552 the common shortest note.  So if we were to add only a few 16th notes
1553 to the example above, they would be followed by half a NHW:
1555 @lilypond[quote,fragment,verbatim,relative=2]
1556 c2 c4. c8 c4. c16[ c] c4. c8 c8 c8 c4 c4 c4
1557 @end lilypond
1560 In the introduction (see @rlearning{Engraving}), it was explained that stem
1561 directions influence spacing.  This is controlled with the
1562 @code{stem-spacing-correction} property in the
1563 @rinternals{NoteSpacing}, object.  These are generated for every
1564 @rinternals{Voice} context.  The @code{StaffSpacing} object
1565 (generated in @rinternals{Staff} context) contains the same property
1566 for controlling the stem/bar line spacing.  The following example shows
1567 these corrections, once with default settings, and once with
1568 exaggerated corrections:
1570 @lilypond[quote,ragged-right]
1572   c'4 e''4 e'4 b'4 |
1573   b'4 e''4 b'4 e''4|
1574   \override Staff.NoteSpacing #'stem-spacing-correction = #1.5
1575   \override Staff.StaffSpacing #'stem-spacing-correction = #1.5
1576   c'4 e''4 e'4 b'4 |
1577   b'4 e''4 b'4 e''4|
1579 @end lilypond
1581 Proportional notation is supported; see @ref{Proportional notation}.
1584 @seealso
1586 Internals: @rinternals{SpacingSpanner}, @rinternals{NoteSpacing},
1587 @rinternals{StaffSpacing}, @rinternals{SeparationItem}, and
1588 @rinternals{SeparatingGroupSpanner}.
1591 @knownissues
1593 There is no convenient mechanism to manually override spacing.  The
1594 following work-around may be used to insert extra space into a score.
1595 @example
1596  \once \override Score.SeparationItem #'padding = #1
1597 @end example
1599 No work-around exists for decreasing the amount of space.
1602 @node New spacing area
1603 @subsection New spacing area
1605 New sections with different spacing parameters can be started with
1606 @code{newSpacingSection}.  This is useful when there are  
1607 sections with a different notions of long and short notes.
1609 In the following example, the time signature change introduces a new
1610 section, and hence the 16ths notes are spaced wider.
1612 @lilypond[relative,fragment,verbatim,quote]
1613 \time 2/4
1614 c4 c8 c 
1615 c8 c c4 c16[ c c8] c4
1616 \newSpacingSection
1617 \time 4/16
1618 c16[ c c8]
1619 @end lilypond
1622 The @code{\newSpacingSection} command creates a new
1623 @rinternals{SpacingSpanner} object, and hence new @code{\override}s
1624 may be used in that location.
1627 @node Changing horizontal spacing
1628 @subsection Changing horizontal spacing
1630 Horizontal spacing may be altered with the
1631 @code{base-shortest-duration} property.  Here
1632 we compare the same music; once without altering
1633 the property, and then altered.  Larger values
1634 of @code{ly:make-moment} will produce smaller
1635 music.  Note that @code{ly:make-moment} constructs
1636 a duration, so @code{1 4} is a longer duration
1637 than @code{1 16}.
1639 @lilypond[verbatim,line-width=12\cm]
1640 \score {
1641   \relative c'' {
1642     g4 e e2 | f4 d d2 | c4 d e f | g4 g g2 |
1643     g4 e e2 | f4 d d2 | c4 e g g | c,1 |
1644     d4 d d d | d4 e f2 | e4 e e e | e4 f g2 |
1645     g4 e e2 | f4 d d2 | c4 e g g | c,1 |
1646   }
1648 @end lilypond
1650 @lilypond[verbatim,line-width=12\cm]
1651 \score {
1652   \relative c'' {
1653     g4 e e2 | f4 d d2 | c4 d e f | g4 g g2 |
1654     g4 e e2 | f4 d d2 | c4 e g g | c,1 |
1655     d4 d d d | d4 e f2 | e4 e e e | e4 f g2 |
1656     g4 e e2 | f4 d d2 | c4 e g g | c,1 |
1657   }
1658   \layout {
1659     \context {
1660       \Score
1661       \override SpacingSpanner
1662                 #'base-shortest-duration = #(ly:make-moment 1 16)
1663     }
1664   }
1666 @end lilypond
1669 @snippets
1671 By default, spacing in tuplets depends on various non-duration
1672 factors (such as accidentals, clef changes, etc).  To disregard
1673 such symbols and force uniform equal-duration spacing, use
1674 @code{Score.SpacingSpanner #'uniform-stretching}.  This
1675 property can only be changed at the beginning of a score,
1677 @lilypond[quote,ragged-right,relative=2,fragment,verbatim]
1678 \new Score \with {
1679   \override SpacingSpanner #'uniform-stretching = ##t
1680 } <<
1681   \new Staff{
1682     \times 4/5 {
1683       c8 c8 c8 c8 c8
1684     }
1685     c8 c8 c8 c8
1686   }
1687   \new Staff{
1688     c8 c8 c8 c8
1689     \times 4/5 {
1690       c8 c8 c8 c8 c8
1691     }
1692   }
1694 @end lilypond
1697 When @code{strict-note-spacing} is set, notes are spaced without
1698 regard for clefs, bar lines, and grace notes,
1700 @lilypond[quote,ragged-right,relative=2,fragment,verbatim]
1701 \override Score.SpacingSpanner #'strict-note-spacing = ##t
1702 \new Staff { c8[ c \clef alto c \grace { c16[ c] } c8 c c]  c32[ c32] }
1703 @end lilypond
1706 @node Line length
1707 @subsection Line length
1709 @cindex page breaks
1710 @cindex breaking pages
1712 @funindex indent
1713 @funindex line-width
1714 @funindex ragged-right
1715 @funindex ragged-last
1717 @c Although line-width can be set in \layout, it should be set in paper
1718 @c block, to get page layout right.
1719 @c Setting indent in \paper block makes not much sense, but it works.
1721 @c Bit verbose and vague, use examples?
1722 The most basic settings influencing the spacing are @code{indent} and
1723 @code{line-width}.  They are set in the @code{\layout} block.  They
1724 control the indentation of the first line of music, and the lengths of
1725 the lines.
1727 If @code{ragged-right} is set to true in the @code{\layout} block, then
1728 systems ends at their natural horizontal length, instead of being spread
1729 horizontally to fill the whole line.  This is useful for
1730 short fragments, and for checking how tight the natural spacing is.
1732 @cindex page layout
1733 @cindex vertical spacing
1735 The option @code{ragged-last} is similar to @code{ragged-right}, but
1736 only affects the last line of the piece.  No restrictions are put on
1737 that line.  The result is similar to formatting text paragraphs.  In a
1738 paragraph, the last line simply takes its natural horizontal length.
1739 @c Note that for text there are several options for the last line.
1740 @c While Knuth TeX uses natural length, lead typesetters use the same
1741 @c stretch as the previous line.  eTeX uses \lastlinefit to
1742 @c interpolate between both these solutions.
1744 @example
1745 \layout @{
1746   indent = #0
1747   line-width = #150
1748   ragged-last = ##t
1750 @end example
1753 @node Proportional notation
1754 @subsection Proportional notation
1756 LilyPond supports proportional notation, a type of horizontal spacing
1757 in which each note consumes an amount of horizontal space exactly
1758 equivalent to its rhythmic duration.  This type of proportional spacing
1759 is comparable to horizontal spacing on top of graph paper.  Some late
1760 20th- and early 21st-century scores use proportional notation to
1761 clarify complex rhythmic relationships or to facilitate the placement
1762 of timelines or other graphics directly in the score.
1764 LilyPond supports five different settings for proportional notation,
1765 which may be used together or alone:
1767 @itemize
1768 @item @code{proportionalNotationDuration}
1769 @item @code{uniform-stretching}
1770 @item @code{strict-note-spacing}
1771 @item @code{\remove Separating_line_group_engraver}
1772 @item @code{\override PaperColumn #'used = ##t}
1773 @end itemize
1775 In the examples that follow, we explore these five different
1776 proportional notation settings and examine how these settings interact.
1778 We start with the following one-measure example, which uses classical
1779 spacing with ragged-right turned on.
1781 @lilypond[quote,verbatim,ragged-right]
1782 \new Score <<
1783   \new RhythmicStaff {
1784     c'2
1785     c'16 c'16 c'16 c'16
1786     \times 4/5 {
1787       c'16 c'16 c'16 c'16 c'16
1788     }
1789   }
1791 @end lilypond
1793 Notice that the half note which begins the measure takes up far less
1794 than half of the horizontal space of the measure.  Likewise, the
1795 sixteenth notes and sixteenth-note quintuplets (or twentieth notes)
1796 which end the measure together take up far more than half the
1797 horizontal space of the measure.
1799 In classical engraving, this spacing may be exactly what we want
1800 because we can borrow horizontal space from the half note and conserve
1801 horizontal space across the measure as a whole.
1803 On the other hand, if we want to insert a measured timeline or other
1804 graphic above or below our score, we need proportional notation.  We
1805 turn proportional notation on with the proportionalNotationDuration
1806 setting.
1808 @lilypond[quote,verbatim,ragged-right]
1809 \new Score \with {
1810   proportionalNotationDuration = #(ly:make-moment 1 20)
1811 } <<
1812   \new RhythmicStaff {
1813     c'2
1814     c'16 c'16 c'16 c'16
1815     \times 4/5 {
1816       c'16 c'16 c'16 c'16 c'16
1817     }
1818   }
1820 @end lilypond
1822 The half note at the beginning of the measure and the faster notes in
1823 the second half of the measure now occupy equal amounts of horizontal
1824 space.  We could place a measured timeline or graphic above or below
1825 this example.
1827 The @code{proportionalNotationDuration} setting is a context setting that
1828 lives in @code{Score}.  Recall that context settings appear in one of
1829 three locations in our input file -- in a @code{\with} block, in a
1830 @code{\context} block, or directly in music entry
1831 preceded by the @code{\set} command.  As with all
1832 context settings, users can pick which of the three different
1833 locations they would like to set @code{proportionalNotationDuration}.
1835 The @code{proportionalNotationDuration} setting takes a single argument,
1836 which is the reference duration against which all music will be
1837 spaced.  The LilyPond Scheme function make-moment takes two arguments
1838 -- a numerator and denominator which together express some fraction of
1839 a whole note.  The call @code{#(ly:make-moment 1 20)} therefore produces a
1840 reference duration of a twentieth note.  The values
1841 @code{#(ly:make-moment 1 16)}, @code{#(ly:make-moment 1 8)}, and
1842 @code{#(ly:make-moment 3 97)} are all possible as well.
1844 How do we select the right reference duration to pass to
1845 @code{proportionalNotationDuration}?  Usually by a process of trial and error,
1846 beginning with a duration close to the fastest (or smallest) duration
1847 in the piece.  Smaller reference durations space music loosely; larger
1848 reference durations space music tightly.
1850 @lilypond[quote,verbatim,ragged-right]
1851 \new Score \with {
1852   proportionalNotationDuration = #(ly:make-moment 1 8)
1853 } <<
1854   \new RhythmicStaff {
1855     c'2
1856     c'16 c'16 c'16 c'16
1857     \times 4/5 {
1858       c'16 c'16 c'16 c'16 c'16
1859     }
1860   }
1863 \new Score \with {
1864   proportionalNotationDuration = #(ly:make-moment 1 16)
1865 } <<
1866   \new RhythmicStaff {
1867     c'2
1868     c'16 c'16 c'16 c'16
1869     \times 4/5 {
1870       c'16 c'16 c'16 c'16 c'16
1871     }
1872   }
1875 \new Score \with {
1876   proportionalNotationDuration = #(ly:make-moment 1 32)
1877 } <<
1878   \new RhythmicStaff {
1879     c'2
1880     c'16 c'16 c'16 c'16
1881     \times 4/5 {
1882       c'16 c'16 c'16 c'16 c'16
1883     }
1884   }
1886 @end lilypond
1888 Note that too large a reference duration -- such as the eighth note,
1889 above -- spaces music too tightly and can cause note head collisions.
1890 Note also that proportional notation in general takes up more
1891 horizontal space that does classical spacing.  Proportional spacing
1892 provides rhythmic clarity at the expense of horizontal space.
1894 Next we examine how to optimally space overlapping tuplets.
1896 We start by examining what happens to our original example, with
1897 classical spacing, when we add a second staff with a different type of
1898 tuplet.
1900 @lilypond[quote,verbatim,ragged-right]
1901 \new Score <<
1902   \new RhythmicStaff {
1903     c'2
1904     c'16 c'16 c'16 c'16
1905     \times 4/5 {
1906       c'16 c'16 c'16 c'16 c'16
1907     }
1908   }
1909   \new RhythmicStaff {
1910     \times 8/9 {
1911       c'8 c'8 c'8 c'8 c'8 c'8 c'8 c'8 c'8
1912     }
1913   }
1915 @end lilypond
1917 The spacing is bad because the evenly notes of the bottom staff do not
1918 stretch uniformly.  Classical engraving includes very few complex
1919 triplets and so classical engraving rules can generate this type of
1920 result.  Setting @code{proportionalNotationDuration} remedies this
1921 situation considerably.
1923 @lilypond[quote,verbatim,ragged-right]
1924 \new Score \with {
1925   proportionalNotationDuration = #(ly:make-moment 1 20)
1926 } <<
1927   \new RhythmicStaff {
1928     c'2
1929     c'16 c'16 c'16 c'16
1930     \times 4/5 {
1931       c'16 c'16 c'16 c'16 c'16
1932     }
1933   }
1934   \new RhythmicStaff {
1935     \times 8/9 {
1936       c'8 c'8 c'8 c'8 c'8 c'8 c'8 c'8 c'8
1937     }
1938   }
1940 @end lilypond
1942 But if we look very carefully we can see that notes of the second half
1943 of the 9-tuplet space ever so slightly more widely than do the notes
1944 of the first half of the 9-tuplet.  To ensure uniform stretching, we
1945 turn on @code{uniform-stretching}, which is a property of
1946 @code{SpacingSpanner}.
1948 @lilypond[quote,verbatim,ragged-right]
1949 \new Score \with {
1950   proportionalNotationDuration = #(ly:make-moment 1 20)
1951   \override SpacingSpanner #'uniform-stretching = ##t
1952 } <<
1953   \new RhythmicStaff {
1954     c'2
1955     c'16 c'16 c'16 c'16
1956     \times 4/5 {
1957       c'16 c'16 c'16 c'16 c'16
1958     }
1959   }
1960   \new RhythmicStaff {
1961     \times 8/9 {
1962       c'8 c'8 c'8 c'8 c'8 c'8 c'8 c'8 c'8
1963     }
1964   }
1966 @end lilypond
1968 Our two-staff example now spaces exactly, our rhythmic
1969 relationships are visually clear, and we can include a measured
1970 timeline or graphic if we want.
1972 Note that the LilyPond's proportional notation package expects
1973 that all proportional scores set the SpacingSpanner's
1974 'uniform-stretching attribute to ##t. Setting
1975 proportionalNotationDuration without also setting the
1976 SpacingSpanner's 'uniform-stretching attribute to ##t will, for
1977 example, cause Skips to consume an incorrect amount of horizontal
1978 space.
1980 The SpacingSpanner is an abstract grob that lives in the Score
1981 context. As with our settings of proportionalNotationDuration,
1982 overrides to the SpacingSpanner can occur in any of three
1983 different places in our input file – in the Score \with block, in
1984 a Score \context block, or in note entry directly.
1986 There is by default only one @code{SpacingSpanner} per @code{Score}.  This
1987 means that, by default, @code{uniform-stretching} is either turned on for the
1988 entire score or turned off for the entire score.  We can, however,
1989 override this behavior and turn on different spacing features at
1990 different places in the score.  We do this with the command
1991 @code{\newSpacingSection}.  See @ref{New spacing area}, for more info.
1993 Next we examine the effects of the @code{Separating_line_group_engraver} and
1994 see why proportional scores frequently remove this engraver.  The following
1995 example shows that there is a small amount of @qq{preferatory} space
1996 just before the first note in each system.
1998 @lilypond[quote,verbatim,ragged-right]
1999 \paper {
2000   indent = #0
2003 \new Staff {
2004   c'1
2005   \break
2006   c'1
2008 @end lilypond
2011 The amount of this preferatory space is the same whether after a time
2012 signature, a key signature or a clef.  @code{Separating_line_group_engraver}
2013 is responsible for this space.  Removing @code{Separating_line_group_engraver}
2014 reduces this space to zero.
2016 @lilypond[quote,verbatim,ragged-right]
2017 \paper {
2018   indent = #0
2021 \new Staff \with {
2022   \remove Separating_line_group_engraver
2023 } {
2024   c'1
2025   \break
2026   c'1
2028 @end lilypond
2030 Nonmusical elements like time signatures, key signatures, clefs and
2031 accidentals are problematic in proportional notation.  None of these
2032 elements has rhythmic duration.  But all of these elements consume
2033 horizontal space.  Different proportional scores approach these
2034 problems differently.
2036 It may be possible to avoid spacing problems with key signatures
2037 simply by not having any.  This is a valid option since most
2038 proportional scores are contemporary music.  The same may be true
2039 of time signatures, especially for those scores
2040 that include a measured timeline or other graphic.  But these scores
2041 are exceptional and most proportional scores include at least some
2042 time signatures.  Clefs and accidentals are even more essential.
2044 So what strategies exist for spacing nonmusical elements in a
2045 proportional context?  One good option is the @code{strict-note-spacing}
2046 property of @code{SpacingSpanner}.  Compare the two scores below:
2048 @lilypond[quote,verbatim,ragged-right]
2049 \new Staff {
2050   \set Score.proportionalNotationDuration = #(ly:make-moment 1 16)
2051   c''8
2052   c''8
2053   c''8
2054   \clef alto
2055   d'8
2056   d'2
2059 \new Staff {
2060   \set Score.proportionalNotationDuration = #(ly:make-moment 1 16)
2061   \override Score.SpacingSpanner #'strict-note-spacing = ##t
2062   c''8
2063   c''8
2064   c''8
2065   \clef alto
2066   d'8
2067   d'2
2069 @end lilypond
2071 Both scores are proportional, but the spacing in the first score
2072 is too loose because of the clef change. The spacing of the second
2073 score remains strict, however, because strict-note-spacing is
2074 turned on.  Turning on strict-note-spacing causes the width of
2075 time signatures, key signatures, clefs and accidentals to play no
2076 part in the spacing algorithm.
2078 In addition to the settings given here, there are other settings
2079 that frequently appear in proportional scores. These include:
2081 @itemize
2082 @item @code{\override SpacingSpanner #'strict-grace-spacing = ##t}
2083 @item @code{tupletFullLength = ##t}
2084 @item @code{\override Beam #'breakable = ##t}
2085 @item @code{\override Glissando #'breakable = ##t}
2086 @item @code{\override TextSpanner #'breakable = ##t}
2087 @item @code{\remove Forbid_line_break_engraver in the Voice context}
2088 @end itemize
2090 These settings space grace notes strictly, extend tuplet brackets to
2091 mark both rhythmic start- and stop-points, and allow spanning elements
2092 to break across systems and pages.  See the respective parts of the manual
2093 for these related settings.
2097 @node Page layout MOVED FROM LM
2098 @section Page layout MOVED FROM LM
2100 @menu
2101 * Introduction to layout::      
2102 * Global sizes::                
2103 * Line breaks::                 
2104 * Page breaks::                 
2105 * Fitting music onto fewer pages::  
2106 @end menu
2108 @node Introduction to layout
2109 @subsection Introduction to layout
2111 The global paper layout is determined by three factors: 
2112 the page layout, the line breaks, and the spacing. These all 
2113 influence each other. The choice of spacing determines how 
2114 densely each system of music is set. This influences where line 
2115 breaks are chosen, and thus ultimately, how many pages a piece 
2116 of music takes.
2118 Settings which influence layout may be placed in two blocks.
2119 The @code{\paper @{...@}} block is placed outside any
2120 @code{\score @{...@}} blocks and contains settings that
2121 relate to the entire document.  The @code{\layout @{...@}}
2122 block is placed within a @code{\score @{...@}} block and
2123 contains settings for that particular score.  If you have
2124 only one @code{\score @{...@}} block the two have the same
2125 effect.  In general the commands shown in this section can
2126 be placed in either.
2128 Much more detail on the options for tweaking the laying out
2129 of music are contained in @ref{Spacing issues}.
2131 @node Global sizes
2132 @subsection Global sizes
2134 TODO Check all these examples
2136 The default @strong{paper size} which LilyPond assumes in laying
2137 out the music is A4.  This may be changed in two ways:
2139 @example
2140 #(set-default-paper-size "a6")
2142 \paper @{
2143 #(set-paper-size "letter")
2145 @end example
2147 @noindent
2148 The first command sets the size of all pages. The second command
2149 sets the size of the pages to which the \paper block applies -- if
2150 the \paper block is at the top of the file, then it will apply
2151 to all pages.  Support for the following paper sizes is available:
2152 a6, a5, a4, a3, legal, letter, 11x17 (also known as tabloid).
2153 Setting the paper size automatically sets suitable margins and
2154 line length.
2156 If the symbol @code{landscape} is supplied as an argument to
2157 @code{set-default-paper-size}, the pages will be rotated by 90
2158 degrees, and wider line widths will be set correspondingly, e.g.
2160 @example
2161 #(set-default-paper-size "a6" 'landscape)
2162 @end example
2164 The default @strong{staff size} is set to 20 points.
2165 This may be changed in two ways:
2167 @example
2168 #(set-global-staff-size 14)
2170 \paper @{
2171 #(set-global-staff-size 16)
2173 @end example
2175 @noindent
2176 The first command sets the size in all pages. The second command
2177 sets the size in the pages to which the \paper block applies -– if
2178 the \paper block is at the top of the file, then it will apply
2179 to all pages.  All the fonts are automatically scaled to suit
2180 the new value of the staff size.
2182 @node Line breaks
2183 @subsection Line breaks
2185 Line breaks are normally determined automatically. They are chosen
2186 so that lines look neither cramped nor loose, and consecutive
2187 lines have similar density.  Occasionally you might want to
2188 override the automatic breaks; you can do this by specifying
2189 @code{\break}. This will force a line break at this point.  However,
2190 line breaks can only occur at the end of @q{complete} bars, i.e.,
2191 where there are no notes or tuplets left @q{hanging} over the bar
2192 line.  If you want to have a line break where there is no bar line,
2193 you can force an invisible bar line by entering @code{\bar ""},
2194 although again there must be no notes left hanging over in any of
2195 the staves at this point, or it will be ignored.
2197 The opposite command, @code{\noBreak}, forbids a line break at the
2198 bar line where it is inserted.
2200 The most basic settings influencing line spacing are @code{indent}
2201 and @code{line-width}. They are set in the @code{\layout} block.
2202 They control the indentation of the first line of music, and the
2203 lengths of the lines.
2205 If @code{ragged-right} is set to true in the @code{\layout} block,
2206 then systems end at their natural horizontal length, instead of
2207 being spread horizontally to fill the whole line. This is useful
2208 for short fragments, and for checking how tight the natural
2209 spacing is.
2211 The option @code{ragged-last} is similar to @code{ragged-right},
2212 but affects only the last line of the piece.
2214 @example
2215 \layout @{
2216 indent = #0
2217 line-width = #150
2218 ragged-last = ##t
2220 @end example
2222 @node Page breaks
2223 @subsection Page breaks
2225 The default page breaking may be overridden by inserting 
2226 @code{\pageBreak} or @code{\noPageBreak} commands.
2227 These commands are analogous to the @code{\break} and 
2228 @code{\noBreak} commands discussed above and force or forbid 
2229 a page-break at the point where they are inserted.
2230 Of course, the @code{\pageBreak} command also forces a line break.
2231 Like @code{\break}, the @code{\pageBreak} command is effective only
2232 at the end of a @q{complete} bar as defined above.  For more
2233 details see @ref{Page breaking} and following sections.
2235 There are also analogous settings to @code{ragged-right} and
2236 @code{ragged-last} which have the same effect on vertical spacing:
2237 @code{ragged-bottom} and @code{ragged-last-bottom}.  If set to
2238 @code{##t} the systems on all pages or just the last page
2239 respectively will not be justified vertically.
2241 For more details see @ref{Vertical spacing}.
2243 @node Fitting music onto fewer pages
2244 @subsection Fitting music onto fewer pages
2246 Sometimes you can end up with one or two staves on a second
2247 (or third, or fourth...) page.  This is annoying, especially
2248 if you look at previous pages and it looks like there is plenty
2249 of room left on those.
2251 When investigating layout issues, @code{annotate-spacing} is
2252 an invaluable tool.  This command prints the values of various
2253 layout spacing commands; see @ref{Displaying spacing}, for more
2254 details.  From the output of @code{annotate-spacing}, we can
2255 see which margins we may wish to alter.
2257 Other than margins, there are a few other options to save space:
2259 @itemize
2260 @item
2261 You may tell LilyPond to place systems as close together as
2262 possible (to fit as many systems as possible onto a page), but
2263 then to space those systems out so that there is no blank
2264 space at the bottom of the page.
2266 @example
2267 \paper @{
2268   between-system-padding = #0.1
2269   between-system-space = #0.1
2270   ragged-last-bottom = ##f
2271   ragged-bottom = ##f
2273 @end example
2275 @item
2276 You may force the number of systems (i.e., if LilyPond wants
2277 to typeset some music with 11 systems, you could force it to
2278 use 10).
2280 @example
2281 \paper @{
2282   system-count = #10
2284 @end example
2286 @item
2287 Avoid (or reduce) objects which increase the vertical size of
2288 a system.  For example, volta repeats (or alternate repeats)
2289 require extra space.  If these repeats are spread over two
2290 systems, they will take up more space than one system with
2291 the volta repeats and another system without.
2293 Another example is moving dynamics which @q{stick out} of
2294 a system, as in the second bar here:
2296 @lilypond[verbatim,quote,fragment,ragged-right,relative=1]
2297 e4 c g\f c
2298 \override DynamicText #'extra-offset = #'( -2.2 . 2.0)
2299 e4 c g\f c
2300 @end lilypond
2302 @item
2303 Alter the horizontal spacing via @code{SpacingSpanner}.  See
2304 @ref{Changing horizontal spacing}, for more details.  Here's
2305 an example first showing the default behavior:
2307 @lilypond[verbatim,quote,ragged-right]
2308 \score {
2309   \relative c'' {
2310     g4 e e2 |
2311     f4 d d2 |
2312     c4 d e f |
2313     g4 g g2 |
2314     g4 e e2 |
2315   }
2317 @end lilypond
2319 @noindent
2320 and now with @code{common-shortest-duration} increased from the
2321 value of @code{1/4} (a quarter note is the most common in this
2322 example) to @code{1/2}:
2324 @lilypond[verbatim,quote,ragged-right]
2325 \score {
2326   \relative c'' {
2327     g4 e e2 |
2328     f4 d d2 |
2329     c4 d e f |
2330     g4 g g2 |
2331     g4 e e2 |
2332   }
2333   \layout {
2334     \context {
2335       \Score
2336       \override SpacingSpanner
2337                 #'common-shortest-duration = #(ly:make-moment 1 2)
2338     }
2339   }
2341 @end lilypond
2343 @noindent
2344 Note that this override cannot be modified dynamically, so it must
2345 always be placed in a @code{\context@{..@}} block so that it applies
2346 to the whole score.
2348 TODO Add description of using \context in this way earlier if it is
2349 not already anywhere  -td
2351 @end itemize