@}
@end example
+When only a couple of flat systems are placed on a page, the resulting
+vertical spacing may be non-eleguant: one system at the top of the page,
+and the other at the bottom, with a huge gap between them. To avoid this
+situation, the space added between the systems can be limited. This
+feature is activated by setting to @code{#t} the
+@code{page-limit-inter-system-space} variable in the @code{\paper}
+block. The paper variable @code{page-limit-inter-system-space-factor}
+determines how much the space can be increased: for instance, the value
+@code{1.3} means that the space can be 30% larger than what it would be
+on a ragged-bottom page.
+
+In the following example, if the inter system space were not limited,
+the second system of page 1 would be placed at the page bottom. By
+activating the space limitation, the second system is placed closer to
+the first one. By setting @code{page-limit-inter-system-space-factor} to
+@code{1}, the spacing would the same as on a ragged-bottom page, like
+the last one.
+
+@lilypond[verbatim]
+#(set-default-paper-size "a6")
+\book {
+ \paper {
+ page-limit-inter-system-space = ##t
+ page-limit-inter-system-space-factor = 1.3
+
+ oddFooterMarkup = \markup "page bottom"
+ evenFooterMarkup = \markup "page bottom"
+ oddHeaderMarkup = \markup \fill-line {
+ "page top" \fromproperty #'page:page-number-string }
+ evenHeaderMarkup = \markup \fill-line {
+ "page top" \fromproperty #'page:page-number-string }
+ }
+ \new Staff << \repeat unfold 4 { g'4 g' g' g' \break }
+ { s1*2 \pageBreak } >>
+}
+@end lilypond
@node Explicit staff and system positioning
@subsection Explicit staff and system positioning
--- /dev/null
+\version "2.11.27"
+#(set-default-paper-size "a6")
+
+\header {
+ texidoc = "The space between systems can be limited when there is too
+much space left on the page by setting @code{page-limit-inter-system-space}."
+}
+
+\book {
+ \paper {
+ page-limit-inter-system-space = ##t
+ page-limit-inter-system-space-factor = 1.4
+
+ ragged-last-bottom = ##f
+
+ oddFooterMarkup = \markup "page bottom"
+ evenFooterMarkup = \markup "page bottom"
+ oddHeaderMarkup = \markup \fill-line {
+ "page top" \fromproperty #'page:page-number-string }
+ evenHeaderMarkup = \markup \fill-line {
+ "page top" \fromproperty #'page:page-number-string }
+ }
+ \new Staff << \repeat unfold 9 { g'4 g' g' g' \break }
+ { s1*2 \pageBreak
+ s1*3 \pageBreak } >>
+}
line-minimum-distance line-ideal-distance
first-line-position
line-ideal-relative-position line-minimum-relative-position
- line-minimum-position-on-page
page-maximum-space-to-fill page-maximum-space-left space-systems))
; this is for 2-pass spacing. Delete me.
(filter stretchable? systems)))
height-left))
- (let* ((lines (map print-system systems))
- (posns (if (null? lines)
- (list)
- (let* ((paper (ly:paper-book-paper paper-book))
- (space-to-fill (page-maximum-space-to-fill
- page lines paper))
- (spacing (space-systems space-to-fill lines ragged paper #f)))
- (if (and (> (length lines) 1)
- (or (not (car spacing)) (inf? (car spacing))))
- (begin
- (ly:warning (_ "Can't fit systems on page -- ignoring between-system-padding"))
- (cdr (space-systems space-to-fill lines ragged paper #t)))
- (cdr spacing))))))
+ (let ((lines (map print-system systems)))
(page-set-property! page 'lines lines)
- (page-set-property! page 'configuration posns)
+ (page-set-property!
+ page 'configuration
+ (if (null? lines)
+ (list)
+ (let* ((paper (ly:paper-book-paper paper-book))
+ (max-space-to-fill (page-maximum-space-to-fill page lines paper))
+ (space-to-fill (if (ly:output-def-lookup
+ paper 'page-limit-inter-system-space #f)
+ (min max-space-to-fill
+ (* (ly:output-def-lookup
+ paper 'page-limit-inter-system-space-factor 1.4)
+ (- max-space-to-fill
+ (or (page-ideal-space-left page) 0))))
+ max-space-to-fill))
+ (spacing (space-systems space-to-fill lines ragged paper #f)))
+ (if (and (> (length lines) 1)
+ (or (not (car spacing)) (inf? (car spacing))))
+ (begin
+ (ly:warning (_ "Can't fit systems on page -- ignoring between-system-padding"))
+ (cdr (space-systems space-to-fill lines ragged paper #t)))
+ (cdr spacing)))))
page)))
(define (page-breaking-wrapper paper-book)
;; not the first line on page
(line-minimum-distance prev-line line layout ignore-padding)))
-(define (line-minimum-position-on-page line prev-line prev-position page)
+(define (line-position-on-page line prev-line prev-position page relative-positionning-fn)
"If `line' fits on `page' after `prev-line', which position on page is
`prev-position', then return the line's postion on page, otherwise #f.
`prev-line' can be #f, meaning that `line' is the first line."
(let* ((layout (ly:paper-book-paper (page-property page 'paper-book)))
- (position (+ (line-minimum-relative-position line prev-line layout #f)
+ (position (+ (relative-positionning-fn line prev-line layout #f)
(if prev-line prev-position 0.0)))
(bottom-position (- position
(interval-start (line-extent line)))))
'bottom-space 0.0)
(- (interval-start (line-extent last-line))))))
-(define (page-maximum-space-left page)
+(define (page-space-left page relative-positionning-fn)
(let ((paper (ly:paper-book-paper (page-property page 'paper-book))))
(let bottom-position ((lines (page-property page 'lines))
(prev-line #f)
(if (null? lines)
(page-printable-height page)
(let* ((line (first lines))
- (position (line-minimum-position-on-page
- line prev-line prev-position page)))
+ (position (line-position-on-page
+ line prev-line prev-position page relative-positionning-fn)))
(if (null? (cdr lines))
(and position
(- (page-printable-height page)
(interval-start (line-extent line)))))
(bottom-position (cdr lines) line position)))))))
+(define (page-maximum-space-left page)
+ (page-space-left page line-minimum-relative-position))
+
+(define (page-ideal-space-left page)
+ (page-space-left page line-ideal-relative-position))
+
;;;
;;; Utilities for distributing systems on a page
;;;