]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/page.itely
Minor fixes from mailist.
[lilypond.git] / Documentation / user / page.itely
1 @c -*- coding: utf-8; mode: texinfo; -*-
2 @c This file is part of lilypond.tely
3
4 @c A menu is needed before every deeper *section nesting of @node's; run
5 @c     M-x texinfo-all-menus-update
6 @c to automatically fill in these menus before saving changes
7
8 @node Spacing issues
9 @chapter Spacing issues
10
11 The global paper layout is determined by three factors: the page layout, the
12 line breaks, and the spacing.  These all influence each other.  The
13 choice of spacing determines how densely each system of music is set.
14 This influences where line breaks are chosen, and thus ultimately, how
15 many pages a piece of music takes.
16
17 Globally spoken, this procedure happens in three steps: first,
18 flexible distances (``springs'') are chosen, based on durations.  All
19 possible line breaking combinations are tried, and the one with the
20 best results -- a layout that has uniform density and requires as
21 little stretching or cramping as possible -- is chosen.
22
23 After spacing and linebreaking, the systems are distributed across
24 pages, taking into account the size of the page, and the size of the
25 titles.
26
27 @menu
28 * Paper and pages::             
29 * Music layout::                
30 * Vertical spacing::            
31 * Horizontal spacing::          
32 * Breaks::                      
33 * Displaying spacing::          
34 @end menu
35
36
37 @node Paper and pages
38 @section Paper and pages
39
40 This section deals with the boundaries that define the area
41 that music can be printed inside.
42
43 @menu
44 * Paper size::                  
45 * Page formatting::             
46 @end menu
47
48
49 @node Paper size
50 @subsection Paper size
51
52 @cindex paper size
53 @cindex page size
54 @funindex papersize
55
56 To change the paper size, there are two commands,
57 @example
58 #(set-default-paper-size "a4")
59 \paper @{
60   #(set-paper-size "a4")
61 @}
62 @end example
63
64 The first command sets the size of all pages.  The second command sets the
65 size
66 of the pages that the @code{\paper} block applies to -- if the @code{\paper}
67 block is at the top of the file, then it will apply to all pages.  If the
68 @code{\paper} block is inside a @code{\book}, then the paper size will only
69 apply to that book.
70
71 Support for the following paper sizes are included by default,
72 @code{a6}, @code{a5}, @code{a4}, @code{a3}, @code{legal}, @code{letter},
73 @code{11x17} (also known as tabloid).
74
75 Extra sizes may be added by editing the definition for
76 @code{paper-alist} in the initialization file @file{scm/paper.scm}.
77
78 @cindex orientation
79 @cindex landscape
80
81 If the symbol @code{landscape} is supplied as an argument to
82 @code{set-default-paper-size}, the pages will be rotated by 90 degrees,
83 and wider line widths will be set correspondingly.
84
85 @example
86 #(set-default-paper-size "a6" 'landscape)
87 @end example
88
89 Setting the paper size will adjust a number of @code{\paper} variables
90 (such as margins).  To use a particular paper size with altered
91 @code{\paper} variables, set the paper size before setting the variables.
92
93
94 @node Page formatting
95 @subsection Page formatting
96
97 @cindex page formatting
98 @cindex margins
99 @cindex header, page
100 @cindex footer, page
101
102 LilyPond will do page layout, set margins, and add headers and
103 footers to each page.
104
105 The default layout responds to the following settings in the
106 @code{\paper} block.
107
108 @funindex \paper
109
110 @quotation
111 @table @code
112 @funindex first-page-number
113 @item first-page-number
114 The value of the page number of the first page.  Default is@tie{}1.
115
116 @funindex printfirst-page-number
117 @item printfirst-page-number
118 If set to true, will print the page number in the first page.  Default is
119 false.
120
121 @funindex print-page-number
122 @item print-page-number
123 If set to false, page numbers will not be printed.
124
125 @funindex paper-width
126 @item paper-width
127 The width of the page.
128
129 @funindex paper-height
130 @item paper-height
131 The height of the page.
132
133 @funindex top-margin
134 @item top-margin
135 Margin between header and top of the page.
136
137 @funindex bottom-margin
138 @item bottom-margin
139 Margin between footer and bottom of the page.
140
141 @funindex left-margin
142 @item left-margin
143 Margin between the left side of the page and the beginning of the music.
144
145 @funindex line-width
146 @item line-width
147 The length of the systems.
148
149 @funindex head-separation
150 @item head-separation
151 Distance between the top-most music system and the page header.
152
153 @funindex foot-separation
154 @item foot-separation
155 Distance between the bottom-most music system and the page footer.
156
157 @funindex page-top-space
158 Distance from the top of the printable area to the center of the first
159 staff. This only works for staves which are vertically small. Big staves
160 are set with the top of their bounding box aligned to the top of the
161 printable area.
162
163 @funindex ragged-bottom
164 @item ragged-bottom
165 If set to true, systems will not be spread vertically across the page.  This
166 does not affect the last page.
167
168 This should be set to true for pieces that have only two or three
169 systems per page, for example orchestral scores.
170
171 @funindex ragged-last-bottom
172 @item ragged-last-bottom
173 If set to false, systems will be spread vertically to fill the last page.
174
175 Pieces that amply fill two pages or more should have this set to
176 true.
177
178 @funindex system-count
179 @item system-count
180 This variable, if set, specifies into how many lines a score should be
181 broken.
182
183 @funindex between-system-space
184 @item between-system-space
185 This dimensions determines the distance between systems.  It is the
186 ideal distance between the center of the bottom staff of one system
187 and the center of the top staff of the next system.
188
189 Increasing this will provide a more even appearance of the page at the
190 cost of using more vertical space.
191
192 @funindex between-system-padding
193 @item between-system-padding
194 This dimension is the minimum amount of white space that will always
195 be present between the bottom-most symbol of one system, and the
196 top-most of the next system.
197
198 Increasing this will put systems whose bounding boxes almost touch
199 farther apart.
200
201
202 @funindex horizontal-shift
203 @item horizontal-shift
204 All systems (including titles and system separators) are shifted by
205 this amount to the right. Page markup, such as headers and footers are
206 not affected by this. The purpose of this variable is to make space
207 for instrument names at the left.
208
209 @funindex after-title-space
210 @item after-title-space
211 Amount of space between the title and the first system.
212
213 @funindex after-title-space
214 @item before-title-space
215 Amount of space between the last system of the previous piece and the
216 title of the next.
217
218 @funindex between-title-space
219 @item between-title-space
220 Amount of space between consecutive titles (e.g., the title of the
221 book and the title of a piece).
222
223 @funindex printallheaders
224 @item printallheaders
225 Setting this to #t will print all headers for each \score in a
226 \book.  Normally only the piece and opus \headers are printed.
227
228 @funindex systemSeparatorMarkup
229 @item systemSeparatorMarkup
230 This contains a markup object, which will be inserted between
231 systems.  This is often used for orchestral scores.
232
233 The markup command @code{\slashSeparator} is provided as a sensible
234 default,  for example
235
236 @lilypond[ragged-right]
237 \book {
238   \score {
239     \relative { c1 \break c1 }
240   }
241   \paper {
242     systemSeparatorMarkup = \slashSeparator
243   }
244 }
245 @end lilypond
246
247
248 @end table
249 @end quotation
250
251 Example:
252
253 @example
254 \paper@{
255   paper-width = 2\cm
256   top-margin = 3\cm
257   bottom-margin = 3\cm
258   ragged-last-bottom = ##t
259 @}
260 @end example
261
262 You can also define these values in Scheme.  In that case @code{mm},
263 @code{in}, @code{pt}, and @code{cm} are variables defined in
264 @file{paper-defaults.ly} with values in millimeters.  That is why the
265 value must be multiplied in the example
266
267 @example
268 \paper @{
269   #(define bottom-margin (* 2 cm))
270 @}
271 @end example
272
273 The header and footer are created by the functions @code{make-footer}
274 and @code{make-header}, defined in @code{\paper}.  The default
275 implementations are in @file{ly/@/paper@/-defaults@/.ly} and
276 @file{ly/@/titling@/-init@/.ly}.
277
278 The page layout itself is done by two functions in the
279 @code{\paper} block, @code{page-music-height} and
280 @code{page-make-stencil}.  The former tells the line-breaking algorithm
281 how much space can be spent on a page, the latter creates the actual
282 page given the system to put on it.
283
284
285 @refbugs
286
287 The option right-margin is defined but doesn't set the right margin
288 yet.  The value for the right margin has to be defined adjusting the
289 values of @code{left-margin} and @code{line-width}.
290
291 The default page header puts the page number and the @code{instrument}
292 field from the @code{\header} block on a line.
293
294 The titles (from the @code{\header@{@}} section) are treated as a
295 system, so @code{ragged-bottom} and @code{ragged-last-bottom} will
296 add space between the titles and the first system of the score.
297
298
299 @node Music layout
300 @section Music layout
301
302 @menu
303 * Setting global staff size::   
304 * Score layout::                
305 @end menu
306
307
308 @node Setting global staff size
309 @subsection Setting global staff size
310
311 @cindex font size, setting
312 @cindex staff size, setting
313 @funindex layout file
314
315 To set the global staff size, use @code{set-global-staff-size}.
316
317 @example
318 #(set-global-staff-size 14)
319 @end example
320
321 @noindent
322 This sets the global default size to 14pt staff height and scales all
323 fonts accordingly.
324
325 The Feta font provides musical symbols at eight different
326 sizes.  Each font is tuned for a different staff size: at a smaller size
327 the font becomes heavier, to match the relatively heavier staff lines.
328 The recommended font sizes are listed in the following table:
329
330 @quotation
331 @multitable @columnfractions .15 .2 .22 .2
332
333 @item @b{font name}
334 @tab @b{staff height (pt)}
335 @tab @b{staff height (mm)}
336 @tab @b{use}
337
338 @item feta11
339 @tab 11.22
340 @tab 3.9
341 @tab pocket scores
342
343 @item feta13
344 @tab 12.60
345 @tab 4.4
346 @tab
347
348 @item feta14
349 @tab 14.14
350 @tab 5.0
351 @tab
352
353 @item feta16
354 @tab 15.87
355 @tab 5.6
356 @tab
357
358 @item feta18
359 @tab 17.82
360 @tab 6.3
361 @tab song books
362
363 @item feta20
364 @tab 20
365 @tab 7.0
366 @tab standard parts
367
368 @item feta23
369 @tab 22.45
370 @tab 7.9
371 @tab
372
373 @item feta26
374 @tab 25.2
375 @tab 8.9
376 @tab
377 @c modern rental material?
378
379 @end multitable
380 @end quotation
381
382 These fonts are available in any sizes.  The context property
383 @code{fontSize} and the layout property @code{staff-space} (in
384 @internalsref{StaffSymbol}) can be used to tune the size for individual
385 staves.  The sizes of individual staves are relative to the global size.
386
387 @example
388
389 @end example
390
391 @seealso
392
393 This manual: @ref{Selecting notation font size}.
394
395
396 @node Score layout
397 @subsection Score layout
398
399 @funindex \layout
400
401 While @code{\paper} contains settings that relate to the page formatting
402 of the whole document, @code{\layout} contains settings for score-specific
403 layout.
404
405 @example
406 \layout @{
407   indent = 2.0\cm
408   \context @{ \Staff
409     \override VerticalAxisGroup #'minimum-Y-extent = #'(-6 . 6)
410   @}
411   \context @{ \Voice
412     \override TextScript #'padding = #1.0
413     \override Glissando #'thickness = #3
414   @}
415 @}
416 @end example
417
418
419 @seealso
420
421 This manual: @ref{Changing context default settings}
422
423
424 @node Vertical spacing
425 @section Vertical spacing
426
427 @cindex vertical spacing
428 @cindex spacing, vertical
429
430 Vertical spacing is controlled by three things: the amount of
431 space available (i.e., paper size and margins), the amount of
432 space between systems, and the amount of space between
433 staves inside a system.
434
435 @menu
436 * Vertical spacing inside a system::  
437 * Vertical spacing of piano staves::  
438 * Vertical spacing between systems::  
439 * Controlling spacing of individual systems::  
440 @end menu
441
442
443 @node Vertical spacing inside a system
444 @subsection Vertical spacing inside a system
445
446 @cindex distance between staves
447 @cindex staff distance
448 @cindex space between staves
449 @cindex space inside systems
450
451 The height of each system is determined automatically.  To prevent
452 staves from bumping into each other, some minimum distances are set.
453 By changing these, you can put staves closer together.  This
454 reduces the amount of space each system requires, and may result
455 in having more systems per page.
456
457 Normally staves are stacked vertically.  To make staves maintain a
458 distance, their vertical size is padded.  This is done with the
459 property @code{minimum-Y-extent}.  When applied to a
460 @internalsref{VerticalAxisGroup}, it controls the size of a horizontal
461 line, such as a staff or a line of lyrics.  @code{minimum-Y-extent}
462 takes a pair of numbers, so
463 if you want to make it smaller than its default @code{#'(-4 . 4)}
464 then you could set
465
466 @example
467 \override Staff.VerticalAxisGroup #'minimum-Y-extent = #'(-3 . 3)
468 @end example
469
470 @noindent
471 This sets the vertical size of the current staff to 3 staff spaces on
472 either side of the center staff line.  The value @code{(-3 . 3)} is
473 interpreted as an interval, where the center line is the 0, so the
474 first number is generally negative.  The numbers need not match;
475 for example, the staff can be made larger at the bottom by setting
476 it to @code{(-6 . 4)}.
477
478
479 @seealso
480
481 Internals: Vertical alignment of staves is handled by the
482 @internalsref{VerticalAlignment} object. The context parameters
483 specifying the vertical extent are described in connection with
484 the @internalsref{Axis_group_engraver}.
485
486 Example files: @inputfileref{input/regression/,page-spacing.ly},
487 @inputfileref{input/regression/,alignment-vertical-spacing.ly}.
488
489
490 @node Vertical spacing of piano staves
491 @subsection Vertical spacing of piano staves
492
493 The distance between staves of a @internalsref{PianoStaff} cannot be
494 computed during formatting.  Rather, to make cross-staff beaming work
495 correctly, that distance has to be fixed beforehand.
496
497 The distance of staves in a @code{PianoStaff} is set with the
498 @code{forced-distance} property of the
499 @internalsref{VerticalAlignment} object, created in
500 @internalsref{PianoStaff}.
501
502 It can be adjusted as follows
503 @example
504 \new PianoStaff \with @{
505   \override VerticalAlignment #'forced-distance = #7
506 @} @{
507   ...
508 @}
509 @end example
510
511 @noindent
512 This would bring the staves together at a distance of 7 staff spaces,
513 measured from the center line of each staff.
514
515 The difference is demonstrated in the following example,
516 @lilypond[quote,verbatim]
517 \relative c'' <<
518   \new PianoStaff \with {
519     \override VerticalAlignment #'forced-distance = #7
520   } <<
521     \new Staff { c1 }
522     \new Staff { c }
523   >>
524   \new PianoStaff <<
525     \new Staff { c }
526     \new Staff { c }
527   >>
528 >>
529 @end lilypond
530
531
532 @seealso
533
534 Example files: @inputfileref{input/regression/,alignment-vertical-spacing.ly}.
535
536
537 @node Vertical spacing between systems
538 @subsection Vertical spacing between systems
539
540 Space between systems are controlled by four @code{\paper} variables,
541
542 @example
543 \paper @{
544   between-system-space = 1.5\cm
545   between-system-padding = #1
546   ragged-bottom=##f
547   ragged-last-bottom=##f
548 @}
549 @end example
550
551
552 @node Controlling spacing of individual systems
553 @subsection Controlling spacing of individual systems
554
555 It is also possible to change the distance between for each system
556 individually.  This is done by including the command
557
558 @example
559 \overrideProperty
560 #"Score.NonMusicalPaperColumn"
561 #'line-break-system-details
562 #'((fixed-alignment-extra-space . 15))
563 @end example
564
565 @noindent
566 at the line break before the system to be changed. The distance
567 @code{15} is distributed over all staves that have a fixed distance
568 alignment.  For example,
569
570 @lilypond[ragged-right, fragment, relative=2, staffsize=13]
571 \new PianoStaff <<
572   \new Staff {
573     c1\break
574   
575     \overrideProperty
576     #"Score.NonMusicalPaperColumn"
577     #'line-break-system-details
578     #'((fixed-alignment-extra-space . 15))
579
580     c\break
581   }
582   \new Staff { c c }
583 >>
584 @end lilypond
585
586 The distance for @code{fixed-alignment-extra-space} may also be
587 negative.
588
589
590
591 @node Horizontal spacing
592 @section Horizontal Spacing
593
594 @cindex horizontal spacing
595 @cindex spacing, horizontal
596
597 @menu
598 * Horizontal spacing overview::  
599 * New spacing area::            
600 * Changing horizontal spacing::  
601 * Line length::                 
602 @end menu
603
604
605 @node Horizontal spacing overview
606 @subsection Horizontal spacing overview
607
608 The spacing engine translates differences in durations into stretchable
609 distances (``springs'') of differring lengths.  Longer durations get
610 more space, shorter durations get less.  The shortest durations get a
611 fixed amount of space (which is controlled by
612 @code{shortest-duration-space} in the @internalsref{SpacingSpanner}
613 object).  The longer the duration, the more space it gets: doubling a
614 duration adds a fixed amount (this amount is controlled by
615 @code{spacing-increment}) of space to the note.
616
617 For example, the following piece contains lots of half, quarter, and
618 8th notes; the eighth note is followed by 1 note head width (NHW).
619 The quarter note is followed by 2 NHW, the half by 3 NHW, etc.
620
621 @lilypond[quote,fragment,verbatim,relative=1]
622 c2 c4. c8 c4. c8 c4. c8 c8
623 c8 c4 c4 c4
624 @end lilypond
625
626 Normally, @code{spacing-increment} is set to 1.2 staff space, which is
627 approximately the width of a note head, and
628 @code{shortest-duration-space} is set to 2.0, meaning that the
629 shortest note gets 2.4 staff space (2.0 times the
630 @code{spacing-increment}) of horizontal space.  This space is counted
631 from the left edge of the symbol, so the shortest notes are generally
632 followed by one NHW of space.
633
634 If one would follow the above procedure exactly, then adding a single
635 32nd note to a score that uses 8th and 16th notes, would widen up the
636 entire score a lot.  The shortest note is no longer a 16th, but a 32nd,
637 thus adding 1 NHW to every note.  To prevent this, the shortest
638 duration for spacing is not the shortest note in the score, but rather
639 the one which occurs most frequently.
640
641
642 The most common shortest duration is determined as follows: in every
643 measure, the shortest duration is determined.  The most common shortest
644 duration is taken as the basis for the spacing, with the stipulation
645 that this shortest duration should always be equal to or shorter than
646 an 8th note.  The shortest duration is printed when you run
647 @code{lilypond} with the @code{--verbose} option.
648
649 These durations may also be customized.  If you set the
650 @code{common-shortest-duration} in @internalsref{SpacingSpanner}, then
651 this sets the base duration for spacing.  The maximum duration for this
652 base (normally an 8th), is set through @code{base-shortest-duration}.
653
654 @funindex common-shortest-duration
655 @funindex base-shortest-duration
656 @funindex stem-spacing-correction
657 @funindex spacing
658
659 Notes that are even shorter than the common shortest note are
660 followed by a space that is proportional to their duration relative to
661 the common shortest note.  So if we were to add only a few 16th notes
662 to the example above, they would be followed by half a NHW:
663
664 @lilypond[quote,fragment,verbatim,relative=2]
665 c2 c4. c8 c4. c16[ c] c4. c8 c8 c8 c4 c4 c4
666 @end lilypond
667
668
669 In the introduction (see @ref{Engraving}), it was explained that stem
670 directions influence spacing.  This is controlled with the
671 @code{stem-spacing-correction} property in the
672 @internalsref{NoteSpacing}, object.  These are generated for every
673 @internalsref{Voice} context.  The @code{StaffSpacing} object
674 (generated in @internalsref{Staff} context) contains the same property
675 for controlling the stem/bar line spacing.  The following example shows
676 these corrections, once with default settings, and once with
677 exaggerated corrections:
678
679 @lilypond[quote,ragged-right]
680 {
681   c'4 e''4 e'4 b'4 |
682   b'4 e''4 b'4 e''4|
683   \override Staff.NoteSpacing #'stem-spacing-correction = #1.5
684   \override Staff.StaffSpacing #'stem-spacing-correction = #1.5
685   c'4 e''4 e'4 b'4 |
686   b'4 e''4 b'4 e''4|
687 }
688 @end lilypond
689
690 Proportional notation is supported; see @ref{Proportional notation}.
691
692
693 @seealso
694
695 Internals: @internalsref{SpacingSpanner}, @internalsref{NoteSpacing},
696 @internalsref{StaffSpacing}, @internalsref{SeparationItem}, and
697 @internalsref{SeparatingGroupSpanner}.
698
699
700 @refbugs
701
702 There is no convenient mechanism to manually override spacing.  The
703 following work-around may be used to insert extra space into a score.
704 @example
705  \once \override Score.SeparationItem #'padding = #1
706 @end example
707
708 No work-around exists for decreasing the amount of space.
709
710
711 @node New spacing area
712 @subsection New spacing area
713
714 New sections with different spacing parameters can be started with
715 @code{newSpacingSection}.  This is useful when there are  
716 sections with a different notions of long and short notes.
717
718 In the following example, the time signature change introduces a new
719 section, and hence the 16ths notes are spaced wider.
720
721 FIXME: wait until we're definitely adding NEWS items.  -gp
722
723 @lilypond[relative,fragment,verbatim]
724 \time 2/4
725 c4 c8 c 
726 c8 c c4 c16[ c c8] c4
727 %\newSpacingSection
728 \time 4/16
729 c16[ c c8]
730 @end lilypond
731
732
733 @node Changing horizontal spacing
734 @subsection Changing horizontal spacing
735
736 By default, spacing in tuplets depends on various non-duration
737 factors (such as accidentals, clef changes, etc).  To disregard
738 such symbols and force uniform equal-duration spacing, use
739 @code{Score.SpacingSpanner #'uniform-stretching}.  This
740 property can only be changed at the beginning of a score,
741
742 @lilypond[quote,ragged-right,relative=2,fragment,verbatim]
743 \new Score \with {
744   \override SpacingSpanner #'uniform-stretching = ##t
745 } <<
746   \new Staff{
747     \times 4/5 {
748       c8 c8 c8 c8 c8
749     }
750     c8 c8 c8 c8
751   }
752   \new Staff{
753     c8 c8 c8 c8
754     \times 4/5 {
755       c8 c8 c8 c8 c8
756     }
757   }
758 >>
759 @end lilypond
760
761
762 When @code{strict-note-spacing} is set, notes are spaced without
763 regard for clefs, bar lines, and grace notes,
764
765 @lilypond[quote,ragged-right,relative=2,fragment,verbatim]
766 \override Score.SpacingSpanner #'strict-note-spacing = ##t
767 \new Staff { c8[ c \clef alto c \grace { c16[ c] } c8 c c]  c32[ c32] }
768 @end lilypond
769
770
771 @node Line length
772 @subsection Line length
773
774 @cindex page breaks
775 @cindex breaking pages
776
777 @funindex indent
778 @funindex line-width
779 @funindex ragged-right
780 @funindex ragged-last
781
782 @c Although line-width can be set in \layout, it should be set in paper
783 @c block, to get page layout right.
784 @c Setting indent in \paper block makes not much sense, but it works.
785
786 @c Bit verbose and vague, use examples?
787 The most basic settings influencing the spacing are @code{indent} and
788 @code{line-width}.  They are set in the @code{\layout} block.  They
789 control the indentation of the first line of music, and the lengths of
790 the lines.
791
792 If @code{ragged-right} is set to true in the @code{\layout} block, then
793 systems ends at their natural horizontal length, instead of being spread
794 horizontally to fill the whole line.  This is useful for
795 short fragments, and for checking how tight the natural spacing is.
796
797 @cindex page layout
798 @cindex vertical spacing
799
800 The option @code{ragged-last} is similar to @code{ragged-right}, but
801 only affects the last line of the piece.  No restrictions are put on
802 that line.  The result is similar to formatting text paragraphs.  In a
803 paragraph, the last line simply takes its natural horizontal length.
804 @c Note that for text there are several options for the last line.
805 @c While Knuth TeX uses natural length, lead typesetters use the same
806 @c stretch as the previous line.  eTeX uses \lastlinefit to
807 @c interpolate between both these solutions.
808
809 @example
810 \layout @{
811   indent = #0
812   line-width = #150
813   ragged-last = ##t
814 @}
815 @end example
816
817
818 @node Breaks
819 @section Breaks
820
821 @menu
822 * Line breaking::               
823 * Page breaking::               
824 @end menu
825
826 @node Line breaking
827 @subsection Line breaking
828
829 @cindex line breaks
830 @cindex breaking lines
831
832 Line breaks are normally computed automatically.  They are chosen so
833 that lines look neither cramped nor loose, and that consecutive lines
834 have similar density.
835
836 Occasionally you might want to override the automatic breaks; you can
837 do this by specifying @code{\break}.  This will force a line break at
838 this point.  Line breaks can only occur at places where there are bar
839 lines.  If you want to have a line break where there is no bar line,
840 you can force an invisible bar line by entering @code{\bar
841 ""}.  Similarly, @code{\noBreak} forbids a line break at a
842 point.
843
844
845 @cindex regular line breaks
846 @cindex four bar music.
847
848 For line breaks at regular intervals use @code{\break} separated by
849 skips and repeated with @code{\repeat}:
850 @example
851 << \repeat unfold 7 @{
852          s1 \noBreak s1 \noBreak
853          s1 \noBreak s1 \break @}
854    @emph{the real music}
855 >>
856 @end example
857
858 @noindent
859 This makes the following 28 measures (assuming 4/4 time) be broken every
860 4 measures, and only there.
861
862 @refcommands
863
864 @code{\break}, and @code{\noBreak}.
865 @funindex \break
866 @funindex \noBreak
867
868 @seealso
869
870 Internals: @internalsref{BreakEvent}.
871
872 A linebreaking configuration can now be saved as a @code{.ly} file
873 automatically.  This allows vertical alignments to be stretched to
874 fit pages in a second formatting run.  This is fairly new and
875 complicated; see @inputfileref{input/regression/,page-layout-twopass.ly}
876 for details.
877
878 @refbugs
879
880 Line breaks can only occur if there is a ``proper'' bar line.  A note
881 which is hanging over a bar line is not proper, such as
882
883 @lilypond[quote,ragged-right,relative=2,fragment,verbatim]
884 c4 c2 c2 \break   % this does nothing
885 c2 c4 |           % a break here would work
886 c4 c2 c4 ~ \break % as does this break
887 c4 c2 c4
888 @end lilypond
889
890
891 @node Page breaking
892 @subsection Page breaking
893
894 The default page breaking may be overriden by inserting
895 @code{\pageBreak} or @code{\noPageBreak} commands.  These commands are
896 analogous to @code{\break} and @code{\noBreak}.  They should be
897 inserted at a bar line.  These commands force and forbid a page-break
898 from happening.  Of course, the @code{\pageBreak} command also forces
899 a line break.
900
901 Page breaks are computed by the @code{page-breaking} function in the
902 @code{\paper} block.
903
904 To force a new page for a new piece (in a collection of pieces or a
905 piece in several movements), use @code{breakbefore} in the header.
906
907 @example
908 \header@{
909   breakbefore = ##t
910   piece = ""
911 @}
912 @end example
913
914 @refcommands
915
916 @funindex \pageBreak
917 @code{\pageBreak}
918 @funindex \noPageBreak
919 @code{\noPageBreak}
920
921
922 @refbugs
923
924 The @code{breakbefore=##t} header requires that there is a @code{piece}
925 header as well.  It may be used as a normal header, or left  blank
926 (@code{=""}) as in the example above, but it must be present.
927
928
929 @node Displaying spacing
930 @section Displaying spacing
931
932 @funindex annotate-spacing
933 @cindex Spacing, display of properties
934
935 To graphically display the dimensions of vertical properties
936 that may be altered for page formatting, use
937
938 @lilypond[verbatim]
939 \paper { annotate-spacing = ##t }
940 { c4 }
941 @end lilypond
942
943 @noindent
944 @c  FIXME: really bad vagueness due to bug in annotate-spacing.  -gp
945 Some unit dimensions are measured in staff spaces, while others
946 are measured in millimeters.
947 The pairs
948 (@var{a},@var{b}) are intervals, where @var{a} is the lower edge and
949 @var{b} the upper edge of the interval.
950
951