4.1.2 Paper size and automatic scaling


Setting the paper size

‘A4’ is the default value when no explicit paper size is set. However, there are two functions that can be used to change it:

set-default-paper-size
#(set-default-paper-size "quarto")

which must always be placed at the toplevel scope, and

set-paper-size
\paper {
  #(set-paper-size "tabloid")
}

which must always be placed in a \paper block.

If the set-default-paper-size function is used in the toplevel scope, it must come before any \paper block. set-default-paper-size sets the paper size for all pages, whereas set-paper-size only sets the paper size for the pages that the \paper block applies to. For example, if the \paper block is at the top of the file, then it will apply the paper size to all pages. If the \paper block is inside a \book, then the paper size will only apply to that book.

When the set-paper-size function is used, it must be placed before any other functions used within the same \paper block. See Automatic scaling to paper size.

Paper sizes are defined in ‘scm/paper.scm’, and while it is possible to add custom sizes, they will be overwritten on subsequent software updates. The available paper sizes are listed in Predefined paper sizes.

The following command can be used in the file to add a custom paper size which can then be used with set-default-paper-size or set-paper-size as appropriate,

#(set! paper-alist (cons '("my size" . (cons (* 15 in) (* 3 in))) paper-alist))

\paper {
  #(set-paper-size "my size")
}

The units in (inches), cm (centimeters) and mm (millimeters) can all be used.

If the symbol 'landscape is added to the paper size function, pages will be rotated by 90 degrees, and wider line widths will be set accordingly.

#(set-default-paper-size "a6" 'landscape)

Swapping the paper dimensions without having the print rotated (like when printing to postcard size, or creating graphics for inclusion rather than a standalone document) can be achieved by appending ‘landscape’ to the name of the paper size itself:

#(set-default-paper-size "a6landscape")

When the paper size ends with an explicit ‘landscape’ or ‘portrait’, the presence of a 'landscape symbol only affects print orientation, not the paper dimensions used for layout.

Vegeu també

Notation Reference: Automatic scaling to paper size, Predefined paper sizes.

Installed Files: ‘scm/paper.scm’.


Automatic scaling to paper size

If the paper size is changed with one of the scheme functions (set-default-paper-size or set-paper-size), the values of several \paper variables are automatically scaled to the new size. To bypass the automatic scaling for a particular variable, set the variable after setting the paper size. Note that the automatic scaling is not triggered by setting the paper-height or paper-width variables, even though paper-width can influence other values (this is separate from scaling and is discussed below). The set-default-paper-size and set-paper-size functions are described in Setting the paper size.

The vertical dimensions affected by automatic scaling are top-margin and bottom-margin (see Fixed vertical spacing \paper variables). The horizontal dimensions affected by automatic scaling are left-margin, right-margin, inner-margin, outer-margin, binding-offset, indent, and short-indent (see Horizontal spacing \paper variables).

The default values for these dimensions are set in ‘ly/paper-defaults-init.ly’, using internal variables named top-margin-default, bottom-margin-default, etc. These are the values that result at the default paper size a4. For reference, with a4 paper the paper-height is 297\mm and the paper-width is 210\mm.

Vegeu també

Notation Reference: Fixed vertical spacing \paper variables, Horizontal spacing \paper variables.

Installed Files: ‘ly/paper-defaults-init.ly’, ‘scm/paper.scm’.


Altres idiomes: English, deutsch, español, français, italiano, 日本語.
Quant a la selecció automàtica de la llengua.

LilyPond — Referència de la notació v2.21.0 (branca de desenvolupament).