I would like the page header to change on the fly as data about the composition changes. For instance, I'd like the header on the pages for each part of a quartet to indicate the part name. The page number changes, but info from the header field does not get changed. Is there some means to do that? Using

\fromproperty #'header:instrument

in one of the evenHeaderMarkup fields seems like the obvious method. The titles seem to get updated that way. But the page header doesn't change.
\version "2.22.1"
\language "english"

% Composition consists of two movements
%  for quartet.
% I am printing the score and the parts as separate bookParts.
% I want the header for the pages for the instrument parts
%  to display the instrument name.
%  For the moment I am using the formatting of the poet field for the instrument name.
% The problem I have is that the header seems to update the page number (as expected)
%  but it does not update the poet field from the header.

\paper {
  print-all-headers = ##t
  #(set-paper-size "letter")
  top-margin = 10
  bottom-margin = 10
  % footer just displays the title in the center field
  evenFooterMarkup = \markup {
      \fill-line {
        " "  %left 
        \fromproperty #'header:title    %middle 
        " "  %right
      }
    }
  oddFooterMarkup = \evenFooterMarkup
  % I want header to display the page number and the poet, which changes between parts
   evenHeaderMarkup = \markup {
     \fill-line {
        \fromproperty #'page:page-number-string  % this gets updated as page changes
        \on-the-fly \not-part-first-page
           \fromproperty #'header:poet    % this does not get updated as header changes
        " "  %right
      }
   }
   %evenHeaderMarkup = \oddHeaderMarkup
}

\header {
  title = "Major Title"
  composer = "Some Body"
  %poet = "trombone quartet"   % used in even page header if defined
}

global = {
  \key c \major
  \time 4/4
  \tempo "Moderato" 4=76
  \set Score.markFormatter = #format-mark-box-barnumbers
}

scoreATromboneI = \relative c' {
  \global
  r4 e--\mf d2--
}

scoreATromboneII = \relative c {
  \global
  r4 f--\mf e2--
}

scoreATromboneIII = \relative c {
  \global
  r2 r4 f--\mf
}

scoreATromboneIV = \relative c {
  \global
  r4 f--\mf e2--
}

scoreATromboneIPart = \new Staff  { \clef tenor \scoreATromboneI }

scoreATromboneIIPart = \new Staff  { \clef bass \scoreATromboneII }

scoreATromboneIIIPart = \new Staff  { \clef bass \scoreATromboneIII }

scoreATromboneIVPart = \new Staff  { \clef bass \scoreATromboneIV }

% --------------------------------
%  second part
% --------------------------------
globalS = {
  \key f \major
  \time 6/8
  \tempo "Allegretto" 4.=100
  \set Score.markFormatter = #format-mark-box-barnumbers
}

scoreSTromboneI = \relative c' {
  \globalS
  d4->\f d8~-> d d-. e-.
  \pageBreak
  f-. e-. d-. c-. a-. c-.
}

scoreSTromboneII = \relative c' {
  \globalS
  a4->\f g8~-> g a-. a-.
  \pageBreak
  a-. a-. a-. a-. a-. a-.
}

scoreSTromboneIII = \relative c {
  \globalS
  f4->\f e8~-> e f-. e-.
  \pageBreak
  d-. e-. f-. g-. a-. g-.
}

scoreSTromboneIV = \relative c {
  \globalS
  d4->\f d8~-> d d-. c-.
  \pageBreak
  bf-. c-. d-. e-. f-. e-.
}

scoreSTromboneIPart = \new Staff \with {
  %instrumentName = "Tbn I"
  midiInstrument = "trombone"
} { \clef tenor \scoreSTromboneI }

scoreSTromboneIIPart = \new Staff \with {
  %instrumentName = "Tbn II"
  midiInstrument = "trombone"
} { \clef bass \scoreSTromboneII }

scoreSTromboneIIIPart = \new Staff \with {
  %instrumentName = "Tbn III"
  midiInstrument = "trombone"
} { \clef bass \scoreSTromboneIII }

scoreSTromboneIVPart = \new Staff \with {
  %instrumentName = "Tbn IV"
  midiInstrument = "trombone"
} { \clef bass \scoreSTromboneIV }

% ------------
%  Assemble both movements into the book
% ------------

\markup { \vspace #1 }
\score {
  \header {
    title = "Part I"
    instrument = ##f
    composer = ##f
  }
  <<
    \scoreATromboneIPart
    \scoreATromboneIIPart
    \scoreATromboneIIIPart
    \scoreATromboneIVPart
  >>
  \layout { }
  \midi { }
}

\markup { \vspace #1 }
\score {
  \header {
    title = "Part II"
    instrument = ##f
    composer = ##f
  }
  <<
    \scoreSTromboneIPart
    \scoreSTromboneIIPart
    \scoreSTromboneIIIPart
    \scoreSTromboneIVPart
  >>
  \layout { }
  \midi { }
}

\bookpart {
  \markup { \vspace #1 }
  \score {
  \header {
    title = "Part I"
    instrument = ##f
    poet  = "trombone I"
    composer = ##f
  }
    \scoreATromboneIPart
    \layout{}
  }
  \markup { \vspace #1 }
  \score {
  \header {
    title = "Part II"
    instrument = ##f
    poet  = "trombone I"
    composer = ##f
  }
    \scoreSTromboneIPart
    \layout{}
  }
}

\bookpart {
  \markup { \vspace #1 }
  \score {
  \header {
    title = "Part I"
    instrument = ##f
    poet  = "trombone II"
    composer = ##f
  }
    \scoreATromboneIIPart
    \layout{}
  }
  \markup { \vspace #1 }
  \score {
  \header {
    title = "Part II"
    instrument = ##f
    composer = ##f
    poet  = "trombone II"
  }
    \scoreSTromboneIIPart
    \layout{}
  }
}

\bookpart {
  \markup { \vspace #1 }
  \score {
  \header {
    title = "Part I"
    instrument = ##f
    poet = "trombone III"
    composer = ##f
  }
    \scoreATromboneIIIPart
    \layout{}
  }
  \markup { \vspace #1 }
  \score {
  \header {
    title = "Part II"
    instrument = ##f
    composer = ##f
    poet  = "trombone III"
  }
    \scoreSTromboneIIIPart
    \layout{}
  }
}

\bookpart {
  \markup { \vspace #1 }
  \score {
  \header {
    title = "Part I"
    instrument = ##f
    poet =  "trombone IV"
    composer = ##f
  }
    \scoreATromboneIVPart
    \layout{}
  }
  \markup { \vspace #1 }
  \score {
  \header {
    title = "Part II"
    instrument = ##f
    composer = ##f
    poet  = "trombone IV"
  }
    \scoreSTromboneIVPart
    \layout{}
  }
}

Reply via email to