Next: , Previous: Tweaks and overrides, Up: Top


Paper and layout

These snippets illustrate the Notation Reference, section Spacing issues.

Aligning and centering instrument names

Instrument names are generally printed to the left of the staves. To align the names of several different intruments, put them in a \markup block and use one of the following possibilites:

* Right-aligned instrument names: this is the default behavior

* Center-aligned instrument names: using the \hcenter-in #n command places the instrument names inside a padded box, with n being the width of the box

* Left-aligned instrument names: the names are printed on top of an empty box, using the \combine command with an \hspace #n object.

\paper {
  indent = #0
  left-margin = #30
  line-width = #160
}

\new StaffGroup \relative c' <<
  \new Staff {
    \set Staff.instrumentName = #"Piccolo"
    c1^"default" | c \break
    \set Staff.instrumentName = \markup { \hcenter-in #10 Piccolo }
    c1^"centered" | c \break
    \set Staff.instrumentName = \markup { \combine \hspace #8 Piccolo }
    c1^"left-aligned" | c
  } 
  \new Staff {
    \set Staff.instrumentName = #"Flute"
    c1 | c \break
    \set Staff.instrumentName = \markup { \hcenter-in #10 Flute }
    c1 | c \break
    \set Staff.instrumentName = \markup { \combine \hspace #8 Flute }
    c1 | c
  }
>>

[image of music]

Alignment vertical spacing

By setting properties in NonMusicalPaperColumn, vertical spacing can be adjusted per system.

By setting alignment-extra-space or fixed-alignment-extra-space an individual system may be stretched vertically.

For technical reasons, \overrideProperty must be used for changing these properties within a staff; \override in a \context block may still be used for global overrides.

#(set-global-staff-size 13)

\relative c''
\new StaffGroup <<
  \new Staff {
    c1 \break
    c1 \break
    c1 \break
  }
  \new Staff {
    c1 | c | c
  }
  \new PianoStaff <<
    \new Voice  {
      \set PianoStaff.instrumentName = #"piano"
      \set PianoStaff.shortInstrumentName = #"pn"
      c1_"normal"
      
      \overrideProperty
        #"Score.NonMusicalPaperColumn"
        #'line-break-system-details
        #'((fixed-alignment-extra-space . 15))
      c_"fixed-aligment-extra-space"

      \overrideProperty
        #"Score.NonMusicalPaperColumn"
        #'line-break-system-details
        #'((alignment-extra-space . 15))
      c_"aligment-extra-space"
    }
    { c1 | c | c }
  >>
>>

[image of music]

Changing the staff size

Though the simplest way to resize staves is to use #(set-global-staff-size xx), an individual staff's size can be changed by scaling the properties staff-space and fontSize.

<<
  \new Staff \relative c'' {
    \dynamicDown
    c8\ff c c c c c c c
  }
  \new Staff \with {
    fontSize = #-3
    \override StaffSymbol #'staff-space = #(magstep -3)
  } {
    \clef bass
    c8 c c c c\f c c c
  }
>>

[image of music]

Clip systems

This code shows how to clip (extract) snippets from a full score.

This file needs to be run separately with -dclip-systems; the snippets page may not adequately show the results.

The result will be files named base-from-start-to-end[-count].eps.

#(ly:set-option 'clip-systems)
#(set! output-count 1)

origScore = \score {
  \relative c' {
    \set Staff.instrumentName = #"bla"
    c1
    d1
    \grace c16 e1
    \key d \major
    f1 \break
    \clef bass
    g,1
    fis1
  }
}

\book {
  \score {
    \origScore
    \layout {
      % Each clip-region is a (START . END) pair
      % where both are rhythmic-locations.
      
      % (make-rhythmic-locations BAR-NUMBER NUM DEN)
      % means NUM/DEN whole-notes into bar numbered BAR-NUMBER

      clip-regions = #(list
      (cons
       (make-rhythmic-location 2 0 1)
       (make-rhythmic-location 4 0 1))
      
      (cons
       (make-rhythmic-location 0 0 1)
       (make-rhythmic-location 4 0 1))

      (cons
       (make-rhythmic-location 0 0 1)
       (make-rhythmic-location 6 0 1))
      )
    }
  }
}

#(set! output-count 0)
#(ly:set-option 'clip-systems #f)

\book {
  \score { \origScore }
  \markup { \bold \fontsize #6 clips }
  \score {
    \lyrics {
      \markup { from-2.0.1-to-4.0.1-clip.eps }
      \markup {
        \epsfile #X #30.0 #(format #f "~a-1-from-2.0.1-to-4.0.1-clip.eps"
                            (ly:parser-output-name parser)) }
    }
  }
}

[image of music]

Creating blank staves

To create blank staves, generate empty measures then remove the Bar_number_engraver from the Score context, and the Time_signature_engraver, Clef_engraver and Bar_engraver from the Staff context.

#(set-global-staff-size 20)

\score {
  { 
    \repeat unfold 12 { s1 \break } 
  }
  \layout {
    indent = 0\in
    \context {
      \Staff
      \remove "Time_signature_engraver"
      \remove "Clef_engraver"
      \remove "Bar_engraver"
    }
    \context {
      \Score
      \remove "Bar_number_engraver"
    }
  }
}

\paper {
  #(set-paper-size "letter")
  ragged-last-bottom = ##f
  line-width = 7.5\in
  left-margin = 0.5\in
  bottom-margin = 0.25\in
  top-margin = 0.25\in
}

[image of music]

Demonstrating all headers

All header fields with special meanings.

\header {
  copyright = "copyright"
  title = "title"
  subtitle = "subtitle"
  composer = "composer"
  arranger = "arranger"
  instrument = "instrument"
  metre = "metre"
  opus = "opus"
  piece = "piece"
  poet = "poet"
  texidoc = "All header fields with special meanings."
  copyright = "public domain"
  enteredby = "jcn"
  source = "urtext"
}

\layout {
  ragged-right = ##f
}

\score {
  \relative c'' { c1 | c | c | c }
}

\score {
   \relative c'' { c1 | c | c | c }
   \header {
     title = "localtitle"
     subtitle = "localsubtitle"
     composer = "localcomposer"
     arranger = "localarranger"
     instrument = "localinstrument"
     metre = "localmetre"
     opus = "localopus"
     piece = "localpiece"
     poet = "localpoet"
     copyright = "localcopyright"
   }
}

[image of music]

Table of contents

A table of contents is included using \markuplines \table-of-contents. The TOC items are added with the \tocItem command.

#(set-default-paper-size "a6")

\book {
  \markuplines \table-of-contents
  \pageBreak
  \tocItem \markup { The first score }
  \score {
    {
      c'1 \pageBreak
      \mark "A" \tocItem \markup { Mark A }
      d'1
    }
  }
  \pageBreak
  \tocItem \markup { The second score }
  \score {
    { e'1 }
    \header { piece = "Second score" }
  }
}

[image of music]

This page is for LilyPond-2.11.58 (development-branch).

Report errors to http://post.gmane.org/post.php?group=gmane.comp.gnu.lilypond.bugs.

Your suggestions for the documentation are welcome.