Paper and layout

Spacing issues


Aligning and centering instrument names

The horizontal alignment of instrument names is tweaked by changing the Staff.InstrumentName.self-alignment-X property. The \layout variables indent and short-indent define the space in which the instrument names are aligned before the first and the following systems, respectively.

\paper{left-margin=3\cm}
\score{
\newStaffGroup<<
\newStaff\with{
\overrideInstrumentName.self-alignment-X=#LEFT
instrumentName=\markup\left-column{
"Left aligned"
"instrument name"
}
shortInstrumentName="Left"
}
{c''1\breakc''1}
\newStaff\with{
\overrideInstrumentName.self-alignment-X=#CENTER
instrumentName=\markup\center-column{
Centered
"instrument name"
}
shortInstrumentName="Centered"
}
{g'1g'1}
\newStaff\with{
\overrideInstrumentName.self-alignment-X=#RIGHT
instrumentName=\markup\right-column{
"Right aligned"
"instrument name"
}
shortInstrumentName="Right"
}
{e'1e'1}
>>
\layout{
ragged-right=##t
indent=4\cm
short-indent=2\cm
}
}

[image of music]


Arranging separate lyrics on a single line

Sometimes you may want to put lyrics for different performers on a single line: where there is rapidly alternating text, for example. This snippet shows how this can be done with \override VerticalAxisGroup.nonstaff-nonstaff-spacing.minimum-distance = ##f.

\layout{
\context{
\Lyrics
\overrideVerticalAxisGroup.nonstaff-nonstaff-spacing.minimum-distance=##f
}
}
aliceSings=\markup{\smallCaps"Alice"}
eveSings=\markup{\smallCaps"Eve"}
<<
\newStaff<<
\newVoice="alice"{
f'4^\aliceSingsg'r2|
s1|
f'4^\aliceSingsg'r2|
s1|\break
% ...
\voiceOne
s2a'8^\aliceSingsa'b'4|
\oneVoice
g'1
}
\newVoice="eve"{
s1|
a'2^\eveSingsg'|
s1|
a'2^\eveSingsg'
% ...
\voiceTwo
f'4^\eveSingsa'8g'f'4e'|
\oneVoice
s1
}
>>
\newLyrics\lyricsto"alice"{
may--be
sec--ond
% ...
Shutup,youfool!
}
\newLyrics\lyricsto"eve"{
thatthe
wordsare
% ...
...andthenIwaslike–
}
>>

[image of music]


Book parts

\bookpart can be used to split a book into several parts. Each part last page can be affected by ragged-last-bottom. Header and footer markups can detect a part last page, and make the difference with the book last page.

#(set-default-paper-size"a6")
\book{
%% book paper, which is inherited by all children bookparts
\paper{
ragged-last-bottom=##t
%% Page footer: add a different part-tagline at part last page
oddFooterMarkup=\markup{
\column{
\fill-line{
%% Copyright header field only on book first page.
\if\on-first-page\fromproperty#'header:copyright
}
\fill-line{
%% Part tagline header field only on each part last page.
\if\on-last-page-of-part\fromproperty#'header:parttagline
}
\fill-line{
%% Tagline header field only on book last page.
\if\on-last-page\fromproperty#'header:tagline
}
}
}
}
%% book header, which is inherited by the first bookpart
\header{
title="Book title"
copyright="Copyright line on book first page"
parttagline="Part tagline"
tagline="Book tagline"
}
\bookpart{
%% a different page breaking function may be used on each part
\paper{page-breaking=#ly:minimal-breaking}
\header{subtitle="First part"}
\markup{Thefirstbookpart}
\markup{apagebreak}
\pageBreak
\markup{firstpartlastpage}
\markup\wordwrap{withragged-last-bottom(seethespacebelowthistext)}
}
\bookpart{
\header{subtitle="Second part"}
{c'4}
}
}

[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.

<<
\newStaff{
\relativec''{
\dynamicDown
c8\ffccccccc
}
}
\newStaff\with{
fontSize=#-3
\overrideStaffSymbol.staff-space=#(magstep-3)
}{
\clefbass
c8cccc\fccc
}
>>

[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’.

If system starts and ends are included, they include extents of the System grob, e.g., instrument names.

Grace notes at the end point of the region are not included.

Regions can span multiple systems. In this case, multiple EPS files are generated.

#(ly:set-option'clip-systems)
#(defineoutput-suffix"1")
origScore=\score{
\relativec'{
\newStaff\with{instrumentName="Instrument"}
c1
d1
\gracec16e1
\keyd\major
f1\break
\clefbass
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-location201)
(make-rhythmic-location401))
(cons
(make-rhythmic-location001)
(make-rhythmic-location401))
(cons
(make-rhythmic-location001)
(make-rhythmic-location601))
)
}
}
}
#(ly:set-option'clip-systems#f)
#(defineoutput-suffix#f)
\book{
\score{\origScore}
\markup{\bold\fontsize#6clips}
\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))}
}
}
}

[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-size20)
\score{
{
\repeatunfold12{s1\break}
}
\layout{
indent=0\in
\context{
\Staff
\remove"Time_signature_engraver"
\remove"Clef_engraver"
\remove"Bar_engraver"
}
\context{
\Score
\remove"Bar_number_engraver"
}
}
}
% uncomment these lines for "letter" size
%{
\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
}
%}
% uncomment these lines for "A4" size
%{
\paper {
 #(set-paper-size "a4")
 ragged-last-bottom = ##f
 line-width = 180
 left-margin = 15
 bottom-margin = 10
 top-margin = 10
}
%}

[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"
meter="meter"
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{
\relativec''{c1|c|c|c}
}
\score{
\relativec''{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]


Setting system separators

System separators can be inserted between systems. Any markup can be used, but \slashSeparator has been provided as a sensible default.

\paper{
system-separator-markup=\slashSeparator
line-width=120
}
notes=\relativec'{
c1|c\break
c1|c\break
c1|c
}
\book{
\score{
\newGrandStaff<<
\newStaff\notes
\newStaff\notes
>>
}
}

[image of music]


Table of contents

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

#(set-default-paper-size"a6")
\book{
\markuplist\table-of-contents
\pageBreak
\tocItem\markup{Thefirstscore}
\score{
{
c'1\pageBreak
\mark\default\tocItem\markup{MarkA}
d'1
}
}
\pageBreak
\tocItem\markup{Thesecondscore}
\score{
{e'1}
\header{piece="Second score"}
}
}

[image of music]


Vertical aligned StaffGroups without connecting SystemStartBar

This snippet shows how to achieve vertically aligned StaffGroups with a SystemStartBar for each StaffGroup, but without connecting them.

#(set-global-staff-size18)
\paper{
indent=0
ragged-right=##f
print-all-headers=##t
}
\layout{
\context{
\StaffGroup
\consistsText_mark_engraver
\consistsStaff_collecting_engraver
systemStartDelimiterHierarchy=
#'(SystemStartBrace(SystemStartBracketab))
}
\context{
\Score
\removeText_mark_engraver
\removeStaff_collecting_engraver
\overrideSystemStartBrace.style=#'bar-line
\omitSystemStartBar
\overrideSystemStartBrace.padding=#-0.1
\overrideSystemStartBrace.thickness=#1.6
\overrideStaffGrouper.staffgroup-staff-spacing.basic-distance=#15
}
}
%%%% EXAMPLE
txt=
\lyricmode{
Wer4nurdenlie--benGottläßtwal2--ten4
und4hof--fetaufihnal--leZeit2.
}
% First StaffGroup "exercise"
eI=
\relativec'{
\textMark\markup{
\boldTeacher:
Thisisasimplesettingofthechoral.Pleaseimproveit.
}
\keya\minor
\time4/4
\voiceOne
\partial4
e4
abcb
abgis2
e4\fermatag!gf
eaagis
a2.\fermata
\bar":|."
}
eII=
\relativec'{
\keya\minor
\time4/4
\voiceTwo
\partial4
c4
eeegis
afe2
b4bdd
ccdd
c2.
\bar":|."
}
eIII=
\relativec'{
\keya\minor
\time4/4
\clefbass
\voiceOne
\partial4
a4
cbab
cdb2
gis4ggb
cafe
e2.
}
eIV=
\relativec'{
\keya\minor
\time4/4
\clefbass
\voiceTwo
\partial4
a,4
a'gisae
a,de2
e,4\fermatae'bg
cfde
a,2.\fermata
\bar":|."
}
exercise=
\newStaffGroup="exercise"
<<
\newStaff
<<
\newVoice\eI
\newVoice\eII
>>
\newLyrics\txt
\newStaff
<<
\newVoice\eIII
\newVoice\eIV
>>
>>
% Second StaffGroup "simple Bach"
sbI=
\relativec'{
\textMark\markup{\bold" Pupil:"Here'smyversion!}
\keya\minor
\time4/4
\voiceOne
\partial4
e4
abcb
abgis2
e4\fermatag!gf
eaagis
a2.\fermata
\bar":|."
}
sbII=
\relativec'{
\keya\minor
\time4/4
\voiceTwo
\partial4
c8d
e4ee8fg4
ffe2
b4b8cd4d
e8dc4b8cd4
c2.
\bar":|."
}
sbIII=
\relativec'{
\keya\minor
\time4/4
\clefbass
\voiceOne
\partial4
a8b
c4bab8c
d4d8cb2
gis4gg8ab4
ba8gf4e
e2.
}
sbIV=
\relativec'{
\keya\minor
\time4/4
\clefbass
\voiceTwo
\partial4
a,4
a'gisae
f8ed4e2
e,4\fermatae'ba8g
c4f8ed4e
a,2.\fermata
\bar":|."
}
simpleBach=
\newStaffGroup="simple Bach"
<<
\newStaff
<<
\newVoice\sbI
\newVoice\sbII
>>
\newLyrics\txt
\newStaff
<<
\newVoice\sbIII
\newVoice\sbIV
>>
>>
% Third StaffGroup "chromatic Bach"
cbI=
\relativec'{
\textMark\markup{
\bold"Teacher:"
\column{
"Well, you simply copied and transposed a version of J.S.Bach."
"Do you know this one?"
}
}
\keya\minor
\time4/4
\voiceOne
\partial4
e4
abcb
abgis4.fis8
e4\fermatag!gf
eaa8bgis4
a2.\fermata
\bar":|."
}
cbII=
\relativec'{
\keya\minor
\time4/4
\voiceTwo
\partial4
c8d
e4ee8fisgis4
a8g!f!4e2
b4eed
d8[cis]ddisefise4
e2.
\bar":|."
}
cbIII=
\relativec'{
\keya\minor
\time4/4
\clefbass
\voiceOne
\partial4
a8b
c[b]agis8a4d,
e8[e']dcb4.a8
gis4bcd8c
b[a]abcbbc16d
c2.
}
cbIV=
\relativec'{
\keya\minor
\time4/4
\clefbass
\voiceTwo
\partial4
a4
c,ea,b
cde2
e4\fermataeab8c
gis[g]fisfedise4
a,2.\fermata
\bar":|."
}
chromaticBach=
\newStaffGroup="chromatic Bach"
<<
\newStaff
<<
\newVoice\cbI
\newVoice\cbII
>>
\newLyrics\txt
\newStaff
<<
\newVoice\cbIII
\newVoice\cbIV
>>
>>
% Score
\score{
<<
\exercise
\simpleBach
\chromaticBach
>>
\header{
title=\markup
\column{
\combine\null\vspace#1
"Exercise: Improve the given choral"
" "
}
}
\layout{
\context{
\Lyrics
\overrideLyricText.X-offset=#-1
}
}
}

[image of music]


<< Back to Documentation Index

LilyPond — Snippets v2.24.4 (stable-branch).

AltStyle によって変換されたページ (->オリジナル) /