%% => http://lilypond.1069038.n5.nabble.com/Partial-Bars-td178358.html
\version "2.18.2"

global = {
  \time 3/4
  \key g\major
}

menuet = {
 
  %% PART A
  \mark\default
  \repeat volta 2 {
    % mes.0
      \partial 4 r4 |
    % mes.1-7
      R2.*7
    % mes.(8)
      r2 % <= no barcheck (incomplete measure)
  }
  
  %% PART B
  \mark\default
  \repeat volta 2 {
    % mes.8
      r4 | % <= barcheck (end of measure 8)
    % mes.9-15
      R2.*7
  }
  \alternative {
    {
      % mes.16a
        \override Score.BarNumber.before-line-breaking =
          #(lambda (grob)
            (let* ((txt (ly:grob-property grob 'text)))
              (ly:grob-set-property! grob 'text (markup #:concat ( txt "a"))))) 
        r2 % <= no barcheck (incomplete measure)
        \tweak direction #DOWN
        \tweak self-alignment-X #RIGHT
        \mark\markup\small\italic "Fine."
    }
    {
      % mes.16b
        \override Score.BarNumber.before-line-breaking =
          #(lambda (grob)
            (let* ((txt (ly:grob-property grob 'text)))
              (ly:grob-set-property! grob 'text (markup #:concat ( txt "b"))))) 
        \set Timing.measurePosition = #(ly:make-moment 0)
        r4 r8 % <= no barcheck (incomplete measure)
    }
  }
  
  %% PART C
  \mark\default
  \tempo "Trio"
  \repeat volta 2 {
    % mes.(16)
      \revert Score.BarNumber.before-line-breaking 
      r8 r4 | % <= barcheck (end of measure 16)
    % mes.17-23
      R2.*7
    % mes.(24)
      r2 % <= no barcheck (incomplete measure)  
  }
  
  %% PART D
  \mark\default
  \repeat volta 2 {
    % mes.24
      r4 | % <= barcheck (end of measure 24)
    % mes.25-31
      R2.*7
  }
  \alternative {
    {
      % mes.32a
        \override Score.BarNumber.before-line-breaking =
          #(lambda (grob)
            (let* ((txt (ly:grob-property grob 'text)))
              (ly:grob-set-property! grob 'text (markup #:concat ( txt "a"))))) 
        r4 r8 % <= no barcheck (incomplete measure 32a)
    }
    {
      % mes.32b
      \set Timing.measurePosition = #(ly:make-moment 0)
      \override Score.BarNumber.before-line-breaking =
          #(lambda (grob)
            (let* ((txt (ly:grob-property grob 'text)))
              (ly:grob-set-property! grob 'text (markup #:concat ( txt "b"))))) 
        r2 % <= no barcheck (incomplete measure 32b)
    }
  }
  %% D.C.
  \tweak direction #DOWN
  \tweak self-alignment-X #RIGHT
  \mark\markup\small\italic "D.C. al Fine."
  \bar "|."
}

\header {
  title = "Six Minuets"
  composer = "Ludwig van Beethoven"
  opus = "WoO 10"
  piece = "Menuet No.2"
}

\score {
  \new PianoStaff <<
    \new Staff = "RH" { \clef G \global \menuet }
    \new Staff = "LH" { \clef F \global \menuet }
  >>
  \layout {
    system-count = 5
    \context {
      \Score
      \override BarNumber.break-visibility = #all-visible
      \override BarNumber.break-visibility = #end-of-line-invisible
      \override BarNumber.color = #red
      barNumberVisibility = #(lambda (n x) (= (modulo n 1) 0)) 
    }
  }
}
