So, I couldn't help but make a small post about this when I saw it, since I've heard numerous people ask about it. In programs like Musescore, to increase/decrease the size of a measure, there's a keyboard shortcut for that. In LilyPond, since the horizontal spacing engine makes the whitespace "springy" and compressible, it's a less straightforward process. The documented ways of adjusting the horizontal spacing are found in the Notation Reference (
NR), so I won't go over them here (well, maybe later).
As I was browsing through the LilyPond Snippet Repository (
LSR), looking for something completely different, I stumbled upon this little trick for adjusting measure width. Unfortunately, it is only helpful for
increasing the width. Let's start with a simple score:
\new Voice \relative c' {
\dynamicUp
<< { c1 } { s2\f s2\p } >> | \noBreak
f4 e d c | \noBreak
<< { c1 } { s2\f s2\p } >> | \noBreak
d2 e | \break
}
The issue we'd like to remedy is the horizontal spacing given to the dynamics in the first measure, which we will adjust in the third measure for comparison. The real trick here is to use a parallel voice that contains basically no musical information, but allows us to override some dimensions. Using a
MultiMeasureRest (MMR) gives us access to a property called "
minimum-length". This is what we will use to force the measure to extend in length, thus creating more space for the second dynamic marking. To make it more useful, I wrapped the code within a music function that we can reuse.
extender = #(define-music-function (parser location length music)
(number? ly:music?)
#{
<<
{ $music }
\new Voice {
\override MultiMeasureRest.transparent = ##t
\override MultiMeasureRest.minimum-length = #length
R1
}
>>
#})
This function takes two arguments. The first sets the value for "minimum-length". By definition, if the measure is already as long or longer than this value, then nothing changes. The second argument is the music expression that the spacing should apply to. There are two things to remember with this:
- The above code assumes the largest duration is a whole note, so you will need to change the duration of the MMR if you are using a different time signature ("R2." for 3/4 time, etc.).
- It's designed to extend the length of ONE measure only. Repeat as necessary.
Now, let's put it to use:
\version "2.18.2"
\paper {
line-width = 9\cm
indent = 0
}
extender = #(define-music-function (parser location length music)
(number? ly:music?)
#{
<<
{ $music }
\new Voice {
\override MultiMeasureRest.transparent = ##t
\override MultiMeasureRest.minimum-length = #length
R1
}
>>
#})
\markup "Before"
\new Voice \relative c' {
\dynamicUp
<< { c1 } { s2\f s2\p } >> | \noBreak
f4 e d c | \noBreak
<< { c1 } { s2\f s2\p } >> | \noBreak
d2 e | \break
}
\markup "After"
\new Voice \relative c' {
\dynamicUp
<< { c1 } { s2\f s2\p } >> | \noBreak
f4 e d c | \noBreak
\extender #12 << { c1 } { s2\f s2\p } >> | \noBreak
d2 e | \break
}
That looks better (focus is on the
third measure, of course) and certainly could be adjusted further, but we'll stop there for now, having accomplished our goal.
I'm still on the lookout for a more convenient solution for "shrinking" a measure, but some of the methods in the NR (above) can help with this.
Got any other great ideas for shrinking or expanding measures to make the page look better? Share them in the comments!