Hi Jan-Peter,
Am 12.12.2017 um 14:15 schrieb
Jan-Peter Voigt:
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.
Thank you. While I had to figure out how to adapt this to 2.18 I
realized that the missing information was that I can turn the symbol
"cm" into a value through ly:parser-lookup.
This works with 2.18, and I will further refine it (the idea is to
store several sets of paper variables and select a set with a single
function:
\version "2.18"
#(define paper-values
'((top-margin . (5 . cm))
(indent . (4 . cm))))
paperValue =
#(define-scheme-function (parser location val)(symbol?)
(let*
((entry (assoc-ref paper-values val))
(unit (ly:parser-lookup parser (cdr entry))))
(* unit (car entry))))
\paper {
indent = \paperValue #'indent
top-margin = \paperValue #'top-margin
}
\relative { bes' a c b }
Best
Urs
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
address@hidden
https://lists.gnu.org/mailman/listinfo/lilypond-user
_______________________________________________
lilypond-user mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/lilypond-user
|