Am 20.04.2015 um 08:45 schrieb Andrew Bernard:
So Ponders,

What size paper do you print scores on?
I haven’t yet tried to use any other format than A4 (except for printing brochures on folded A3), although I learned from <http://www.dante.de/tex/Dokumente/KohmSatzspiegel.pdf> (only in German, I think…) that the irrational proportions make good typography very difficult. Yet I have taken inspiration from there to create the attached tool for making nice margins, which I’ve been using ever since.

Yours, Simon
\version "2.19.8"

#(define pair-or-rational? (or pair? rational?))
%% use inside \paper {} or on top level
typeArea =
#(define-scheme-function
  ;; size: optional paper size specification as defined in scm/paper.scm
  ;; orientation: 'portrait or 'landscape (optional, with 'portrait as default)
  ;; ratio:  typeAreaWidth/typeAreaHeight
;;;; examples:
;;;; portrait: standard 3/2, smaller would be 8/5 and 5/3
;;;; landscape: standard  5/4, smaller would be 6/5, larger 4/3
  (parser location sz orientation ratio-input)
  ((string? "a4") (symbol? 'portrait) pair-or-rational?)

  (_i "Calculate paper margins for DIN A paper formats so that:
– the width-to-height ratio of the type area is @var{ratio}
– the upper corners of the type area are on the diagonals of imaginary double 
pages
– the lower corners of the type area are on the diagonals of the page
which is supposed to make a pleasant visual appearance")
  (let
   ((ratio (if
            (rational? ratio-input)
            ratio-input
            (/ (car ratio-input) (cdr ratio-input))))
    (ref (lambda (sym) (module-ref (current-module) sym))))
   (cond
    ((and (eq? orientation 'portrait) (< ratio (sqrt 2)))
     (ly:warning "Type area ratio has to be larger than square root
 of 2 (1,414...). Using default margins"))
    ((and (eq? orientation 'landscape) (> ratio (sqrt 2)))
     (ly:warning "Type area ratio has to be smaller than square root
 of 2 (1,414...). Using default margins"))
    (else
     (cond ((eq? orientation 'portrait)
            #{ \paper {
              #(set-paper-size sz)
              top-margin = $(*
                             (ref 'paper-height)
                             (/ (- (numerator ratio)
                                  (* (denominator ratio) (sqrt 2)))
                               (- (* 4 (numerator ratio))
                                 (* 3 (denominator ratio) (sqrt 2))) ))
              bottom-margin = #(* (ref 'top-margin) 2)
              left-margin = #(* (ref 'top-margin) (sqrt 2))
              right-margin = #(ref 'left-margin)
               }
            #} )
       ((eq? orientation 'landscape)
        #{ \paper {
          #(set-paper-size sz orientation)
          left-margin = $(*
                          (ref 'paper-width)
                          (/ (- (numerator ratio)
                               (* (denominator ratio) (sqrt 2)))
                            (- (* 1.5 (numerator ratio))
                              (* 2 (denominator ratio) (sqrt 2))) ))
          right-margin = #(ref 'left-margin)
          bottom-margin = #(* 0.5 (ref 'left-margin) (sqrt 2))
          top-margin = #(* (ref 'bottom-margin) 0.5)
           }
        #} )))
    )
   ;(format #t "Margins used: \n top margin: ~a \n bottom margin: ~a \n side 
margins: ~a"
   ; (ref 'top-margin)
   ;(ref 'bottom-margin)
   ;(ref 'left-margin))
   ))
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to