Jump to content

Appoggiatura or grace note before a bar line: Difference between revisions

From LilyPond wiki
Import snippet from LSR
 
Extend example to cover multi-staff situation.
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
By default, appoggiaturas and grace notes that occur on the first beat of a measure are printed after the bar line. They can however be printed before, simply by adding an invisible BarLine and then the visible one, as demonstrated here.
By default, appoggiaturas and grace notes that occur on the first beat of a measure are printed after the bar line. A possible solution for single staves to  print it before the bar line is to add an invisible bar line and then the visible one.


<lilypond version="2.24.0">
In multi-staff systems, however, adding an invisible bar line distorts the positioning of full-bar rests in other staves; they are no longer centered but slightly shifted to the left.  A better solution for such situations is to use the <code>\afterGrace</code> command with setting <code>afterGraceFraction</code> appropriately.
{
 
   R1
<lilypond version="2.24">
  %% default
<<
  \appoggiatura d''8 c''4 r2.
   {
  %% cheated
    \appoggiatura d''8 c''4 r2. |
  \appoggiatura { \bar "" d''8 \bar "|" } c''4 r2.
    \appoggiatura { \bar "" d''8 \bar "|" } |
}
    c''4 r2.
  }
  { R1 | R1 }
>>
 
afterGraceFraction = 15/16
 
<<
  {
    \appoggiatura d''8 c''4 \afterGrace r2. d''8( |
    c''4) r2.
  }
  { R1 | R1 }
>>
</lilypond>
</lilypond>


Line 14: Line 27:
[[Category:Workaround]]
[[Category:Workaround]]
[[Category:Included in the official documentation]]
[[Category:Included in the official documentation]]
[[Category:Snippet]]

Latest revision as of 07:12, 30 November 2025

By default, appoggiaturas and grace notes that occur on the first beat of a measure are printed after the bar line. A possible solution for single staves to print it before the bar line is to add an invisible bar line and then the visible one.

In multi-staff systems, however, adding an invisible bar line distorts the positioning of full-bar rests in other staves; they are no longer centered but slightly shifted to the left. A better solution for such situations is to use the \afterGrace command with setting afterGraceFraction appropriately.

\version "2.24"

<<
  {
    \appoggiatura d''8 c''4 r2. |
    \appoggiatura { \bar "" d''8 \bar "|" } |
    c''4 r2.
  }
  { R1 | R1 }
>>

afterGraceFraction = 15/16

<<
  {
    \appoggiatura d''8 c''4 \afterGrace r2. d''8( |
    c''4) r2.
  }
  { R1 | R1 }
>>