lilypond-user
[Top][All Lists]
Advanced

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

Re: How to store lengths in variables


From: Jan-Peter Voigt
Subject: Re: How to store lengths in variables
Date: Tue, 12 Dec 2017 14:15:21 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0

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
address@hidden
https://lists.gnu.org/mailman/listinfo/lilypond-user

Attachment: paper-value.ly
Description: Text Data


reply via email to

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