Walt North <[email protected]> writes:
> I must be missing something obvious. Attached are two code samples.
>
> The first is the code I expected to work but instead splits the voices
> into two staffs.
Why wouldn't it?
> =========================
>
> \version "2.26.0"
> \language "english"
> \book {\score {
> <<
> \context ChordNames \chordmode {
> \time 3/4 \key a \major
> fs2.:m7 |
> }
> \context Staff {
> \time 3/4 \key a \major \clef "treble_8"
> <<
> \new Voice \fixed c' {\voiceOne <e a>2 b4 |}
> \new Voice \fixed c, {\voiceTwo fs4 fs e |}
> >>
> }
> >>
> }}
>
Let's see what happens: you start with a \context ChordNames.
ChordNames is aliased to Staff so that things like \key and
\transposition are interpreted in ChordNames. Since you write \context
Staff below, this means that \time 3/4 \key a \major ... all end up in
the ChordNames context. However, ChordNames does not accept a Voice
context, so each of the Voice contexts creates its own implicit true
Staff context (not just an alias) to go into.
>
> The second is if I comment out the chordnames and then the tab staff has both
> voices on one staff (though in the wrong octave).
>
> Walt
>
> *
>
> \version "2.26.0"
> \language "english"
> \book {\score {
> <<
> % \context ChordNames \chordmode {
> % \time 3/4 \key a \major
> % fs2.:m7 |
> % }
> \context Staff {
> \time 3/4 \key a \major \clef "treble_8"
> <<
> \new Voice \fixed c' {\voiceOne <e a>2 b4 |}
> \new Voice \fixed c, {\voiceTwo fs4 fs e |}
> >>
> }
> >>
> }}
>
> *
Well, then there is no preexisting context with a Staff alias, so
LilyPond creates an actual Staff. Staff takes Voice contexts as child,
so both of them end up in the true Staff context.
Lesson: if you want to _create_ a context rather than reuse a possibly
unexpected one, write \new.
--
David Kastrup