lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Center-align a score


From: David Nalesnik
Subject: Re: Center-align a score
Date: Wed, 26 Apr 2017 18:37:19 -0500

On Wed, Apr 26, 2017 at 3:08 PM, Kieren MacMillan
<address@hidden> wrote:
> Hi all,
>
>> I think this request is idiosyncratic enough to be left to a
>> two-stage process, some thing along the lines of:
>
> That would work, of course… but I think it would be easier (and better for 
> long-term maintainability) to do it all in Lilypond, e.g.,
>
> %%  SNIPPET BEGINS
> \version "2.19.17"
>
> \paper {
>   ragged-right = ##t
>   indent = 0
> }
>
> music = {
>   \overrideProperty Score.NonMusicalPaperColumn.line-break-system-details 
> #'((X-offset . 38))
>   \repeat unfold 8 c'' \break
>   \overrideProperty Score.NonMusicalPaperColumn.line-break-system-details 
> #'((X-offset . 33))
>   \repeat unfold 12 c'' \break
>   \overrideProperty Score.NonMusicalPaperColumn.line-break-system-details 
> #'((X-offset . 46))
>   \repeat unfold 4 c'' \break
>   \overrideProperty Score.NonMusicalPaperColumn.line-break-system-details 
> #'((X-offset . 39.5))
>   \repeat unfold 8 c'' \break
> }
>
> \score { \music }
> %%  SNIPPET ENDS
>
> A little trial-and-error is required if doing it manually, but there might be 
> a way to automate the process.
>

Here you go:

%%%%%%%%%%%%%%%%%

\version "2.19"

\paper {
  ragged-right = ##t
  indent = 0
}

\layout {
  \context {
    \Score
    \override NonMusicalPaperColumn.after-line-breaking =
    #(lambda (grob)
       (if (eqv? (ly:item-break-dir grob) 1) ; line beginning
           (let* ((sys (ly:grob-system grob))
                  (sys-width (ly:grob-extent sys sys X))
                  (layout (ly:grob-layout grob))
                  (line-full-width (ly:output-def-lookup layout 'line-width)))
             (ly:grob-set-nested-property! grob
'(line-break-system-details X-offset)
               (/ (- line-full-width (interval-length sys-width)) 2)))))
  }
}

music = {
  \repeat unfold 8 c'' \break
  \repeat unfold 12 c'' \break
  \repeat unfold 4 c'' \break
  \repeat unfold 8 c'' \break
}

\score { \music }

%%%%%%%%%%%%%%%%%%

Hope this helps,

David



reply via email to

[Prev in Thread] Current Thread [Next in Thread]