1 @c -*- coding: latin-1; mode: texinfo; -*-
2 @c This file is part of lilypond.tely
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
11 This is a placeholder until I can write a nice intro for this chapter.
21 @section Global layout
23 The global layout is determined by three factors: the page layout, the
24 line breaks, and the spacing. These all influence each other. The
25 choice of spacing determines how densely each system of music is set.
26 This influences where line breaks are chosen, and thus ultimately, how
27 many pages a piece of music takes.
29 Globally spoken, this procedure happens in three steps: first,
30 flexible distances (``springs'') are chosen, based on durations. All
31 possible line breaking combinations are tried, and the one with the
32 best results -- a layout that has uniform density and requires as
33 little stretching or cramping as possible -- is chosen.
35 After spacing and linebreaking, the systems are distributed across
36 pages, taking into account the size of the page, and the size of the
42 * Setting global staff size::
46 * Vertical spacing of piano staves::
47 * Horizontal spacing::
51 * Multiple movements::
56 @node Setting global staff size
57 @subsection Setting global staff size
59 @cindex font size, setting
60 @cindex staff size, setting
61 @cindex @code{layout} file
63 To set the global staff size, use @code{set-global-staff-size}.
66 #(set-global-staff-size 14)
70 This sets the global default size to 14pt staff height and scales all
73 The Feta font provides musical symbols at eight different
74 sizes. Each font is tuned for a different staff size: at a smaller size
75 the font becomes heavier, to match the relatively heavier staff lines.
76 The recommended font sizes are listed in the following table:
79 @multitable @columnfractions .15 .2 .22 .2
82 @tab @b{staff height (pt)}
83 @tab @b{staff height (mm)}
125 @c modern rental material?
130 These fonts are available in any sizes. The context property
131 @code{fontSize} and the layout property @code{staff-space} (in
132 @internalsref{StaffSymbol}) can be used to tune the size for individual
133 staves. The sizes of individual staves are relative to the global size.
141 This manual: @ref{Selecting font sizes}.
145 @subsection Paper size
149 @cindex @code{papersize}
151 To change the paper size, there are two equal commands,
153 #(set-default-paper-size "a4")
155 #(set-paper-size "a4")
159 The first command sets the size of all pages. The second command sets the size
160 of the pages that the @code{\paper} block applies to -- if the @code{\paper}
161 block is at the top of the file, then it will apply to all pages. If the
162 @code{\paper} block is inside a @code{\score}, then the paper size will only
165 The following paper sizes are supported: @code{a6}, @code{a5}, @code{a4},
166 @code{a3}, @code{legal}, @code{letter}, @code{tabloid}.
171 If the symbol @code{landscape} is supplied as an argument to
172 @code{set-default-paper-size}, the pages will be rotated by 90 degrees,
173 and wider line widths will be set correspondingly.
176 #(set-default-paper-size "a6" 'landscape)
181 @subsection Page layout
188 LilyPond will do page layout, set margins, and add headers and
189 footers to each page.
191 The default layout responds to the following settings in the
198 @item firstpagenumber
199 The value of the page number of the first page. Default is@tie{}1.
201 @item printfirstpagenumber
202 If set to true, will print the page number in the first page. Default is
206 The width of the page.
209 The height of the page.
212 Margin between header and top of the page.
215 Margin between footer and bottom of the page.
218 Margin between the left side of the page and the beginning of the music.
221 The length of the systems.
224 Distance between the top-most music system and the page header.
227 Distance between the bottom-most music system and the page footer.
230 If set to true, systems will not be spread across the page.
232 This should be set false for pieces that have only two or three
233 systems per page, for example orchestral scores.
235 @item raggedlastbottom
236 If set to false, systems will be spread to fill the last page.
238 Pieces that amply fill two pages or more should have this set to
241 @item betweensystemspace
242 This dimensions determines the distance between systems. It is the
243 ideal distance between the center of the bottom staff of one system
244 and the center of the top staff of the next system.
246 Increasing this will provide a more even appearance of the page at the
247 cost of using more vertical space.
249 @item betweensystempadding
250 This dimension is the minimum amount of white space that will always
251 be present between the bottom-most symbol of one system, and the
252 top-most of the next system.
254 Increasing this will put systems whose bounding boxes almost touch
257 @item aftertitlespace
258 Amount of space between the title and the first system.
260 @item beforetitlespace
261 Amount of space between the last system of the previous piece and the
264 @item betweentitlespace
265 Amount of space between consecutive titles (e.g., the title of the
266 book and the title of a piece).
268 @item systemSeparatorMarkup
269 This contains a markup object, which will be inserted between
270 systems. This is often used for orchestral scores.
272 The markup command @code{\slashSeparator} is provided as a sensible
275 @lilypond[raggedright]
277 systemSeparatorMarkup = \slashSeparator
280 \relative { c1 \break c1 }
294 raggedlastbottom = ##t
298 You can also define these values in Scheme. In that case @code{mm},
299 @code{in}, @code{pt}, and @code{cm} are variables defined in
300 @file{paper-defaults.ly} with values in millimeters. That's why the
301 value has to be multiplied in the example
305 #(define bottommargin (* 2 cm))
312 The default footer is empty, except for the first page, where the
313 @code{copyright} field from @code{\header} is inserted, and the last
314 page, where @code{tagline} from @code{\header} is added. The default
315 tagline is ``Engraved by LilyPond (@var{version})''.@footnote{Nicely
316 printed parts are good PR for us, so please leave the tagline if you
319 The header and footer are created by the functions @code{make-footer}
320 and @code{make-header}, defined in @code{\paper}. The default
321 implementations are in @file{scm/@/page@/-layout@/.scm}.
323 The following settings influence the header and footer layout.
327 @item printpagenumber
328 this boolean controls whether a pagenumber is printed.
332 The page layout itself is done by two functions in the
333 @code{\paper} block, @code{page-music-height} and
334 @code{page-make-stencil}. The former tells the line-breaking algorithm
335 how much space can be spent on a page, the latter creates the actual
336 page given the system to put on it.
341 The option rightmargin is defined but doesn't set the right margin
342 yet. The value for the right margin has to be defined adjusting the
343 values of the leftmargin and linewidth.
345 The default page header puts the page number and the @code{instrument}
346 field from the @code{\header} block on a line.
349 @node Vertical spacing
350 @subsection Vertical spacing
352 @cindex vertical spacing
353 @cindex distance between staves
354 @cindex staff distance
355 @cindex between staves, distance
356 @cindex staves per page
357 @cindex space between staves
359 The height of each system is determined automatically. To prevent
360 systems from bumping into each other, some minimum distances are set.
361 By changing these, you can put staves closer together, and thus put
362 more systems onto one page.
364 Normally staves are stacked vertically. To make staves maintain a
365 distance, their vertical size is padded. This is done with the
366 property @code{minimumVerticalExtent}. It takes a pair of numbers, so
367 if you want to make it smaller than its default @code{#'(-4 . 4)},
371 \set Staff.minimumVerticalExtent = #'(-3 . 3)
375 This sets the vertical size of the current staff to 3 staff spaces on
376 either side of the center staff line. The argument of
377 @code{minimumVerticalExtent} is interpreted as an interval, where the
378 center line is the 0, so the first number is generally negative. The
379 staff can be made larger at the bottom by setting it to @code{(-6 . 4)}.
381 To change the amount of space between systems, use
382 @code{betweensystemspace}. A score with only one staff is still
383 considered to have systems, so setting @code{betweensystemspace}
384 will be much more useful than changing @code{minimumVerticalExtent}.
388 betweensystemspace = 10\mm
395 Internals: Vertical alignment of staves is handled by the
396 @internalsref{VerticalAlignment} object.
400 @code{minimumVerticalExtent} is syntactic sugar for setting
401 @code{minimum-Y-extent} of the @internalsref{VerticalAxisGroup} of the
402 current context. It can only be changed score wide.
407 @node Vertical spacing of piano staves
408 @subsection Vertical spacing of piano staves
410 The distance between staves of a @internalsref{PianoStaff} cannot be
411 computed during formatting. Rather, to make cross-staff beaming work
412 correctly, that distance has to be fixed beforehand.
414 The distance of staves in a @code{PianoStaff} is set with the
415 @code{forced-distance} property of the
416 @internalsref{VerticalAlignment} object, created in
417 @internalsref{PianoStaff}.
419 It can be adjusted as follows
421 \new PianoStaff \with @{
422 \override VerticalAlignment #'forced-distance = #7
429 This would bring the staves together at a distance of 7 staff spaces,
430 measured from the center line of each staff.
432 The difference is demonstrated in the following example,
433 @lilypond[quote,verbatim]
435 \new PianoStaff \with {
436 \override VerticalAlignment #'forced-distance = #7
452 @code{forced-distance} cannot be changed per system.
455 @node Horizontal spacing
456 @subsection Horizontal Spacing
458 The spacing engine translates differences in durations into
459 stretchable distances (``springs'') of differring lengths. Longer
460 durations get more space, shorter durations get less. The shortest
461 durations get a fixed amount of space (which is controlled by
462 @code{shortest-duration-space} in the @internalsref{SpacingSpanner} object).
463 The longer the duration, the more space it gets: doubling a
464 duration adds a fixed amount (this amount is controlled by
465 @code{spacing-increment}) of space to the note.
467 For example, the following piece contains lots of half, quarter, and
468 8th notes; the eighth note is followed by 1 note head width (NHW).
469 The quarter note is followed by 2 NHW, the half by 3 NHW, etc.
471 @lilypond[quote,fragment,verbatim,relative=1]
472 c2 c4. c8 c4. c8 c4. c8 c8
476 Normally, @code{spacing-increment} is set to 1.2 staff space, which is
477 approximately the width of a note head, and
478 @code{shortest-duration-space} is set to 2.0, meaning that the
479 shortest note gets 2.4 staff space (2.0 times the
480 @code{spacing-increment}) of horizontal space. This space is counted
481 from the left edge of the symbol, so the shortest notes are generally
482 followed by one NHW of space.
484 If one would follow the above procedure exactly, then adding a single
485 32nd note to a score that uses 8th and 16th notes, would widen up the
486 entire score a lot. The shortest note is no longer a 16th, but a 32nd,
487 thus adding 1 NHW to every note. To prevent this, the shortest
488 duration for spacing is not the shortest note in the score, but rather
489 the one which occurs most frequently.
492 The most common shortest duration is determined as follows: in every
493 measure, the shortest duration is determined. The most common shortest
494 duration is taken as the basis for the spacing, with the stipulation
495 that this shortest duration should always be equal to or shorter than
496 an 8th note. The shortest duration is printed when you run
497 @code{lilypond} with the @code{--verbose} option.
499 These durations may also be customized. If you set the
500 @code{common-shortest-duration} in @internalsref{SpacingSpanner}, then
501 this sets the base duration for spacing. The maximum duration for this
502 base (normally an 8th), is set through @code{base-shortest-duration}.
504 @cindex @code{common-shortest-duration}
505 @cindex @code{base-shortest-duration}
506 @cindex @code{stem-spacing-correction}
507 @cindex @code{spacing}
509 Notes that are even shorter than the common shortest note are
510 followed by a space that is proportional to their duration relative to
511 the common shortest note. So if we were to add only a few 16th notes
512 to the example above, they would be followed by half a NHW:
514 @lilypond[quote,fragment,verbatim,relative=2]
515 c2 c4. c8 c4. c16[ c] c4. c8 c8 c8 c4 c4 c4
519 In the introduction (see @ref{Engraving}), it was explained that stem
520 directions influence spacing. This is controlled with the
521 @code{stem-spacing-correction} property in the
522 @internalsref{NoteSpacing}, object. These are generated for every
523 @internalsref{Voice} context. The @code{StaffSpacing} object
524 (generated in @internalsref{Staff} context) contains the same property
525 for controlling the stem/bar line spacing. The following example shows
526 these corrections, once with default settings, and once with
527 exaggerated corrections:
529 @lilypond[quote,raggedright]
533 \override Staff.NoteSpacing #'stem-spacing-correction = #1.5
534 \override Staff.StaffSpacing #'stem-spacing-correction = #1.5
543 Internals: @internalsref{SpacingSpanner}, @internalsref{NoteSpacing},
544 @internalsref{StaffSpacing}, @internalsref{SeparationItem}, and
545 @internalsref{SeparatingGroupSpanner}.
549 Spacing is determined on a score wide basis. If you have a score that
550 changes its character (measured in durations) halfway during the
551 score, the part containing the longer durations will be spaced too
554 There is no convenient mechanism to manually override spacing. The
555 following work-around may be used to insert extra space into a score.
557 \once \override Score.SeparationItem #'padding = #1
560 No work-around exists for decreasing the amount of space.
563 @subsection Line length
566 @cindex breaking pages
568 @cindex @code{indent}
569 @cindex @code{linewidth}
571 @c Although linewidth can be set in \layout, it should be set in paper
572 @c block, to get page layout right.
573 @c Setting indent in \paper block makes not much sense, but it works.
575 @c Bit verbose and vague, use examples?
576 The most basic settings influencing the spacing are @code{indent} and
577 @code{linewidth}. They are set in the @code{\layout} block. They
578 control the indentation of the first line of music, and the lengths of
581 If @code{raggedright} is set to true in the @code{\layout} block, then
582 the lines are justified at their natural length. This is useful for
583 short fragments, and for checking how tight the natural spacing is.
586 @cindex vertical spacing
588 The option @code{raggedlast} is similar to @code{raggedright}, but
589 only affects the last line of the piece. No restrictions are put on
590 that line. The result is similar to formatting text paragraphs. In a
591 paragraph, the last line simply takes its natural length.
592 @c Note that for text there are several options for the last line.
593 @c While Knuth TeX uses natural length, lead typesetters use the same
594 @c stretch as the previous line. eTeX uses \lastlinefit to
595 @c interpolate between both these solutions.
598 @subsection Line breaking
601 @cindex breaking lines
603 Line breaks are normally computed automatically. They are chosen so
604 that lines look neither cramped nor loose, and that consecutive lines
605 have similar density.
607 Occasionally you might want to override the automatic breaks; you can
608 do this by specifying @code{\break}. This will force a line break at
609 this point. Line breaks can only occur at places where there are bar
610 lines. If you want to have a line break where there is no bar line,
611 you can force an invisible bar line by entering @code{\bar
612 ""}. Similarly, @code{\noBreak} forbids a line break at a
616 @cindex regular line breaks
617 @cindex four bar music.
619 For line breaks at regular intervals use @code{\break} separated by
620 skips and repeated with @code{\repeat}:
622 << \repeat unfold 7 @{
623 s1 \noBreak s1 \noBreak
624 s1 \noBreak s1 \break @}
625 @emph{the real music}
630 This makes the following 28 measures (assuming 4/4 time) be broken every
631 4 measures, and only there.
635 @code{\break}, and @code{\noBreak}.
636 @cindex @code{\break}
637 @cindex @code{\noBreak}
641 Internals: @internalsref{BreakEvent}.
645 @subsection Page breaking
647 The default page breaking may be overriden by inserting
648 @code{\pageBreak} or @code{\noPageBreak} commands. These commands are
649 analogous to @code{\break} and @code{\noBreak}. They should be
650 inserted at a bar line. These commands force and forbid a page-break
651 from happening. Of course, the @code{\pageBreak} command also forces
654 Page breaks are computed by the @code{page-breaking} function in the
659 @cindex @code{\pageBreak}
661 @cindex @code{\noPageBreak}
665 @node Multiple movements
666 @subsection Multiple movements
668 @cindex bibliographic information
671 @cindex Engraved by LilyPond
673 A document may contain multiple pieces of music. Examples of these
674 are an etude book, or an orchestral part with multiple movements.
675 Each movement is entered with a @code{\score} block,
683 The movements are combined together in a @code{\book} block, like
697 The header for each piece of music can be put inside the @code{\score}
698 block. The @code{piece} name from the header will be printed before
699 each movement. The title for the entire book can be put inside the
700 @code{\book}, but if it is not present, the @code{\header} which is at
701 the top of the file is inserted.
703 @cindex Engraved by LilyPond
704 @cindex signature line
709 title = "Eight miniatures"
710 composer = "Igor Stravinsky"
714 \header @{ piece = "Romanze" @}
718 \header @{ piece = "Menuetto" @}
724 @node Creating titles
725 @subsection Creating titles
727 Titles are created for each @code{\score} block, and over a
730 The contents of the titles are taken from the @code{\header} blocks.
731 The header block for a book supports the following
734 The title of the music. Centered on top of the first page.
737 Subtitle, centered below the title.
740 Subsubtitle, centered below the subtitle.
743 Name of the poet, flush-left below the subtitle.
746 Name of the composer, flush-right below the subtitle.
749 Meter string, flush-left below the poet.
752 Name of the opus, flush-right below the composer.
755 Name of the arranger, flush-right below the opus.
758 Name of the instrument, centered below the arranger.
761 To whom the piece is dedicated.
764 Name of the piece, flush-left below the instrument.
766 @cindex page breaks, forcing
768 This forces the title to start on a new page.
771 Here is a demonstration of the fields available,
773 @lilypond[quote,verbatim,linewidth=11.0\cm]
782 subtitle = "the subtitle,"
783 subsubtitle = "and the sub sub title"
785 composer = "Composer"
786 texttranslator = "Text Translator"
788 arranger = "Arranger"
789 instrument = "Instrument"
810 Different fonts may be selected for each element by using
811 @code{\markup}, e.g.,
815 title = \markup @{ \italic @{ The italic title @} @}
819 A more advanced option is to change the definitions of the following
820 variables in the @code{\paper} block. The init file
821 @file{ly/titling-init.ly} lists the default layout.
824 @item bookTitleMarkup
825 This is the title put over an entire @code{\book} block. Typically,
826 it has the composer and the title of the piece
828 @item scoreTitleMarkup
829 This is the title put over a @code{\score} block within a
830 @code{\book}. Typically, it has the name of the movement (@code{piece}
833 @item oddHeaderMarkup
834 This is the page header for odd-numbered pages.
836 @item evenHeaderMarkup
837 This is the page header for even-numbered pages. If unspecified,
838 the odd header is used instead.
840 By default, headers are defined such that the page number is on the
841 outside edge, and the instrument is centered.
843 @item oddFooterMarkup
844 This is the page footer for odd-numbered pages.
846 @item evenFooterMarkup
847 This is the page footer for even-numbered pages. If unspecified,
848 the odd header is used instead.
850 By default, the footer has the copyright notice on the first, and
851 the tagline on the last page.
861 The following definition will put the title flush left, and the
862 composer flush right on a single line.
866 bookTitleMarkup = \markup {
868 \fromproperty #'header:title
869 \fromproperty #'header:composer
878 @section File structure
880 The major part of this manual is concerned with entering various
881 forms of music in LilyPond. However, many music expressions are not
882 valid input on their own, for example, a @code{.ly} file containing
889 will result in a parsing error. Instead, music should be inside other
890 expressions, which may be put in a file by themselves. Such
891 expressions are called toplevel expressions. This section enumerates
894 A @code{.ly} file contains any number of toplevel expressions, where a
895 toplevel expression is one of the following
899 An output definition, such as @code{\paper}, @code{\midi}, and
900 @code{\layout}. Such a definition at the toplevel changes the default
901 settings for the block entered.
904 A @code{\header} block. This sets the global header block. This
905 is the block containing the definitions for book-wide settings, like
906 composer, title, etc.
909 An @code{\addquote} statement. See @ref{Quoting other voices}
910 for more information.
913 A @code{\score} block. This score will be collected with other
914 toplevel scores, and combined as a single @code{\book}.
916 This behavior can be changed by setting the variable
917 @code{toplevel-score-handler} at toplevel. The default handler is
918 defined in the init file @file{scm/@/lily@/.scm}.
921 A @code{\book} block logically combines multiple movements
922 (i.e., multiple @code{\score} blocks) in one document. A number of
923 @code{\scores} creates a single output file, where all movement are
926 This behavior can be changed by setting the variable
927 @code{toplevel-book-handler} at toplevel. The default handler is
928 defined in the init file @file{scm/@/lily@/.scm}.
930 @item A compound music expression, such as
935 This will add the piece in a @code{\score} and format it in a
936 single book together with all other toplevel @code{\score}s and music
939 This behavior can be changed by setting the variable
940 @code{toplevel-music-handler} at toplevel. The default handler is
941 defined in the init file @file{scm/@/lily@/.scm}.
943 @item An indentifier, such as
948 This can be used later on in the file by entering @code{\foo}.
952 The following example shows three things that may be entered at
957 % movements are non-justified by default
969 At any point in a file, any of the following lexical instructions can
973 @item @code{\version}
974 @item @code{\include}
975 @item @code{\renameinput}
985 MIDI (Musical Instrument Digital Interface) is a standard for
986 connecting and controlling digital instruments. A MIDI file is a
987 series of notes in a number of tracks. It is not an actual
988 sound file; you need special software to translate between the
989 series of notes and actual sounds.
991 Pieces of music can be converted to MIDI files, so you can listen to
992 what was entered. This is convenient for checking the music; octaves
993 that are off or accidentals that were mistyped stand out very much
994 when listening to the MIDI output.
998 Many musically interesting effects, such as swing, articulation,
999 slurring, etc., are not translated to midi.
1001 The midi output allocates a channel for each staff, and one for global
1002 settings. Therefore the midi file should not have more than 15 staves
1003 (or 14 if you do not use drums). Other staves will remain silent.
1005 Not all midi players correctly handle tempo changes in the midi
1006 output. Players that are known to work include
1007 @uref{http://@/timidity@/.sourceforge@/.net/,timidity}.
1010 * Creating MIDI files::
1012 * MIDI instrument names::
1015 @node Creating MIDI files
1016 @subsection Creating MIDI files
1018 To create a MIDI from a music piece of music, add a @code{\midi} block
1019 to a score, for example,
1024 \midi @{ \tempo 4=72 @}
1028 The tempo is specified using the @code{\tempo} command. In this
1029 example the tempo of quarter notes is set to 72 beats per minute.
1032 If there is a @code{\midi} command in a @code{\score}, only MIDI will
1033 be produced. When notation is needed too, a @code{\layout} block must
1039 \midi @{ \tempo 4=72 @}
1043 @cindex layout block
1047 Ties, dynamics, and tempo changes are interpreted. Dynamic marks,
1048 crescendi and decrescendi translate into MIDI volume levels. Dynamic
1049 marks translate to a fixed fraction of the available MIDI volume
1050 range, crescendi and decrescendi make the volume vary linearly between
1051 their two extremes. The fractions can be adjusted by
1052 @code{dynamicAbsoluteVolumeFunction} in @internalsref{Voice} context.
1053 For each type of MIDI instrument, a volume range can be defined. This
1054 gives a basic equalizer control, which can enhance the quality of
1055 the MIDI output remarkably. The equalizer can be controlled by
1056 setting @code{instrumentEqualizer}.
1060 @subsection MIDI block
1064 The MIDI block is analogous to the layout block, but it is somewhat
1065 simpler. The @code{\midi} block can contain
1069 @item a @code{\tempo} definition, and
1070 @item context definitions.
1073 A number followed by a period is interpreted as a real number, so
1074 for setting the tempo for dotted notes, an extra space should be
1075 inserted, for example
1078 \midi @{ \tempo 4 . = 120 @}
1082 @cindex context definition
1084 Context definitions follow precisely the same syntax as within the
1085 \layout block. Translation modules for sound are called performers.
1086 The contexts for MIDI output are defined in @file{ly/@/performer@/-init@/.ly}.
1089 @node MIDI instrument names
1090 @subsection MIDI instrument names
1092 @cindex instrument names
1093 @cindex @code{Staff.midiInstrument}
1095 The MIDI instrument name is set by the @code{Staff.midiInstrument}
1096 property. The instrument name should be chosen from the list in
1097 @ref{MIDI instruments}.
1100 \set Staff.midiInstrument = "glockenspiel"
1104 If the selected instrument does not exactly match an instrument from
1105 the list of MIDI instruments, the Grand Piano (@code{"acoustic grand"})