Hi Alasdair, See also: https://lilypond.org/doc/v2.22/Documentation/notation/defining-new-contexts.html Cheers, Pierre
Le ven. 15 juil. 2022 à 16:22, Lukas-Fabian Moser <l...@gmx.de> a écrit : > Hi Alasdair, > > > Here a new staff is instantiated; with about 10 lines of "\with" to > > change its appearance and behaviour. > > > > However, if I wish to use several such staves, I don't want to be > > copying the "\with" material into each one. Is it possible to create > > a new context just from such a definition? What I mean is something like > > > > myStaff = staff \with { > > < lots of lines of definition > > > } > > > > so that I can simply create a new staff the way I want it with, for > > example > > > > \new myStaff { > > > > } > > > > All I want is an example. There is some information about defining a > > new context, but in my case all I want is a tweaked version of a > > current context. > > This is easier than one might think, but - somewhat counterintuitively - > you need _two_ instances of the word \with. > > \version "2.23.7" > > rainbowSettings = \with { > \override Clef.color = #red > \override TimeSignature.color = #green > \override StaffSymbol.color = #blue > clefGlyph = "clefs.C" > } > > \new Staff \with \rainbowSettings { > \key d \major > d'4 > } > > \new Staff \with { > \rainbowSettings > \magnifyStaff 2 > } { > \key d \major > d'4 > } > > And I just found out that you can even do > > rainbowSettings = { > \override Clef.color = #red > \override TimeSignature.color = #green > \override StaffSymbol.color = #blue > \set clefGlyph = "clefs.C" > } > > (To wit, if rainbowSettings are entered as music instead of as a \with > clause, context properties have to be set with \set.) > > Lukas > > >