3.5.1 Extracting fragments of music

It is possible to output one or more fragments of a score by defining the explicit location of the music to be extracted within the \layout block of the input file using the clip-regions function, and then running LilyPond with the ‘-dclip-systems’ option;

\layout {
  clip-regions
  = #(list
      (cons
       (make-rhythmic-location 5 1 2)
       (make-rhythmic-location 7 3 4)))
}

This example will extract a single fragment of the input file starting after a half note duration in fifth measure (5 1 2) and ending after the third quarter note in the seventh measure (7 3 4).

Additional fragments can be extracted by adding more pairs of make-rhythmic-location entries to the clip-regions list in the \layout block.

By default, each music fragment will be output as a separate EPS file, but other formats such as PDF or PNG can also be created if required. The extracted music is output as if had been literally ‘cut’ from the original printed score so if a fragment runs over one or more lines, a separate output file for each line will be generated.

See also

Notation Reference: The \layout block.

Application Usage: Command-line usage.


LilyPond — Notation Reference v2.23.82 (development-branch).