lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Get the margin values


From: Simon Albrecht
Subject: Re: Get the margin values
Date: Mon, 5 Jun 2023 15:34:38 +0200

Hi Pierre,

On 05.06.23 15:07, Pierre Perol-Schneider wrote:
So how can I get the paper values as a markp?

the call to ly:output-def-lookup returns a number or an empty list. So this returns valid markup regardless:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\version "2.24.1"

\paper {
  top-margin = 30
  %bottom-margin = 30
  left-margin = 30
  %right-margin = 30
}

#(define-markup-command
  (margin layout props)()
  (let* ((prnt (lambda (i) (let ((mrgn (ly:output-def-lookup $defaultpaper i)))
                             (if (number? mrgn)
                                 (number->string mrgn)
                                 "not yet known"))))
         (top-margin (prnt 'top-margin))
         (bottom-margin (prnt 'bottom-margin))
         (left-margin (prnt 'left-margin))
         (right-margin  (prnt 'right-margin)))
    (interpret-markup layout props
      #{
        \markup\column {
          \line { top-margin = #top-margin }
          \line { bottom-margin = #bottom-margin }
          \line { left-margin = #left-margin }
          \line { right-margin = #right-margin }
        }
      #})))

% Test:
\markup\margin

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

However, I can’t say why the right margin isn’t yet known by the time it is queried.

Best, Simon



reply via email to

[Prev in Thread] Current Thread [Next in Thread]