diff --git a/toc_include.ly b/toc_include.ly index 483125c..9ded83e 100644 --- a/toc_include.ly +++ b/toc_include.ly @@ -25,15 +25,14 @@ (let* ((line-to-stencil (lambda (line) (interpret-markup layout (cons (list (cons 'line-width line-width) (cons 'baseline-skip 1)) props) (markup line)))) (stencil-height (lambda (stencil) (interval-length (ly:stencil-extent stencil Y)))) (linestencil (line-to-stencil (car lines))) - (calc-height (- height-left (stencil-height linestencil))) - (calc-width (interval-length (ly:stencil-extent linestencil X))) - (is-less-than-half-line-width (< calc-width (/ line-width 2.0))) - (next-line-height (if (null? (cdr lines)) 0 (stencil-height (line-to-stencil (cadr lines))))) - (no-space-for-next-line (and is-less-than-half-line-width (< (- calc-height next-line-height) 0))) + (current-line-height (stencil-height linestencil)) + (new-height-left (- height-left current-line-height)) + (next-line-height (if (null? (cdr lines)) current-line-height (stencil-height (line-to-stencil (cadr lines))))) + (no-space-for-next-line (and (< next-line-height current-line-height) (< new-height-left next-line-height))) ) - (if (or (< calc-height 0) no-space-for-next-line) + (if (or (< new-height-left 0) no-space-for-next-line) '() - (cons (markup #:stencil linestencil) (add-to-col (cdr lines) calc-height)))))))))) + (cons (markup #:stencil linestencil) (add-to-col (cdr lines) new-height-left)))))))))) (make-list cols)))) (if (null? restlines) (list)