I'm typesetting a theme+variations movement, where each variation follows a
||:   A   :||    B    |
            Fine      D.C. al Fine
structure. The following small example illustrates the type of output I would like (apart from some font size/weight tweaking):

%-------------------------------------------

\version "2.25.25"

\markup\large\bold "Desired result"
\fixed c' {
  \sectionLabel "Thème"
  \repeat segno 2 {
    \repeat volta 2 {
      c2 g |
      c1 |
    }
    \volta 1 \fine
    \volta 2 {
      f2 g |
    }
  }
  \section \break
  \sectionLabel \markup{\concat{1 \super er } Variation }
  \repeat volta 2 {
    c2 e4 g |
    e d c2 |
    \volta 2 \fine
  }
  f4 a g2 |
  \jump \markup\right-column { \line {D.S. \concat{1 \super er } Variation } "al Fine" }

  \section \break
  \sectionLabel "II Variation"
  \repeat volta 2 {
    c8 d e f g a g f |
    e f e d c2 |
    \volta 2 \fine
  }
  f8 g a f g f g g, |
  \jump \markup\right-column { "D.S. II Variation" "al Fine" }
}

%-------------------------------------------


In an attempt to achieve the result using \repeat segno, I tried the following, where for each variation I redefine the segnoMarkFormatter. However this causes a "timing" problem during processing, since the redefinition before Variation II happens at the same musical moment as the D.S. text is generated, and unfortunately, the redefinition seems to be done before the D.S. text is generated, resulting in "D.S. II Variation" instead of "D.S. 1er Variation".

%-------------------------------------------

\markup\large\bold "Failed attempt"
\fixed c' {
  \sectionLabel "Thème"
  \repeat segno 2 {
    \repeat volta 2 {
      c2 g |
      c1 |
    }
    \volta 1 \fine
    \volta 2 {
      f2 g |
    }
  }
  \section \break
  \set Score.segnoMarkFormatter = #(lambda args #{ \markup \normalsize \bold { \concat{1 \super er } Variation } #})
  \repeat segno 2 {
    \repeat volta 2 {
      c2 e4 g |
      e d c2 |
    }
    \volta 1 \fine
    \volta 2 {
      f4 a g2 |
  }}
  \section \break
  \set Score.segnoMarkFormatter = #(lambda args #{ \markup \normalsize \bold { "II Variation" } #})
  \repeat segno 2 {
    \repeat volta 2 {
      c8 d e f g a g f |
      e f e d c2 |
    }
    \volta 1 \fine
    \volta 2 {
      f8 g a f g f g g, |
    }
  }
}

%-------------------------------------------


An ugly workaround is to insert some musical space between end of one variation and the start of the next, as shown below, where I inserted a grace spacer rest. However, this additional space is reflected in the typeset output.

%-------------------------------------------

\markup\large\bold "Workaround using grace spacer"
\fixed c' {
  \sectionLabel "Thème"
  \repeat segno 2 {
    \repeat volta 2 {
      c2 g |
      c1 |
    }
    \volta 1 \fine
    \volta 2 {
      f2 g |
    }
  }
  \section \break
  \grace s8
  \set Score.segnoMarkFormatter = #(lambda args #{ \markup \normalsize \bold { \concat{1 \super er } Variation } #})
  \repeat segno 2 {
    \repeat volta 2 {
      c2 e4 g |
      e d c2 |
    }
    \volta 1 \fine
    \volta 2 {
      f4 a g2 |
  }}
  \section \break
  \grace s8
  \set Score.segnoMarkFormatter = #(lambda args #{ \markup \normalsize \bold { "II Variation" } #})
  \repeat segno 2 {
    \repeat volta 2 {
      c8 d e f g a g f |
      e f e d c2 |
    }
    \volta 1 \fine
    \volta 2 {
      f8 g a f g f g g, |
    }
  }
}

%-------------------------------------------

I attach the result of these three approaches.

Another possible solution in this particular case is to implement a more intelligent function to use as segnoMarkFormatter, that determines the desired label for each variation based on the segno number. Of course, I could also stick to the default segnoMarkFormatter, but I have honestly never seen any printed music that uses the resulting layout, at least not in any music from the classical era. I could also use the version with \jump instead of \repeat segno, but then \unfoldRepeats doesn't work.

Does anybody have a clever solution that uses \repeat segno? Should it even be considered a bug of the \repeat segno functionality?

   /Mats

Attachment: segno_redef_probl.pdf
Description: Adobe PDF document

Reply via email to