[ << Spacing issues ] | [Top][Contents][Index][ ? ] | [ Changing defaults >> ] | ||
[ < Paper size ] | [ Up : Paper and pages ] | [ Vertical dimensions > ] |
4.1.2 Page formatting
Margins, headers, and footers and other layout variables are automatically set according to the paper size.
Default margin values are accessible in ‘ly/paper-defaults-init.ly’. They apply to the default paper size (a4, unless specified differently) and are scaled accordingly for other paper sizes.
This section lists and describes a number of paper variables that may be altered.
Vertical dimensions | ||
Horizontal dimensions | ||
Other layout variables |
[ << Spacing issues ] | [Top][Contents][Index][ ? ] | [ Changing defaults >> ] | ||
[ < Page formatting ] | [ Up : Page formatting ] | [ Horizontal dimensions > ] |
Vertical dimensions
These variables are used to set different vertical dimensions on a page:
-
after-title-spacing
-
Specifies how to calculate the space between a title (or top-level markup) and the system that follows it. This is an associative list with five components:
- space – the amount of stretchable space between the baseline of a title and the center of the staff that follows it;
- padding – the minimum amount of whitespace that must be present between a title and the staff that follows it;
- stretchability – the ease with which the stretchable space increases when a page is stretched. If this is zero, the distance to the next staff will not stretch at all;
- minimum-distance – the minimum distance to place between the baseline of a title and the center of the staff that follows it. This differs from padding in that the height of a staff has no effect on the application of minimum-distance (whereas the height of a staff is crucial for padding).
For example, the default is:
after-title-spacing = #'((space . 2) (padding . 0.5))
If a page has a ragged bottom, space is not stretched. In particular, the resulting distance on such a page is the largest of
- space,
- minimum-distance, and
- padding plus the smallest distance necessary to eliminate overlap.
-
before-title-spacing
-
Specifies the spacing between a system and the title (or top-level markup) that follows it. The distances are measured from the center of the last staff in the system to the baseline of the title that follows it. See after-title-spacing.
-
between-scores-system-spacing
-
Specifies the spacing between two systems if they are in different scores, but there is no title between them. See after-title-spacing.
-
between-system-spacing
-
Specifies the spacing between the center of the bottom staff of one system and the center of the top staff of the following system. See after-title-spacing.
-
between-title-spacing
-
Specifies the spacing between two titles (or top-level markups). The distances are measured from the baseline of the first title to the baseline of the second. See after-title-spacing.
-
bottom-margin
-
The margin between footer and bottom of the page. Default:
6\mm
. -
bottom-system-spacing
-
Specifies the spacing from the center of the last staff (or the baseline of the last top-level markup) to the bottom of the printable area (ie. the top of the bottom margin). See after-title-spacing.
-
top-title-spacing
-
Specifies the spacing from the top of the printable area (ie. the bottom of the top margin) to the baseline of the title. See after-title-spacing.
-
top-system-spacing
-
Specifies the spacing from the top of the printable area (ie. the bottom of the top margin) to the center of the first staff. This only takes effect if there is no title at the top of the page (in which case top-title-spacing is used instead). See after-title-spacing.
-
paper-height
-
The height of the page. Default: the height of the current paper size. For details, see Paper size.
-
top-margin
-
The margin between header and top of the page. Default:
5\mm
.
Selected Snippets
The header and footer are created by the functions make-footer and make-header, defined in \paper. The default implementations are in ly/paper-defaults.ly and ly/titling-init.ly.
The page layout itself is done by two functions in the \paper block, page-music-height and page-make-stencil. The former tells the line-breaking algorithm how much space can be spent on a page, the latter creates the actual page given the system to put on it.
You can define paper block values in Scheme. In that case mm, in, pt, and cm are variables defined in paper-defaults.ly with values in millimeters. That is why the value 2 cm must be multiplied in the example
\paper { #(define bottom-margin (* 2 cm)) }
Example:
\paper { paper-width = 2\cm top-margin = 3\cm bottom-margin = 3\cm ragged-last-bottom = ##t }
This second example centers page numbers at the bottom of every page.
\paper { print-page-number = ##t print-first-page-number = ##t oddHeaderMarkup = \markup \fill-line { " " } evenHeaderMarkup = \markup \fill-line { " " } oddFooterMarkup = \markup { \fill-line { \bold \fontsize #3 \on-the-fly #print-page-number-check-first \fromproperty #'page:page-number-string } } evenFooterMarkup = \markup { \fill-line { \bold \fontsize #3 \on-the-fly #print-page-number-check-first \fromproperty #'page:page-number-string } } }
You can also define these values in Scheme. In that case mm
,
in
, pt
, and cm
are variables defined in
‘paper-defaults-init.ly’ with values in millimeters. That is why the
value must be multiplied in the example
\paper { #(define bottom-margin (* 2 cm)) }
The header and footer are created by the functions make-footer
and make-header
, defined in \paper
. The default
implementations are in ‘ly/paper-defaults-init.ly’ and
‘ly/titling-init.ly’.
The page layout itself is done by two functions in the
\paper
block, page-music-height
and
page-make-stencil
. The former tells the line-breaking algorithm
how much space can be spent on a page, the latter creates the actual
page given the system to put on it.
See also
Notation Reference: Vertical spacing between systems.
Snippets: Spacing.
[ << Spacing issues ] | [Top][Contents][Index][ ? ] | [ Changing defaults >> ] | ||
[ < Vertical dimensions ] | [ Up : Page formatting ] | [ Other layout variables > ] |
Horizontal dimensions
There are a few variables that determine the horizontal dimensions on a page:
-
binding-offset
-
The amount
inner-margin
is increased to make sure nothing will be hidden by the binding. Works only withtwo-sided
set to true. Default:0
. -
horizontal-shift
-
The amount that all systems (including titles and system separators) are shifted to the right. Default:
0.0
. -
indent
-
The level of indentation for the first system in a score. Default:
15\mm
. -
inner-margin
-
The margin all pages have at the inner side if they are part of a book. Works only with
two-sided
set to true. Default:10\mm
. -
left-margin
-
The margin between the left edge of the page and the beginning of each system. Default:
10\mm
. -
line-width
-
The width of music systems. Default:
paper-width
minusleft-margin
andright-margin
. -
outer-margin
-
The margin all pages have at the outer side if they are part of a book. Works only with
two-sided
set to true. Default:20\mm
. -
paper-width
-
The width of the page. Default: the width of the current paper size. For details, see Paper size.
-
right-margin
-
The margin between the right edge of the page and the end of each system. Default:
10\mm
. -
short-indent
-
The level of indentation for all systems in a score besides the first system. Default:
0
.
If some values are not set, defaults will be taken. Their exact value is adjusted, depending on the paper size specified. Currently, the following values are affected by this scaling:
- left-margin
- right-margin
- top-margin
- bottom-margin
- head-separation
- foot-separation
- indent
- short-indent
The settings for line-width
, left-margin
,
right-margin
and paper-width
depend on
each other, but they do not have to be specified
completely.
\paper { left-margin = 30\mm }
In this example, only left-margin
is set. The value for
right-margin
will remain default, line-width
is
calculated automatically.
\paper { line-width = 150\mm }
Here left-margin
and right-margin
will be set
to the same value. Therefore, line-width
is subtracted
from paper-width
and divided by two. That means systems
are centered on the page, if only line-width
is
specified.
Some checks occur to ensure the values are set correctly. If the values do not match or systems would run off the page, a warning is printed and default values are set.
\paper { paper-width = 210\mm left-margin = 20\mm right-margin = 30\mm line-width = 100\mm }
These checks can be avoided by setting check-consistency
to false.
\paper { paper-width = 210\mm left-margin = 20\mm line-width = 200\mm check-consistency = ##f }
Note: If paper-width
is manually set, line-width
,
left-margin
, indent
, and short-indent
may
have to be adjusted as well.
See also
Snippets: Spacing.
[ << Spacing issues ] | [Top][Contents][Index][ ? ] | [ Changing defaults >> ] | ||
[ < Horizontal dimensions ] | [ Up : Page formatting ] | [ Music layout > ] |
Other layout variables
These variables can be used to adjust page layout in general.
-
auto-first-page-number
-
The page breaking algorithm is affected by the first page number being odd or even. If set to true, the page breaking algorithm will decide whether to start with an odd or even number. This will result in the first page number remaining as is or being increased by one. Default:
##f
. -
blank-last-page-force
-
The penalty for ending the score on an odd-numbered page. Default:
0
. -
blank-page-force
-
The penalty for having a blank page in the middle of a score. This is not used by
ly:optimal-breaking
since it will never consider blank pages in the middle of a score. Default:5
. -
check-consistency
-
If set to true, check whether
left-margin
,right-margin
andline-width
fit each other. Also make sure that their combination does not exceed the availablepaper-width
. Default:##t
. -
first-page-number
-
The value of the page number on the first page. Default:
#1
. -
max-systems-per-page
The maximum number of systems that will be placed on a page. This is currently supported only by the
ly:optimal-breaking
algorithm. Default: unset.-
min-systems-per-page
The minimum number of systems that will be placed on a page. This may cause pages to be overfilled if it is made too large. This is currently supported only by the
ly:optimal-breaking
algorithm. Default: unset.-
page-breaking-between-system-spacing
-
Tricks the page breaker into thinking that
between-system-spacing
is set to something different than it really is. For example, ifpage-breaking-between-system-spacing #'padding
is set to something substantially larger thanbetween-system-spacing #'padding
, then the page-breaker will put fewer systems on each page. Default: unset. -
page-count
-
The number of pages to be used for a score. Default: unset.
-
page-limit-inter-system-space
-
If set to true, limits space between systems on a page with a lot of space left. Default:
##f
. For details, see Vertical spacing between systems. -
page-limit-inter-system-space-factor
-
The factor used by
page-limit-inter-system-space
. Default:1.4
. For details, see Vertical spacing between systems. -
page-spacing-weight
-
The relative importance of page (vertical) spacing and line (horizontal) spacing. High values will make page spacing more important. Default:
#10
. -
print-all-headers
-
If set to true, this will print all headers for each \score in the output. Normally only the piece and opus header variables are printed. Default:
##f
. -
print-first-page-number
-
If set to true, a page number is printed on the first page. Default:
##f
. -
print-page-number
-
If set to false, page numbers are not printed. Default:
##t
. -
ragged-bottom
-
If set to true, systems will not spread vertically across the page. This does not affect the last page. Default:
##f
.This should be set to true for pieces that have only two or three systems per page, for example orchestral scores.
-
ragged-last
-
If set to true, the last system in the score will not fill the line width. Instead the last system ends at its natural horizontal length. Default:
##f
. -
ragged-last-bottom
-
If set to false, systems will spread vertically across the last page. Default:
##t
.Pieces that amply fill two pages or more should have this set to true.
It also affects the last page of book parts, ie parts of a book created with
\bookpart
blocks. -
ragged-right
-
If set to true, systems will not fill the line width. Instead, systems end at their natural horizontal length. Default:
##f
.If the score has only one system, the default value is
##t
. -
system-separator-markup
-
A markup object that is inserted between systems. This is often used for orchestral scores. Default: unset.
The markup command
\slashSeparator
is provided as a sensible default, for example -
system-count
-
The number of systems to be used for a score. Default: unset.
-
systems-per-page
-
The number of systems that should be placed on each page. This is currently supported only by the
ly:optimal-breaking
algorithm. Default: unset. -
two-sided
-
If set to true, use
inner-margin
,outer-margin
andbinding-offset
to determine margins depending on whether the page number is odd or even. This overridesleft-margin
andright-margin
. Default:##f
.
See also
Snippets: Spacing.
Known issues and warnings
The default page header puts the page number and the instrument
field from the \header
block on a line.
The titles (from the \header{}
section) are treated as a
system, so ragged-bottom
and ragged-last-bottom
will
add space between the titles and the first system of the score.
[ << Spacing issues ] | [Top][Contents][Index][ ? ] | [ Changing defaults >> ] | ||
[ < Horizontal dimensions ] | [ Up : Page formatting ] | [ Music layout > ] |