Jeff Olson
2018-11-29 06:12:20 UTC
I have a complex Mutopia submission that requires different formatting
for A4 and Letter sized paper (it's too tight on the page to trust
lilypond's spacing algorithms on the same source without paper specific
tweaks).
So I'd like to define a music function (see "ifLetter" below) that can
sense the paper choice and select either of two music definitions
accordingly.
In the demo below, I'd like to switch output between music-one (one
system) and music-two (two systems) depending upon which paper size is
set. But I'm just guessing about how to reference the documented
variable "paper-width" to compare to the value 8.5\in. In the attempt
below, the condition always evaluates to ##f and produces two systems on
letter size paper (I want music-one for letter paper).
I'd prefer testing a variable whose value was "letter" (rather than 8.5
inches) but I couldn't find such a variable documented (paper-size?,
default-paper-size?).
I've seen ly:output-def-lookup, but that requires a props or layout that
is not obvious how to access within a music function.
The code below produces the expected results when the condition (eqv?
'paper:paper-width (* 8.5 25.4))is rewritten as(eqv? 1 1) or (eqv? 1 2).
BTW, documented spacing examples suggest that the construct (* 8.5 in)
should be effective in scheme, but I get a compile error indicating that
"in" is unbound, so I've written in 25.4 as a literal.
BTW2, I've similarly been unable to access the paper variable page-count
within a music function.
Thx,
Jeff
--
\version "2.18.2"
\paper{
page-count = #1
%#(set-paper-size "a4") %uncomment to test specific paper size
#(set-paper-size "letter") %uncomment to test specific paper size
}
music-one = { a b c d e f g }
music-two = { a b c d \break e f g }
ifLetter =
#(define-music-function (parser location musL musE) (ly:music? ly:music?)
(if (eqv? 'paper:paper-width (* 8.5 25.4)) musL musE )
)
\score { \ifLetter \music-one \music-two }
for A4 and Letter sized paper (it's too tight on the page to trust
lilypond's spacing algorithms on the same source without paper specific
tweaks).
So I'd like to define a music function (see "ifLetter" below) that can
sense the paper choice and select either of two music definitions
accordingly.
In the demo below, I'd like to switch output between music-one (one
system) and music-two (two systems) depending upon which paper size is
set. But I'm just guessing about how to reference the documented
variable "paper-width" to compare to the value 8.5\in. In the attempt
below, the condition always evaluates to ##f and produces two systems on
letter size paper (I want music-one for letter paper).
I'd prefer testing a variable whose value was "letter" (rather than 8.5
inches) but I couldn't find such a variable documented (paper-size?,
default-paper-size?).
I've seen ly:output-def-lookup, but that requires a props or layout that
is not obvious how to access within a music function.
The code below produces the expected results when the condition (eqv?
'paper:paper-width (* 8.5 25.4))is rewritten as(eqv? 1 1) or (eqv? 1 2).
BTW, documented spacing examples suggest that the construct (* 8.5 in)
should be effective in scheme, but I get a compile error indicating that
"in" is unbound, so I've written in 25.4 as a literal.
BTW2, I've similarly been unable to access the paper variable page-count
within a music function.
Thx,
Jeff
--
\version "2.18.2"
\paper{
page-count = #1
%#(set-paper-size "a4") %uncomment to test specific paper size
#(set-paper-size "letter") %uncomment to test specific paper size
}
music-one = { a b c d e f g }
music-two = { a b c d \break e f g }
ifLetter =
#(define-music-function (parser location musL musE) (ly:music? ly:music?)
(if (eqv? 'paper:paper-width (* 8.5 25.4)) musL musE )
)
\score { \ifLetter \music-one \music-two }