[Top][All Lists]

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

Re: Nesting paper blocks

From: David Wright
Subject: Re: Nesting paper blocks
Date: Fri, 20 Mar 2020 09:22:59 -0500
User-agent: Mutt/1.10.1 (2018-07-13)

On Fri 20 Mar 2020 at 12:50:23 (+0100), Peter Crighton wrote:

> So I need to be flexible with what paper variables I choose for each book.
> I can include just those that I need, but I still need to access a
> combination of them. That’s why chaining them all together does not work.
> \paperCategoryOne in one case would need to include \paperSizeOne, but in
> another case \paperSizeTwo. \paperGlobal needs to be included always, which
> is no problem; I can just include that into all the \paperSize variables,
> for example.
> So far, all the \paperX variables are \paper blocks in themselves. Ideally,
> there would be a way to just inject the literal content of a variable
> inside a paper block, so this would work:
> someVariable = {
>   indent = 0
> }
> \paper {
>   \someVariable
> }
> But I don’t know if that’s possible. Maybe all it needs is some other
> syntax around the content of someVariable, other than curly braces, or it
> is possible with some Scheme magic, but I’m out of ideas.

To tackle a problem like this, I'd start from the source file
and build a generalised \paper file with all the variables you use
within it. All the literals (like 0, 10, 30, …) would be in a form
suitable for substitution by whatever method you choose.

For a shell "here-document", that would be shell variables, like
$Indent, $Linewidth, etc. If substitution was done with a stream
editor, or a scripting language like Python, you could choose
any strings that don't otherwise occur, such as %%%INDENT%%%, etc.

So you perform the substitution by any means you like, producing
a single, ephemeral paper.ily file which you include in your LP
source file, compile with LP, and throw away.

> With categories being different types of scores I want to do for the same
> song (namely music sheets with all the music, including notes, chords and
> lyrics; chord sheets with only chord symbols; and lyric sheets with just
> lyrics and chords).

As you're now running LP with a script, your script(s) could
automatically build several files in turn, and rerun
LP to produce different formats.

You can extend this in any way you like, dealing with other parts
of the LP source that might need to be altered. For example, I have
a script that typesets psalms, and it modifies the source files of
the Anglican chants (which always contain a   \transpose f f   line),
transposing them into mutually compatible keys before compiling them
into a document for that particular church service.

IOW, use a scripting language to script, and LP to typeset music.


reply via email to

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