Hi Urs,
as you already said units are only known inside the paper block, because
they are dependent of the paper size an the global staff size. Inside
the paper block the units are just numbers. If you want to multiply
numbers you can do so outside the paper block like this:
xx = 2
yy = 3\xx
#(display yy) % will display '6'
One idea might be to store pairs or lists with the number and the unit
name as a symbol. Inside the paper block a scheme-function can retrieve
the unit factor and multiply it with the given value.
A rough sketch is attached.
HTH
Jan-Peter
Am 12.12.2017 um 11:40 schrieb Urs Liska:
Hi,
I would like to parametrize my paper settings. But for that I need to
either store the measurement unit in a variable (outside the paper
block) or store the plain number in the variable and create a length
from that within the paper block.
tm = 5\in
\paper {
top-margin = #tm
}
This doesn't work because LilyPond doesn't recognize the "\in" in the
toplevel variable definition.
And rather than using the LilyPond syntax I would need to store the
settings in an alist like
values =
#'((top-margin . 5)
(bottom-margin . 2.5))
etc. and retrieve those values in the paper definition.
So I need to either store the numbers together with their unit (so I can
directly use them in the paper block) or have a way to "create" that
variable from the stored number within the paper block.
Any pointers appreciated
Urs
_______________________________________________
lilypond-user mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/lilypond-user
\version "2.19.80"
% store the value in an alist
values.top-level = 5.cm
% function to calculate the value for the paper block
#(define (paper-value v)(and (list? v)(number? (car v))(symbol? (cadr v))))
paperValue =
#(define-scheme-function (val)(paper-value)
(let ((unit (ly:parser-lookup (cadr val))))
(* unit (car val))
))
% test
\paper {
indent = \paperValue \values.top-level
}
\relative { bes' a c b }
_______________________________________________
lilypond-user mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/lilypond-user