Jump to content

Changing the width of ledger lines: Difference between revisions

From LilyPond wiki
Import snippet from LSR
 
m New category
Tags: Mobile edit Mobile web edit
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
If you want to modify the width of ledger lines (for example to make them wider) you can do this by overriding the values of <code>LedgerLineSpanner.length-fraction</code> and (optionally) <code>LedgerLineSpanner.minimum-length-fraction</code>.
If you want to modify the width of ledger lines (for example to make them wider) you can do this by overriding the values of <code>LedgerLineSpanner.length-fraction</code> and (optionally) <code>LedgerLineSpanner.minimum-length-fraction</code>.


<lilypond version="2.24.0">
<lilypond version="2.24">
% Override LedgerLineSpanner.length-fraction to change the width
% Override LedgerLineSpanner.length-fraction to change the width
% of ledger lines. Its default setting is 0.25 which extends ledger
% of ledger lines. Its default setting is 0.25 which extends ledger
Line 39: Line 39:


[[Category:Tweaks and overrides]]
[[Category:Tweaks and overrides]]
[[Category:Snippet]]

Latest revision as of 23:17, 21 November 2025

If you want to modify the width of ledger lines (for example to make them wider) you can do this by overriding the values of LedgerLineSpanner.length-fraction and (optionally) LedgerLineSpanner.minimum-length-fraction.

\version "2.24"

% Override LedgerLineSpanner.length-fraction to change the width
% of ledger lines. Its default setting is 0.25 which extends ledger
% lines beyond the note head on each side by 0.25 times the width
% of the note head. (1.0 is equal to the width of the note head.)
%
% LilyPond will automatically shorten ledger lines to avoid collisions.
% LedgerLineSpanner.minimum-length-fraction sets their minimum 
% length (i.e. smallest possible length) for such cases of potential 
% collision. It guarantees that ledger lines will always be at least 
% that wide. Its default setting is 0.25  (It should always be less 
% than or equal to the value of LedgerLineSpanner.length-fraction.)
%
% See the illustrations here:
% http://lilypond.1069038.n5.nabble.com/Widening-ledger-lines-by-overriding-LedgerLineSpanner-td162842.html#a162850

notes = {
  d4 e f g 
  c''' d''' e''' f'''
}

<<
\new Staff \with {
  instrumentName = "default "
} {
  \notes
}
\new Staff \with {
  instrumentName = "wider "
  \override LedgerLineSpanner.length-fraction = #0.45
  \override LedgerLineSpanner.minimum-length-fraction = #0.45
} {
  \notes
}
>>