LilyPond

The music typesetter
Learning Manual
The LilyPond development team
Copyright c 1999–2009 by the authors
Permission is granted to copy, distribute and/or modify this document under the
terms of the GNU Free Documentation License, Version 1.1 or any later version
published by the Free Software Foundation; with no Invariant Sections. A copy of
the license is included in the section entitled “GNU Free Documentation License”.
For LilyPond version 2.12.3
i
Table of Contents
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.1 Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Engraving . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Automated engraving. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
What symbols to engrave? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Music representation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Example applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.2 About the documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
About the Learning Manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
About the Music Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
About the Notation Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
About the Application Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
About the Snippet List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
About the Internals Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Other documentation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2 Tutorial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.1 First steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.1.1 Compiling a fle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.1.2 Simple notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.1.3 Working on input fles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2.1.4 How to read the manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
2.2 Single staf notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
2.2.1 Accidentals and key signatures. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
2.2.2 Ties and slurs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
2.2.3 Articulation and dynamics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
2.2.4 Adding text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
2.2.5 Automatic and manual beams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
2.2.6 Advanced rhythmic commands. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
2.3 Multiple notes at once . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
2.3.1 Music expressions explained . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
2.3.2 Multiple staves . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
2.3.3 Staf groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
2.3.4 Combining notes into chords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
2.3.5 Single staf polyphony . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
2.4 Songs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
2.4.1 Setting simple songs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
2.4.2 Aligning lyrics to a melody . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
2.4.3 Lyrics to multiple staves . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
2.5 Final touches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
2.5.1 Organizing pieces with variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
2.5.2 Version number. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
2.5.3 Adding titles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
2.5.4 Absolute note names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
2.5.5 After the tutorial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
ii
3 Fundamental concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
3.1 How LilyPond input fles work. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
3.1.1 Introduction to the LilyPond fle structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
3.1.2 Score is a (single) compound musical expression. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
3.1.3 Nesting music expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
3.1.4 On the un-nestedness of brackets and ties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
3.2 Voices contain music . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
3.2.1 I’m hearing Voices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
3.2.2 Explicitly instantiating voices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
3.2.3 Voices and vocals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
3.3 Contexts and engravers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
3.3.1 Contexts explained . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
3.3.2 Creating contexts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
3.3.3 Engravers explained . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
3.3.4 Modifying context properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
3.3.5 Adding and removing engravers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
3.4 Extending the templates. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
3.4.1 Soprano and cello . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
3.4.2 Four-part SATB vocal score . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
3.4.3 Building a score from scratch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
4 Tweaking output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
4.1 Tweaking basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
4.1.1 Introduction to tweaks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
4.1.2 Objects and interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
4.1.3 Naming conventions of objects and properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
4.1.4 Tweaking methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
4.2 The Internals Reference manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
4.2.1 Properties of layout objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
4.2.2 Properties found in interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
4.2.3 Types of properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
4.3 Appearance of objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
4.3.1 Visibility and color of objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
4.3.2 Size of objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
4.3.3 Length and thickness of objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
4.4 Placement of objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
4.4.1 Automatic behavior . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
4.4.2 Within-staf objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
4.4.3 Outside-staf objects. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
4.5 Collisions of objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
4.5.1 Moving objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
4.5.2 Fixing overlapping notation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
4.5.3 Real music example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
4.6 Further tweaking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
4.6.1 Other uses for tweaks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
4.6.2 Using variables for tweaks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
4.6.3 Other sources of information. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
4.6.4 Avoiding tweaks with slower processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
4.6.5 Advanced tweaks with Scheme . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
iii
5 Working on LilyPond projects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
5.1 Suggestions for writing LilyPond input fles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
5.1.1 General suggestions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
5.1.2 Typesetting existing music. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
5.1.3 Large projects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
5.1.4 Saving typing with variables and functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
5.1.5 Style sheets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
5.2 When things don’t work. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
5.2.1 Updating old input fles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
5.2.2 Troubleshooting (taking it all apart) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
5.2.3 Minimal examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
5.3 Scores and parts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
Appendix A Templates. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
A.1 Single staf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
A.1.1 Notes only. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
A.1.2 Notes and lyrics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
A.1.3 Notes and chords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
A.1.4 Notes, lyrics, and chords. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
A.2 Piano templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
A.2.1 Solo piano . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
A.2.2 Piano and melody with lyrics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
A.2.3 Piano centered lyrics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
A.2.4 Piano centered dynamics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
A.3 String quartet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
A.3.1 String quartet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
A.3.2 String quartet parts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
A.4 Vocal ensembles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
A.4.1 SATB vocal score . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
A.4.2 SATB vocal score and automatic piano reduction. . . . . . . . . . . . . . . . . . . . . . . . . . . 154
A.4.3 SATB with aligned contexts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
A.5 Ancient notation templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
A.5.1 Transcription of mensural music. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
A.5.2 Gregorian transcription template . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
A.6 Jazz combo. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
A.7 lilypond-book templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
A.7.1 LaTeX. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
A.7.2 Texinfo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171
A.7.3 xelatex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171
Appendix B Scheme tutorial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
B.1 Tweaking with Scheme. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174
Appendix C GNU Free Documentation License . . . . . . . . . . . 176
Appendix D LilyPond index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182
Preface 1
Preface
It must have been during a rehearsal of the EJE (Eindhoven Youth Orchestra), somewhere in
1995 that Jan, one of the cranked violists, told Han-Wen, one of the distorted French horn
players, about the grand new project he was working on. It was an automated system for
printing music (to be precise, it was MPP, a preprocessor for MusiXTeX). As it happened,
Han-Wen accidentally wanted to print out some parts from a score, so he started looking at the
software, and he quickly got hooked. It was decided that MPP was a dead end. After lots of
philosophizing and heated email exchanges, Han-Wen started LilyPond in 1996. This time, Jan
got sucked into Han-Wen’s new project.
In some ways, developing a computer program is like learning to play an instrument. In the
beginning, discovering how it works is fun, and the things you cannot do are challenging. After
the initial excitement, you have to practice and practice. Scales and studies can be dull, and
if you are not motivated by others – teachers, conductors or audience – it is very tempting to
give up. You continue, and gradually playing becomes a part of your life. Some days it comes
naturally, and it is wonderful, and on some days it just does not work, but you keep playing,
day after day.
Like making music, working on LilyPond can be dull work, and on some days it feels like
plodding through a morass of bugs. Nevertheless, it has become a part of our life, and we keep
doing it. Probably the most important motivation is that our program actually does something
useful for people. When we browse around the net we fnd many people who use LilyPond, and
produce impressive pieces of sheet music. Seeing that feels unreal, but in a very pleasant way.
Our users not only give us good vibes by using our program, many of them also help us by
giving suggestions and sending bug reports, so we would like to thank all users that sent us bug
reports, gave suggestions or contributed in any other way to LilyPond.
Playing and printing music is more than a nice analogy. Programming together is a lot of
fun, and helping people is deeply satisfying, but ultimately, working on LilyPond is a way to
express our deep love for music. May it help you create lots of beautiful music!
Han-Wen and Jan
Utrecht/Eindhoven, The Netherlands, July 2002.
Chapter 1: Introduction 2
1 Introduction
This chapter introduces readers to LilyPond and the documentation.
1.1 Background
This section covers the overall goals and architecture of LilyPond.
Engraving
The art of music typography is called (plate) engraving. The term derives from the traditional
process of music printing. Just a few decades ago, sheet music was made by cutting and stamping
the music into a zinc or pewter plate in mirror image. The plate would be inked, the depressions
caused by the cutting and stamping would hold ink. An image was formed by pressing paper
to the plate. The stamping and cutting was completely done by hand. Making a correction was
cumbersome, if possible at all, so the engraving had to be perfect in one go. Engraving was a
highly specialized skill; a craftsman had to complete around fve years of training before earning
the title of master engraver, and another fve years of experience were necessary to become truly
skilled.
Nowadays, all newly printed music is produced with computers. This has obvious advantages;
prints are cheaper to make, and editorial work can be delivered by email. Unfortunately, the
pervasive use of computers has also decreased the graphical quality of scores. Computer printouts
have a bland, mechanical look, which makes them unpleasant to play from.
The images below illustrate the diference between traditional engraving and typical computer
output, and the third picture shows how LilyPond mimics the traditional look. The left picture
shows a scan of a fat symbol from an edition published in 2000. The center depicts a symbol
from a hand-engraved B¨arenreiter edition of the same music. The left scan illustrates typical
faws of computer print: the staf lines are thin, the weight of the fat symbol matches the light
lines and it has a straight layout with sharp corners. By contrast, the B¨arenreiter fat has a
bold, almost voluptuous rounded look. Our fat symbol is designed after, among others, this
one. It is rounded, and its weight harmonizes with the thickness of our staf lines, which are
also much thicker than lines in the computer edition.
Henle (2000) B¨arenreiter (1950) LilyPond Feta font
(2003)
In spacing, the distribution of space should refect the durations between notes. However,
many modern scores adhere to the durations with mathematical precision, which leads to poor
results. In the next example a motive is printed twice: once using exact mathematical spacing,
and once with corrections. Can you spot which fragment is which?

Chapter 1: Introduction 3

Each bar in the fragment only uses notes that are played in a constant rhythm. The spacing
should refect that. Unfortunately, the eye deceives us a little; not only does it notice the
distance between note heads, it also takes into account the distance between consecutive stems.
As a result, the notes of an up-stem/down-stem combination should be put farther apart, and
the notes of a down-stem/up-stem combination should be put closer together, all depending on
the combined vertical positions of the notes. The upper two measures are printed with this
correction, the lower two measures without, forming down-stem/up-stem clumps of notes.
Musicians are usually more absorbed with performing than with studying the looks of a piece
of music, so nitpicking about typographical details may seem academical. But it is not. In larger
pieces with monotonous rhythms, spacing corrections lead to subtle variations in the layout of
every line, giving each one a distinct visual signature. Without this signature all lines would
look the same, and they become like a labyrinth. If a musician looks away once or has a lapse
in concentration, the lines might lose their place on the page.
Similarly, the strong visual look of bold symbols on heavy staf lines stands out better when
the music is far away from the reader, for example, if it is on a music stand. A careful distribution
of white space allows music to be set very tightly without cluttering symbols together. The result
minimizes the number of page turns, which is a great advantage.
This is a common characteristic of typography. Layout should be pretty, not only for its own
sake, but especially because it helps the reader in her task. For performance material like sheet
music, this is of double importance: musicians have a limited amount of attention. The less
attention they need for reading, the more they can focus on playing the music. In other words,
better typography translates to better performances.
These examples demonstrate that music typography is an art that is subtle and complex,
and that producing it requires considerable expertise, which musicians usually do not have.
LilyPond is our efort to bring the graphical excellence of hand-engraved music to the computer
age, and make it available to normal musicians. We have tuned our algorithms, font-designs,
and program settings to produce prints that match the quality of the old editions we love to see
and love to play from.
Automated engraving
How do we go about implementing typography? If craftsmen need over ten years to become
true masters, how could we simple hackers ever write a program to take over their jobs?
The answer is: we cannot. Typography relies on human judgment of appearance, so people
cannot be replaced completely. However, much of the dull work can be automated. If LilyPond
solves most of the common situations correctly, this will be a huge improvement over existing
software. The remaining cases can be tuned by hand. Over the course of years, the software
can be refned to do more and more things automatically, so manual overrides are less and less
necessary.
When we started, we wrote the LilyPond program entirely in the C++ programming language;
the program’s functionality was set in stone by the developers. That proved to be unsatisfactory
for a number of reasons:
• When LilyPond makes mistakes, users need to override formatting decisions. Therefore, the
user must have access to the formatting engine. Hence, rules and settings cannot be fxed
by us at compile-time but must be accessible for users at run-time.
• Engraving is a matter of visual judgment, and therefore a matter of taste. As knowledgeable
as we are, users can disagree with our personal decisions. Therefore, the defnitions of
typographical style must also be accessible to the user.
Chapter 1: Introduction 4
• Finally, we continually refne the formatting algorithms, so we need a fexible approach to
rules. The C++ language forces a certain method of grouping rules that do not match well
with how music notation works.
These problems have been addressed by integrating an interpreter for the Scheme program-
ming language and rewriting parts of LilyPond in Scheme. The current formatting architecture
is built around the notion of graphical objects, described by Scheme variables and functions.
This architecture encompasses formatting rules, typographical style and individual formatting
decisions. The user has direct access to most of these controls.
Scheme variables control layout decisions. For example, many graphical objects have a direc-
tion variable that encodes the choice between up and down (or left and right). Here you see two
chords, with accents and arpeggios. In the frst chord, the graphical objects have all directions
down (or left). The second chord has all directions up (right).

The process of formatting a score consists of reading and writing the variables of graphical
objects. Some variables have a preset value. For example, the thickness of many lines – a
characteristic of typographical style – is a variable with a preset value. You are free to alter this
value, giving your score a diferent typographical impression.

Formatting rules are also preset variables: each object has variables containing procedures.
These procedures perform the actual formatting, and by substituting diferent ones, we can
change the appearance of objects. In the following example, the rule which note head objects
are used to produce their symbol is changed during the music fragment.

G
F
D
c
m
2 2
c
m
4
2
c

bla

What symbols to engrave?
The formatting process decides where to place symbols. However, this can only be done once it
is decided what symbols should be printed, in other words what notation to use.
Common music notation is a system of recording music that has evolved over the past 1000
years. The form that is now in common use dates from the early renaissance. Although the
basic form (i.e., note heads on a 5-line staf) has not changed, the details still evolve to express
the innovations of contemporary notation. Hence, it encompasses some 500 years of music. Its
applications range from monophonic melodies to monstrous counterpoints for large orchestras.
Chapter 1: Introduction 5
How can we get a grip on such a many-headed beast, and force it into the confnes of a com-
puter program? Our solution is to break up the problem of notation (as opposed to engraving,
i.e., typography) into digestible and programmable chunks: every type of symbol is handled by
a separate module, a so-called plug-in. Each plug-in is completely modular and independent, so
each can be developed and improved separately. Such plug-ins are called engravers, by analogy
with craftsmen who translate musical ideas to graphic symbols.
In the following example, we see how we start out with a plug-in for note heads, the Note_
heads_engraver.

Then a Staff_symbol_engraver adds the staf

the Clef_engraver defnes a reference point for the staf

and the Stem_engraver adds stems.

The Stem_engraver is notifed of any note head coming along. Every time one (or more, for a
chord) note head is seen, a stem object is created and connected to the note head. By adding
engravers for beams, slurs, accents, accidentals, bar lines, time signature, and key signature, we
get a complete piece of notation.

This system works well for monophonic music, but what about polyphony? In polyphonic
notation, many voices can share a staf.

In this situation, the accidentals and staf are shared, but the stems, slurs, beams, etc., are
private to each voice. Hence, engravers should be grouped. The engravers for note heads, stems,
Chapter 1: Introduction 6
slurs, etc., go into a group called ‘Voice context,’ while the engravers for key, accidental, bar,
etc., go into a group called ‘Staf context.’ In the case of polyphony, a single Staf context
contains more than one Voice context. Similarly, multiple Staf contexts can be put into a single
Score context. The Score context is the top level notation context.
See also
Internals Reference: Section “Contexts” in Internals Reference.
·

,

,
,
¸
,

,

,

,

/
,
,
,
,
,

,
,
,
,
,
,
,

,
,
,
,

,

,

/
,
,
,
, ,
,
,
,
,

,

,
,

,

,
,
¸
,

,

,
,

,
·

Music representation
Ideally, the input format for any high-level formatting system is an abstract description of the
content. In this case, that would be the music itself. This poses a formidable problem: how
can we defne what music really is? Instead of trying to fnd an answer, we have reversed the
question. We write a program capable of producing sheet music, and adjust the format to be
as lean as possible. When the format can no longer be trimmed down, by defnition we are left
with content itself. Our program serves as a formal defnition of a music document.
The syntax is also the user-interface for LilyPond, hence it is easy to type:
{
c'4 d'8
}
to create a quarter note C1 (middle C) and an eighth note D1 (D above middle C).

On a microscopic scale, such syntax is easy to use. On a larger scale, syntax also needs
structure. How else can you enter complex pieces like symphonies and operas? The structure is
formed by the concept of music expressions: by combining small fragments of music into larger
ones, more complex music can be expressed. For example
f4

Simultaneous notes can be constructed by enclosing them with << and >>:
<<c4 d4 e4>>

Chapter 1: Introduction 7
This expression is put in sequence by enclosing it in curly braces { ... }:
{ f4 <<c4 d4 e4>> }

The above is also an expression, and so it may be combined again with another simultaneous
expression (a half note) using <<, \\, and >>:
<< g2 \\ { f4 <<c4 d4 e4>> } >>

Such recursive structures can be specifed neatly and formally in a context-free grammar.
The parsing code is also generated from this grammar. In other words, the syntax of LilyPond
is clearly and unambiguously defned.
User-interfaces and syntax are what people see and deal with most. They are partly a matter
of taste, and also subject of much discussion. Although discussions on taste do have their merit,
they are not very productive. In the larger picture of LilyPond, the importance of input syntax is
small: inventing neat syntax is easy, while writing decent formatting code is much harder. This
is also illustrated by the line-counts for the respective components: parsing and representation
take up less than 10% of the source code.
Example applications
We have written LilyPond as an experiment of how to condense the art of music engraving into
a computer program. Thanks to all that hard work, the program can now be used to perform
useful tasks. The simplest application is printing notes.

4
2

By adding chord names and lyrics we obtain a lead sheet.
C

star tle

4
2

C
kle

twin twin

C
lit

F
kle

Polyphonic notation and piano music can also be printed. The following example combines
some more exotic constructs.
Screech and boink
Random complex notation
Han-Wen Nienhuys
Chapter 1: Introduction 8
¸
,
,
, ,
, ¸
,
,
,
,
,
,
8
4
,
,
,
,
8
4
, ¸
,
,
,

¸
/
¸
,
,
,
,
,

,
,

,
,

,
¸
,
¸
,
,,
,
3
,
,
,
.
·
·
·
,
,
,
,
The fragments shown above have all been written by hand, but that is not a requirement.
Since the formatting engine is mostly automatic, it can serve as an output means for other
programs that manipulate music. For example, it can also be used to convert databases of
musical fragments to images for use on websites and multimedia presentations.
This manual also shows an application: the input format is text, and can therefore be easily
embedded in other text-based formats such as L
A
T
E
X, HTML, or in the case of this manual,
Texinfo. By means of a special program, the input fragments can be replaced by music images
in the resulting PDF or HTML output fles. This makes it easy to mix music and text in
documents.
1.2 About the documentation
This section explains the diferent portions of the documentation.
About the Learning Manual
This book explains how to begin learning LilyPond, as well as explaining some key concepts in
easy terms. You should read these chapters in a linear fashion.
There is a paragraph See also at the end of each section, which contains cross-references to
other sections: you should not follow these cross-references at frst reading; when you have read
all of the Learning Manual, you may want to read some sections again and follow cross-references
for further reading.
• Chapter 1 [Introduction], page 2: explains the background and overall goal of LilyPond.
• Chapter 2 [Tutorial], page 11: gives a gentle introduction to typesetting music. First time
users should start here.
• Chapter 3 [Fundamental concepts], page 37: explains some general concepts about the
LilyPond fle format. If you are not certain where to place a command, read this chapter!
• Chapter 4 [Tweaking output], page 80: shows how to change the default engraving that
LilyPond produces.
• Chapter 5 [Working on LilyPond projects], page 131: discusses practical uses of LilyPond
and how to avoid some common problems. Read this before undertaking large projects!
The Learning Manual also contains appendices which are not part of the recommended linear
reading. They may be useful for later viewing:
• Appendix A [Templates], page 141: shows ready-made templates of LilyPond pieces. Just
cut and paste a template into a fle, add notes, and you’re done!
• Appendix B [Scheme tutorial], page 173: presents a short introduction to Scheme, the
programming language that music functions use. This is material for advanced tweaks;
many users never touch Scheme at all.
About the Music Glossary
Section “Music glossary” in Music Glossary this explains musical terms, and includes transla-
tions to various languages. If you are not familiar with music notation or music terminology
(especially if you are a non-native English speaker), it is highly advisable to consult the glossary.
Chapter 1: Introduction 9
About the Notation Reference
This book explains all the LilyPond commands which produce notation. It assumes that readers
are familiar with the concepts in the Learning Manual.
• Section “Musical notation” in Notation Reference: discusses topics grouped by notation
construct. This section gives details about basic notation that will be useful in almost any
notation project.
• Section “Specialist notation” in Notation Reference: discusses topics grouped by notation
construct. This section gives details about special notation that will only be useful for
particular instrument (or vocal) groups.
• Section “General input and output” in Notation Reference: discusses general information
about LilyPond input fles and controlling output.
• Section “Spacing issues” in Notation Reference: discusses issues which afect the global
output, such as selecting paper size or specifying page breaks.
• Section “Changing defaults” in Notation Reference: explains how to tweak LilyPond to
produce exactly the notation you want.
• Section “Interfaces for programmers” in Notation Reference: explains how to create music
functions with scheme.
The Notation Reference also contains appendices with useful reference charts.
• Section “Literature list” in Notation Reference: contains a set of useful reference books for
those who wish to know more on notation and engraving.
• Section “Notation manual tables” in Notation Reference: are a set of tables showing the
chord names, MIDI instruments, a list of color names, and the Feta font.
• Section “Cheat sheet” in Notation Reference: is a handy reference of the most common
LilyPond commands.
• Section “LilyPond command index” in Notation Reference: an index of all LilyPond
\commands.
• Section “LilyPond index” in Notation Reference: a complete index.
About the Application Usage
This book explains how to execute the programs and how to integrate LilyPond notation with
other programs.
• Section “Install” in Application Usage: explains how to install LilyPond, including compi-
lation if desired.
• Section “Setup” in Application Usage: describes how to confgure your computer for opti-
mum LilyPond usage, such as using special environments for certain text editors.
• Section “Running LilyPond” in Application Usage: shows how to run LilyPond and its
helper programs. In addition, this section explains how to upgrade input fles from previous
versions of LilyPond.
• Section “LilyPond-book” in Application Usage: explains the details behind creating docu-
ments with in-line music examples, like this manual.
• Section “Converting from other formats” in Application Usage: explains how to run the
conversion programs. These programs are supplied with the LilyPond package, and convert
a variety of music formats to the .ly format.
About the Snippet List
Section “LilyPond Snippet List” in Snippets: this shows a selected set of LilyPond snippets
from the LilyPond Snippet Repository (LSR). All the snippets are in the public domain.
Chapter 1: Introduction 10
Please note that this document is not an exact subset of LSR. LSR is running a stable
LilyPond version, so any snippet which demonstrates new features of a development version
must be added separately. These are stored in ‘input/new/’ in the LilyPond source tree.
The list of snippets for each subsection of the Notation Reference are also linked from the
See also portion.
About the Internals Reference
Section “Internals Reference” in Internals Reference: this is a set of heavily cross linked HTML
pages which document the nitty-gritty details of each and every LilyPond class, object, and
function. It is produced directly from the formatting defnitions in the source code.
Almost all formatting functionality that is used internally is available directly to the user.
For example, most variables that control thickness values, distances, etc., can be changed in
input fles. There are a huge number of formatting options, and all of them are described in this
document. Each section of the Notation Reference has a See also subsection, which refers to the
generated documentation. In the HTML document, these subsections have clickable links.
Other documentation
There are a number of other sources of information which may be very valuable.
• News: this is a summary of important changes and new features in LilyPond since the
previous version.
• The lilypond-user mailist archives: this is a collection of previous emails sent to the user
list. Many questions have been asked multiple times; there is a very good chance that if
you have a question, the answer might be found in these archives.
• The lilypond-devel mailist archives: this is a collection of previous emails sent to the devel-
oper’s list. The discussion here is more technical; if you have an advanced question about
lilypond internals, the answer might be in these archives.
• Embedded music fragments: in all HTML documents that have music fragments embedded,
the exact LilyPond input that was used to produce that image can be viewed by clicking
the image.
• Init fles: the location of the documentation fles that are mentioned here can vary from sys-
tem to system. On occasion, this manual refers to initialization and example fles. Through-
out this manual, we refer to input fles relative to the top-directory of the source archive.
For example, ‘input/lsr/dirname/bla.ly’ may refer to the fle ‘lilypond2.x.y/input/
lsr/dirname/bla.ly’. On binary packages for the UNIX platform, the documentation and
examples can typically be found somewhere below ‘/usr/share/doc/lilypond/’. Initial-
ization fles, for example ‘scm/lily.scm’, or ‘ly/engraver-init.ly’, are usually found in
the directory ‘/usr/share/lilypond/’. For more details, see Section 4.6.3 [Other sources
of information], page 127.
Chapter 2: Tutorial 11
2 Tutorial
This tutorial starts with an introduction to the LilyPond music language and explains how to
produce printed music. After this frst contact we will explain how to create beautiful printed
music containing common musical notation.
2.1 First steps
This section gives a basic introduction to working with LilyPond.
2.1.1 Compiling a fle
“Compiling” is the term used for processing an input fle in LilyPond format to produce a fle
which can be printed and (optionally) a MIDI fle which can be played. LilyPond input fles are
simple text fles. The frst example shows what a simple input fle looks like.
To create sheet music, we write an input fle that specifes the notation. For example, if we
write:
{
c' e' g' e'
}
the result looks like this:

¨
Note: Notes and lyrics in LilyPond input must always be surrounded
by { curly braces }. The braces should also be surrounded by a space
unless they are at the beginning or end of a line to avoid ambiguities.
The braces may be omitted in some examples in this manual, but don’t
forget them in your own music! For more information about the display
of examples in the manual, see Section 2.1.4 [How to read the manual],
page 17.
©
In addition, LilyPond input is case sensitive. { c d e } is valid input; { C D E } will produce
an error message.
Entering music and viewing output
In this section we will explain what commands to run and how to view or print the output.
Note that there are several other text editors available with better support for LilyPond. For
more information, see Section “Text editor support” in Application Usage.
¨
Note: The frst time you ever run LilyPond, it may take a minute or
two because all of the system fonts have to be analyzed frst. After this,
LilyPond will be much faster!
©
MacOS X
If you double click LilyPond.app, it will open with an example fle. Save it, for
example, to ‘test.ly’ on your Desktop, and then process it with the menu command
Compile > Typeset File. The resulting PDF fle will be displayed on your screen.
Chapter 2: Tutorial 12
For future use of LilyPond, you should begin by selecting ‘New’ or ‘Open’. You must save
your fle before typesetting it. If any errors occur in processing, please see the log window.
Windows
On Windows, if you double-click in the LilyPond icon on the Desktop, it will open a simple
text editor with an example fle. Save it, for example, to ‘test.ly’ on your Desktop and then
double-click on the fle to process it (the fle icon looks like a note). After some seconds, you will
get a fle ‘test.pdf’ on your desktop. Double-click on this PDF fle to view the typeset score.
An alternative method to process the ‘test.ly’ fle is to drag and drop it onto the LilyPond
icon using your mouse pointer.
To edit an existing ‘.ly’ fle, right-click on it and select “Edit source”. To get an empty fle
to start from, run the editor as described above and use “New” in the “File” menu, or right-click
on the desktop and select “New..Text Document”, change its name to a name of your choice and
change the fle extension to .ly. Double-click the icon to type in your LilyPond source code as
before.
Double-clicking the fle does not only result in a PDF fle, but also produces a ‘.log’ fle that
contains some information on what LilyPond has done to the fle. If any errors occur, please
examine this fle.
UNIX
Create a text fle called ‘test.ly’ and enter:
{
c' e' g' e'
}
To process ‘test.ly’, proceed as follows:
lilypond test.ly
You will see something resembling:
lilypond test.ly
GNU LilyPond 2.12.3
Processing `test.ly'
Parsing...
Interpreting music...
Preprocessing graphical objects...
Finding the ideal number of pages...
Fitting music on 1 page...
Drawing systems...
Layout output to `test.ps'...
Converting to `test.pdf'...
2.1.2 Simple notation
LilyPond will add some notation elements automatically. In the next example, we have only
specifed four pitches, but LilyPond has added a clef, time signature, and rhythms.
{
c' e' g' e'
}

Chapter 2: Tutorial 13
This behavior may be altered, but in most cases these automatic values are useful.
Pitches
Music Glossary: Section “pitch” in Music Glossary, Section “interval” in Music Glossary,
Section “scale” in Music Glossary, Section “middle C” in Music Glossary, Section “octave”
in Music Glossary, Section “accidental” in Music Glossary.
The easiest way to enter notes is by using \relative mode. In this mode, the octave is chosen
automatically by assuming the following note is always to be placed closest to the previous note,
i.e., it is to be placed in the octave which is within three staf spaces of the previous note. We
begin by entering the most elementary piece of music, a scale, in which every note is within just
one staf space of the previous note.
% set the starting point to middle C
\relative c' {
c d e f
g a b c
}

The initial note is middle C. Each successive note is placed closest to the previous note – in
other words, the frst c is the closest C to middle C. This is followed by the closest D to the
previous note. We can create melodies which have larger intervals, still using only \relative
mode:
\relative c' {
d f a g
c b f d
}

It is not necessary for the frst note of the melody to start on the note which specifes the starting
pitch. In the previous example, the frst note – the d – is the closest D to middle C.
By adding (or removing) quotes ' or commas , from the \relative c' { command, we can
change the starting octave:
% one octave above middle C
\relative c'' {
e c a c
}

Relative mode can be confusing initially, but is the easiest way to enter most melodies. Let
us see how this relative calculation works in practice. Starting from a B, which is on the middle
line in a treble clef, you can reach a C, D and E within 3 staf spaces going up, and an A, G
and F within 3 staf spaces going down. So if the note following a B is a C, D or E it will be
assumed to be above the B, and an A, G or F will be assumed to be below.
Chapter 2: Tutorial 14
\relative c'' {
b c % c is 1 staff space up, so is the c above
b d % d is 2 up or 5 down, so is the d above
b e % e is 3 up or 4 down, so is the e above
b a % a is 6 up or 1 down, so is the a below
b g % g is 5 up or 2 down, so is the g below
b f % f is 4 up or 3 down, so is the f below
}

Exactly the same happens even when any of these notes are sharpened or fattened. Acci-
dentals are totally ignored in the calculation of relative position. Precisely the same staf space
counting is done from a note at any other position on the staf.
To add intervals that are larger than three staf spaces, we can raise the octave by adding a
single quote ' (or apostrophe) to the note name. We can lower the octave by adding a comma
, to the note name.
\relative c'' {
a a, c' f,
g g'' a,, f'
}

To change a note by two (or more!) octaves, we use multiple '' or ,, – but be careful that you
use two single quotes '' and not one double quote " ! The initial value in \relative c' may
also be modifed like this.
Durations (rhythms)
Music Glossary: Section “beam” in Music Glossary, Section “duration” in Music Glossary,
Section “whole note” in Music Glossary, Section “half note” in Music Glossary, Section “quarter
note” in Music Glossary, Section “dotted note” in Music Glossary.
The duration of a note is specifed by a number after the note name. 1 for a whole note, 2
for a half note, 4 for a quarter note and so on. Beams are added automatically.
If you do not specify a duration, the previous duration is used for the next note. The duration
of the frst note defaults to a quarter.
\relative c'' {
a1
a2 a4 a8 a
a16 a a a a32 a a a a64 a a a a a a a a2
}

Chapter 2: Tutorial 15

3

To create dotted notes, add a dot . to the duration number. The duration of a dotted note
must be stated explicitly (i.e., with a number).
\relative c'' {
a a a4. a8
a8. a16 a a8. a8 a4.
}

Rests
Music Glossary: Section “rest” in Music Glossary.
A rest is entered just like a note with the name r :
\relative c'' {
a r r2
r8 a r4 r4. r8
}

Time signature
Music Glossary: Section “time signature” in Music Glossary.
The time signature can be set with the \time command:
\relative c'' {
\time 3/4
a4 a a
\time 6/8
a4. a
\time 4/4
a4 a a a
}

8
6

4
3

Clef
Music Glossary: Section “clef” in Music Glossary.
The clef can be set using the \clef command:
\relative c' {
\clef treble
c1
\clef alto
c1
Chapter 2: Tutorial 16
\clef tenor
c1
\clef bass
c1
}

All together
Here is a small example showing all these elements together:
\relative c, {
\time 3/4
\clef bass
c2 e8 c' g'2.
f4 e d c4 c, r4
}

4
3

See also
Notation Reference: Section “Writing pitches” in Notation Reference, Section “Writing
rhythms” in Notation Reference, Section “Writing rests” in Notation Reference, Section “Time
signature” in Notation Reference, Section “Clef” in Notation Reference.
2.1.3 Working on input fles
LilyPond input fles are similar to source fles in many common programming languages. They
are case sensitive, and white-space is generally ignored. Expressions are formed with curly braces
{ }, and comments are denoted with % or %{ ... %}.
If the previous sentences sound like nonsense, don’t worry! We’ll explain what all these terms
mean:
• Case sensitive: it matters whether you enter a letter in lower case (e.g. a, b, s, t) or
upper case (e.g. A, B, S, T). Notes are lower case: { c d e } is valid input; { C D E } will
produce an error message.
• Whitespace insensitive: it does not matter how many spaces (or new lines) you add.
{ c d e } means the same thing as { c d e } and:
{ c d
e }
Of course, the previous example is hard to read. A good rule of thumb is to indent code
blocks with either a tab or two spaces:
{
c d e
}
• Expressions: every piece of LilyPond input needs to have { curly braces } placed around
the input. These braces tell LilyPond that the input is a single music expression, just like
Chapter 2: Tutorial 17
parentheses () in mathematics. The braces should be surrounded by a space unless they
are at the beginning or end of a line to avoid ambiguities.
A LilyPond command followed by a simple expression in braces (such as \relative { })
also counts as a single music expression.
• Comments: a comment is a remark for the human reader of the music input; it is ignored
while parsing, so it has no efect on the printed output. There are two types of comments.
The percent symbol % introduces a line comment; anything after % on that line is ignored.
By convention, a line comment is placed above the code it refers to.
a4 a a a
% this comment refers to the Bs
b2 b
A block comment marks a whole section of music input as a comment. Anything that is
enclosed in %{ and %} is ignored. However, block comments do not ‘nest’. This means that
you cannot place a block comment inside another block comment. If you try, the frst %} will
terminate both block comments. The following fragment shows possible uses for comments:
% notes for twinkle twinkle follow
c4 c g' g a a g2
%{
This line, and the notes below are ignored,
since they are in a block comment.
f f e e d d c2
%}
2.1.4 How to read the manual
LilyPond input must be surrounded by { } marks or a \relative c'' { ... }, as we saw in
Section 2.1.3 [Working on input fles], page 16. For the rest of this manual, most examples will
omit this. To replicate the examples, you may copy and paste the displayed input, but you must
add the \relative c'' { } like this:
\relative c'' {
... example goes here...
}
Why omit the braces? Most examples in this manual can be inserted into the middle of a
longer piece of music. For these examples, it does not make sense to add \relative c'' { } –
you should not place a \relative inside another \relative! If we included \relative c'' { }
around every example, you would not be able to copy a small documentation example and paste
it inside a longer piece of your own. Most people want to add material to an existing piece, so
we format the manual this way.
Clickable examples
Many people learn programs by trying and fddling around with the program. This is also
possible with LilyPond. If you click on a picture in the HTML version of this manual, you will
see the exact LilyPond input that was used to generate that image. Try it on this image:

Click here.

Chapter 2: Tutorial 18
By cutting and pasting everything in the “ly snippet” section, you have a starting template
for experiments. To see exactly the same output (line-width and all), copy everything from
“Start cut-&-pastable section” to the bottom of the fle.
See also
There are more tips for constructing input fles in Section 5.1 [Suggestions for writing Lily-
Pond input fles], page 131. But it might be best to read through the rest of the tutorial frst.
2.2 Single staf notation
This section introduces common notation that is used for one voice on one staf.
2.2.1 Accidentals and key signatures
Accidentals
Music Glossary: Section “sharp” in Music Glossary, Section “fat” in Music Glossary, Section
“double sharp” in Music Glossary, Section “double fat” in Music Glossary, Section “accidental”
in Music Glossary.
A sharp pitch is made by adding is to the name, and a fat pitch by adding es. As you
might expect, a double sharp or double fat is made by adding isis or eses. This syntax is
derived from note naming conventions in Nordic and Germanic languages, like German and
Dutch. To use other names for accidentals, see Section “Note names in other languages” in
Notation Reference.
cis1 ees fisis, aeses

Key signatures
Music Glossary: Section “key signature” in Music Glossary, Section “major” in Music Glossary,
Section “minor” in Music Glossary.
The key signature is set with the command \key followed by a pitch and \major or \minor.
\key d \major
a1
\key c \minor
a

Warning: key signatures and pitches
Music Glossary: Section “accidental” in Music Glossary, Section “key signature” in Music Glos-
sary, Section “pitch” in Music Glossary, Section “fat” in Music Glossary, Section “natural” in
Music Glossary, Section “sharp” in Music Glossary, Section “transposition” in Music Glossary.
To determine whether to print an accidental, LilyPond examines the pitches and the key
signature. The key signature only afects the printed accidentals, not the note’s pitch! This is
a feature that often causes confusion to newcomers, so let us explain it in more detail.
Chapter 2: Tutorial 19
LilyPond makes a sharp distinction between musical content and layout. The alteration (fat,
natural sign or sharp) of a note is part of the pitch, and is therefore musical content. Whether
an accidental (a printed fat, natural or sharp sign) is printed in front of the corresponding
note is a question of layout. Layout is something that follows rules, so accidentals are printed
automatically according to those rules. The pitches in your music are works of art, so they will
not be added automatically, and you must enter what you want to hear.
In this example:
\key d \major
d cis fis

No note has a printed accidental, but you must still add is and type cis and fis in the input
fle.
The code b does not mean “print a black dot just on the middle line of the staf.” Rather,
it means “there is a note with pitch B-natural.” In the key of A-fat major, it does get an
accidental:
\key aes \major
b

Adding all alterations explicitly might require a little more efort when typing, but the
advantage is that transposing is easier, and accidentals can be printed according to diferent
conventions. For some examples how accidentals can be printed according to diferent rules, see
Section “Automatic accidentals” in Notation Reference.
See also
Notation Reference: Section “Note names in other languages” in Notation Reference, Section
“Accidentals” in Notation Reference, Section “Automatic accidentals” in Notation Reference,
Section “Key signature” in Notation Reference.
Music Glossary: Section “Pitch names” in Music Glossary.
2.2.2 Ties and slurs
Ties
Music Glossary: Section “tie” in Music Glossary.
A tie is created by appending a tilde ~ to the frst note being tied.
g4~ g c2~
c4 ~ c8 a8 ~ a2

Chapter 2: Tutorial 20
Slurs
Music Glossary: Section “slur” in Music Glossary.
A slur is a curve drawn across many notes. The starting note and ending note are marked
with ( and ) respectively.
d4( c16) cis( d e c cis d) e( d4)

Phrasing slurs
Music Glossary: Section “slur” in Music Glossary, Section “phrasing” in Music Glossary.
Slurs to indicate longer phrasing can be entered with \( and \). You can have both slurs
and phrasing slurs at the same time, but you cannot have simultaneous slurs or simultaneous
phrasing slurs.
a8(\( ais b c) cis2 b'2 a4 cis,\)

Warnings: slurs vs. ties
Music Glossary: Section “articulation” in Music Glossary, Section “slur” in Music Glossary,
Section “tie” in Music Glossary.
A slur looks like a tie, but it has a diferent meaning. A tie simply makes the frst note longer,
and can only be used on pairs of notes with the same pitch. Slurs indicate the articulation of
notes, and can be used on larger groups of notes. Slurs and ties can be nested.
c2~( c8 fis fis4 ~ fis2 g2)

See also
Notation Reference: Section “Ties” in Notation Reference, Section “Slurs” in Notation Ref-
erence, Section “Phrasing slurs” in Notation Reference.
2.2.3 Articulation and dynamics
Articulations
Music Glossary: Section “articulation” in Music Glossary.
Common articulations can be added to a note using a dash - and a single character:
c-. c-- c-> c-^ c-+ c-_

,
,

,

,
/
.
, , ,
Chapter 2: Tutorial 21
Fingerings
Music Glossary: Section “fngering” in Music Glossary.
Similarly, fngering indications can be added to a note using a dash (-) and the digit to be
printed:
c-3 e-5 b-2 a-1
1

2 3

5

Articulations and fngerings are usually placed automatically, but you can specify a direction
by replacing the dash (-) with ^ (up) or _ (down). You can also use multiple articulations on
the same note. However, in most cases it is best to let LilyPond determine the articulation
directions.
c_-^1 d^. f^4_2-> e^-_+

2
4

1

Dynamics
Music Glossary: Section “dynamics” in Music Glossary, Section “crescendo” in Music Glossary,
Section “decrescendo” in Music Glossary.
Dynamic signs are made by adding the markings (with a backslash) to the note:
c\ff c\mf c\p c\pp

pp

ffmf

p
Crescendi and decrescendi are started with the commands \< and \>. The next dynamics
sign, for example \f, will end the (de)crescendo, or the command \! can be used:
c2\< c2\ff\> c2 c2\!

ff

See also
Notation Reference: Section “Articulations and ornamentations” in Notation Reference,
Section “Fingering instructions” in Notation Reference, Section “Dynamics” in Notation Refer-
ence.
Chapter 2: Tutorial 22
2.2.4 Adding text
Text may be added to your scores:
c1^"espr" a_"legato"
legato

espr

Extra formatting may be added with the \markup command:
c1^\markup{ \bold espr}
a1_\markup{
\dynamic f \italic \small { 2nd } \hspace #0.1 \dynamic p
}

espr
f 2nd p
See also
Notation Reference: Section “Writing text” in Notation Reference.
2.2.5 Automatic and manual beams
Music Glossary: Section “beam” in Music Glossary.
All beams are drawn automatically:
a8 ais d ees r d c16 b a8

If you do not like the automatic beams, they may be overridden manually. To correct just
an occasional beam mark the frst note to be beamed with [ and the last one with ].
a8[ ais] d[ ees r d] a b

If you want to turn of automatic beaming entirely or for an extended section of music, use
the command \autoBeamOff to turn of automatic beaming and \autoBeamOn to turn it on
again.
\autoBeamOff
a8 c b4 d8. c16 b4
\autoBeamOn
a8 c b4 d8. c16 b4

Chapter 2: Tutorial 23
See also
Notation Reference: Section “Automatic beams” in Notation Reference, Section “Manual
beams” in Notation Reference.
2.2.6 Advanced rhythmic commands
Partial measure
Music Glossary: Section “anacrusis” in Music Glossary.
A pickup (or anacrusis) is entered with the keyword \partial. It is followed by a duration:
\partial 4 is a quarter note pickup and \partial 8 an eighth note.
\partial 8
f8 c2 d

Tuplets
Music Glossary: Section “note value” in Music Glossary, Section “triplet” in Music Glossary.
Tuplets are made with the \times keyword. It takes two arguments: a fraction and a piece
of music. The duration of the piece of music is multiplied by the fraction. Triplets make notes
occupy 2/3 of their notated duration, so a triplet has 2/3 as its fraction
\times 2/3 { f8 g a }
\times 2/3 { c r c }
\times 2/3 { f,8 g16[ a g a] }
\times 2/3 { d4 a8 }

3

3 3

3

Grace notes
Music Glossary: Section “grace notes” in Music Glossary, Section “acciaccatura” in Music
Glossary, Section “appoggiatura” in Music Glossary.
Grace notes are created with the \grace command, although they can also be created by
prefxing a music expression with the keyword \appoggiatura or \acciaccatura:
c2 \grace { a32[ b] } c2
c2 \appoggiatura b16 c2
c2 \acciaccatura b16 c2

See also
Notation Reference: Section “Grace notes” in Notation Reference, Section “Tuplets” in No-
tation Reference, Section “Upbeats” in Notation Reference.
Chapter 2: Tutorial 24
2.3 Multiple notes at once
This section introduces having more than one note at the same time: multiple instruments,
multiple staves for a single instrument (i.e. piano), and chords.
Polyphony in music refers to having more than one voice occurring in a piece of music.
Polyphony in LilyPond refers to having more than one voice on the same staf.
2.3.1 Music expressions explained
In LilyPond input fles, music is represented by music expressions. A single note is a music
expression:
a4

Enclosing a note in braces creates a compound music expression. Here we have created a
compound music expression with two notes:
{ a4 g4 }

Putting a group of music expressions (e.g. notes) in braces means that they are in sequence
(i.e. each one follows the previous one). The result is another music expression:
{ { a4 g } f g }

Analogy: mathematical expressions
This mechanism is similar to mathematical formulas: a big formula is created by composing
small formulas. Such formulas are called expressions, and they can contain other expressions,
so you can make arbitrarily complex and large expressions. For example,
1
1 + 2
(1 + 2) * 3
((1 + 2) * 3) / (4 * 5)
This is a sequence of expressions, where each expression is contained in the next (larger) one.
The simplest expressions are numbers, and larger ones are made by combining expressions with
operators (like +, * and /) and parentheses. Like mathematical expressions, music expressions
can be nested arbitrarily deep, which is necessary for complex music like polyphonic scores.
Chapter 2: Tutorial 25
Simultaneous music expressions: multiple staves
Music Glossary: Section “polyphony” in Music Glossary.
This technique is useful for polyphonic music. To enter music with more voices or more
staves, we combine expressions in parallel. To indicate that two voices should play at the same
time, simply enter a simultaneous combination of music expressions. A ‘simultaneous’ music
expression is formed by enclosing expressions inside << and >>. In the following example, three
sequences (all containing two separate notes) are combined simultaneously:
\relative c'' {
<<
{ a4 g }
{ f e }
{ d b }
>>
}

Note that we have indented each level of the input with a diferent amount of space. LilyPond
does not care how much (or little) space there is at the beginning of a line, but indenting LilyPond
code like this makes it much easier for humans to read.
¨
Note: each note is relative to the previous note in the input, not relative
to the c'' in the initial \relative command.
©
Simultaneous music expressions: single staf
To determine the number of staves in a piece, LilyPond looks at the beginning of the frst
expression. If is a single note, there is one staf; if there is a simultaneous expression, there is
more than one staf.
\relative c'' {
c2 <<c e>>
<< { e f } { c <<b d>> } >>
}

2.3.2 Multiple staves
LilyPond input fles are constructed out of music expressions, as we saw in Section 2.3.1 [Music
expressions explained], page 24. If the score begins with simultaneous music expressions, Lily-
Pond creates multiples staves. However, it is easier to see what happens if we create each staf
explicitly.
Chapter 2: Tutorial 26
To print more than one staf, each piece of music that makes up a staf is marked by adding
\new Staff before it. These Staff elements are then combined in parallel with << and >>:
\relative c'' {
<<
\new Staff { \clef treble c }
\new Staff { \clef bass c,, }
>>
}

The command \new introduces a ‘notation context.’ A notation context is an environment
in which musical events (like notes or \clef commands) are interpreted. For simple pieces,
such notation contexts are created automatically. For more complex pieces, it is best to mark
contexts explicitly.
There are several types of contexts. Score, Staff, and Voice handle melodic notation, while
Lyrics sets lyric texts and ChordNames prints chord names.
In terms of syntax, prepending \new to a music expression creates a bigger music expression.
In this way it resembles the minus sign in mathematics. The formula (4 + 5) is an expression,
so −(4 + 5) is a bigger expression.
Time signatures entered in one staf afects all other staves by default. On the other hand,
the key signature of one staf does not afect other staves. This diferent default behavior is
because scores with transposing instruments are more common than polyrhythmic scores.
\relative c'' {
<<
\new Staff { \clef treble \key d \major \time 3/4 c }
\new Staff { \clef bass c,, }
>>
}
4
3

4
3

2.3.3 Staf groups
Music Glossary: Section “brace” in Music Glossary.
Piano music is typeset in two staves connected by a brace. Printing such a staf is similar
to the polyphonic example in Section 2.3.2 [Multiple staves], page 25. However, now this entire
expression is inserted inside a PianoStaff:
\new PianoStaff <<
\new Staff ...
Chapter 2: Tutorial 27
\new Staff ...
>>
Here is a small example:
\relative c'' {
\new PianoStaff <<
\new Staff { \time 2/4 c4 e g g, }
\new Staff { \clef bass c,, c' e c }
>>
}

4
2

4
2

Other staf groupings are introduced with \new GrandStaff, suitable for orchestral scores,
and \new ChoirStaff, suitable for vocal scores. These staf groups each form another type of
context, one that generates the brace at the left end of every system and also controls the extent
of bar lines.
See also
Notation Reference: Section “Keyboard and other multi-staf instruments” in Notation Ref-
erence, Section “Displaying staves” in Notation Reference.
2.3.4 Combining notes into chords
Music Glossary: Section “chord” in Music Glossary.
We saw earlier how notes can be combined into chords by indicating they are simultaneous
by enclosing them in double angle brackets. However, the normal way of indicating a chord is
to surround the pitches with single angle brackets. Note that all the notes in a chord must have
the same duration, and that the duration is placed after the closing bracket.
r4 <c e g>4 <c f a>2

Think of chords as almost equivalent to single notes: almost everything you can attach to
a single note can be attached to a chord, and everything must go outside the angle brackets.
For example, you can combine markings like beams and ties with chords. They must be placed
outside the angle brackets.
r4 <c e g>8[ <c f a>]~ <c f a>2
r4 <c e g>8( <c e g>\> <c e g>4 <c f a>\!)

Chapter 2: Tutorial 28
2.3.5 Single staf polyphony
Polyphonic music in lilypond, while not difcult, uses concepts that we haven’t discussed yet, so
we’re not going to introduce them here. Instead, the following sections introduce these concepts
and explain them thoroughly.
See also
Learning Manual: Section 3.2 [Voices contain music], page 44.
Notation Reference: Section “Simultaneous notes” in Notation Reference.
2.4 Songs
This section introduces vocal music and simple song sheets.
2.4.1 Setting simple songs
Music Glossary: Section “lyrics” in Music Glossary.
Here is the start of the melody to a nursery rhyme, Girls and boys come out to play:
\relative c'' {
\key g \major
\time 6/8
d4 b8 c4 a8 d4 b8 g4
}
8
6

The lyrics can be set to these notes, combining both with the \addlyrics keyword. Lyrics
are entered by separating each syllable with a space.
<<
\relative c'' {
\key g \major
\time 6/8
d4 b8 c4 a8 d4 b8 g4
}
\addlyrics {
Girls and boys come out to play,
}
>>

play,
8
6

boys

come Girls

to

and

out
Note the curly brackets delimiting both the music and the lyrics, and the double angle
brackets << ... >> around the whole piece to show that the music and lyrics are to occur at the
same time.
Chapter 2: Tutorial 29
2.4.2 Aligning lyrics to a melody
Music Glossary: Section “melisma” in Music Glossary, Section “extender line” in Music Glos-
sary.
The next line in the nursery rhyme is The moon doth shine as bright as day. Let’s extend it:
<<
\relative c'' {
\key g \major
\time 6/8
d4 b8 c4 a8 d4 b8 g4
g8 a4 b8 c b a d4 b8 g4.
}
\addlyrics {
Girls and boys come out to play,
The moon doth shine as bright as day;
}
>>

boys

and

Girls play, The

come

out to

8
6

day;

moon shine as as

3

doth

bright

We see the extra lyrics do not align properly with the notes. The word shine should be sung
on two notes, not one. This is called a melisma, a single syllable sung to more than one note.
There are several ways to spread a syllable over multiple notes, the simplest being to add a slur
across them, for details, see Section 2.2.2 [Ties and slurs], page 19:
<<
\relative c'' {
\key g \major
\time 6/8
d4 b8 c4 a8 d4 b8 g4
g8 a4 b8 c( b) a d4 b8 g4.
}
\addlyrics {
Girls and boys come out to play,
The moon doth shine as bright as day;
}
>>

come boys Girls and

8
6

to The

play,

out
Chapter 2: Tutorial 30

day;

moon bright

3

as as

shine

doth

The words now line up correctly with the notes, but the automatic beaming for the notes
above shine as does not look right. We can correct this by inserting manual beaming commands
to override the automatic beaming here, for details, see Section 2.2.5 [Automatic and manual
beams], page 22.
<<
\relative c'' {
\key g \major
\time 6/8
d4 b8 c4 a8 d4 b8 g4
g8 a4 b8 c([ b]) a d4 b8 g4.
}
\addlyrics {
Girls and boys come out to play,
The moon doth shine as bright as day;
}
>>

The

to and

boys

8
6

Girls come

out

play,

as

as

shine

3

moon bright

doth

day;

As an alternative to using slurs, the melismata may be indicated in just the lyrics by using
an underscore _ for each note that should be included in the melisma:
<<
\relative c'' {
\key g \major
\time 6/8
d4 b8 c4 a8 d4 b8 g4
g8 a4 b8 c[ b] a d4 b8 g4.
}
\addlyrics {
Girls and boys come out to play,
The moon doth shine _ as bright as day;
}
>>

to

out Girls come

and

8
6

play, boys The

Chapter 2: Tutorial 31

as
3

day;

doth

shine bright

moon

as
If a syllable extends over several notes or a single very long note an extender line is usually
drawn from the syllable extending under all the notes for that syllable. It is entered as two
underscores __. Here is an example from the frst three bars of Dido’s Lament, from Purcell’s
Dido and Æneas:
<<
\relative c'' {
\key g \minor
\time 3/2
g2 a bes bes( a)
b c4.( bes8 a4. g8 fis4.) g8 fis1
}
\addlyrics {
When I am laid,
am laid __ in earth,
}
>>
am
,
,

·
laid
,
.
am
,
,

2
3
.
I
,
earth,
,

When
.
.
laid,
.
,
,
in
,
,
/
¸ .

None of the examples so far have involved words containing more than one syllable. Such
words are usually split one syllable to a note, with hyphens between syllables. Such hyphens are
entered as two dashes, resulting in a centered hyphen between the syllables. Here is an example
showing this and everything we have learned so far about aligning lyrics to notes.
<<
\relative c' {
\key g \major
\time 3/4
\partial 4
d4 g4 g a8( b) g4 g4
b8( c) d4 d e4 c2
}
\addlyrics {
A -- way in a __ man -- ger,
no __ crib for a bed, __
}
>>

way for ger, A

in

no

crib

a man

bed,

a

4
3

Some lyrics, especially those in Italian, require the opposite: setting more than one syllable
to a single note. This is achieved by linking the syllables together with a single underscore _
(with no spaces), or enclosing them in quotes. Here’s an example from Rossini’s Figaro, where
al has to be sung on the same note as the go of Largo in Figaro’s aria Largo al factotum:
Chapter 2: Tutorial 32
<<
\relative c' {
\clef bass
\key c \major
\time 6/8
c4.~ c8 d b c([ d]) b c d b c
}
\addlyrics {
Lar -- go_al fac -- to -- tum del -- la cit -- t`a
}
>>
8
6

Lar

to

fac

go al cit

la

del

tum

See also
Notation Reference: Section “Vocal music” in Notation Reference.
2.4.3 Lyrics to multiple staves
The simple approach using \addlyrics can be used for placing lyrics under more than one staf.
Here is an example from Handel’s Judas Maccabæus:
<<
\relative c'' {
\key f \major
\time 6/8
\partial 8
c8 c([ bes]) a a([ g]) f f'4. b, c4.~ c4
}
\addlyrics {
Let flee -- cy flocks the hills a -- dorn, __
}
\relative c' {
\key f \major
\time 6/8
\partial 8
r8 r4. r4 c8 a'([ g]) f f([ e]) d e([ d]) c bes'4
}
\addlyrics {
Let flee -- cy flocks the hills a -- dorn,
}
>>
Chapter 2: Tutorial 33
,
,
the
¸

flocks
,
a
,
8
6 ,
dorn,
,
,

a
,

cy
,

·

,
flocks
,

hills
,
dorn,
,
Let
,
8
6 ,
/
/ ,
,

flee
,
hills
,

Let
,
the
,
,
,
flee
,
,
,
cy
,
Scores any more complex than this simple example are better produced by separating out
the score structure from the notes and lyrics with variables. These are discussed in Section 2.5.1
[Organizing pieces with variables], page 33.
See also
Notation Reference: Section “Vocal music” in Notation Reference.
2.5 Final touches
This is the fnal section of the tutorial; it demonstrates how to add the fnal touches to simple
pieces, and provides an introduction to the rest of the manual.
2.5.1 Organizing pieces with variables
When all of the elements discussed earlier are combined to produce larger fles, the music ex-
pressions get a lot bigger. In polyphonic music with many staves, the input fles can become
very confusing. We can reduce this confusion by using variables.
With variables (also known as identifers or macros), we can break up complex music expres-
sions. A variable is assigned as follows:
namedMusic = { ... }
The contents of the music expression namedMusic can be used later by placing a backslash
in front of the name (\namedMusic, just like a normal LilyPond command).
violin = \new Staff {
\relative c'' {
a4 b c b
}
}
cello = \new Staff {
\relative c {
\clef bass
e2 d
}
}
{
<<
\violin
\cello
>>
}
Chapter 2: Tutorial 34

The name of a variable must have alphabetic characters only, no numbers, underscores, or
dashes.
Variables must be defned before the main music expression, but may be used as many times
as required anywhere after they have been defned. They may even be used in a later defnition
of another variable, giving a way of shortening the input if a section of music is repeated many
times.
tripletA = \times 2/3 { c,8 e g }
barA = { \tripletA \tripletA \tripletA \tripletA }
\relative c'' {
\barA \barA
}

3



3

3

3

3

3

3

3

Variables may be used for many other types of objects in the input. For example,
width = 4.5\cm
name = "Wendy"
aFivePaper = \paper { paperheight = 21.0 \cm }
Depending on its contents, the variable can be used in diferent places. The following example
uses the above variables:
\paper {
\aFivePaper
line-width = \width
}
{
c4^\name
}
2.5.2 Version number
The \version statement records the version of LilyPond that was used to write the fle:
\version "2.12.3"
By convention, this is placed at the top of your LilyPond fle.
These annotations make future upgrades of LilyPond go more smoothly. Changes in the
syntax are handled with a special program, convert-ly, and it uses \version to determine
what rules to apply. For details, see Section “Updating fles with convert-ly” in Application
Usage.
2.5.3 Adding titles
The title, composer, opus number, and similar information are entered in the \header block.
This exists outside of the main music expression; the \header block is usually placed underneath
the version number.
Chapter 2: Tutorial 35
\version "2.12.3"
\header {
title = "Symphony"
composer = "Me"
opus = "Op. 9"
}
{
... music ...
}
When the fle is processed, the title and composer are printed above the music. More infor-
mation on titling can be found in Section “Creating titles” in Notation Reference.
2.5.4 Absolute note names
So far we have always used \relative to defne pitches. This is the easiest way to enter most
music, but another way of defning pitches exists: absolute mode.
If you omit the \relative, LilyPond treats all pitches as absolute values. A c' will always
mean middle C, a b will always mean the note one step below middle C, and a g, will always
mean the note on the bottom staf of the bass clef.
{
\clef bass
c' b g, g,
g, f, f c'
}

Here is a four-octave scale:
{
\clef bass
c, d, e, f,
g, a, b, c
d e f g
a b c' d'
\clef treble
e' f' g' a'
b' c'' d'' e''
f'' g'' a'' b''
c'''1
}

5

Chapter 2: Tutorial 36
As you can see, writing a melody in the treble clef involves a lot of quote ' marks. Consider
this fragment from Mozart:
{
\key a \major
\time 6/8
cis''8. d''16 cis''8 e''4 e''8
b'8. cis''16 b'8 d''4 d''8
}

8
6

All these quotes makes the input less readable and they are a source of errors. With
\relative, the previous example is much easier to read and type:
\relative c'' {
\key a \major
\time 6/8
cis8. d16 cis8 e4 e8
b8. cis16 b8 d4 d8
}

8
6

If you make a mistake with an octave mark (' or ,) while working in \relative mode, it
is very obvious – many notes will be in the wrong octave. When working in absolute mode, a
single mistake will not be as visible, and will not be as easy to fnd.
However, absolute mode is useful for music which has large intervals, and is extremely useful
for computer-generated LilyPond fles.
2.5.5 After the tutorial
After fnishing the tutorial, you should probably try writing a piece or two. Start by adding
notes to one of the Appendix A [Templates], page 141. If you need any notation that was not
covered in the tutorial, look at the Notation Reference, starting with Section “Musical notation”
in Notation Reference. If you want to write for an instrument ensemble that is not covered in
the templates, take a look at Section 3.4 [Extending the templates], page 68.
Once you have written a few short pieces, read the rest of the Learning Manual (chapters 3-5).
There’s nothing wrong with reading it now, of course! However, the rest of the Learning Manual
assumes that you are familiar with LilyPond input. You may wish to skim these chapters right
now, and come back to them after you have more experience.
In this tutorial and in the rest of the Learning Manual, there is a paragraph See also at
the end of each section, which contains cross-references to other sections: you should not follow
these cross-references at frst reading; when you have read all of the Learning Manual, you may
want to read some sections again and follow cross-references for further reading.
If you have not done so already, please read Section 1.2 [About the documentation], page 8.
There is a lot of information about LilyPond, so newcomers often do not know where they should
look for help. If you spend fve minutes reading that section carefully, you might save yourself
hours of frustration looking in the wrong places!
Chapter 3: Fundamental concepts 37
3 Fundamental concepts
You’ve seen in the Tutorial how to produce beautifully printed music from a simple text fle.
This section introduces the concepts and techniques required to produce equally beautiful but
more complex scores.
3.1 How LilyPond input fles work
The LilyPond input format is quite free-form, giving experienced users a lot of fexibility to
structure their fles however they wish. But this fexibility can make things confusing for new
users. This section will explain some of this structure, but may gloss over some details in favor
of simplicity. For a complete description of the input format, see Section “File structure” in
Notation Reference.
3.1.1 Introduction to the LilyPond fle structure
A basic example of a LilyPond input fle is
\version "2.12.3"
\header { }
\score {
...compound music expression... % all the music goes here!
\layout { }
\midi { }
}
There are many variations of this basic pattern, but this example serves as a useful starting
place.
Up to this point none of the examples you have seen has used a \score{} command. This
is because LilyPond automatically adds the extra commands which are needed when you give it
simple input. LilyPond treats input like this:
\relative c'' {
c4 a d c
}
as shorthand for this:
\book {
\score {
\new Staff {
\new Voice {
\relative c'' {
c4 a b c
}
}
}
\layout { }
}
}
In other words, if the input contains a single music expression, LilyPond will interpret the
fle as though the music expression was wrapped up inside the commands shown above.
A word of warning! Many of the examples in the LilyPond documentation will omit the \new
Staff and \new Voice commands, leaving them to be created implicitly. For simple examples
this works well, but for more complex examples, especially when additional commands are used,
the implicit creation of contexts can give surprising results, maybe creating extra unwanted
Chapter 3: Fundamental concepts 38
staves. The way to create contexts explicitly is explained in Section 3.3 [Contexts and engravers],
page 58.
¨
Note: When entering more than a few lines of music it is advisable to
always create staves and voices explicitly.
©
For now, though, let us return to the frst example and examine the \score command, leaving
the others to default.
A \score block must always contain just one music expression, and this must appear imme-
diately after the \score command. Remember that a music expression could be anything from
a single note to a huge compound expression like
{
\new StaffGroup <<
...insert the whole score of a Wagner opera in here...
>>
}
Since everything is inside { ... }, it counts as one music expression.
As we saw previously, the \score block can contain other things, such as
\score {
{ c'4 a b c' }
\header { }
\layout { }
\midi { }
}
Note that these three commands – \header, \layout and \midi – are special: unlike many
other commands which begin with a backward slash (\) they are not music expressions and are
not part of any music expression. So they may be placed inside a \score block or outside it. In
fact, these commands are commonly placed outside the \score block – for example, \header is
often placed above the \score command, as the example at the beginning of this section shows.
Two more commands you have not previously seen are \layout { } and \midi {}. If these
appear as shown they will cause LilyPond to produce a printed output and a MIDI output
respectively. They are described fully in the Notation Reference – Section “Score layout” in
Notation Reference, and Section “Creating MIDI fles” in Notation Reference.
You may code multiple \score blocks. Each will be treated as a separate score, but they
will be all combined into a single output fle. A \book command is not necessary – one will
be implicitly created. However, if you would like separate output fles from one .ly fle then
the \book command should be used to separate the diferent sections: each \book block will
produce a separate output fle.
In summary:
Every \book block creates a separate output fle (e.g., a PDF fle). If you haven’t explicitly
added one, LilyPond wraps your entire input code in a \book block implicitly.
Every \score block is a separate chunk of music within a \book block.
Every \layout block afects the \score or \book block in which it appears – i.e., a \layout
block inside a \score block afects only that \score block, but a \layout block outside of a
\score block (and thus in a \book block, either explicitly or implicitly) will afect every \score
in that \book.
For details see Section “Multiple scores in a book” in Notation Reference.
Another great shorthand is the ability to defne variables. All the templates use this
Chapter 3: Fundamental concepts 39
melody = \relative c' {
c4 a b c
}
\score {
\melody
}
When LilyPond looks at this fle, it takes the value of melody (everything after the equals
sign) and inserts it whenever it sees \melody. There’s nothing special about the names – it
could be melody, global, TimeKey, pianorighthand, or foofoobarbaz. For more details, see
Section 5.1.4 [Saving typing with variables and functions], page 133. Remember that you can
use almost any name you like as long as it contains just alphabetic characters and is distinct
from LilyPond command names. The exact limitations on variable names are detailed in Section
“File structure” in Notation Reference.
See also
For a complete defnition of the input format, see Section “File structure” in Notation Ref-
erence.
3.1.2 Score is a (single) compound musical expression
We saw the general organization of LilyPond input fles in the previous section, Section 3.1.1
[Introduction to the LilyPond fle structure], page 37. But we seemed to skip over the most
important part: how do we fgure out what to write after \score?
We didn’t skip over it at all. The big mystery is simply that there is no mystery. This line
explains it all:
A \score block must begin with a compound music expression.
To understand what is meant by a music expression and a compound music expression, you may
fnd it useful to review the tutorial, Section 2.3.1 [Music expressions explained], page 24. In that
section, we saw how to build big music expressions from small pieces – we started from notes,
then chords, etc. Now we’re going to start from a big music expression and work our way down.
\score {
{ % this brace begins the overall compound music expression
\new StaffGroup <<
...insert the whole score of a Wagner opera in here...
>>
} % this brace ends the overall compound music expression
\layout { }
}
A whole Wagner opera would easily double the length of this manual, so let’s just add a singer
and piano. We don’t need a StaffGroup for this ensemble, which simply groups a number of
staves together with a bracket at the left, so we shall remove it. We do need a singer and a
piano, though.
\score {
<<
\new Staff = "singer" <<
>>
\new PianoStaff = "piano" <<
>>
>>
\layout { }
Chapter 3: Fundamental concepts 40
}
Remember that we use << ... >> instead of { ... } to show simultaneous music. And we
defnitely want to show the vocal part and piano part at the same time, not one after the other!
Note that the << ... >> construct is not really necessary for the Singer staf, as it contains only
one sequential music expression; however, using << ... >> instead of braces is still necessary if
the music in the Staf is made of two simultaneous expressions, e.g. two simultaneous Voices,
or a Voice with lyrics. We’ll add some real music later; for now let’s just put in some dummy
notes and lyrics.
\score {
<<
\new Staff = "singer" <<
\new Voice = "vocal" { c'1 }
\addlyrics { And }
>>
\new PianoStaff = "piano" <<
\new Staff = "upper" { c'1 }
\new Staff = "lower" { c'1 }
>>
>>
\layout { }
}

And

Now we have a lot more details. We have the singer’s staf: it contains a Voice (in LilyPond,
this term refers to a set of notes, not necessarily vocal notes – for example, a violin generally
plays one voice) and some lyrics. We also have a piano staf: it contains an upper staf (right
hand) and a lower staf (left hand).
At this stage, we could start flling in notes. Inside the curly braces next to \new Voice =
"vocal", we could start writing
\relative c'' {
r4 d8\noBeam g, c4 r
}
But if we did that, the \score section would get pretty long, and it would be harder to
understand what was happening. So let’s use variables instead. These were introduced at the
end of the previous section, remember? So, adding a few notes, we now have a piece of real
music:
melody = \relative c'' { r4 d8\noBeam g, c4 r }
text = \lyricmode { And God said, }
upper = \relative c'' { <g d g,>2~ <g d g,> }
lower = \relative c { b2 e2 }
Chapter 3: Fundamental concepts 41
\score {
<<
\new Staff = "singer" <<
\new Voice = "vocal" { \melody }
\addlyrics { \text }
>>
\new PianoStaff = "piano" <<
\new Staff = "upper" { \upper }
\new Staff = "lower" {
\clef "bass"
\lower
}
>>
>>
\layout { }
}

God

said,

And

Be careful about the diference between notes, which are introduced with \relative or which
are directly included in a music expression, and lyrics, which are introduced with \lyricmode.
These are essential to tell LilyPond to interpret the following content as music and text respec-
tively.
When writing (or reading) a \score section, just take it slowly and carefully. Start with the
outer level, then work on each smaller level. It also really helps to be strict with indentation –
make sure that each item on the same level starts on the same horizontal position in your text
editor.
See also
Notation Reference: Section “Structure of a score” in Notation Reference.
3.1.3 Nesting music expressions
It is not essential to declare all staves at the beginning; they may be introduced temporarily at
any point. This is particularly useful for creating ossia sections – see Section “ossia” in Music
Glossary. Here is a simple example showing how to introduce a new staf temporarily for the
duration of three notes:
\new Staff {
\relative g' {
r4 g8 g c4 c8 d |
e4 r8
Chapter 3: Fundamental concepts 42
<<
{ f c c }
\new Staff {
f8 f c
}
>>
r4 |
}
}

Note that the size of the clef is the same as a clef printed following a clef change – slightly
smaller than the clef at the beginning of the line. This is usual for clefs printed in the middle of
a line.
The ossia section may be placed above the staf as follows:
\new Staff = "main" {
\relative g' {
r4 g8 g c4 c8 d |
e4 r8
<<
{ f c c }
\new Staff \with {
alignAboveContext = #"main" }
{ f8 f c }
>>
r4 |
}
}

This example uses \with, which will be explained more fully later. It is a means of modifying
the default behavior of a single Staf. Here it says that the new staf should be placed above the
staf called “main” instead of the default position which is below.
See also
Ossia are often written without clef and without time signature and are usually in a smaller
font. These require further commands which have not yet been introduced. See Section 4.3.2
[Size of objects], page 95, and Section “Ossia staves” in Notation Reference.
Chapter 3: Fundamental concepts 43
3.1.4 On the un-nestedness of brackets and ties
You have already met a number of diferent types of bracket in writing the input fle to LilyPond.
These obey diferent rules which can be confusing at frst. Before we explain the rules let’s frst
review the diferent types of bracket.
Bracket Type Function
{ .. } Encloses a sequential segment of music
< .. > Encloses the notes of a chord
<< .. >> Encloses simultaneous music expressions
( .. ) Marks the start and end of a slur
\( .. \) Marks the start and end of a phrasing slur
[ .. ] Marks the start and end of a manual beam
To these we should add other constructs which generate lines between or across notes:
ties (marked by a tilde, ~), tuplets written as \times x/y {..}, and grace notes written as
\grace{..}.
Outside LilyPond, the conventional use of brackets requires the diferent types to be properly
nested, like this, << [ { ( .. ) } ] >>, with the closing brackets being encountered in exactly
the opposite order to the opening brackets. This is a requirement for the three types of bracket
described by the word ‘Encloses’ in the table above – they must nest properly. However, the
remaining brackets, described with the word ‘Marks’ in the table above together with ties and
tuplets, do not have to nest properly with any of the brackets. In fact, these are not brackets in
the sense that they enclose something – they are simply markers to indicate where something
starts and ends.
So, for example, a phrasing slur can start before a manually inserted beam and end before
the end of the beam – not very musical, perhaps, but possible:
{ g8\( a b[ c b\) a] }

In general, diferent kinds of brackets, and those implied by tuplets, ties and grace notes, may
be mixed freely. This example shows a beam extending into a tuplet (line 1), a slur extending
into a tuplet (line 2), a beam and a slur extending into a tuplet, a tie crossing two tuplets, and
a phrasing slur extending out of a tuplet (lines 3 and 4).
{
r16[ g16 \times 2/3 {r16 e'8] }
g16( a \times 2/3 {b d) e' }
g8[( a \times 2/3 {b d') e'~]}
\times 4/5 {e'32\( a b d' e'} a'4.\)
}

3

3

3

5

2

Chapter 3: Fundamental concepts 44
3.2 Voices contain music
Singers need voices to sing, and so does LilyPond. The actual music for all instruments in a
score is contained in Voices – the most fundamental of all LilyPond’s concepts.
3.2.1 I’m hearing Voices
The lowest, most fundamental or innermost layers in a LilyPond score are called ‘Voice contexts’
or just ‘Voices’ for short. Voices are sometimes called ‘layers’ in other notation packages.
In fact, a Voice layer or context is the only one which can contain music. If a Voice context is
not explicitly declared one is created automatically, as we saw at the beginning of this chapter.
Some instruments such as an Oboe can play only one note at a time. Music written for such
instruments is monophonic and requires just a single voice. Instruments which can play more
than one note at a time like the piano will often require multiple voices to encode the diferent
concurrent notes and rhythms they are capable of playing.
A single voice can contain many notes in a chord, of course, so when exactly are multiple
voices needed? Look frst at this example of four chords:
\key g \major
<d g>4 <d fis> <d a'> <d g>

This can be expressed using just the single angle bracket chord symbols, < ... >, and for
this just a single voice is needed. But suppose the F-sharp were actually an eighth-note followed
by an eighth-note G, a passing note on the way to the A? Now we have two notes which start
at the same time but have diferent durations: the quarter-note D and the eighth-note F-sharp.
How are these to be coded? They cannot be written as a chord because all the notes in a chord
must have the same duration. And they cannot be written as two sequential notes as they need
to start at the same time. This is when two voices are required.
Let us see how this is done in LilyPond input syntax.
The easiest way to enter fragments with more than one voice on a staf is to enter each voice as
a sequence (with {...}), and combine them simultaneously with angle brackets, <<...>>. The
fragments must also be separated with double backward slashes, \\, to place them in separate
voices. Without these, the notes would be entered into a single voice, which would usually cause
errors. This technique is particularly suited to pieces of music which are largely monophonic
with occasional short sections of polyphony.
Here’s how we split the chords above into two voices and add both the passing note and a
slur:
\key g \major
% Voice "1" Voice "2"
<< { g4 fis8( g) a4 g } \\ { d4 d d d } >> |

Notice how the stems of the second voice now point down.
Here’s another simple example:
Chapter 3: Fundamental concepts 45
\key d \minor
% Voice "1" Voice "2"
<< { r4 g g4. a8 } \\ { d,2 d4 g } >> |
<< { bes4 bes c bes } \\ { g4 g g8( a) g4 } >> |
<< { a2. r4 } \\ { fis2. s4 } >> |
,
,
,

,
, ,
, , /
, ,
,
,
,
.
,

,

.
,
,
.
,
,
It is not necessary to use a separate << \\ >> construct for each bar. For music with few
notes in each bar this layout can help the legibility of the code, but if there are many notes in
each bar it may be better to split out each voice separately, like this:
\key d \minor
<< {
% Voice "1"
r4 g g4. a8 |
bes4 bes c bes |
a2. r4 |
} \\ {
% Voice "2"
d,2 d4 g |
g4 g g8( a) g4 |
fis2. s4 |
} >>
,

,
,

,
, / ,
,
.
,

,
,
,

,
,
,
,
,
,
.
.
,
,
This example has just two voices, but the same construct may be used to encode three or
more voices by adding more back-slash separators.
The Voice contexts bear the names "1", "2", etc. In each of these contexts, the vertical
direction of slurs, stems, ties, dynamics etc., is set appropriately.
\new Staff \relative c' {
% Main voice
c16 d e f
% Voice "1" Voice "2" Voice "3"
<< { g4 f e } \\ { r8 e4 d c8 ~ } >> |
<< { d2 e2 } \\ { c8 b16 a b8 g ~ g2 } \\ { s4 b4 c2 } >> |
}

These voices are all separate from the main voice that contains the notes just outside the
<< .. >> construct. Let’s call this the simultaneous construct. Slurs and ties may only connect
notes within the same voice, so slurs and ties cannot go into or out of a simultaneous construct.
Chapter 3: Fundamental concepts 46
Conversely, parallel voices from separate simultaneous constructs on the same staf are the same
voice. Other voice-related properties also carry across simultaneous constructs. Here is the same
example, with diferent colors and note heads for each voice. Note that changes in one voice do
not afect other voices, but they do persist in the same voice later. Note also that tied notes
may be split across the same voices in two constructs, shown here in the blue triangle voice.
\new Staff \relative c' {
% Main voice
c16 d e f
<< % Bar 1
{
\voiceOneStyle
g4 f e
}
\\
{
\voiceTwoStyle
r8 e4 d c8 ~
}
>>
<< % Bar 2
% Voice 1 continues
{ d2 e2 }
\\
% Voice 2 continues
{ c8 b16 a b8 g ~ g2 }
\\
{
\voiceThreeStyle
s4 b4 c2
}
>>
}
,
,
,
,
,
,,
,
,
,
,
,
,
,
,
·
/
,
,
,
,
,
,
,
The commands \voiceXXXStyle are mainly intended for use in educational documents such
as this one. They modify the color of the note head, the stem and the beams, and the style of
the note head, so that the voices may be easily distinguished. Voice one is set to red diamonds,
voice two to blue triangles, voice three to green crossed circles, and voice four (not used here) to
magenta crosses; \voiceNeutralStyle (also not used here) reverts the style back to the default.
We shall see later how commands like these may be created by the user. See Section 4.3.1
[Visibility and color of objects], page 91 and Section 4.6.2 [Using variables for tweaks], page 126.
Polyphony does not change the relationship of notes within a \relative { } block. Each
note is still calculated relative to the note immediately preceding it, or to the frst note of the
preceding chord. So in
\relative c' { noteA << < noteB noteC > \\ noteD >> noteE }
noteB is relative to noteA
noteC is relative to noteB, not noteA;
Chapter 3: Fundamental concepts 47
noteD is relative to noteB, not noteA or noteC;
noteE is relative to noteD, not noteA.
An alternative way, which may be clearer if the notes in the voices are widely separated, is
to place a \relative command at the start of each voice:
\relative c' { noteA ... }
<<
\relative c'' { < noteB noteC > ... }
\\
\relative g' { noteD ... }
>>
\relative c' { noteE ... }
Let us fnally analyze the voices in a more complex piece of music. Here are the notes from
the frst two bars of the second of Chopin’s Deux Nocturnes, Op 32. This example will be
used at later stages in this and the next chapter to illustrate several techniques for producing
notation, so please ignore for now anything in the underlying code which looks mysterious and
concentrate just on the music and the voices – the complications will all be explained in later
sections.

The direction of the stems is often used to indicate the continuity of two simultaneous melodic
lines. Here the stems of the highest notes are all pointing up and the stems of the lower notes
are all pointing down. This is the frst indication that more than one voice is required.
But the real need for multiple voices arises when notes which start at the same time have
diferent durations. Look at the notes which start at beat three in the frst bar. The A-fat is
a dotted quarter note, the F is a quarter note and the D-fat is a half note. These cannot be
written as a chord as all the notes in a chord must have the same duration. Neither can they be
written as sequential notes, as they must start at the same time. This section of the bar requires
three voices, and the normal practice would be to write the whole bar as three voices, as shown
below, where we have used diferent note heads and colors for the three voices. Again, the code
behind this example will be explained later, so ignore anything you do not understand.
,
,
,
,
,
,
,
,
,
,
,
,

,
/
,
,
,
,
, ,
Let us try to encode this music from scratch. As we shall see, this encounters some difculties.
We begin as we have learnt, using the << \\ >> construct to enter the music of the frst bar in
three voices:
\new Staff \relative c'' {
\key aes \major
<<
{ c2 aes4. bes8 } \\ { aes2 f4 fes } \\ { <ees c>2 des2 }
>>
<c ees aes c>1
}
Chapter 3: Fundamental concepts 48

The stem directions are automatically assigned with the odd-numbered voices taking upward
stems and the even-numbered voices downward ones. The stems for voices 1 and 2 are right,
but the stems in voice 3 should go down in this particular piece of music. We can correct this
simply by missing out voice three and placing the music in voice four:
\new Staff \relative c'' {
\key aes \major
<< % Voice one
{ c2 aes4. bes8 }
\\ % Voice two
{ aes2 f4 fes }
\\ % Omit Voice three
\\ % Voice four
{ <ees c>2 des2 }
>> |
<c ees aes c>1 |
}

We see that this fxes the stem direction, but exposes a problem sometimes encountered with
multiple voices – the stems of the notes in one voice can collide with the note heads in other
voices. In laying out the notes, LilyPond allows the notes or chords from two voices to occupy
the same vertical note column provided the stems are in opposite directions, but the notes from
the third and fourth voices are displaced, if necessary, to avoid the note heads colliding. This
usually works well, but in this example the notes of the lowest voice are clearly not well placed
by default. LilyPond provides several ways to adjust the horizontal placing of notes. We are not
quite ready yet to see how to correct this, so we shall leave this problem until a later section —
see the force-hshift property in Section 4.5.2 [Fixing overlapping notation], page 111.
See also
Notation Reference: Section “Multiple voices” in Notation Reference.
3.2.2 Explicitly instantiating voices
Voice contexts can also be created manually inside a << >> block to create polyphonic music,
using \voiceOne ... \voiceFour to indicate the required directions of stems, slurs, etc. In
longer scores this method is clearer, as it permits the voices to be separated and to be given
more descriptive names.
Specifcally, the construct << \\ >> which we used in the previous section:
\new Staff {
\relative c' {
<< { e4 f g a } \\ { c,4 d e f } >>
}
}
is equivalent to
\new Staff <<
\new Voice = "1" { \voiceOne \relative c' { e4 f g a } }
Chapter 3: Fundamental concepts 49
\new Voice = "2" { \voiceTwo \relative c' { c4 d e f } }
>>
Both of the above would produce

The \voiceXXX commands set the direction of stems, slurs, ties, articulations, text annota-
tions, augmentation dots of dotted notes, and fngerings. \voiceOne and \voiceThree make
these objects point upwards, while \voiceTwo and \voiceFour make them point downwards.
These commands also generate a horizontal shift for each voice when this is required to avoid
clashes of note heads. The command \oneVoice reverts the settings back to the normal values
for a single voice.
Let us see in some simple examples exactly what efect \oneVoice, \voiceOne and voiceTwo
have on markup, ties, slurs, and dynamics:
\relative c'{
% Default behavior or behavior after \oneVoice
c d8 ~ d e4 ( f g a ) b-> c
}

\relative c'{
\voiceOne
c d8 ~ d e4 ( f g a ) b-> c
\oneVoice
c, d8 ~ d e4 ( f g a ) b-> c
}

\relative c'{
\voiceTwo
c d8 ~ d e4 ( f g a ) b-> c
\oneVoice
c, d8 ~ d e4 ( f g a ) b-> c
}

Now let’s look at three diferent ways to notate the same passage of polyphonic music, each of
which is advantageous in diferent circumstances, using the example from the previous section.
Chapter 3: Fundamental concepts 50
An expression that appears directly inside a << >> belongs to the main voice (but, note, not
in a << \\ >> construct). This is useful when extra voices appear while the main voice is playing.
Here is a more correct rendition of our example. The red diamond-shaped notes demonstrate
that the main melody is now in a single voice context, permitting a phrasing slur to be drawn
over them.
\new Staff \relative c' {
\voiceOneStyle
% The following notes are monophonic
c16^( d e f
% Start simultaneous section of three voices
<<
% Continue the main voice in parallel
{ g4 f e | d2 e2) }
% Initiate second voice
\new Voice {
% Set stems, etc, down
\voiceTwo
r8 e4 d c8 ~ | c8 b16 a b8 g ~ g2
}
% Initiate third voice
\new Voice {
% Set stems, etc, up
\voiceThree
s2. | s4 b4 c2
}
>>
}

More deeply nested polyphony constructs are possible, and if a voice appears only briefy
this might be a more natural way to typeset the music:
\new Staff \relative c' {
c16^( d e f
<<
{ g4 f e | d2 e2) }
\new Voice {
\voiceTwo
r8 e4 d c8 ~ |
<<
{c8 b16 a b8 g ~ g2}
\new Voice {
\voiceThree
s4 b4 c2
}
>>
}
>>
Chapter 3: Fundamental concepts 51
}

This method of nesting new voices briefy is useful when only small sections of the music
are polyphonic, but when the whole staf is largely polyphonic it can be clearer to use multiple
voices throughout, using spacing notes to step over sections where the voice is silent, as here:
\new Staff \relative c' <<
% Initiate first voice
\new Voice {
\voiceOne
c16^( d e f g4 f e | d2 e2) |
}
% Initiate second voice
\new Voice {
% Set stems, etc, down
\voiceTwo
s4 r8 e4 d c8 ~ | c8 b16 a b8 g ~ g2 |
}
% Initiate third voice
\new Voice {
% Set stems, etc, up
\voiceThree
s1 | s4 b4 c2 |
}
>>

Note columns
Closely spaced notes in a chord, or notes occurring at the same time in diferent voices, are
arranged in two, occasionally more, columns to prevent the note heads overlapping. These are
called note columns. There are separate columns for each voice, and the currently specifed
voice-dependent shift is applied to the note column if there would otherwise be a collision. This
can be seen in the example above. In bar 2 the C in voice two is shifted to the right relative to
the D in voice one, and in the fnal chord the C in voice three is also shifted to the right relative
to the other notes.
The \shiftOn, \shiftOnn, \shiftOnnn, and \shiftOff commands specify the degree to
which notes and chords of the voice should be shifted if a collision would otherwise occur. By
default, the outer voices (normally voices one and two) have \shiftOff specifed, while the
inner voices (three and four) have \shiftOn specifed. When a shift is applied, voices one and
three are shifted to the right and voices two and four to the left.
\shiftOnn and \shiftOnnn defne further shift levels which may be specifed temporarily to
resolve collisions in complex situations – see Section 4.5.3 [Real music example], page 116.
Chapter 3: Fundamental concepts 52
A note column can contain just one note (or chord) from a voice with stems up and one note
(or chord) from a voice with stems down. If notes from two voices which have their stems in the
same direction are placed at the same position and both voices have no shift or the same shift
specifed, the error message “Too many clashing note columns” will be produced.
See also
Notation Reference: Section “Multiple voices” in Notation Reference.
3.2.3 Voices and vocals
Vocal music presents a special difculty: we need to combine two expressions – notes and lyrics.
You have already seen the \addlyrics{} command, which handles simple scores well. How-
ever, this technique is quite limited. For more complex music, you must introduce the lyrics in a
Lyrics context using \new Lyrics and explicitly link the lyrics to the notes with \lyricsto{},
using the name assigned to the Voice.
<<
\new Voice = "one" \relative c'' {
\autoBeamOff
\time 2/4
c4 b8. a16 g4. f8 e4 d c2
}
\new Lyrics \lyricsto "one" {
No more let sins and sor -- rows grow.
}
>>

and No

grow.

4
2


sins

let rows

more

sor

Note that the lyrics must be linked to a Voice context, not a Staff context. This is a case
where it is necessary to create Staff and Voice contexts explicitly.
The automatic beaming which LilyPond uses by default works well for instrumental music,
but not so well for music with lyrics, where beaming is either not required at all or is used to
indicate melismata in the lyrics. In the example above we use the command \autoBeamOff to
turn of the automatic beaming.
Let us reuse the earlier example from Judas Maccabæus to illustrate this more fexible tech-
nique. We frst recast it to use variables so the music and lyrics can be separated from the staf
structure. We also introduce a ChoirStaf bracket. The lyrics themselves must be introduced
with \lyricmode to ensure they are interpreted as lyrics rather than music.
global = { \time 6/8 \partial 8 \key f \major}
SopOneMusic = \relative c'' {
c8 | c([ bes)] a a([ g)] f | f'4. b, | c4.~ c4 }
SopTwoMusic = \relative c' {
r8 | r4. r4 c8 | a'([ g)] f f([ e)] d | e([ d)] c bes' }
SopOneLyrics = \lyricmode {
Let | flee -- cy flocks the | hills a -- dorn, __ }
SopTwoLyrics = \lyricmode {
Let | flee -- cy flocks the | hills a -- dorn, }
Chapter 3: Fundamental concepts 53
\score {
\new ChoirStaff <<
\new Staff <<
\new Voice = "SopOne" {
\global
\SopOneMusic
}
\new Lyrics \lyricsto "SopOne" {
\SopOneLyrics
}
>>
\new Staff <<
\new Voice = "SopTwo" {
\global
\SopTwoMusic
}
\new Lyrics \lyricsto "SopTwo" {
\SopTwoLyrics
}
>>
>>
}
,
flocks
,

flee
,
hills

, /


8
6 , ,
·
,
a
,
cy
,
,
the
,
,
hills

,
a
.
.
the

dorn,
,
,

,
Let
, ,

,
Let
,
flocks
dorn,
,
,
,
¸

,
,
·
cy flee
/
8
6
,
,
This is the basic structure of all vocal scores. More staves may be added as required, more
voices may be added to the staves, more verses may be added to the lyrics, and the variables
containing the music can easily be placed in separate fles should they become too long.
Here is an example of the frst line of a hymn with four verses, set for SATB. In this case
the words for all four parts are the same. Note how we use variables to separate the music
notation and words from the staf structure. See too how a variable, which we have chosen
to call ‘TimeKey’, is used to hold several commands for use within the two staves. In other
examples this is often called ‘global’.
TimeKey = { \time 4/4 \partial 4 \key c \major}
SopMusic = \relative c' { c4 | e4. e8 g4 g | a a g }
AltoMusic = \relative c' { c4 | c4. c8 e4 e | f f e }
TenorMusic = \relative c { e4 | g4. g8 c4. b8 | a8 b c d e4 }
BassMusic = \relative c { c4 | c4. c8 c4 c | f8 g a b c4 }
VerseOne = \lyricmode {
E -- | ter -- nal fa -- ther, | strong to save, }
VerseTwo = \lyricmode {
O | Christ, whose voice the | wa -- ters heard, }
VerseThree = \lyricmode {
O | Ho -- ly Spi -- rit, | who didst brood }
Chapter 3: Fundamental concepts 54
VerseFour = \lyricmode {
O | Tri -- ni -- ty of | love and pow'r }
\score {
\new ChoirStaff <<
\new Staff <<
\clef "treble"
\new Voice = "Sop" { \voiceOne \TimeKey \SopMusic }
\new Voice = "Alto" { \voiceTwo \AltoMusic }
\new Lyrics \lyricsto "Sop" { \VerseOne }
\new Lyrics \lyricsto "Sop" { \VerseTwo }
\new Lyrics \lyricsto "Sop" { \VerseThree }
\new Lyrics \lyricsto "Sop" { \VerseFour }
>>
\new Staff <<
\clef "bass"
\new Voice = "Tenor" { \voiceOne \TimeKey \TenorMusic }
\new Voice = "Bass" { \voiceTwo \BassMusic }
>>
>>
}
,
,
Ho
Christ,
ter
,
,
,
,
pow'r
brood
heard,
save,
,
,
,
,
E

·
,
love
who
wa
strong
,
,
.
.
Tri
nal
,
,
,

,
,
,
,
/
,
,
ty
Spi
voice
fa
,
ters
to
,
,
O
O
O

,
,
ni
ly
whose
·
,
,
and
didst
,

,

,
,
,
,
of
rit,
the
ther,
,
,
,
,
We end with an example to show how we might code a solo verse which continues into a
two-part refrain in two staves. The positioning of the sequential and simultaneous sections to
achieve this within a single score is quite tricky, so follow the explanation carefully!
Let’s start with a score block containing a ChoirStaff, as we would like the brace to appear
at the start of the chorus. Normally you would need angle brackets after \new ChoirStaff to
bring in all the staves in parallel, but here we want to defer the parallelism during the solo so
we use braces, although angle brackets here wouldn’t hurt. Inside the ChoirStaff we want frst
the staf which will contain the verse. This must contain notes and lyrics in parallel, so here we
need angle brackets around the \new Voice and \new Lyrics to start them at the same time:
versenotes = \relative c'' {
\clef "treble"
\key g \major
\time 3/4 g g g b b b
}
versewords = \lyricmode {
One two three four five six
Chapter 3: Fundamental concepts 55
}
\score {
\new ChoirStaff {
\new Staff <<
\new Voice = "verse" {
\versenotes \break
}
\new Lyrics \lyricsto verse {
\versewords
}
>>
}
}

six

two

4
3
four five

One

three
That gives the verse line.
Now we want to continue with refrainA on the same staf while a second staf is introduced in
parallel with it for refrainB, so this is a parallel section which must be positioned immediately
following the \break in the verse Voice. Yes, within the verse Voice! Here’s that parallel section.
More staves could be introduced here in the same way.
<<
\refrainnotesA
\new Lyrics \lyricsto verse {
\refrainwordsA
}
\new Staff <<
\new Voice = "refrainB" {
\refrainnotesB
}
\new Lyrics \lyricsto "refrainB" {
\refrainwordsB
}
>>
>>
Here’s the fnal result with two staves in the chorus showing how the parallel section is
positioned within the verse Voice:
versenotes = \relative c'' {
\clef "treble"
\key g \major
\time 3/4 g g g b b b
}
refrainnotesA = \relative c'' {
\time 2/4
c c g g \bar "|."
}
refrainnotesB = \relative c {
\clef "bass"
Chapter 3: Fundamental concepts 56
\key g \major
c e d d
}
versewords = \lyricmode {
One two three four five six
}
refrainwordsA = \lyricmode {
la la la la
}
refrainwordsB = \lyricmode {
dum dum dum dum
}
\score {
\new ChoirStaff {
\new Staff <<
\new Voice = "verse" {
\versenotes \break
<<
\refrainnotesA
\new Lyrics \lyricsto "verse" {
\refrainwordsA
}
\new Staff <<
\new Voice = "refrainB" {
\refrainnotesB
}
\new Lyrics \lyricsto "refrainB" {
\refrainwordsB
}
>>
>>
}
\new Lyrics \lyricsto "verse" {
\versewords
}
>>
}
}
six

two

four
4
2

five

One

4
3
three

Chapter 3: Fundamental concepts 57
dum

la

3

4
2

la
dum
la

dum

la

4
2

dum
However, although this is an interesting and useful exercise to help you to understand how
sequential and simultaneous blocks work, in practice one would perhaps choose to code this as
two \score blocks within an implicit \book block, as follows:
versenotes = \relative c'' {
\clef "treble"
\key g \major
\time 3/4 g g g b b b
}
refrainnotesA = \relative c'' {
\time 2/4
c c g g \bar "|."
}
refrainnotesB = \relative c {
\clef "bass"
\key g \major
c e d d
}
versewords = \lyricmode {
One two three four five six
}
refrainwordsA = \lyricmode {
la la la la
}
refrainwordsB = \lyricmode {
dum dum dum dum
}
\score {
\new Staff <<
\new Voice = "verse" {
\versenotes
}
\new Lyrics \lyricsto "verse" {
\versewords
}
>>
}
\score {
\new ChoirStaff <<
\new Staff <<
\new Voice = "refrainA" {
\refrainnotesA
}
\new Lyrics \lyricsto "refrainA" {
Chapter 3: Fundamental concepts 58
\refrainwordsA
}
>>
\new Staff <<
\new Voice = "refrainB" {
\refrainnotesB
}
\new Lyrics \lyricsto "refrainB" {
\refrainwordsB
}
>>
>>
}
six

4
3
One

three five

four

two
la

dum

dum

4
2

dum

la

4
2

la

dum

la

See also
Notation Reference: Section “Vocal music” in Notation Reference.
3.3 Contexts and engravers
Contexts and engravers have been mentioned informally in earlier sections; we now must look
at these concepts in more detail, as they are important in the fne-tuning of LilyPond output.
3.3.1 Contexts explained
When music is printed, many notational elements which do not appear explicitly in the input
fle must be added to the output. For example, compare the input and output of the following
example:
cis4 cis2. g4




The input is rather sparse, but in the output, bar lines, accidentals, clef, and time signature
have been added. When LilyPond interprets the input the musical information is inspected in
time order, similar to reading a score from left to right. While reading the input, the program
Chapter 3: Fundamental concepts 59
remembers where measure boundaries are, and which pitches require explicit accidentals. This
information must be held on several levels. For example, the efect of an accidental is limited to
a single staf, while a bar line must be synchronized across the entire score.
Within LilyPond, these rules and bits of information are grouped in Contexts. We have
already met the Voice context. Others are the Staff and Score contexts. Contexts are hier-
archical to refect the hierarchical nature of a musical score. For example: a Staff context can
contain many Voice contexts, and a Score context can contain many Staff contexts.
Each context has the responsibility for enforcing some notation rules, creating some nota-
tion objects and maintaining the associated properties. For example, the Voice context may
introduce an accidental and then the Staff context maintains the rule to show or suppress the
accidental for the remainder of the measure.
As another example, the synchronization of bar lines is, by default, handled in the Score
context. However, in some music we may not want the bar lines to be synchronized – consider
a polymetric score in 4/4 and 3/4 time. In such cases, we must modify the default settings of
the Score and Staff contexts.
For very simple scores, contexts are created implicitly, and you need not be aware of them.
For larger pieces, such as anything with more than one staf, they must be created explicitly
to make sure that you get as many staves as you need, and that they are in the correct order.
For typesetting pieces with specialized notation, it is usual to modify existing, or even to defne
totally new, contexts.
In addition to the Score, Staff and Voice contexts there are contexts which ft between the
score and staf levels to control staf groups, such as the PianoStaff and ChoirStaff contexts.
There are also alternative staf and voice contexts, and contexts for lyrics, percussion, fret
boards, fgured bass, etc.
The names of all context types are formed from one or more words, each word being cap-
italized and joined immediately to the preceding word with no hyphen or underscore, e.g.,
GregorianTranscriptionStaff.
See also
Notation Reference: Section “Contexts explained” in Notation Reference.
3.3.2 Creating contexts
There can be only one top level context: the Score context. This is created with the \score
command, or, in simple scores, it is created automatically.
For scores with only one voice and one staf, the Voice and Staff contexts may be left to be
created automatically, but for more complex scores it is necessary to create them by hand. The
simplest command that does this is \new. It is prepended to a music expression, for example
\new type music-expression
where type is a context name (like Staff or Voice). This command creates a new context, and
starts interpreting the music-expression within that context.
Note that there is no \new Score command; the single top-level Score context is introduced
with \score.
Chapter 3: Fundamental concepts 60
You have seen many practical examples which created new Staff and Voice contexts in
earlier sections, but to remind you how these commands are used in practice, here’s an annotated
real-music example:
\score { % start of single compound music expression
<< % start of simultaneous staves section
\time 2/4
\new Staff { % create RH staff
\key g \minor
\clef "treble"
\new Voice { % create voice for RH notes
\relative c'' { % start of RH notes
d4 ees16 c8. |
d4 ees16 c8. |
} % end of RH notes
} % end of RH voice
} % end of RH staff
\new Staff << % create LH staff; needs two simultaneous voices
\key g \minor
\clef "bass"
\new Voice { % create LH voice one
\voiceOne
\relative g { % start of LH voice one notes
g8 <bes d> ees, <g c> |
g8 <bes d> ees, <g c> |
} % end of LH voice one notes
} % end of LH voice one
\new Voice { % create LH voice two
\voiceTwo
\relative g { % start of LH voice two notes
g4 ees |
g4 ees |
} % end of LH voice two notes
} % end of LH voice two
>> % end of LH staff
>> % end of simultaneous staves section
} % end of single compound music expression

4
2

4
2

(Note how all the statements which open a block with either a curly bracket, {, or double
angle brackets, <<, are indented by two further spaces, and the corresponding closing bracket
is indented by exactly the same amount. While this is not required, following this practice
will greatly reduce the number of ‘unmatched bracket’ errors, and is strongly recommended. It
enables the structure of the music to be seen at a glance, and any unmatched brackets will be
obvious. Note too how the LH staf is created using double angle brackets because it requires two
Chapter 3: Fundamental concepts 61
voices for its music, whereas the RH staf is created with a single music expression surrounded
by curly brackets because it requires only one voice.)
The \new command may also give a identifying name to the context to distinguish it from
other contexts of the same type,
\new type = id music-expression
Note the distinction between the name of the context type, Staff, Voice, etc, and the
identifying name of a particular instance of that type, which can be any sequence of letters
invented by the user. Digits and spaces can also be used in the identifying name, but then it
has to be placed in quotes, i.e. \new Staff = "MyStaff 1" music-expression. The identifying
name is used to refer back to that particular instance of a context. We saw this in use in the
section on lyrics, see Section 3.2.3 [Voices and vocals], page 52.
See also
Notation Reference: Section “Creating contexts” in Notation Reference.
3.3.3 Engravers explained
Every mark on the printed output of a score produced by LilyPond is produced by an Engraver.
Thus there is an engraver to print staves, one to print note heads, one for stems, one for beams,
etc, etc. In total there are over 120 such engravers! Fortunately, for most scores it is not
necessary to know about more than a few, and for simple scores you do not need to know about
any.
Engravers live and operate in Contexts. Engravers such as the Metronome_mark_engraver,
whose action and output apply to the score as a whole, operate in the highest level context –
the Score context.
The Clef_engraver and Key_engraver are to be found in every Staff Context, as diferent
staves may require diferent clefs and keys.
The Note_heads_engraver and Stem_engraver live in every Voice context, the lowest level
context of all.
Each engraver processes the particular objects associated with its function, and maintains
the properties that relate to that function. These properties, like the properties associated with
contexts, may be modifed to change the operation of the engraver or the appearance of those
elements in the printed score.
Engravers all have compound names formed from words which describe their function. Just
the frst word is capitalized, and the remainder are joined to it with underscores. Thus the
Staff_symbol_engraver is responsible for creating the lines of the staf, the Clef_engraver
determines and sets the pitch reference point on the staf by drawing a clef symbol.
Here are some of the most common engravers together with their function. You will see it is
usually easy to guess the function from the name, or vice versa.
Engraver Function
Accidental engraver Makes accidentals, cautionary and suggested accidentals
Beam engraver Engraves beams
Clef engraver Engraves clefs
Completion heads engraver Splits notes which cross bar lines
New dynamic engraver Creates hairpins and dynamic texts
Forbid line break engraver Prevents line breaks if a musical element is still active
Key engraver Creates the key signature
Metronome mark engraver Engraves metronome marking
Note heads engraver Engraves note heads
Chapter 3: Fundamental concepts 62
Rest engraver Engraves rests
Staf symbol engraver Engraves the fve (by default) lines of the staf
Stem engraver Creates stems and single-stem tremolos
Time signature engraver Creates time signatures
We shall see later how the output of LilyPond can be changed by modifying the action of
Engravers.
See also
Internals reference: Section “Engravers and Performers” in Internals Reference.
3.3.4 Modifying context properties
Contexts are responsible for holding the values of a number of context properties. Many of them
can be changed to infuence the interpretation of the input and so change the appearance of the
output. They are changed by the \set command. This takes the form
\set ContextName.propertyName = #value
Where the ContextName is usually Score, Staff or Voice. It may be omitted, in which case
Voice is assumed.
The names of context properties consist of words joined together with no hyphens or under-
scores, all except the frst having a capital letter. Here are a few examples of some commonly
used ones. There are many more.
propertyName Type Function Example
Value
extraNatural Boolean If true, set extra natural signs before
accidentals
#t, #f
currentBarNumber Integer Set the current bar number 50
doubleSlurs Boolean If true, print slurs both above and below
notes
#t, #f
instrumentName Text Set the name to be placed at the start of
the staf
"Cello I"
fontSize Real Increase or decrease the font size 2.4
stanza Text Set the text to print before the start of
a verse
"2"
where a Boolean is either True (#t) or False (#f), an Integer is a positive whole number, a Real
is a positive or negative decimal number, and text is enclosed in double apostrophes. Note the
occurrence of hash signs, (#), in two diferent places – as part of the Boolean value before the t
or f, and before value in the \set statement. So when a Boolean is being entered you need to
code two hash signs, e.g., ##t.
Before we can set any of these properties we need to know in which context they operate.
Sometimes this is obvious, but occasionally it can be tricky. If the wrong context is specifed,
no error message is produced, but the expected action will not take place. For example, the
instrumentName clearly lives in the Staff context, since it is the staf that is to be named. In
this example the frst staf is labelled, but not the second, because we omitted the context name.
<<
\new Staff \relative c'' {
\set Staff.instrumentName = #"Soprano"
c4 c
}
Chapter 3: Fundamental concepts 63
\new Staff \relative c' {
\set instrumentName = #"Alto" % Wrong!
d4 d
}
>>

Soprano

Remember the default context name is Voice, so the second \set command set the property
instrumentName in the Voice context to “Alto”, but as LilyPond does not look for any such
property in the Voice context, no further action took place. This is not an error, and no error
message is logged in the log fle.
Similarly, if the property name is mis-spelt no error message is produced, and clearly the
expected action cannot be performed. In fact, you can set any (fctitious) ‘property’ using any
name you like in any context that exists by using the \set command. But if the name is not
known to LilyPond it will not cause any action to be taken. Some text editors with special
support for LilyPond input fles document property names with bullets when you hover them
with the mouse, like JEdit with LilyPondTool, or highlight unknown property names diferently,
like ConTEXT. If you do not use an editor with such features, it is recommended to check the
property name in the Internals Reference: see Section “Tunable context properties” in Internals
Reference, or Section “Contexts” in Internals Reference.
The instrumentName property will take efect only if it is set in the Staff context, but some
properties can be set in more than one context. For example, the property extraNatural is
by default set to ##t (true) for all staves. If it is set to ##f (false) in one particular Staff
context it applies just to the accidentals on that staf. If it is set to false in the Score context
it applies to all staves.
So this turns of extra naturals in one staf:
<<
\new Staff \relative c'' {
ais4 aes
}
\new Staff \relative c'' {
\set Staff.extraNatural = ##f
ais4 aes
}
>>

and this turns them of in all staves:
Chapter 3: Fundamental concepts 64
<<
\new Staff \relative c'' {
ais4 aes
}
\new Staff \relative c'' {
\set Score.extraNatural = ##f
ais4 aes
}
>>

As another example, if clefOctavation is set in the Score context this immediately changes
the value of the octavation in all current staves and sets a new default value which will be applied
to all staves.
The opposite command, \unset, efectively removes the property from the context, which
causes most properties to revert to their default value. Usually \unset is not required as a new
\set command will achieve what is wanted.
The \set and \unset commands can appear anywhere in the input fle and will take efect
from the time they are encountered until the end of the score or until the property is \set or
\unset again. Let’s try changing the font size, which afects the size of the note heads (among
other things) several times. The change is from the default value, not the most recently set
value.
c4
% make note heads smaller
\set fontSize = #-4
d e
% make note heads larger
\set fontSize = #2.5
f g
% return to default size
\unset fontSize
a b

We have now seen how to set the values of several diferent types of property. Note that
integers and numbers are always preceded by a hash sign, #, while a true or false value is
specifed by ##t and ##f, with two hash signs. A text property should be enclosed in double
quotation signs, as above, although we shall see later that text can actually be specifed in a
much more general way by using the very powerful markup command.
Chapter 3: Fundamental concepts 65
Setting context properties with \with
Context properties may also be set at the time the context is created. Sometimes this is a clearer
way of specifying a property value if it is to remain fxed for the duration of the context. When
a context is created with a \new command it may be followed immediately by a \with { .. }
block in which the property values are set. For example, if we wish to suppress the printing of
extra naturals for the duration of a staf we would write:
\new Staff \with { extraNatural = ##f }
like this:
<<
\new Staff
\relative c'' {
gis ges aes ais
}
\new Staff \with { extraNatural = ##f }
\relative c'' {
gis ges aes ais
}
>>

Properties set in this way may still be changed dynamically using \set and returned to their
default value with \unset.
The fontSize property is treated diferently. If this is set in a \with clause it efectively
resets the default value of the font size. If it is later changed with \set, this new default value
may be restored with the \unset fontSize command.
Setting context properties with \context
The values of context properties may be set in all contexts of a particular type, such as all
Staff contexts, with a single command. The context type is identifed by using its type name,
like Staff, prefxed by a back-slash: \Staff. The statement which sets the property value is
the same as that in a \with block, introduced above. It is placed in a \context block within
a \layout block. Each \context block will afect all contexts of the type specifed throughout
the \score or \book block in which the \layout block appears. Here is a example to show the
format:
\score {
\new Staff {
\relative c'' {
cis4 e d ces
}
}
\layout {
\context {
\Staff
extraNatural = ##t
Chapter 3: Fundamental concepts 66
}
}
}

Context properties set in this way may be overridden for particular instances of contexts by
statements in a \with block, and by \set commands embedded in music statements.
See also
Notation Reference: Section “Changing context default settings” in Notation Reference.
Internals Reference: Section “Contexts” in Internals Reference, Section “Tunable context
properties” in Internals Reference.
3.3.5 Adding and removing engravers
We have seen that contexts each contain several engravers, each of which is responsible for
producing a particular part of the output, like bar lines, staves, note heads, stems, etc. If an
engraver is removed from a context, it can no longer produce its output. This is a crude way of
modifying the output, but it can sometimes be useful.
Changing a single context
To remove an engraver from a single context we use the \with command placed immediately
after the context creation command, as in the previous section.
As an illustration, let’s repeat an example from the previous section with the staf lines
removed. Remember that the staf lines are produced by the Staff_symbol_engraver.
\new Staff \with {
\remove Staff_symbol_engraver
}
\relative c' {
c4
\set fontSize = #-4 % make note heads smaller
d e
\set fontSize = #2.5 % make note heads larger
f g
\unset fontSize % return to default size
a b
}

Engravers can also be added to individual contexts. The command to do this is
\consists Engraver_name,
placed inside a \with block. Some vocal scores have an ambitus placed at the beginning of a
staf to indicate the range of notes in that staf – see Section “ambitus” in Music Glossary. The
ambitus is produced by the Ambitus_engraver, which is not normally included in any context.
If we add it to the Voice context, it calculates the range from that voice only:
Chapter 3: Fundamental concepts 67
\new Staff <<
\new Voice \with {
\consists Ambitus_engraver
}
\relative c'' {
\voiceOne
c a b g
}
\new Voice
\relative c' {
\voiceTwo
c e d f
}
>>

but if we add the ambitus engraver to the Staff context, it calculates the range from all the
notes in all the voices on that staf:
\new Staff \with {
\consists Ambitus_engraver
}
<<
\new Voice
\relative c'' {
\voiceOne
c a b g
}
\new Voice
\relative c' {
\voiceTwo
c e d f
}
>>

Changing all contexts of the same type
The examples above show how to remove or add engravers to individual contexts. It is also
possible to remove or add engravers to every context of a specifc type by placing the commands
in the appropriate context in a \layout block. For example, if we wanted to show an ambitus
for every staf in a four-staf score, we could write
\score {
<<
\new Staff <<
\relative c'' { c a b g }
Chapter 3: Fundamental concepts 68
>>
\new Staff <<
\relative c' { c a b g }
>>
\new Staff <<
\clef "G_8"
\relative c' { c a b g }
>>
\new Staff <<
\clef "bass"
\relative c { c a b g }
>>
>>
\layout {
\context {
\Staff
\consists Ambitus_engraver
}
}
}

8

The values of context properties may also be set for all contexts of a particular type by including
the \set command in a \context block in the same way.
See also
Notation Reference: Section “Modifying context plug-ins” in Notation Reference, Section
“Changing context default settings” in Notation Reference.
3.4 Extending the templates
You’ve read the tutorial, you know how to write music, you understand the fundamental con-
cepts. But how can you get the staves that you want? Well, you can fnd lots of templates (see
Appendix A [Templates], page 141) which may give you a start. But what if you want something
that isn’t covered there? Read on.
Chapter 3: Fundamental concepts 69
3.4.1 Soprano and cello
Start of with the template that seems closest to what you want to end up with. Let’s say that
you want to write something for soprano and cello. In this case, we would start with ‘Notes and
lyrics’ (for the soprano part).
\version "2.12.3"
melody = \relative c' {
\clef treble
\key c \major
\time 4/4
a4 b c d
}
text = \lyricmode {
Aaa Bee Cee Dee
}
\score {
<<
\new Voice = "one" {
\autoBeamOff
\melody
}
\new Lyrics \lyricsto "one" \text
>>
\layout { }
\midi { }
}
Now we want to add a cello part. Let’s look at the ‘Notes only’ example:
\version "2.12.3"
melody = \relative c' {
\clef treble
\key c \major
\time 4/4
a4 b c d
}
\score {
\new Staff \melody
\layout { }
\midi { }
}
We don’t need two \version commands. We’ll need the melody section. We don’t want two
\score sections – if we had two \scores, we’d get the two parts separately. We want them
together, as a duet. Within the \score section, we don’t need two \layout or \midi.
If we simply cut and paste the melody section, we would end up with two melody defnitions.
This would not generate an error, but the second one would be used for both melodies. So
let’s rename them to make them distinct. We’ll call the section for the soprano sopranoMusic
and the section for the cello celloMusic. While we’re doing this, let’s rename text to be
sopranoLyrics. Remember to rename both instances of all these names – both the initial
defnition (the melody = \relative c' { part) and the name’s use (in the \score section).
Chapter 3: Fundamental concepts 70
While we’re doing this, let’s change the cello part’s staf – celli normally use bass clef. We’ll
also give the cello some diferent notes.
\version "2.12.3"
sopranoMusic = \relative c' {
\clef treble
\key c \major
\time 4/4
a4 b c d
}
sopranoLyrics = \lyricmode {
Aaa Bee Cee Dee
}
celloMusic = \relative c {
\clef bass
\key c \major
\time 4/4
d4 g fis8 e d4
}
\score {
<<
\new Voice = "one" {
\autoBeamOff
\sopranoMusic
}
\new Lyrics \lyricsto "one" \sopranoLyrics
>>
\layout { }
\midi { }
}
This is looking promising, but the cello part won’t appear in the score – we haven’t used it
in the \score section. If we want the cello part to appear under the soprano part, we need to
add
\new Staff \celloMusic
underneath the soprano stuf. We also need to add << and >> around the music – that tells
LilyPond that there’s more than one thing (in this case, two Staves) happening at once. The
\score looks like this now:
\score {
<<
<<
\new Voice = "one" {
\autoBeamOff
\sopranoMusic
}
\new Lyrics \lyricsto "one" \sopranoLyrics
>>
\new Staff \celloMusic
>>
\layout { }
Chapter 3: Fundamental concepts 71
\midi { }
}
This looks a bit messy; the indentation is messed up now. That is easily fxed. Here’s the
complete soprano and cello template.
\version "2.12.3"
sopranoMusic = \relative c' {
\clef treble
\key c \major
\time 4/4
a4 b c d
}
sopranoLyrics = \lyricmode {
Aaa Bee Cee Dee
}
celloMusic = \relative c {
\clef bass
\key c \major
\time 4/4
d4 g fis8 e d4
}
\score {
<<
<<
\new Voice = "one" {
\autoBeamOff
\sopranoMusic
}
\new Lyrics \lyricsto "one" \sopranoLyrics
>>
\new Staff \celloMusic
>>
\layout { }
\midi { }
}

Dee

Bee

Aaa

Cee

See also
The starting templates can be found in the ‘Templates’ appendix, see Section A.1 [Single
staf], page 141.
Chapter 3: Fundamental concepts 72
3.4.2 Four-part SATB vocal score
Most vocal scores of music written for four-part mixed choir with orchestral accompaniment such
as Mendelssohn’s Elijah or Handel’s Messiah have the choral music and words on four staves,
one for each of SATB, with a piano reduction of the orchestral accompaniment underneath.
Here’s an example from Handel’s Messiah:
.
.
.
.
.
lamb
.
lamb
.
lamb
.
lamb
.
·
,
,
,
,
,
that
,
that
,
that
,
that
,
,
,
,
,
,
,
,
/
,
,
,
/
,
,
Soprano
,
,
,
,
,
was
,
was
,
was
,
was
,
.
.
.
.
.
slain
.
slain
.
slain
.
slain
.
,
,
,
,
the
,
.
.
.
.
.
,
,
,
,
,
thy
,
thy
,
thy
,
thy
,
·
,
,
,
,
,
,
,
Piano

.
.
Bass
Tenor
Alto
Wor
.
Wor
.
Wor
.
Wor
.
,
,

·
·
·

/
,
,
,
,
,
,
,
8
/
,
the
,
the
,
the

,
,
,
,
,
is
,
is
,
is
,
is
,

None of the templates provides this layout exactly. The nearest is ‘SATB vocal score and
automatic piano reduction’ – see Section A.4 [Vocal ensembles], page 152 – but we need to
change the layout and add a piano accompaniment which is not derived automatically from the
vocal parts. The variables holding the music and words for the vocal parts are fne, but we shall
need to add variables for the piano reduction.
The order in which the contexts appear in the ChoirStaf of the template do not correspond
with the order in the vocal score shown above. We need to rearrange them so there are four
staves with the words written directly underneath the notes for each part. All the voices should
be \voiceOne, which is the default, so the \voiceXXX commands should be removed. We also
need to specify the tenor clef for the tenors. The way in which lyrics are specifed in the template
has not yet been encountered so we need to use the method with which we are familiar. We
should also add the names of each staf.
Doing this gives for our ChoirStaf:
\new ChoirStaff <<
\new Staff = "sopranos" <<
\set Staff.instrumentName = #"Soprano"
\new Voice = "sopranos" { \global \sopranoMusic }
>>
\new Lyrics \lyricsto "sopranos" { \sopranoWords }
Chapter 3: Fundamental concepts 73
\new Staff = "altos" <<
\set Staff.instrumentName = #"Alto"
\new Voice = "altos" { \global \altoMusic }
>>
\new Lyrics \lyricsto "altos" { \altoWords }
\new Staff = "tenors" <<
\set Staff.instrumentName = #"Tenor"
\new Voice = "tenors" { \global \tenorMusic }
>>
\new Lyrics \lyricsto "tenors" { \tenorWords }
\new Staff = "basses" <<
\set Staff.instrumentName = #"Bass"
\new Voice = "basses" { \global \bassMusic }
>>
\new Lyrics \lyricsto "basses" { \bassWords }
>> % end ChoirStaff
Next we must work out the piano part. This is easy - we just pull out the piano part from
the ‘Solo piano’ template:
\new PianoStaff <<
\set PianoStaff.instrumentName = #"Piano "
\new Staff = "upper" \upper
\new Staff = "lower" \lower
>>
and add the variable defnitions for upper and lower.
The ChoirStaf and PianoStaf must be combined using angle brackets as we want them to
be stacked one above the other:
<< % combine ChoirStaff and PianoStaff one above the other
\new ChoirStaff <<
\new Staff = "sopranos" <<
\new Voice = "sopranos" { \global \sopranoMusic }
>>
\new Lyrics \lyricsto "sopranos" { \sopranoWords }
\new Staff = "altos" <<
\new Voice = "altos" { \global \altoMusic }
>>
\new Lyrics \lyricsto "altos" { \altoWords }
\new Staff = "tenors" <<
\clef "G_8" % tenor clef
\new Voice = "tenors" { \global \tenorMusic }
>>
\new Lyrics \lyricsto "tenors" { \tenorWords }
\new Staff = "basses" <<
\clef "bass"
\new Voice = "basses" { \global \bassMusic }
>>
\new Lyrics \lyricsto "basses" { \bassWords }
>> % end ChoirStaff
\new PianoStaff <<
\set PianoStaff.instrumentName = #"Piano"
\new Staff = "upper" \upper
Chapter 3: Fundamental concepts 74
\new Staff = "lower" \lower
>>
>>
Combining all these together and adding the music for the three bars of the example above
gives:
\version "2.12.3"
global = { \key d \major \time 4/4 }
sopranoMusic = \relative c'' {
\clef "treble"
r4 d2 a4 | d4. d8 a2 | cis4 d cis2 |
}
sopranoWords = \lyricmode {
Wor -- thy is the lamb that was slain
}
altoMusic = \relative a' {
\clef "treble"
r4 a2 a4 | fis4. fis8 a2 | g4 fis fis2 |
}
altoWords = \sopranoWords
tenorMusic = \relative c' {
\clef "G_8"
r4 fis2 e4 | d4. d8 d2 | e4 a, cis2 |
}
tenorWords = \sopranoWords
bassMusic = \relative c' {
\clef "bass"
r4 d2 cis4 | b4. b8 fis2 | e4 d a'2 |
}
bassWords = \sopranoWords
upper = \relative a' {
\clef "treble"
\global
r4 <a d fis>2 <a e' a>4 |
<d fis d'>4. <d fis d'>8 <a d a'>2 |
<g cis g'>4 <a d fis> <a cis e>2 |
}
lower = \relative c, {
\clef "bass"
\global
<d d'>4 <d d'>2 <cis cis'>4 |
<b b'>4. <b' b'>8 <fis fis'>2 |
<e e'>4 <d d'> <a' a'>2 |
}
\score {
<< % combine ChoirStaff and PianoStaff in parallel
\new ChoirStaff <<
\new Staff = "sopranos" <<
\set Staff.instrumentName = #"Soprano"
\new Voice = "sopranos" { \global \sopranoMusic }
>>
Chapter 3: Fundamental concepts 75
\new Lyrics \lyricsto "sopranos" { \sopranoWords }
\new Staff = "altos" <<
\set Staff.instrumentName = #"Alto"
\new Voice = "altos" { \global \altoMusic }
>>
\new Lyrics \lyricsto "altos" { \altoWords }
\new Staff = "tenors" <<
\set Staff.instrumentName = #"Tenor"
\new Voice = "tenors" { \global \tenorMusic }
>>
\new Lyrics \lyricsto "tenors" { \tenorWords }
\new Staff = "basses" <<
\set Staff.instrumentName = #"Bass"
\new Voice = "basses" { \global \bassMusic }
>>
\new Lyrics \lyricsto "basses" { \bassWords }
>> % end ChoirStaff
\new PianoStaff <<
\set PianoStaff.instrumentName = #"Piano "
\new Staff = "upper" \upper
\new Staff = "lower" \lower
>>
>>
}
.
.
.
.
.
lamb
.
lamb
.
lamb
.
lamb
.
·
,
,
,
,
,
that
,
that
,
that
,
that
,
,
,
,
,
,
,
,
/
,
,
,
/
,
,
Soprano
,
,
,
,
,
was
,
was
,
was
,
was
,
.
.
.
.
.
slain
.
slain
.
slain
.
slain
.
,
,
,
,
the
,
.
.
.
.
.
,
,
,
,
,
thy
,
thy
,
thy
,
thy
,
·
,
,
,
,
,
,
,
Piano

.
.
Bass
Tenor
Alto
Wor
.
Wor
.
Wor
.
Wor
.
,
,

·
·
·

/
,
,
,
,
,
,
,
8
/
,
the
,
the
,
the

,
,
,
,
,
is
,
is
,
is
,
is
,

Chapter 3: Fundamental concepts 76
3.4.3 Building a score from scratch
After gaining some facility with writing LilyPond code, you may fnd that it is easier to build a
score from scratch rather than modifying one of the templates. You can also develop your own
style this way to suit the sort of music you like. Let’s see how to put together the score for an
organ prelude as an example.
We begin with a header section. Here go the title, name of composer, etc, then come any
variable defnitions, and fnally the score block. Let’s start with these in outline and fll in the
details later.
We’ll use the frst two bars of Bach’s prelude based on Jesu, meine Freude which is written
for two manuals and pedal organ. You can see these two bars of music at the bottom of this
section. The top manual part has two voices, the lower and pedal organ one each. So we need
four music defnitions and one to defne the time signature and key:
\version "2.12.3"
\header {
title = "Jesu, meine Freude"
composer = "J S Bach"
}
TimeKey = { \time 4/4 \key c \minor }
ManualOneVoiceOneMusic = {s1}
ManualOneVoiceTwoMusic = {s1}
ManualTwoMusic = {s1}
PedalOrganMusic = {s1}
\score {
}
For now we’ve just used a spacer note, s1, instead of the real music. We’ll add that later.
Next let’s see what should go in the score block. We simply mirror the staf structure we
want. Organ music is usually written on three staves, one for each manual and one for the
pedals. The manual staves should be bracketed together, so we need to use a PianoStaf for
them. The frst manual part needs two voices and the second manual part just one.
\new PianoStaff <<
\new Staff = "ManualOne" <<
\new Voice { \ManualOneVoiceOneMusic }
\new Voice { \ManualOneVoiceTwoMusic }
>> % end ManualOne Staff context
\new Staff = "ManualTwo" <<
\new Voice { \ManualTwoMusic }
>> % end ManualTwo Staff context
>> % end PianoStaff context
Next we need to add a staf for the pedal organ. This goes underneath the PianoStaf, but
it must be simultaneous with it, so we need angle brackets around the two. Missing these out
would generate an error in the log fle. It’s a common mistake which you’ll make sooner or
later! Try copying the fnal example at the end of this section, remove these angle brackets, and
compile it to see what errors it generates.
<< % PianoStaff and Pedal Staff must be simultaneous
\new PianoStaff <<
\new Staff = "ManualOne" <<
\new Voice { \ManualOneVoiceOneMusic }
\new Voice { \ManualOneVoiceTwoMusic }
>> % end ManualOne Staff context
Chapter 3: Fundamental concepts 77
\new Staff = "ManualTwo" <<
\new Voice { \ManualTwoMusic }
>> % end ManualTwo Staff context
>> % end PianoStaff context
\new Staff = "PedalOrgan" <<
\new Voice { \PedalOrganMusic }
>>
>>
It is not necessary to use the simultaneous construct << .. >> for the manual two staf and
the pedal organ staf, since they contain only one music expression, but it does no harm, and
always using angle brackets after \new Staff is a good habit to cultivate in case there are
multiple voices. The opposite is true for Voices: these should habitually be followed by braces
{ .. } in case your music is coded in several variables which need to run consecutively.
Let’s add this structure to the score block, and adjust the indenting. We also add the
appropriate clefs, ensure stems, ties and slurs in each voice on the upper staf point to the right
direction with \voiceOne and \voiceTwo, and enter the time signature and key to each staf
using our predefned variable, \TimeKey.
\score {
<< % PianoStaff and Pedal Staff must be simultaneous
\new PianoStaff <<
\new Staff = "ManualOne" <<
\TimeKey % set time signature and key
\clef "treble"
\new Voice { \voiceOne \ManualOneVoiceOneMusic }
\new Voice { \voiceTwo \ManualOneVoiceTwoMusic }
>> % end ManualOne Staff context
\new Staff = "ManualTwo" <<
\TimeKey
\clef "bass"
\new Voice { \ManualTwoMusic }
>> % end ManualTwo Staff context
>> % end PianoStaff context
\new Staff = "PedalOrgan" <<
\TimeKey
\clef "bass"
\new Voice { \PedalOrganMusic }
>> % end PedalOrgan Staff
>>
} % end Score context
That completes the structure. Any three-staf organ music will have a similar structure,
although the number of voices may vary. All that remains now is to add the music, and combine
all the parts together.
\version "2.12.3"
\header {
title = "Jesu, meine Freude"
composer = "J S Bach"
}
TimeKey = { \time 4/4 \key c \minor }
ManualOneVoiceOneMusic = \relative g' {
g4 g f ees | d2 c2 |
Chapter 3: Fundamental concepts 78
}
ManualOneVoiceTwoMusic = \relative c' {
ees16 d ees8~ ees16 f ees d c8 d~ d c~ |
c c4 b8 c8. g16 c b c d |
}
ManualTwoMusic = \relative c' {
c16 b c8~ c16 b c g a8 g~ g16 g aes ees |
f ees f d g aes g f ees d e8~ ees16 f ees d |
}
PedalOrganMusic = \relative c {
r8 c16 d ees d ees8~ ees16 a, b g c b c8 |
r16 g ees f g f g8 c,2 |
}
\score {
<< % PianoStaff and Pedal Staff must be simultaneous
\new PianoStaff <<
\new Staff = "ManualOne" <<
\TimeKey % set time signature and key
\clef "treble"
\new Voice { \voiceOne \ManualOneVoiceOneMusic }
\new Voice { \voiceTwo \ManualOneVoiceTwoMusic }
>> % end ManualOne Staff context
\new Staff = "ManualTwo" <<
\TimeKey
\clef "bass"
\new Voice { \ManualTwoMusic }
>> % end ManualTwo Staff context
>> % end PianoStaff context
\new Staff = "PedalOrgan" <<
\TimeKey
\clef "bass"
\new Voice { \PedalOrganMusic }
>> % end PedalOrgan Staff context
>>
} % end Score context
Jesu, meine Freude
J S Bach

Chapter 3: Fundamental concepts 79
, ,
,
,
,
,
,
,
, ¸
,
,
,
,
,
,
,
2
/
,
,
,
,
,
,
,
,
,
,
,
,
,
,

.
,
,
,
·
·
¸
,
.,
,
.

,
,
,
,
,
,
,
Chapter 4: Tweaking output 80
4 Tweaking output
This chapter discusses how to modify output. LilyPond is extremely confgurable; virtually
every fragment of output may be changed.
4.1 Tweaking basics
4.1.1 Introduction to tweaks
‘Tweaking’ is a LilyPond term for the various methods available to the user for modifying the
actions taken during interpretation of the input fle and modifying the appearance of the printed
output. Some tweaks are very easy to use; others are more complex. But taken together the
methods available for tweaking permit almost any desired appearance of the printed music to
be achieved.
In this section we cover the basic concepts required to understand tweaking. Later we give a
variety of ready-made commands which can simply be copied to obtain the same efect in your
own scores, and at the same time we show how these commands may be constructed so that you
may learn how to develop your own tweaks.
Before starting on this Chapter you may wish to review the section Section 3.3 [Contexts
and engravers], page 58, as Contexts, Engravers, and the Properties contained within them are
fundamental to understanding and constructing Tweaks.
4.1.2 Objects and interfaces
Tweaking involves modifying the internal operation and structures of the LilyPond program, so
we must frst introduce some terms which are used to describe those internal operations and
structures.
The term ‘Object’ is a generic term used to refer to the multitude of internal structures built
by LilyPond during the processing of an input fle. So when a command like \new Staff is
encountered a new object of type Staff is constructed. That Staff object then holds all the
properties associated with that particular staf, for example, its name and its key signature,
together with details of the engravers which have been assigned to operate within that staf’s
context. Similarly, there are objects to hold the properties of all other contexts, such as Voice
objects, Score objects, Lyrics objects, as well as objects to represent all notational elements
such as bar lines, note heads, ties, dynamics, etc. Every object has its own set of property
values.
Some types of object are given special names. Objects which represent items of notation on
the printed output such as note heads, stems, slurs, ties, fngering, clefs, etc are called ‘Layout
objects’, often known as ‘Graphical Objects’, or ‘Grobs’ for short. These are still objects in
the generic sense above, and so they too all have properties associated with them, such as their
position, size, color, etc.
Some layout objects are still more specialized. Phrasing slurs, crescendo hairpins, ottava
marks, and many other grobs are not localized in a single place – they have a starting point, an
ending point, and maybe other properties concerned with their shape. Objects with an extended
shape like these are called ‘Spanners’.
It remains to explain what ‘Interfaces’ are. Many objects, even though they are quite dif-
ferent, share common features which need to be processed in the same way. For example, all
grobs have a color, a size, a position, etc, and all these properties are processed in the same way
during LilyPond’s interpretation of the input fle. To simplify these internal operations these
common actions and properties are grouped together in an object called a grob-interface.
There are many other groupings of common properties like this, each one given a name ending
Chapter 4: Tweaking output 81
in interface. In total there are over 100 such interfaces. We shall see later why this is of
interest and use to the user.
These, then, are the main terms relating to objects which we shall use in this chapter.
4.1.3 Naming conventions of objects and properties
We met some object naming conventions previously, in Section 3.3 [Contexts and engravers],
page 58. Here for reference is a list of the most common object and property types together
with the conventions for naming them and a couple of examples of some real names. We have
used ‘A’ to stand for any capitalized alphabetic character and ‘aaa’ to stand for any number of
lower-case alphabetic characters. Other characters are used verbatim.
Object/property type Naming convention Examples
Contexts Aaaa or AaaaAaaaAaaa Staf, GrandStaf
Layout Objects Aaaa or AaaaAaaaAaaa Slur, NoteHead
Engravers Aaaa aaa engraver Clef engraver,
Note heads engraver
Interfaces aaa-aaa-interface grob-interface, break-
aligned-interface
Context Properties aaa or aaaAaaaAaaa alignAboveContext,
skipBars
Layout Object Properties aaa or aaa-aaa-aaa direction, beam-thickness
As we shall see shortly, the properties of diferent types of object are modifed by diferent
commands, so it is useful to be able to recognize the type of object from the names of its
properties.
4.1.4 Tweaking methods
\override command
We have already met the commands \set and \with, used to change the properties of
contexts and to remove and add engravers, in Section 3.3.4 [Modifying context properties],
page 62, and Section 3.3.5 [Adding and removing engravers], page 66. We now must meet some
more important commands.
The command to change the properties of layout objects is \override. Because this com-
mand has to modify internal properties deep within LilyPond its syntax is not as simple as the
commands you have met so far. It needs to know precisely which property of which object in
which context has to be modifed, and what its new value is to be. Let’s see how this is done.
The general syntax of this command is:
\override Context.LayoutObject #'layout-property =
#value
This will set the property with the name layout-property of the layout object with the name
LayoutObject, which is a member of the Context context, to the value value.
The Context can be omitted (and usually is) when the required context is unambiguously
implied and is one of lowest level contexts, i.e., Voice, ChordNames or Lyrics, and we shall omit
it in many of the following examples. We shall see later when it must be specifed.
Later sections deal comprehensively with properties and their values, but to illustrate the
format and use of these commands we shall use just a few simple properties and values which
are easily understood.
For now, don’t worry about the #', which must precede the layout property, and the #, which
must precede the value. These must always be present in exactly this form. This is the most
common command used in tweaking, and most of the rest of this chapter will be directed to
Chapter 4: Tweaking output 82
presenting examples of how it is used. Here is a simple example to change the color of the note
head:
c d
\override NoteHead #'color = #red
e f g
\override NoteHead #'color = #green
a b c

\revert command
Once overridden, the property retains its new value until it is overridden again or a \revert
command is encountered. The \revert command has the following syntax and causes the value
of the property to revert to its original default value; note, not its previous value if several
\override commands have been issued.
\revert Context.LayoutObject #'layout-property
Again, just like Context in the \override command, Context is often not needed. It will
be omitted in many of the following examples. Here we revert the color of the note head to the
default value for the fnal two notes:
c d
\override NoteHead #'color = #red
e f g
\override NoteHead #'color = #green
a
\revert NoteHead #'color
b c

\once prefx
Both the \override and the \set commands may be prefxed by \once. This causes the
following \override or \set command to be efective only during the current musical moment
before the property reverts back to its default value. Using the same example, we can change
the color of a single note like this:
c d
\once \override NoteHead #'color = #red
e f g
\once \override NoteHead #'color = #green
a b c

\overrideProperty command
Chapter 4: Tweaking output 83
There is another form of the override command, \overrideProperty, which is occasionally
required. We mention it here for completeness, but for details see Section “Difcult tweaks” in
Notation Reference.
\tweak command
The fnal tweaking command which is available is \tweak. This should be used to change
the properties of objects which occur at the same musical moment, such as the notes within a
chord. Using \override would afect all the notes within a chord, whereas \tweak afects just
the following item in the input stream.
Here’s an example. Suppose we wish to change the size of the middle note head (the E) in a
C major chord. Let’s frst see what \once \override would do:
<c e g>4
\once \override NoteHead #'font-size = #-3
<c e g>
<c e g>

We see the override afects all the note heads in the chord. This is because all the notes of a
chord occur at the same musical moment, and the action of \once is to apply the override to all
layout objects of the type specifed which occur at the same musical moment as the \override
command itself.
The \tweak command operates in a diferent way. It acts on the immediately following item
in the input stream. However, it is efective only on objects which are created directly from the
input stream, essentially note heads and articulations; objects such as stems and accidentals are
created later and cannot be tweaked in this way. Furthermore, when it is applied to note heads
these must be within a chord, i.e., within single angle brackets, so to tweak a single note the
\tweak command must be placed inside single angle brackets with the note.
So to return to our example, the size of the middle note of a chord would be changed in this
way:
<c e g>4
<c \tweak #'font-size #-3 e g>4

Note that the syntax of \tweak is diferent from that of the \override command. Neither
the context nor the layout object should be specifed; in fact, it would generate an error to do
so. These are both implied by the following item in the input stream. Note also that an equals
sign should not be present. So the general syntax of the \tweak command is simply
\tweak #'layout-property #value
A \tweak command can also be used to modify just one in a series of articulations, as shown
here:
a ^Black
-\tweak #'color #red ^Red
-\tweak #'color #green _Green
Chapter 4: Tweaking output 84

Red
Green
Black

Note that the \tweak command must be preceded by an articulation mark as if it were an
articulation itself.
The \tweak command must also be used to change the appearance of one of a set of nested
tuplets which begin at the same musical moment. In the following example, the long tuplet
bracket and the frst of the three short brackets begin at the same musical moment, so any
\override command would apply to both of them. In the example, \tweak is used to distinguish
between them. The frst \tweak command specifes that the long tuplet bracket is to be placed
above the notes and the second one specifes that the tuplet number is to be printed in red on
the frst short tuplet bracket.
\tweak #'direction #up
\times 4/3 {
\tweak #'color #red
\times 2/3 { c8[ c8 c8] }
\times 2/3 { c8[ c8 c8] }
\times 2/3 { c8[ c8 c8] }
}

3

3

3

3
If nested tuplets do not begin at the same moment, their appearance may be modifed in the
usual way with \override commands:
\times 2/3 { c8[ c c]}
\once \override TupletNumber
#'text = #tuplet-number::calc-fraction-text
\times 2/3 {
c[ c]
c[ c]
\once \override TupletNumber #'transparent = ##t
\times 2/3 { c8[ c c] }
\times 2/3 { c8[ c c]}
}
3

3:2

3

See also
Notation Reference: Section “The tweak command” in Notation Reference.
4.2 The Internals Reference manual
4.2.1 Properties of layout objects
Suppose you have a slur in a score which, to your mind, appears too thin and you’d like to draw
it a little heavier. How do you go about doing this? You know from the statements earlier about
the fexibility of LilyPond that such a thing should be possible, and you would probably guess
Chapter 4: Tweaking output 85
that an \override command would be needed. But is there a heaviness property for a slur,
and if there is, how might it be modifed? This is where the Internals Reference manual comes
in. It contains all the information you might need to construct this and all other \override
commands.
Before we look at the Internals Reference a word of warning. This is a reference document,
which means there is little or no explanation contained within it: its purpose is to present
information precisely and concisely. This means it might look daunting at frst sight. Don’t
worry! The guidance and explanation presented here will enable you to extract the information
from the Internals Reference for yourself with just a little practice.
Let’s use a concrete example with a simple fragment of real music:
{
\time 6/8
{
r4 b8 b[( g]) g |
g[( e]) e d[( f]) a |
a g
}
\addlyrics {
The man who feels love's sweet e -- mo -- tion
}
}
who mo

love's

sweet

8
6

e man

tion

feels

The

Suppose now that we decide we would like the slurs to be a little heavier. Is this possible?
The slur is certainly a layout object, so the question is, ‘Is there a property belonging to a slur
which controls the heaviness?’ To answer this we must look in the Internals Reference, or IR
for short.
The IR for the version of LilyPond you are using may be found on the LilyPond website
at http://lilypond.org. Go to the documentation page and click on the Internals Reference
link. For learning purposes you should use the standard HTML version, not the ‘one big page’
or the PDF. For the next few paragraphs to make sense you will need to actually do this as you
read.
Under the heading Top you will see fve links. Select the link to the Backend, which is where
information about layout objects is to be found. There, under the heading Backend, select the
link to All layout objects. The page that appears lists all the layout objects used in your version
of LilyPond, in alphabetic order. Select the link to Slur, and the properties of Slurs are listed.
An alternative way of fnding this page is from the Notation Reference. On one of the pages
that deals with slurs you may fnd a link to the Internals Reference. This link will take you
directly to this page, but if you have an idea about the name of the layout object to be tweaked,
it is easier to go straight to the IR and search there.
This Slur page in the IR tells us frst that Slur objects are created by the Slur engraver.
Then it lists the standard settings. Note these are not in alphabetic order. Browse down them
looking for a property that might control the heaviness of slurs, and you should fnd
thickness (number)
1.2
Line thickness, generally measured in line-thickness
Chapter 4: Tweaking output 86
This looks a good bet to change the heaviness. It tells us that the value of thickness is a
simple number, that the default value is 1.2, and that the units are in another property called
line-thickness.
As we said earlier, there are few to no explanations in the IR, but we already have enough
information to try changing the slur thickness. We see that the name of the layout object is
Slur, that the name of the property to change is thickness and that the new value should be
a number somewhat larger than 1.2 if we are to make slurs thicker.
We can now construct the \override command by simply substituting the values we have
found for the names, omitting the context. Let’s use a very large value for the thickness at frst,
so we can be sure the command is working. We get:
\override Slur #'thickness = #5.0
Don’t forget the #' preceding the property name and a # preceding the new value!
The fnal question is, ‘Where should this command be placed?’ While you are unsure and
learning, the best answer is, ‘Within the music, before the frst slur and close to it.’ Let’s do
that:
{
\time 6/8
{
% Increase thickness of all following slurs from 1.2 to 5.0
\override Slur #'thickness = #5.0
r4 b8 b[( g]) g |
g[( e]) e d[( f]) a |
a g
}
\addlyrics {
The man who feels love's sweet e -- mo -- tion
}
}

The

love's

e feels

sweet

tion

who mo

8
6
man
and we see that the slur is indeed heavier.
So this is the basic way of constructing \override commands. There are a few more com-
plications that we shall meet in later sections, but you now know all the essentials required to
make up your own – but you will still need some practice. This is provided in the examples
which follow.
Finding the context
But frst, what if we had needed to specify the Context? What should it be? We could guess
that slurs are in the Voice context, as they are clearly closely associated with individual lines of
music, but can we be sure? To fnd out, go back to the top of the IR page describing the Slur,
where it says ‘Slur objects are created by: Slur engraver’. So slurs will be created in whichever
context the Slur_engraver is in. Follow the link to the Slur_engraver page. At the very
bottom it tells us that Slur_engraver is part of fve Voice contexts, including the standard
voice context, Voice, so our guess was correct. And because Voice is one of the lowest level
contexts which is implied unambiguously by the fact that we are entering notes, we can omit it
in this location.
Chapter 4: Tweaking output 87
Overriding once only
As you can see, all the slurs are thicker in the fnal example above. But what if we wanted just the
frst slur to be thicker? This is achieved with the \once command. Placed immediately before
the \override command it causes it to change only the slur which begins on the immediately
following note. If the immediately following note does not begin a slur the command has no
efect at all – it is not remembered until a slur is encountered, it is simply discarded. So the
command with \once must be repositioned as follows:
{
\time 6/8
{
r4 b8
% Increase thickness of immediately following slur only
\once \override Slur #'thickness = #5.0
b[( g]) g |
g[( e]) e d[( f]) a |
a g
}
\addlyrics {
The man who feels love's sweet e -- mo -- tion
}
}

who

mo love's

8
6

man

sweet tion e

The feels

Now only the frst slur is made heavier.
The \once command can also be used before the \set command.
Reverting
Finally, what if we wanted just the frst two slurs to be heavier? Well, we could use two
commands, each preceded by \once placed immediately before each of the notes where the slurs
begin:
{
\time 6/8
{
r4 b8
% Increase thickness of immediately following slur only
\once \override Slur #'thickness = #5.0
b[( g]) g |
% Increase thickness of immediately following slur only
\once \override Slur #'thickness = #5.0
g[( e]) e d[( f]) a |
a g
}
\addlyrics {
The man who feels love's sweet e -- mo -- tion
}
}
Chapter 4: Tweaking output 88

e

The love's

man

feels

8
6

mo who

tion

sweet

or we could omit the \once command and use the \revert command to return the thickness
property to its default value after the second slur:
{
\time 6/8
{
r4 b8
% Increase thickness of all following slurs from 1.2 to 5.0
\override Slur #'thickness = #5.0
b[( g]) g |
g[( e])
% Revert thickness of all following slurs to default of 1.2
\revert Slur #'thickness
e d[( f]) a |
a g
}
\addlyrics {
The man who feels love's sweet e -- mo -- tion
}
}
sweet

8
6
e

man

The feels

love's

mo

tion

who
The \revert command can be used to return any property changed with \override back to
its default value. You may use whichever method best suits what you want to do.
That concludes our introduction to the IR, and the basic method of tweaking. Several
examples follow in the later sections of this Chapter, partly to introduce you to some of the
additional features of the IR, and partly to give you more practice in extracting information
from it. These examples will contain progressively fewer words of guidance and explanation.
4.2.2 Properties found in interfaces
Suppose now that we wish to print the lyrics in italics. What form of \override command do
we need to do this? We frst look in the IR page listing ‘All layout objects’, as before, and look
for an object that might control lyrics. We fnd LyricText, which looks right. Clicking on this
shows the settable properties for lyric text. These include the font-series and font-size,
but nothing that might give an italic shape. This is because the shape property is one that is
common to all font objects, so, rather than including it in every layout object, it is grouped
together with other similar common properties and placed in an Interface, the font-interface.
So now we need to learn how to fnd the properties of interfaces, and to discover what objects
use these interface properties.
Look again at the IR page which describes LyricText. At the bottom of the page is a list
of clickable interfaces which LyricText supports. The list has several items, including font-
interface. Clicking on this brings up the properties associated with this interface, which are
also properties of all the objects which support it, including LyricText.
Now we see all the user-settable properties which control fonts, including font-
shape(symbol), where symbol can be set to upright, italics or caps.
Chapter 4: Tweaking output 89
You will notice that font-series and font-size are also listed there. This immediately
raises the question: Why are the common font properties font-series and font-size listed
under LyricText as well as under the interface font-interface but font-shape is not? The
answer is that font-series and font-size are changed from their global default values when
a LyricText object is created, but font-shape is not. The entries in LyricText then tell you
the values for those two properties which apply to LyricText. Other objects which support
font-interface will set these properties diferently when they are created.
Let’s see if we can now construct the \override command to change the lyrics to italics.
The object is LyricText, the property is font-shape and the value is italic. As before, we’ll
omit the context.
As an aside, although it is an important one, note that because the values of font-shape
are symbols they must be introduced with a single apostrophe, '. That is why apostrophes are
needed before thickness in the earlier example and font-shape. These are both symbols too.
Symbols are then read internally by LilyPond. Some of them are the names of properties, like
thickness or font-shape, others are used as values that can be given to properties, like italic.
Note the distinction from arbitrary text strings, which would appear as "a text string"; for
more details about symbols and strings, see Appendix B [Scheme tutorial], page 173.
Ok, so the \override command we need to print the lyrics in italics should be
\override LyricText #'font-shape = #'italic
and this should be placed just in front of and close to the lyrics which it should afect, like this:
{
\time 6/8
{
r4 b8 b[( g]) g |
g[( e]) e d[( f]) a |
a g
}
\addlyrics {
\override LyricText #'font-shape = #'italic
The man who feels love's sweet e -- mo -- tion
}
}

mo

tion

feels
8
6

e The sweet

who love's

man

and the lyrics are all printed in italics.
Specifying the context in lyric mode
In the case of lyrics, if you try specifying the context in the format given earlier the command
will fail. A syllable entered in lyricmode is terminated by either a space, a newline or a digit.
All other characters are included as part of the syllable. For this reason a space or newline
must appear before the terminating } to prevent it being included as part of the fnal syllable.
Similarly, spaces must be inserted before and after the period or dot, ‘.’, separating the context
name from the object name, as otherwise the two names are run together and the interpreter
cannot recognize them. So the command should be:
\override Lyrics . LyricText #'font-shape = #'italic
Chapter 4: Tweaking output 90
¨
Note: In lyrics always leave whitespace between the fnal syllable and
the terminating brace.
©
¨
Note: In overrides in lyrics always place spaces around the dot between
the context name and the object name.
©
See also
Learning Manual: Appendix B [Scheme tutorial], page 173.
4.2.3 Types of properties
So far we have seen two types of property: number and symbol. To be valid, the value given to
a property must be of the correct type and obey the rules for that type. The type of property
is always shown in brackets after the property name in the IR. Here is a list of the types you
may need, together with the rules for that type, and some examples. You must always add a
hash symbol, #, of course, to the front of these values when they are entered in the \override
command.
Property type Rules Examples
Boolean Either True or False, represented by #t
or #f
#t, #f
Dimension (in staf
space)
A positive decimal number (in units of
staf space)
2.5, 0.34
Direction A valid direction constant or its numer-
ical equivalent (decimal values between
-1 and 1 are allowed)
LEFT, CENTER, UP, 1, -1
Integer A positive whole number 3, 1
List A set of values separated by spaces, en-
closed in parentheses and preceded by an
apostrophe
'(left-edge staff-bar),
'(1), '(1.0 0.25 0.5)
Markup Any valid markup \markup { \italic "cresc."
}
Moment A fraction of a whole note constructed
with the make-moment function
(ly:make-moment 1 4),
(ly:make-moment 3 8)
Number Any positive or negative decimal value 3.5, -2.45
Pair (of numbers) Two numbers separated by a ‘space .
space’ and enclosed in brackets preceded
by an apostrophe
'(2 . 3.5), '(0.1 . -3.2)
Symbol Any of the set of permitted sym-
bols for that property, preceded by an
apostrophe
'italic, 'inside
Unknown A procedure, or #f to cause no action bend::print, ly:text-
interface::print,
#f
Vector A list of three items enclosed in paren-
theses and preceded by apostrophe-hash,
'#.
'#(#t #t #f)
See also
Learning Manual: Appendix B [Scheme tutorial], page 173.
Chapter 4: Tweaking output 91
4.3 Appearance of objects
Let us now put what we have learned into practice with a few examples which show how tweaks
may be used to change the appearance of the printed music.
4.3.1 Visibility and color of objects
In the educational use of music we might wish to print a score with certain elements omitted as
an exercise for the student, who is required to supply them. As a simple example, let us suppose
the exercise is to supply the missing bar lines in a piece of music. But the bar lines are normally
inserted automatically. How do we prevent them printing?
Before we tackle this, let us remember that object properties are grouped in what are called
interfaces – see Section 4.2.2 [Properties found in interfaces], page 88. This is simply to group
together those properties that may be used together to tweak a graphical object – if one of
them is allowed for an object, so are the others. Some objects then use the properties in some
interfaces, others use them from other interfaces. The interfaces which contain the properties
used by a particular grob are listed in the IR at the bottom of the page describing that grob,
and those properties may be viewed by looking at those interfaces.
We explained how to fnd information about grobs in Section 4.2.1 [Properties of layout
objects], page 84. Using the same approach, we go to the IR to fnd the layout object which
prints bar lines. Going via Backend and All layout objects we fnd there is a layout object called
BarLine. Its properties include two that control its visibility: break-visibility and stencil.
Barline also supports a number of interfaces, including the grob-interface, where we fnd the
transparent and the color properties. All of these can afect the visibility of bar lines (and,
of course, by extension, many other layout objects too.) Let’s consider each of these in turn.
stencil
This property controls the appearance of the bar lines by specifying the symbol (glyph) which
should be printed. In common with many other properties, it can be set to print nothing by
setting its value to #f. Let’s try it, as before, omitting the implied Context, Voice:
{
\time 12/16
\override BarLine #'stencil = ##f
c4 b8 c d16 c d8 |
g, a16 b8 c d4 e16 |
e8
}

16
12
The bar lines are still printed. What is wrong? Go back to the IR and look again at the page
giving the properties of BarLine. At the top of the page it says “Barline objects are created
by: Bar engraver”. Go to the Bar_engraver page. At the bottom it gives a list of Contexts in
which the bar engraver operates. All of them are of the type Staff, so the reason the \override
command failed to work as expected is because Barline is not in the default Voice context.
If the context is specifed wrongly, the command simply does not work. No error message is
produced, and nothing is logged in the log fle. Let’s try correcting it by adding the correct
context:
{
\time 12/16
Chapter 4: Tweaking output 92
\override Staff.BarLine #'stencil = ##f
c4 b8 c d16 c d8 |
g, a16 b8 c d4 e16 |
e8
}

16
12


Now the bar lines have vanished.
break-visibility
We see from the BarLine properties in the IR that the break-visibility property requires a
vector of three booleans. These control respectively whether bar lines are printed at the end of
a line, in the middle of lines, and at the beginning of lines. For our example we want all bar
lines to be suppressed, so the value we need is '#(#f #f #f). Let’s try that, remembering to
include the Staff context. Note also that in writing this value we have #'# before the opening
bracket. The '# is required as part of the value to introduce a vector, and the frst # is required,
as always, to precede the value itself in the \override command.
{
\time 12/16
\override Staff.BarLine #'break-visibility = #'#(#f #f #f)
c4 b8 c d16 c d8 |
g, a16 b8 c d4 e16 |
e8
}

16
12

And we see this too removes all the bar lines.
transparent
We see from the properties specifed in the grob-interface page in the IR that the transparent
property is a boolean. This should be set to #t to make the grob transparent. In this next
example let us make the time signature invisible rather than the bar lines. To do this we need
to fnd the grob name for the time signature. Back to the ‘All layout objects’ page in the
IR to fnd the properties of the TimeSignature layout object. This is produced by the Time_
signature_engraver which you can check also lives in the Staff context and also supports the
grob-interface. So the command to make the time signature transparent is:
{
\time 12/16
\override Staff.TimeSignature #'transparent = ##t
c4 b8 c d16 c d8 |
g, a16 b8 c d4 e16 |
e8
}
Chapter 4: Tweaking output 93

The time signature is gone, but this command leaves a gap where the time signature should
be. Maybe this is what is wanted for an exercise for the student to fll it in, but in other
circumstances a gap might be undesirable. To remove it, the stencil for the time signature
should be set to #f instead:
{
\time 12/16
\override Staff.TimeSignature #'stencil = ##f
c4 b8 c d16 c d8 |
g, a16 b8 c d4 e16 |
e8
}

and the diference is obvious: setting the stencil to #f removes the object entirely; making the
object transparent leaves it where it is, but makes it invisible.
color
Finally let us try making the bar lines invisible by coloring them white. (There is a difculty
with this in that the white bar line may or may not blank out the staf lines where they cross.
You may see in some of the examples below that this happens unpredictably. The details of
why this is so and how to control it are covered in Section “Painting objects white” in Notation
Reference. But at the moment we are learning about color, so please just accept this limitation
for now.)
The grob-interface specifes that the color property value is a list, but there is no explana-
tion of what that list should be. The list it requires is actually a list of values in internal units,
but, to avoid having to know what these are, several ways are provided to specify colors. The
frst way is to use one of the ‘normal’ colors listed in the frst table in Section “List of colors”
in Notation Reference. To set the bar lines to white we write:
{
\time 12/16
\override Staff.BarLine #'color = #white
c4 b8 c d16 c d8 |
g, a16 b8 c d4 e16 |
e8
}

16
12

and again, we see the bar lines are not visible. Note that white is not preceded by an apostrophe
– it is not a symbol, but a function. When called, it provides the list of internal values required
to set the color to white. The other colors in the normal list are functions too. To convince
yourself this is working you might like to change the color to one of the other functions in the
list.
Chapter 4: Tweaking output 94
The second way of changing the color is to use the list of X11 color names in the second list
in Section “List of colors” in Notation Reference. However, these must be preceded by another
function, which converts X11 color names into the list of internal values, x11-color, like this:
{
\time 12/16
\override Staff.BarLine #'color = #(x11-color 'white)
c4 b8 c d16 c d8 |
g, a16 b8 c d4 e16 |
e8
}

16
12

Note that in this case the function x11-color takes a symbol as an argument, so the symbol
must be preceded by an apostrophe and the two enclosed in brackets.
There is yet a third function, one which converts RGB values into internal colors – the rgb-
color function. This takes three arguments giving the intensities of the red, green and blue
colors. These take values in the range 0 to 1. So to set the color to red the value should be
(rgb-color 1 0 0) and to white it should be (rgb-color 1 1 1):
{
\time 12/16
\override Staff.BarLine #'color = #(rgb-color 1 1 1)
c4 b8 c d16 c d8 |
g, a16 b8 c d4 e16 |
e8
}

16
12

Finally, there is also a grey scale available as part of the X11 set of colors. These range from
black, 'grey0', to white, 'grey100, in steps of 1. Let’s illustrate this by setting all the layout
objects in our example to various shades of grey:
{
\time 12/16
\override Staff.StaffSymbol #'color = #(x11-color 'grey30)
\override Staff.TimeSignature #'color = #(x11-color 'grey60)
\override Staff.Clef #'color = #(x11-color 'grey60)
\override Voice.NoteHead #'color = #(x11-color 'grey85)
\override Voice.Stem #'color = #(x11-color 'grey85)
\override Staff.BarLine #'color = #(x11-color 'grey10)
c4 b8 c d16 c d8 |
g, a16 b8 c d4 e16 |
e8
}

16
12


Chapter 4: Tweaking output 95
Note the contexts associated with each of the layout objects. It is important to get these right,
or the commands will not work! Remember, the context is the one in which the appropriate
engraver is placed. The default context for engravers can be found by starting from the layout
object, going from there to the engraver which produces it, and on the engraver page in the IR
it tells you in which context the engraver will normally be found.
4.3.2 Size of objects
Let us begin by looking again at the earlier example see Section 3.1.3 [Nesting music expressions],
page 41) which showed how to introduce a new temporary staf, as in an Section “ossia” in Music
Glossary.
\new Staff ="main" {
\relative g' {
r4 g8 g c4 c8 d |
e4 r8
<<
{ f c c }
\new Staff \with {
alignAboveContext = #"main" }
{ f8 f c }
>>
r4 |
}
}

Ossia are normally written without clef and time signature, and are usually printed slightly
smaller than the main staf. We already know now how to remove the clef and time signature –
we simply set the stencil of each to #f, as follows:
\new Staff ="main" {
\relative g' {
r4 g8 g c4 c8 d |
e4 r8
<<
{ f c c }
\new Staff \with {
alignAboveContext = #"main"
}
{
\override Staff.Clef #'stencil = ##f
\override Staff.TimeSignature #'stencil = ##f
{ f8 f c }
}
>>
r4 |
}
Chapter 4: Tweaking output 96
}

where the extra pair of braces after the \with clause are required to ensure the enclosed overrides
and music are applied to the ossia staf.
But what is the diference between modifying the staf context by using \with and modifying
the stencils of the clef and the time signature with \override? The main diference is that changes
made in a \with clause are made at the time the context is created, and remain in force as the
default values for the duration of that context, whereas \set or \override commands embedded
in the music are dynamic – they make changes synchronized with a particular point in the music.
If changes are unset or reverted using \unset or \revert they return to their default values,
which will be the ones set in the \with clause, or if none have been set there, the normal default
values.
Some context properties can be modifed only in \with clauses. These are those properties
which cannot sensibly be changed after the context has been created. alignAboveContext and
its partner, alignBelowContext, are two such properties – once the staf has been created its
alignment is decided and it would make no sense to try to change it later.
The default values of layout object properties can also be set in \with clauses. Simply use
the normal \override command leaving out the context name, since this is unambiguously
defned as the context which the \with clause is modifying. If fact, an error will be generated
if a context is specifed in this location.
So we could replace the example above with
\new Staff ="main" {
\relative g' {
r4 g8 g c4 c8 d |
e4 r8
<<
{ f c c }
\new Staff \with {
alignAboveContext = #"main"
% Don't print clefs in this staff
\override Clef #'stencil = ##f
% Don't print time signatures in this staff
\override TimeSignature #'stencil = ##f
}
{ f8 f c }
>>
r4 |
}
}
Chapter 4: Tweaking output 97

Finally we come to changing the size of layout objects.
Some layout objects are created as glyphs selected from a typeface font. These include note
heads, accidentals, markup, clefs, time signatures, dynamics and lyrics. Their size is changed
by modifying the font-size property, as we shall shortly see. Other layout objects such as
slurs and ties – in general, spanner objects – are drawn individually, so there is no font-size
associated with them. These objects generally derive their size from the objects to which they
are attached, so usually there is no need to change their size manually. Still other properties
such as the length of stems and bar lines, thickness of beams and other lines, and the separation
of staf lines all need to be modifed in special ways.
Returning to the ossia example, let us frst change the font-size. We can do this in two ways.
We can either change the size of the fonts of each object type, like NoteHeads with commands
like
\override NoteHead #'font-size = #-2
or we can change the size of all fonts by setting a special property, fontSize, using \set, or
by including it in a \with clause (but without the \set).
\set fontSize = #-2
Both of these statements would cause the font size to be reduced by 2 steps from its previous
value, where each step reduces or increases the size by approximately 12%.
Let’s try it in our ossia example:
\new Staff ="main" {
\relative g' {
r4 g8 g c4 c8 d |
e4 r8
<<
{ f c c }
\new Staff \with {
alignAboveContext = #"main"
\override Clef #'stencil = ##f
\override TimeSignature #'stencil = ##f
% Reduce all font sizes by ~24%
fontSize = #-2
}
{ f8 f c }
>>
r4 |
}
}

Chapter 4: Tweaking output 98
This is still not quite right. The note heads and fags are smaller, but the stems are too long
in proportion and the staf lines are spaced too widely apart. These need to be scaled down in
proportion to the font reduction. The next sub-section discusses how this is done.
4.3.3 Length and thickness of objects
Distances and lengths in LilyPond are generally measured in staf-spaces, the distance between
adjacent lines in the staf, (or occasionally half staf spaces) while most thickness properties
are measured in units of an internal property called line-thickness. For example, by default,
the lines of hairpins are given a thickness of 1 unit of line-thickness, while the thickness of
a note stem is 1.3. Note, though, that some thickness properties are diferent; for example, the
thickness of beams is measured in staf-spaces.
So how are lengths to be scaled in proportion to the font size? This can be done with the help
of a special function called magstep provided for exactly this purpose. It takes one argument,
the change in font size (#-2 in the example above) and returns a scaling factor suitable for
reducing other objects in proportion. It is used like this:
\new Staff ="main" {
\relative g' {
r4 g8 g c4 c8 d |
e4 r8
<<
{ f c c }
\new Staff \with {
alignAboveContext = #"main"
\override Clef #'stencil = ##f
\override TimeSignature #'stencil = ##f
fontSize = #-2
% Reduce stem length and line spacing to match
\override StaffSymbol #'staff-space = #(magstep -2)
}
{ f8 f c }
>>
r4 |
}
}

Since the length of stems and many other length-related properties are always calculated relative
to the value of the staff-space property these are automatically scaled down in length too.
Note that this afects only the vertical scale of the ossia – the horizontal scale is determined by
the layout of the main music in order to remain synchronized with it, so it is not afected by
any of these changes in size. Of course, if the scale of all the main music were changed in this
way then the horizontal spacing would be afected. This is discussed later in the layout section.
This, then, completes the creation of an ossia. The sizes and lengths of all other objects may
be modifed in analogous ways.
For small changes in scale, as in the example above, the thickness of the various drawn lines
such as bar lines, beams, hairpins, slurs, etc does not usually require global adjustment. If
Chapter 4: Tweaking output 99
the thickness of any particular layout object needs to be adjusted this can be best achieved by
overriding its thickness property. An example of changing the thickness of slurs was shown
above in Section 4.2.1 [Properties of layout objects], page 84. The thickness of all drawn objects
(i.e., those not produced from a font) may be changed in the same way.
4.4 Placement of objects
4.4.1 Automatic behavior
There are some objects in musical notation that belong to the staf and there are other objects
that should be placed outside the staf. These are called within-staf objects and outside-staf
objects respectively.
Within-staf objects are those that are located on the staf – note heads, stems, accidentals,
etc. The positions of these are usually fxed by the music itself – they are vertically positioned
on specifc lines of the staf or are tied to other objects that are so positioned. Collisions of note
heads, stems and accidentals in closely set chords are normally avoided automatically. There
are commands and overrides which can modify this automatic behavior, as we shall shortly see.
Objects belonging outside the staf include things such as rehearsal marks, text and dynamic
markings. LilyPond’s rule for the vertical placement of outside-staf objects is to place them as
close to the staf as possible but not so close that they collide with any other object. LilyPond
uses the outside-staff-priority property to determine the order in which the objects should
be placed, as follows.
First, LilyPond places all the within-staf objects. Then it sorts the outside-staf objects
according to their outside-staff-priority. The outside-staf objects are taken one by one,
beginning with the object with the lowest outside-staff-priority, and placed so that they
do not collide with any objects that have already been placed. That is, if two outside-staf
grobs are competing for the same space, the one with the lower outside-staff-priority will
be placed closer to the staf. If two objects have the same outside-staff-priority the one
encountered frst will be placed closer to the staf.
In the following example all the markup texts have the same priority (since it is not explicitly
set). Note that ‘Text3’ is automatically positioned close to the staf again, nestling under ‘Text2’.
c2^"Text1"
c^"Text2"
c^"Text3"
c^"Text4"

Text3

Text4 Text2

Text1

Staves are also positioned, by default, as closely together as possible (subject to a minimum
separation). If notes project a long way towards an adjacent staf they will force the staves
further apart only if an overlap of the notation would otherwise occur. The following example
demonstrates this ‘nestling’ of the notes on adjacent staves:
<<
\new Staff {
\relative c' { c a, }
}
\new Staff {
\relative c'''' { c a, }
Chapter 4: Tweaking output 100
}
>>

4.4.2 Within-staf objects
We have already seen how the commands \voiceXXX afect the direction of slurs, ties, fngering
and everything else which depends on the direction of the stems. These commands are essential
when writing polyphonic music to permit interweaving melodic lines to be distinguished. But
occasionally it may be necessary to override this automatic behavior. This can be done for whole
sections of music or even for an individual note. The property which controls this behavior is the
direction property of each layout object. We frst explain what this does, and then introduce
a number of ready-made commands which avoid your having to code explicit overrides for the
more common modifcations.
Some layout objects like slurs and ties curve, bend or point either up or down; others like
stems and fags also move to right or left when they point up or down. This is controlled
automatically when direction is set.
The following example shows in bar 1 the default behavior of stems, with those on high notes
pointing down and those on low notes pointing up, followed by four notes with all stems forced
down, four notes with all stems forced up, and fnally four notes reverted back to the default
behavior.
a4 g c a
\override Stem #'direction = #DOWN
a g c a
\override Stem #'direction = #UP
a g c a
\revert Stem #'direction
a g c a

Here we use the constants DOWN and UP. These have the values -1 and +1 respectively, and
these numerical values may be used instead. The value 0 may also be used in some cases. It
is simply treated as meaning UP for stems, but for some objects it means ‘center’. There is a
constant, CENTER which has the value 0.
However, these explicit overrides are not usually used, as there are simpler equivalent pre-
defned commands available. Here is a table of the commonest. The meaning of each is stated
where it is not obvious.
Down/Left Up/Right Revert Efect
\arpeggioArrowDown\arpeggioArrowUp\arpeggioNormal Arrow is at bottom, at top, or
no arrow
Chapter 4: Tweaking output 101
\dotsDown \dotsUp \dotsNeutral Direction of movement to avoid
staf lines
\dynamicDown \dynamicUp \dynamicNeutral
\phrasingSlurDown \phrasingSlurUp \phrasingSlurNeutralNote: distinct from slur
commands
\slurDown \slurUp \slurNeutral
\stemDown \stemUp \stemNeutral
\textSpannerDown \textSpannerUp \textSpannerNeutral Text entered as spanner is be-
low/above staf
\tieDown \tieUp \tieNeutral
\tupletDown \tupletUp \tupletNeutral Tuplets are below/above notes
Note that these predefned commands may not be preceded by \once. If you wish to limit
the efect to a single note you must either use the equivalent \once \override command or
use the predefned command followed after the afected note by the corresponding \xxxNeutral
command.
Fingering
The placement of fngering on single notes can also be controlled by the direction property,
but changing direction has no efect on chords. As we shall see, there are special commands
which allow the fngering of individual notes of chords to be controlled, with the fngering being
placed above, below, to the left or to the right of each note.
First, here’s the efect of direction on the fngering attached to single notes. The frst bar
shows the default behaviour, and the following two bars shows the efect of specifying DOWN and
UP:
c-5 a-3 f-1 c'-5
\override Fingering #'direction = #DOWN
c-5 a-3 f-1 c'-5
\override Fingering #'direction = #UP
c-5 a-3 f-1 c'-5

5

3

1
1

5 5

5
5

3
3
5 1


However, overriding the direction property is not the easiest way of manually setting the
fngering above or below the notes; using _ or ^ instead of - before the fngering number is
usually preferable. Here is the previous example using this method:
c-5 a-3 f-1 c'-5
c_5 a_3 f_1 c'_5
c^5 a^3 f^1 c'^5
5
3 3

1

5

5

1 5 5
3

1

5

The direction property is ignored for chords, but the directional prefxes, _ and ^ do work.
By default, the fngering is automatically placed both above and below the notes of a chord, as
shown:
Chapter 4: Tweaking output 102
<c-5 g-3>
<c-5 g-3 e-2>
<c-5 g-3 e-2 c-1>

2

3
1
3

5
3

5

5

2
but this may be overriden to manually force all or any of the individual fngering numbers above
or below:
<c-5 g-3 e-2 c-1>
<c^5 g_3 e_2 c_1>
<c^5 g^3 e^2 c_1>

5
2

1

2
1
5
3

3
3
2 5
1
Even greater control over the placement of fngering of the individual notes in a chord is
possible by using the \set fingeringOrientations command. The format of this command
is:
\set fingeringOrientations = #'([up] [left/right] [down])
\set is used because fingeringOrientations is a property of the Voice context, created and
used by the New_fingering_engraver.
The property may be set to a list of one to three values. It controls whether fngerings may
be placed above (if up appears in the list), below (if down appears), to the left (if left appears,
or to the right (if right appears). Conversely, if a location is not listed, no fngering is placed
there. LilyPond takes these constraints and works out the best placement for the fngering of
the notes of the following chords. Note that left and right are mutually exclusive – fngering
may be placed only on one side or the other, not both.
¨
Note: To control the placement of the fngering of a single note using
this command it is necessary to write it as a single note chord by placing
angle brackets round it.
©
Here are a few examples:
\set fingeringOrientations = #'(left)
<f-2>
< c-1 e-2 g-3 b-5 > 4
\set fingeringOrientations = #'(left)
<f-2>
< c-1 e-2 g-3 b-5 > 4
\set fingeringOrientations = #'(up left down)
<f-2>
< c-1 e-2 g-3 b-5 > 4
\set fingeringOrientations = #'(up left)
Chapter 4: Tweaking output 103
<f-2>
< c-1 e-2 g-3 b-5 > 4
\set fingeringOrientations = #'(right)
<f-2>
< c-1 e-2 g-3 b-5 > 4

5
3

5
2
1

2

2

1
2

5

2
2

2
1
2

5

3
2

3

1
5
3 3
1
2

If the fngering seems a little crowded the font-size could be reduced. The default value can
be seen from the Fingering object in the IR to be -5, so let’s try -7:
\override Fingering #'font-size = #-7
\set fingeringOrientations = #'(left)
<f-2>
< c-1 e-2 g-3 b-5 > 4
\set fingeringOrientations = #'(left)
<f-2>
< c-1 e-2 g-3 b-5 > 4
\set fingeringOrientations = #'(up left down)
<f-2>
< c-1 e-2 g-3 b-5 > 4
\set fingeringOrientations = #'(up left)
<f-2>
< c-1 e-2 g-3 b-5 > 4
\set fingeringOrientations = #'(right)
<f-2>
< c-1 e-2 g-3 b-5 > 4
3
5

2

3

1
1

2
1
2
2
2
3
5
2
3

5

2
3

1
2

1

5

2

5

2

4.4.3 Outside-staf objects
Outside-staf objects are automatically placed to avoid collisions. Objects with the lower value
of the outside-staff-priority property are placed nearer to the staf, and other outside-staf
objects are then raised as far as necessary to avoid collisions. The outside-staff-priority
is defned in the grob-interface and so is a property of all layout objects. By default it is
set to #f for all within-staf objects, and to a numerical value appropriate to each outside-staf
object when the object is created. The following table shows the default numerical values for
some of the commonest outside-staf objects which are, by default, placed in the Staff or Voice
contexts.
Layout Object Priority Controls position of:
MultiMeasureRestText 450 Text over full-bar rests
TextScript 450 Markup text
OttavaBracket 400 Ottava brackets
TextSpanner 350 Text spanners
DynamicLineSpanner 250 All dynamic markings
VoltaBracketSpanner 100 Volta brackets
Chapter 4: Tweaking output 104
TrillSpanner 50 Spanning trills
Here is an example showing the default placement of some of these.
% Set details for later Text Spanner
\override TextSpanner #'(bound-details left text)
= \markup { \small \bold Slower }
% Place dynamics above staff
\dynamicUp
% Start Ottava Bracket
\ottava #1
c' \startTextSpan
% Add Dynamic Text
c\pp
% Add Dynamic Line Spanner
c\<
% Add Text Script
c^Text
c c
% Add Dynamic Text
c\ff c \stopTextSpan
% Stop Ottava Bracket
\ottava #0
c, c c c

ff

Slower

Text

pp

8va

This example also shows how to create Text Spanners – text with extender lines above a sec-
tion of music. The spanner extends from the \startTextSpan command to the \stopTextSpan
command, and the format of the text is defned by the \override TextSpanner command. For
more details see Section “Text spanners” in Notation Reference.
It also shows how ottava brackets are created.
Note that bar numbers, metronome marks and rehearsal marks are not shown. By default
these are created in the Score context and their outside-staff-priority is ignored relative
to the layout objects which are created in the Staff context. If you wish to place bar numbers,
metronome marks or rehearsal marks in accordance with the value of their outside-staff-
priority the Bar_number_engraver, Metronome_mark_engraver or Mark_engraver respec-
tively should be removed from the Score context and placed in the top Staff context. If this
is done, these marks will be given the following default outside-staff-priority values:
Layout Object Priority
RehearsalMark 1500
MetronomeMark 1000
BarNumber 100
If the default values of outside-staff-priority do not give you the placing you want, the
priority of any of the objects may be overridden. Suppose we would like the ottava bracket to
be placed below the text spanner in the example above. All we need to do is to look up the
Chapter 4: Tweaking output 105
priority of OttavaBracket in the IR or in the tables above, and reduce it to a value lower than
that of a TextSpanner, remembering that OttavaBracket is created in the Staff context:
% Set details for later Text Spanner
\override TextSpanner #'(bound-details left text)
= \markup { \small \bold Slower }
% Place dynamics above staff
\dynamicUp
%Place following Ottava Bracket below Text Spanners
\once \override Staff.OttavaBracket #'outside-staff-priority = #340
% Start Ottava Bracket
\ottava #1
c' \startTextSpan
% Add Dynamic Text
c\pp
% Add Dynamic Line Spanner
c\<
% Add Text Script
c^Text
c c
% Add Dynamic Text
c\ff c \stopTextSpan
% Stop Ottava Bracket
\ottava #0
c, c c c

ff

pp

Slower
8va

Text

Slurs by default are classed as within-staf objects, but they often appear above the staf if
the notes to which they are attached are high on the staf. This can push outside-staf objects
such as articulations too high, as the slur will be placed frst. The avoid-slur property of the
articulation can be set to 'inside to bring the articulation inside the slur, but the avoid-slur
property is efective only if the outside-staff-priority is also set to #f. Alternatively, the
outside-staff-priority of the slur can be set to a numerical value to cause it to be placed
along with other outside-staf objects according to that value. Here’s an example showing the
efect of the two methods:
c4( c^\markup\tiny\sharp d4.) c8
c4(
\once \override TextScript #'avoid-slur = #'inside
\once \override TextScript #'outside-staff-priority = ##f
c^\markup\tiny\sharp d4.) c8
\once \override Slur #'outside-staff-priority = #500
c4( c^\markup\tiny\sharp d4.) c8
Chapter 4: Tweaking output 106

Changing the outside-staff-priority can also be used to control the vertical placement
of individual objects, although the results may not always be desirable. Suppose we would
like “Text3” to be placed above “Text4” in the example under Automatic behavior, above (see
Section 4.4.1 [Automatic behavior], page 99). All we need to do is to look up the priority of
TextScript in the IR or in the tables above, and increase the priority of “Text3” to a higher
value:
c2^"Text1"
c^"Text2"
\once \override TextScript #'outside-staff-priority = #500
c^"Text3"
c^"Text4"

Text4 Text1

Text2

Text3

This certainly lifts “Text3” above “Text4” but it also lifts it above “Text2”, and “Text4”
now drops down. Perhaps this is not so good. What we would really like to do is to position all
the annotation at the same distance above the staf. To do this, we clearly will need to space the
notes out horizontally to make more room for the text. This is done using the textLengthOn
command.
\textLengthOn
By default, text produced by markup takes up no horizontal space as far as laying out the music
is concerned. The \textLengthOn command reverses this behavior, causing the notes to be
spaced out as far as is necessary to accommodate the text:
\textLengthOn % Cause notes to space out to accommodate text
c2^"Text1"
c^"Text2"
c^"Text3"
c^"Text4"

Text1

Text3

Text2 Text4
The command to revert to the default behavior is \textLengthOff. Remember \once only
works with \override, \set, \revert or unset, so cannot be used with \textLengthOn.
Markup text will also avoid notes which project above the staf. If this is not desired, the
automatic displacement upwards may be turned of by setting the priority to #f. Here’s an
example to show how markup text interacts with such notes.
% This markup is short enough to fit without collision
c2^"Tex"
c''2
R1
% This is too long to fit, so it is displaced upwards
Chapter 4: Tweaking output 107
c,,2^"Text"
c''2
R1
% Turn off collision avoidance
\once \override TextScript #'outside-staff-priority = ##f
c,,2^"Long Text "
c''2
R1
% Turn off collision avoidance
\once \override TextScript #'outside-staff-priority = ##f
\textLengthOn % and turn on textLengthOn
c,,2^"Long Text " % Spaces at end are honored
c''2

Text

Tex

Long Text

Long Text
Dynamics
Dynamic markings will normally be positioned beneath the staf, but may be positioned above
with the dynamicUp command. They will be positioned vertically relative to the note to which
they are attached, and will foat below (or above) all within-staf objects such as phrasing slurs
and bar numbers. This can give quite acceptable results, as this example shows:
\clef "bass"
\key aes \major
\time 9/8
\dynamicUp
bes4.~\f\< \( bes4 bes8 des4\ff\> c16 bes\! |
ees,2.~\)\mf ees4 r8 |
f

mf

8
9

ff

However, if the notes and attached dynamics are close together the automatic placement will
avoid collisions by displacing later dynamic markings further away, but this may not be the
optimum placement, as this rather artifcial example shows:
\dynamicUp
a4\f b\mf c\mp b\p

f
mf

mp
p

Should a similar situation arise in ‘real’ music, it may be preferable to space out the notes a
little further, so the dynamic markings can all ft at the same vertical distance from the staf.
Chapter 4: Tweaking output 108
We were able to do this for markup text by using the \textLengthOn command, but there is
no equivalent command for dynamic marks. So we shall have to work out how to do this using
\override commands.
Grob sizing
First we must learn how grobs are sized. All grobs have a reference point defned within them
which is used to position them relative to their parent object. This point in the grob is then
positioned at a horizontal distance, X-offset, and at a vertical distance, Y-offset, from its
parent. The horizontal extent of the object is given by a pair of numbers, X-extent, which say
where the left and right edges are relative to the reference point. The vertical extent is similarly
defned by a pair of numbers, Y-extent. These are properties of all grobs which support the
grob-interface.
By default, outside-staf objects are given a width of zero so that they may overlap in the
horizontal direction. This is done by the trick of adding infnity to the leftmost extent and
minus infnity to the rightmost extent by setting the extra-spacing-width to '(+inf.0 . -
inf.0). So to ensure they do not overlap in the horizontal direction we must override this value
of extra-spacing-width to '(0 . 0) so the true width shines through. This is the command
to do this for dynamic text:
\override DynamicText #'extra-spacing-width = #'(0 . 0)
Let’s see if this works in our previous example:
\dynamicUp
\override DynamicText #'extra-spacing-width = #'(0 . 0)
a4\f b\mf c\mp b\p
f

p mf

mp
Well, it has certainly stopped the dynamic marks being displaced, but two problems remain.
The marks should be spaced a little further apart and it would be better if they were all the
same distance from the staf. We can solve the frst problem easily. Instead of making the
extra-spacing-width zero we could add a little more to it. The units are the space between
two staf lines, so moving the left edge half a unit to the left and the right edge half a unit to
the right should do it:
\dynamicUp
% Extend width by 1 staff space
\override DynamicText #'extra-spacing-width = #'(-0.5 . 0.5)
a4\f b\mf c\mp b\p

mp
f

p mf

This looks better, but maybe we would prefer the dynamic marks to be aligned along the same
baseline rather than going up and down with the notes. The property to do this is staff-
padding which is covered in the following section.
Chapter 4: Tweaking output 109
4.5 Collisions of objects
4.5.1 Moving objects
This may come as a surprise, but LilyPond is not perfect. Some notation elements can overlap.
This is unfortunate, but in fact rather rare. Usually the need to move objects is for clarity or
aesthetic reasons – they would look better with a little more or a little less space around them.
There are three main approaches to resolving overlapping notation. They should be consid-
ered in the following order:
1. The direction of one of the overlapping objects may be changed using the predefned
commands listed above for within-staf objects (see Section 4.4.2 [Within-staf objects],
page 100). Stems, slurs, beams, ties, dynamics, text and tuplets may be repositioned easily
in this way. The limitation is that you have a choice of only two positions, and neither may
be suitable.
2. The object properties, which LilyPond uses when positioning layout objects, may be mod-
ifed using \override. The advantages of making changes to this type of property are (a)
that some other objects will be moved automatically if necessary to make room and (b)
the single override can apply to all instances of the same type of object. Such properties
include:
• direction
This has already been covered in some detail – see Section 4.4.2 [Within-staf objects],
page 100.
• padding, left-padding, right-padding, staff-padding
As an object is being positioned the value of its padding property specifes the gap that
must be left between itself and the nearest edge of the object against which it is being
positioned. Note that it is the padding value of the object being placed that is used;
the padding value of the object which is already placed is ignored. Gaps specifed by
padding can be applied to all objects which support the side-position-interface.
Instead of padding, the placement of groups of accidentals is controlled by
left-padding and right-padding. These properties are to be found in the
AccidentalPlacement object which, note, lives in the staf context. In the
type-setting process the note heads are type-set frst and then the accidentals, if
any, are added to the left of the note heads using the right-padding property to
determine the separation from the note heads. So only the right-padding property of
the AccidentalPlacement object has any efect on the placement of the accidentals.
The staff-padding property is closely related to the padding property: padding
controls the minimum amount of space between any object which supports the side-
position-interface and the nearest other object (generally the note or the staf
lines); staff-padding applies only to those objects which are always set outside the
staf – it controls the minimum amount of space that should be inserted between that
object and the staf. Note that staff-padding has no efect on objects which are
positioned relative to the note rather than the staf, even though it may be overridden
without error for such objects – it is simply ignored.
To discover which padding property is required for the object you wish to reposition,
you need to return to the IR and look up the object’s properties. Be aware that the
padding properties might not be located in the obvious object, so look in objects that
appear to be related.
All padding values are measured in staf spaces. For most objects, this value is set by
default to be around 1.0 or less (it varies with each object). It may be overridden if a
larger (or smaller) gap is required.
Chapter 4: Tweaking output 110
• self-alignment-X
This property can be used to align the object to the left, to the right, or to center it with
respect to the parent object’s reference point. It may be used with all objects which
support the self-alignment-interface. In general these are objects that contain
text. The values are LEFT, RIGHT or CENTER. Alternatively, a numerical value between
-1 and +1 may be specifed, where -1 is left-aligned, +1 is right-aligned, and numbers
in between move the text progressively from left-aligned to right-aligned. Numerical
values greater than 1 may be specifed to move the text even further to the left, or
less than -1 to move the text even further to the right. A change of 1 in the value
corresponds to a movement of half the text’s length.
• extra-spacing-width
This property is available for all objects which support the item-interface. It takes
two numbers, the frst is added to the leftmost extent and the second is added to the
rightmost extent. Negative numbers move the edge to the left, positive to the right, so
to widen an object the frst number must be negative, the second positive. Note that
not all objects honor both numbers. For example, the Accidental object only takes
notice of the frst (left edge) number.
• staff-position
staff-position is a property of the staff-symbol-referencer-interface, which is
supported by objects which are positioned relative to the staf. It specifes the vertical
position of the object relative to the center line of the staf in half staf-spaces. It is
useful in resolving collisions between layout objects like multi-measure rests, ties and
notes in diferent voices.
• force-hshift
Closely spaced notes in a chord, or notes occurring at the same time in diferent voices,
are arranged in two, occasionally more, columns to prevent the note heads overlapping.
These are called note columns, and an object called NoteColumn is created to lay out
the notes in that column.
The force-hshift property is a property of a NoteColumn (actually of the note-
column-interface). Changing it permits a note column to be moved in units appro-
priate to a note column, viz. the note head width of the frst voice note. It should be
used in complex situations where the normal \shiftOn commands (see Section 3.2.2
[Explicitly instantiating voices], page 48) do not resolve the note confict. It is prefer-
able to the extra-offset property for this purpose as there is no need to work out
the distance in staf-spaces, and moving the notes into or out of a NoteColumn afects
other actions such as merging note heads.
3. Finally, when all else fails, objects may be manually repositioned relative to the staf center
line vertically, or by displacing them by any distance to a new position. The disadvantages
are that the correct values for the repositioning have to be worked out, often by trial and
error, for every object individually, and, because the movement is done after LilyPond has
placed all other objects, the user is responsible for avoiding any collisions that might ensue.
But the main difculty with this approach is that the repositioning values may need to be
reworked if the music is later modifed. The properties that can be used for this type of
manual repositioning are:
extra-offset
This property applies to any layout object supporting the grob-interface. It
takes a pair of numbers which specify the extra displacement in the horizontal
and vertical directions. Negative numbers move the object to the left or down.
The units are staf-spaces. The extra displacement is made after the typeset-
Chapter 4: Tweaking output 111
ting of objects is fnished, so an object may be repositioned anywhere without
afecting anything else.
positions
This is most useful for manually adjusting the slope and height of beams, slurs,
and tuplets. It takes a pair of numbers giving the position of the left and right
ends of the beam, slur, etc. relative to the center line of the staf. Units are
staf-spaces. Note, though, that slurs and phrasing slurs cannot be repositioned
by arbitrarily large amounts. LilyPond frst generates a list of possible positions
for the slur and by default fnds the slur that “looks best”. If the positions
property has been overridden the slur that is closest to the requested positions
is selected from the list.
A particular object may not have all of these properties. It is necessary to go to the IR to
look up which properties are available for the object in question.
Here is a list of the objects which are most likely to be involved in collisions, together with
the name of the object which should be looked up in the IR in order to discover which properties
should be used to move them.
Object type Object name
Articulations Script
Beams Beam
Dynamics (vertically) DynamicLineSpanner
Dynamics (horizontally) DynamicText
Fingerings Fingering
Rehearsal / Text marks RehearsalMark
Slurs Slur
Text e.g. ^"text" TextScript
Ties Tie
Tuplets TupletBracket
4.5.2 Fixing overlapping notation
Let’s now see how the properties in the previous section can help to resolve overlapping notation.
padding property
The padding property can be set to increase (or decrease) the distance between symbols that
are printed above or below notes.
c2\fermata
\override Script #'padding = #3
b2\fermata

% This will not work, see below:
\override MetronomeMark #'padding = #3
\tempo 4=120
c1
% This works:
\override Score.MetronomeMark #'padding = #3
Chapter 4: Tweaking output 112
\tempo 4=80
d1

= 120

= 80
Note in the second example how important it is to fgure out what context handles a certain
object. Since the MetronomeMark object is handled in the Score context, property changes in
the Voice context will not be noticed. For more details, see Section “Modifying properties” in
Notation Reference.
If the padding property of an object is increased when that object is in a stack of objects
being positioned according to their outside-staff-priority, then that object and all objects
outside it are moved.
left-padding and right-padding
The right-padding property afects the spacing between the accidental and the note to which
it applies. It is not often required, but the following example shows one situation where it is
needed. Suppose we wish to show a chord containing both a B-natural and a B-fat. To avoid
ambiguity we would like to precede the notes with both a natural and a fat sign. Here are a
few attempts to do this:
<b bes>
<b! bes>
<b? bes>

None work, with the second two showing bad collisions between the two signs.
One way of achieving this is to override the accidental stencil with a markup containing the
natural and fat symbols in the order we would like, like this:
naturalplusflat = \markup { \natural \flat }
\relative c'' {
\once \override Accidental
#'stencil = #ly:text-interface::print
\once \override Accidental #'text = #naturalplusflat
\once \override Score.AccidentalPlacement #'right-padding = #1.5
<b bes>
}

This necessarily uses an override for the accidental stencil which will not be covered until later.
The stencil type must be a procedure, here changed to print the contents of the text property
of Accidental, which itself is set to be a natural sign followed by a fat sign. These are then
moved further away from the note head by overriding right-padding.
Chapter 4: Tweaking output 113
staf-padding property
staff-padding can be used to align objects such as dynamics along a baseline at a fxed height
above the staf, rather than at a height dependent on the position of the note to which they are
attached. It is not a property of DynamicText but of DynamicLineSpanner. This is because the
baseline should apply equally to all dynamics, including those created as extended spanners. So
this is the way to align the dynamic marks in the example taken from the previous section:
\dynamicUp
% Extend width by 1 unit
\override DynamicText #'extra-spacing-width = #'(-0.5 . 0.5)
% Align dynamics to a base line 2 units above staff
\override DynamicLineSpanner #'staff-padding = #2
a4\f b\mf c\mp b\p
mf

p

f mp

self-alignment-X property
The following example shows how this can resolve the collision of a string fngering object with
a note’s stem by aligning the right edge with the reference point of the parent note:
\voiceOne
< a \2 >
\once \override StringNumber #'self-alignment-X = #RIGHT
< a \2 >
2 2

staf-position property
Multimeasure rests in one voice can collide with notes in another. Since these rests are typeset
centered between the bar lines, it would require signifcant efort for LilyPond to fgure out
which other notes might collide with it, since all the current collision handling between notes
and between notes and rests is done only for notes and rests that occur at the same time. Here’s
an example of a collision of this type:
<< {c c c c} \\ {R1} >>

The best solution here is to move the multimeasure rest down, since the rest is in voice two.
The default in \voiceTwo (i.e. in the second voice of a <<{...} \\ {...}>> construct) is that
staff-position is set to -4 for MultiMeasureRest, so we need to move it, say, four half-staf
spaces down to -8.
<<
{c c c c}
\\
Chapter 4: Tweaking output 114
\override MultiMeasureRest #'staff-position = #-8
{R1}
>>

This is better than using, for example, extra-offset, because the ledger line above the rest
is inserted automatically.
extra-ofset property
The extra-offset property provides complete control over the positioning of an object both
horizontally and vertically.
In the following example, the second fngering is moved a little to the left, and 1.8 staf space
downwards:
\stemUp
f-5
\once \override Fingering
#'extra-offset = #'(-0.3 . -1.8)
f-5
5

5
positions property
The positions property allows the position and slope of tuplets, slurs, phrasing slurs and beams
to be controlled manually. Here’s an example which has an ugly phrasing slur due to its trying
to avoid the slur on the acciaccatura.
r4 \acciaccatura e8\( d8 c ~c d c d\)

We could simply move the phrasing slur above the notes, and this would be the preferred
solution:
r4
\phrasingSlurUp
\acciaccatura e8\( d8 c ~c d c d\)

But if there were some reason why this could not be done the other alternative would be to
move the left end of the phrasing slur down a little using the positions property. This also
resolves the rather nasty shape.
Chapter 4: Tweaking output 115
r4
\once \override PhrasingSlur #'positions = #'(-4 . -3)
\acciaccatura
e8\( d8 c ~c d c d\)

Here’s a further example taken from the opening of the left-hand staf of Chopin’s Prelude
Op 28 No. 2. We see that the beam collides with the upper notes:
{
\clef "bass"
<< {b,8 ais, b, g,} \\ {e, g e, g} >>
<< {b,8 ais, b, g,} \\ {e, g e, g} >>
}

This can be resolved by manually moving both ends of the beam up from their position at 2
staf-spaces above the center line to, say, 3:
{
\clef "bass"
<<
\override Beam #'positions = #'(3 . 3)
{b,8 ais, b, g,}
\\
{e, g e, g}
>>
<< {b,8 ais, b, g,} \\ {e, g e, g} >>
}

Note that the override continues to apply in the frst voice of the second block of quavers, but
not to any of the beams in the second voice.
force-hshift property
We can now see how to apply the fnal corrections to the Chopin example introduced at the end
of Section 3.2.1 [I’m hearing Voices], page 44, which was left looking like this:
\new Staff \relative c'' {
\key aes \major
<<
{ c2 aes4. bes8 } \\
{ aes2 f4 fes } \\
Chapter 4: Tweaking output 116
{ \voiceFour
<ees c>2
des2
}
>> |
<c ees aes c>1 |
}

The lower two notes of the frst chord (i.e, those in the third voice) should not be shifted away
from the note column of the higher two notes. To correct this we set force-hshift, which is
a property of NoteColumn, of these notes to zero. The lower note of the second chord is best
placed just to the right of the higher notes. We achieve this by setting force-hshift of this
note to 0.5, ie half a note head’s width to the right of the note column of the higher notes.
Here’s the fnal result:
\new Staff \relative c'' {
\key aes \major
<<
{ c2 aes4. bes8 } \\
{ aes2 f4 fes } \\
{ \voiceFour
\once \override NoteColumn #'force-hshift = #0 <ees c>2
\once \override NoteColumn #'force-hshift = #0.5 des2
}
>> |
<c ees aes c>1 |
}

4.5.3 Real music example
We end this section on Tweaks by showing the steps to be taken to deal with a tricky example
which needs several tweaks to produce the desired output. The example has been deliberately
chosen to illustrate the use of the Notation Reference to resolve unusual problems with notation.
It is not representative of more usual engraving process, so please do not let these difculties
put you of! Fortunately, difculties like these are not very common!
The example is from Chopin’s Premi`ere Ballade, Op. 23, bars 6 to 9, the transition from the
opening Lento to Moderato. Here, frst, is what we want the output to look like, but to avoid
over-complicating the example too much we have left out the dynamics, fngering and pedalling.
Chapter 4: Tweaking output 117

.
,

,
.
.
4
6
,
.

,
,
,
,
,
4
6 , ,
,

,
,
.
·
·
·
·
,
,
,

,
,
,
·
,
, ,

.
,
/
.
.
.
,
.
Moderato
,
We note frst that the right hand part in the third bar requires four voices. These are the fve
beamed eighth notes, the tied C, the half-note D which is merged with the eighth note D, and
the dotted quarter note F-sharp, which is also merged with the eighth note at the same pitch.
Everything else is in a single voice, so the easiest way is to introduce these four voices temporarily
at the time they are needed. If you have forgotten how to do this, look at Section 3.2.1 [I’m
hearing Voices], page 44. Let us begin by entering the notes as two variables and setting up the
staf structure in a score block, and see what LilyPond produces by default:
rhMusic = \relative c'' {
r2 c4. g8 |
bes1~ |
\time 6/4
bes2. r8
% Start polyphonic section of four voices
<<
{c,8 d fis bes a | }
\\
{c,8~ c2 | }
\\
{s8 d2 | }
\\
{s4 fis4. | }
>>
g2.
}
lhMusic = \relative c' {
r2 <c g ees>2 |
<d g, d>1 |
r2. d,,4 r4 r |
r4
}
\score {
\new PianoStaff <<
\new Staff = "RH" <<
\key g \minor
\rhMusic
>>
\new Staff = "LH" <<
\key g \minor
\clef "bass"
\lhMusic
>>
>>
}
Chapter 4: Tweaking output 118
.
4
6
,
,

,
.
.
.
, ,
,
,
.
.
.
,
,
,
.

.
,
,

,
,
4
6
,

,
,
,
,
,
.
, ,
,
,
,
/
,

·
,
All the notes are right, but the appearance is far from satisfactory. The tie clashes with
the change in time signature, the beaming in the third bar is wrong, the notes are not merged
together, and several notation elements are missing. Let’s frst deal with the easier things. We
can correct the beaming by inserting a beam manually, and we can easily add the left hand slur
and the right hand phrasing slur, since these were all covered in the Tutorial. Doing this gives:
rhMusic = \relative c'' {
r2 c4.\( g8 |
bes1~ |
\time 6/4
bes2. r8
% Start polyphonic section of four voices
<<
{c,8[ d fis bes a] | }
\\
{c,8~ c2 | }
\\
{s8 d2 | }
\\
{s4 fis4. | }
>>
g2.\)
}
lhMusic = \relative c' {
r2 <c g ees>2( |
<d g, d>1) |
r2. d,,4 r4 r |
r4
}
\score {
\new PianoStaff <<
\new Staff = "RH" <<
\key g \minor
\rhMusic
>>
\new Staff = "LH" <<
\key g \minor
\clef "bass"
\lhMusic
>>
>>
}
Chapter 4: Tweaking output 119
,
.
,,
.

/
,
,
,
.
,
,,
,
4
6
.
4
6
,
,
,
,
, ,
,
,
,
.
.
.
.
,
.

,

·
,
,
,
,

,

.
,
The frst bar is now correct. The second bar contains an arpeggio and is terminated by a
double bar line. How do we do these, as they have not been mentioned in this Learning Manual?
This is where we need to turn to the Notation Reference. Looking up ‘arpeggio’ and ‘bar line’
in the index quickly shows us that an arpeggio is produced by appending \arpeggio to a chord,
and a double bar line is produced by the \bar "||" command. That’s easily done. We next
need to correct the collision of the tie with the time signature. This is best done by moving the
tie upwards. Moving objects was covered earlier in Section 4.5.1 [Moving objects], page 109,
which says that objects positioned relative to the staf can be moved by overriding their staff-
position property, which is specifed in half staf spaces relative to the center line of the staf.
So the following override placed just before the frst tied note would move the tie up to 3.5 half
staf spaces above the center line:
\once \override Tie #'staff-position = #3.5
This completes bar two, giving:
rhMusic = \relative c'' {
r2 c4.\( g8 |
\once \override Tie #'staff-position = #3.5
bes1~ |
\bar "||"
\time 6/4
bes2. r8
% Start polyphonic section of four voices
<<
{c,8[ d fis bes a] | }
\\
{c,8~ c2 | }
\\
{s8 d2 | }
\\
{s4 fis4. | }
>>
g2.\)
}
lhMusic = \relative c' {
r2 <c g ees>2( |
<d g, d>1)\arpeggio |
r2. d,,4 r4 r |
r4
}
\score {
\new PianoStaff <<
\new Staff = "RH" <<
\key g \minor
\rhMusic
>>
Chapter 4: Tweaking output 120
\new Staff = "LH" <<
\key g \minor
\clef "bass"
\lhMusic
>>
>>
}
,,
,
.
.
.

4
6 .
4
6
,
, . ,
,
,

·
.
,

,
,
,
·
·
·
·
,
,,
/
,
,
,
,
,
,
,

.
,
,

.
,
,
.
.
,
On to bar three and the start of the Moderato section. The tutorial showed how to add
embolded text with the \markup command, so adding ‘Moderato’ in bold is easy. But how do
we merge notes in diferent voices together? This is where we need to turn to the Notation
Reference for help. A search for “merge” in the Notation Reference index quickly leads us to
the commands for merging diferently headed and diferently dotted notes in Section “Collision
resolution” in Notation Reference. In our example we need to merge both types of note for the
duration of the polyphonic section in bar 3, so using the information we fnd in the Notation
Reference we add
\mergeDifferentlyHeadedOn
\mergeDifferentlyDottedOn
to the start of that section and
\mergeDifferentlyHeadedOff
\mergeDifferentlyDottedOff
to the end, giving:
rhMusic = \relative c'' {
r2 c4.\( g8 |
\once \override Tie #'staff-position = #3.5
bes1~ |
\bar "||"
\time 6/4
bes2.^\markup {\bold "Moderato"} r8
\mergeDifferentlyHeadedOn
\mergeDifferentlyDottedOn
% Start polyphonic section of four voices
<<
{c,8[ d fis bes a] | }
\\
{c,8~ c2 | }
\\
{s8 d2 | }
\\
{s4 fis4. | }
>>
\mergeDifferentlyHeadedOff
\mergeDifferentlyDottedOff
Chapter 4: Tweaking output 121
g2.\)
}
lhMusic = \relative c' {
r2 <c g ees>2( |
<d g, d>1)\arpeggio |
r2. d,,4 r4 r |
r4
}
\score {
\new PianoStaff <<
\new Staff = "RH" <<
\key g \minor
\rhMusic
>>
\new Staff = "LH" <<
\key g \minor
\clef "bass"
\lhMusic
>>
>>
}
.
.
,
.

,
,
.
,
,

.
4
6

,
,
,
/
,
,
,
·
,
,
Moderato

,
·
·
·
·
,
,
.
,
.
.
, ,
,,
,
,
,

.
.
,

,
4
6
These overrides have merged the two F-sharp notes, but not the two on D. Why not? The
answer is there in the same section in the Notation Reference – notes being merged must have
stems in opposite directions and two notes cannot be merged successfully if there is a third note
in the same note column. Here the two D’s both have upward stems and there is a third note –
the C. We know how to change the stem direction using \stemDown, and the Notation Reference
also says how to move the C – apply a shift using one of the \shift commands. But which
one? The C is in voice two which has shift of, and the two D’s are in voices one and three,
which have shift of and shift on, respectively. So we have to shift the C a further level still
using \shiftOnn to avoid it interfering with the two D’s. Applying these changes gives:
rhMusic = \relative c'' {
r2 c4.\( g8 |
\once \override Tie #'staff-position = #3.5
bes1~ |
\bar "||"
\time 6/4
bes2.^\markup {\bold "Moderato"} r8
\mergeDifferentlyHeadedOn
\mergeDifferentlyDottedOn
% Start polyphonic section of four voices
Chapter 4: Tweaking output 122
<<
{c,8[ d fis bes a] | }
\\
% Move the c2 out of the main note column so the merge will work
{c,8~ \shiftOnn c2 | }
\\
% Stem on the d2 must be down to permit merging
{s8 \stemDown d2 | }
\\
{s4 fis4. | }
>>
\mergeDifferentlyHeadedOff
\mergeDifferentlyDottedOff
g2.\)
}
lhMusic = \relative c' {
r2 <c g ees>2( |
<d g, d>1)\arpeggio |
r2. d,,4 r4 r |
r4
}
\score {
\new PianoStaff <<
\new Staff = "RH" <<
\key g \minor
\rhMusic
>>
\new Staff = "LH" <<
\key g \minor
\clef "bass"
\lhMusic
>>
>>
}
.
,,
·
,
,
/
,
,
,
,
,
,
,
.
.

.
,
,
,
Moderato

,
,
,
4
6 .
4
6
.
.
.
,
.
, ,

,

,
,
,
·
·
·
·
.
,
Nearly there. Only two problems remain: The downward stem on the merged D should not
be there, and the C would be better positioned to the right of the D’s. We know how to do
both of these from the earlier tweaks: we make the stem transparent, and move the C with the
force-hshift property. Here’s the fnal result:
rhMusic = \relative c'' {
r2
Chapter 4: Tweaking output 123
c4.\( g8 |
\once \override Tie #'staff-position = #3.5
bes1~ |
\bar "||"
\time 6/4
bes2.^\markup {\bold "Moderato"} r8
\mergeDifferentlyHeadedOn
\mergeDifferentlyDottedOn
<<
{c,8[ d fis bes a] | }
\\
% Reposition the c2 to the right of the merged note
{c,8~ \once \override NoteColumn #'force-hshift = #1.0
% Move the c2 out of the main note column so the merge will work
\shiftOnn c2}
\\
% Stem on the d2 must be down to permit merging
{s8 \stemDown \once \override Stem #'transparent = ##t d2}
\\
{s4 fis4.}
>>
\mergeDifferentlyHeadedOff
\mergeDifferentlyDottedOff
g2.\)
}
lhMusic = \relative c' {
r2 <c g ees>2( |
<d g, d>1)\arpeggio |
r2. d,,4 r4 r |
r4
}
\score {
\new PianoStaff <<
\new Staff = "RH" <<
\key g \minor
\rhMusic
>>
\new Staff = "LH" <<
\key g \minor
\clef "bass"
\lhMusic
>>
>>
}
Chapter 4: Tweaking output 124
,
.
.
, ,
.
,,
·

,
,
/
,
,

,
.
.
.
,
,,

,
,
,
,
,
4
6
.
4
6
.

,

,
·
·
·
·
,
,
, .
.
Moderato
,
,
4.6 Further tweaking
4.6.1 Other uses for tweaks
Tying notes across voices
The following example demonstrates how to connect notes in diferent voices using ties. Nor-
mally, only two notes in the same voice can be connected with ties. By using two voices, with
the tied notes in one of them

and blanking the frst up-stem in that voice, the tie appears to cross voices:
<<
{
\once \override Stem #'transparent = ##t
b8~ b8\noBeam
}
\\
{ b[ g8] }
>>

To make sure that the just-blanked stem doesn’t squeeze the tie too much, we can lengthen
the stem by setting the length to 8,
<<
{
\once \override Stem #'transparent = ##t
\once \override Stem #'length = #8
b8~ b8\noBeam
}
\\
{ b[ g8] }
>>

Chapter 4: Tweaking output 125
Simulating a fermata in MIDI
For outside-staf objects it is usually better to override the object’s stencil property rather
than its transparent property when you wish to remove it from the printed output. Setting the
stencil property of an object to #f will remove that object entirely from the printed output.
This means it has no efect on the placement of other objects placed relative to it.
For example, if we wished to change the metronome setting in order to simulate a fermata in
the MIDI output we would not want the metronome markings to appear in the printed output,
and we would not want it to infuence the spacing between the two systems or the positions of
adjacent annotations on the staf. So setting its stencil property to #f would be the best way.
We show here the efect of the two methods:
\score {
\relative c'' {
% Visible tempo marking
\tempo 4=120
a4 a a
\once \override Score.MetronomeMark #'transparent = ##t
% Invisible tempo marking to lengthen fermata in MIDI
\tempo 4=80
a\fermata
% New tempo for next section
\tempo 4=100
a a a a
}
\layout { }
\midi { }
}

= 120

= 100

\score {
\relative c'' {
% Visible tempo marking
\tempo 4=120
a4 a a
\once \override Score.MetronomeMark #'stencil = ##f
% Invisible tempo marking to lengthen fermata in MIDI
\tempo 4=80
a\fermata
% New tempo for next section
\tempo 4=100
a a a a
}
\layout { }
\midi { }
}
Chapter 4: Tweaking output 126

= 120


= 100

Both methods remove the metronome mark which lengthens the fermata from the printed output,
and both afect the MIDI timing as required, but the transparent metronome mark in the frst
line forces the following tempo indication too high while the second (with the stencil removed)
does not.
4.6.2 Using variables for tweaks
Override commands are often long and tedious to type, and they have to be absolutely correct.
If the same overrides are to be used many times it may be worth defning variables to hold them.
Suppose we wish to emphasize certain words in lyrics by printing them in bold italics. The
\italic and \bold commands only work within lyrics if they are embedded, together with the
word or words to be modifed, within a \markup block, which makes them tedious to enter. The
need to embed the words themselves prevents their use in simple variables. As an alternative
can we use \override and \revert commands?
\override Lyrics . LyricText #'font-shape = #'italic
\override Lyrics . LyricText #'font-series = #'bold
\revert Lyrics . LyricText #'font-shape
\revert Lyrics . LyricText #'font-series
These would also be extremely tedious to enter if there were many words requiring emphasis.
But we can defne these as two variables and use those to bracket the words to be emphasized.
Another advantage of using variables for these overrides is that the spaces around the dot are
not necessary, since they are not being interpreted in \lyricmode directly. Here’s an example of
this, although in practice we would choose shorter names for the variables to make them quicker
to type:
emphasize = {
\override Lyrics.LyricText #'font-shape = #'italic
\override Lyrics.LyricText #'font-series = #'bold
}
normal = {
\revert Lyrics.LyricText #'font-shape
\revert Lyrics.LyricText #'font-series
}
global = { \time 4/4 \partial 4 \key c \major}
SopranoMusic = \relative c' { c4 | e4. e8 g4 g | a a g }
AltoMusic = \relative c' { c4 | c4. c8 e4 e | f f e }
TenorMusic = \relative c { e4 | g4. g8 c4. b8 | a8 b c d e4 }
BassMusic = \relative c { c4 | c4. c8 c4 c | f8 g a b c4 }
VerseOne = \lyrics { E -- | ter -- nal \emphasize Fa -- ther, \normal | strong to save, }
VerseTwo = \lyricmode { O | \emphasize Christ, \normal whose voice the | wa -- ters heard, }
VerseThree = \lyricmode { O | \emphasize Ho -- ly Spi -- rit, \normal | who didst brood }
VerseFour = \lyricmode { O | \emphasize Tri -- ni -- ty \normal of | love and pow'r }
\score {
\new ChoirStaff <<
\new Staff <<
\clef "treble"
\new Voice = "Soprano" { \voiceOne \global \SopranoMusic }
Chapter 4: Tweaking output 127
\new Voice = "Alto" { \voiceTwo \AltoMusic }
\new Lyrics \lyricsto "Soprano" { \VerseOne }
\new Lyrics \lyricsto "Soprano" { \VerseTwo }
\new Lyrics \lyricsto "Soprano" { \VerseThree }
\new Lyrics \lyricsto "Soprano" { \VerseFour }
>>
\new Staff <<
\clef "bass"
\new Voice = "Tenor" { \voiceOne \TenorMusic }
\new Voice = "Bass" { \voiceTwo \BassMusic }
>>
>>
}
,
, ,
,
of
,
,
love
who
wa
strong
,
,

,
,
pow'r
brood
heard,
,
,
,
/
,
,
and
didst
ters
to
,
,
save,
,
,
,
,

,
,
Ho
Christ,
ter
,
,

Tri
O
O
E
,,
.
.
,
,
O
,
,
ty
Spi
voice
Fa
,
,
rit,
the
ther,
,
,

,
,
ni
ly
whose
nal
,
,
·

·
4.6.3 Other sources of information
The Internals Reference documentation contains a lot of information about LilyPond, but even
more information can be gathered by looking at the internal LilyPond fles. To explore these, you
must frst fnd the directory appropriate to your system. The location of this directory depends
(a) on whether you obtained LilyPond by downloading a precompiled binary from lilypond.org
or whether you installed it from a package manager (i.e. distributed with Linux, or installed
under fnk or cygwin) or compiled it from source, and (b) on which operating system it is being
used:
Downloaded from lilypond.org
• Linux
Navigate to ‘INSTALLDIR/lilypond/usr/share/lilypond/current/’
• MacOS X
Navigate to ‘INSTALLDIR/LilyPond.app/Contents/Resources/share/lilypond/current/’
by either cd-ing into this directory from the Terminal, or control-clicking on the LilyPond
application and selecting ‘Show Package Contents’.
• Windows
Using Windows Explorer, navigate to ‘INSTALLDIR/LilyPond/usr/share/lilypond/current/’
Installed from a package manager or compiled from source
Navigate to ‘PREFIX/share/lilypond/X.Y.Z/’, where PREFIX is set by your package man-
ager or configure script, and X.Y.Z is the LilyPond version number.
Within this directory the two interesting subdirectories are
Chapter 4: Tweaking output 128
• ‘ly/’ - contains fles in LilyPond format
• ‘scm/’ - contains fles in Scheme format
Let’s begin by looking at some fles in ‘ly/’. Open ‘ly/property-init.ly’ in a text editor.
The one you normally use for .ly fles will be fne. This fle contains the defnitions of all the
standard LilyPond predefned commands, such as \stemUp and \slurDotted. You will see that
these are nothing more than defnitions of variables containing one or a group of \override
commands. For example, /tieDotted is defned to be:
tieDotted = {
\override Tie #'dash-period = #0.75
\override Tie #'dash-fraction = #0.1
}
If you do not like the default values these predefned commands can be redefned easily, just
like any other variable, at the head of your input fle.
The following are the most useful fles to be found in ‘ly/’:
Filename Contents
‘ly/engraver-init.ly’ Defnitions of engraver Contexts
‘ly/paper-defaults-init.ly’ Specifcations of paper-related defaults
‘ly/performer-init.ly’ Defnitions of performer Contexts
‘ly/property-init.ly’ Defnitions of all common predefned commands
‘ly/spanner-init.ly’ Defnitions of spanner-related predefned commands
Other settings (such as the defnitions of markup commands) are stored as .scm (Scheme)
fles. The Scheme programming language is used to provide a programmable interface into
LilyPond internal operation. Further explanation of these fles is currently outside the scope of
this manual, as a knowledge of the Scheme language is required. Users should be warned that a
substantial amount of technical knowledge or time is required to understand Scheme and these
fles (see Appendix B [Scheme tutorial], page 173).
If you have this knowledge, the Scheme fles which may be of interest are:
Filename Contents
‘scm/auto-beam.scm’ Sub-beaming defaults
‘scm/define-grobs.scm’ Default settings for grob properties
‘scm/define-markup-commands.scm’ Specify all markup commands
‘scm/midi.scm’ Default settings for MIDI output
‘scm/output-lib.scm’ Settings that afect appearance of frets, colors, acciden-
tals, bar lines, etc
‘scm/parser-clef.scm’ Defnitions of supported clefs
‘scm/script.scm’ Default settings for articulations
4.6.4 Avoiding tweaks with slower processing
LilyPond can perform extra checks while it processes input fles. These checks will take extra
time to perform, but fewer manual tweaks may be required to obtain an acceptable result. If a
text script or part of the lyrics extends over the margins these checks will compress that line of
the score just enough to ft within the margins.
To be efective under all circumstances these checks must be enabled by placing the overrides
in a Score \with block, rather than in-line in music, as follows:
\new Score \with {
% Makes sure text scripts and lyrics are within the paper margins
\override PaperColumn #'keep-inside-line = ##t
Chapter 4: Tweaking output 129
\override NonMusicalPaperColumn #'keep-inside-line = ##t
} {
..
}
4.6.5 Advanced tweaks with Scheme
Although many things are possible with the \override and \tweak commands, an even more
powerful way of modifying the action of LilyPond is available through a programmable interface
to the LilyPond internal operation. Code written in the Scheme programming language can
be incorporated directly in the internal operation of LilyPond. Of course, at least a basic
knowledge of programming in Scheme is required to do this, and an introduction is provided in
the Appendix B [Scheme tutorial], page 173.
As an illustration of one of the many possibilities, instead of setting a property to a constant
it can be set to a Scheme procedure which is then called whenever that property is accessed by
LilyPond. The property can then be set dynamically to a value determined by the procedure at
the time it is called. In this example we color the note head in accordance with its position on
the staf.
#(define (color-notehead grob)
"Color the notehead according to its position on the staff."
(let ((mod-position (modulo (ly:grob-property grob 'staff-position) 7)))
(case mod-position
;; Return rainbow colors
((1) (x11-color 'red )) ; for C
((2) (x11-color 'orange )) ; for D
((3) (x11-color 'yellow )) ; for E
((4) (x11-color 'green )) ; for F
((5) (x11-color 'blue )) ; for G
((6) (x11-color 'purple )) ; for A
((0) (x11-color 'violet )) ; for B
)
)
)
\relative c' {
% Arrange to obtain color from color-notehead procedure
\override NoteHead #'color = #color-notehead
c2 c' |
b4 g8 a b4 c |
c,2 a' |
g1 |
}
\addlyrics {
Some -- where o -- ver the Rain -- bow, way up high,
}

up

way

high, o

where

Some

bow,

Rain

the

ver

Chapter 4: Tweaking output 130
Further examples showing the use of these programmable interfaces can be found in
Section B.1 [Tweaking with Scheme], page 174.
Chapter 5: Working on LilyPond projects 131
5 Working on LilyPond projects
This section explains how to solve or avoid certain common problems. If you have programming
experience, many of these tips may seem obvious, but it is still advisable to read this chapter.
5.1 Suggestions for writing LilyPond input fles
Now you’re ready to begin writing larger LilyPond input fles – not just the little examples in
the tutorial, but whole pieces. But how should you go about doing it?
As long as LilyPond can understand your input fles and produce the output that you want, it
doesn’t matter what your input fles look like. However, there are a few other things to consider
when writing LilyPond input fles.
• What if you make a mistake? The structure of a LilyPond fle can make certain errors easier
(or harder) to fnd.
• What if you want to share your input fles with somebody else? In fact, what if you want
to alter your own input fles in a few years? Some LilyPond input fles are understandable
at frst glance; others may leave you scratching your head for an hour.
• What if you want to upgrade your LilyPond fle for use with a later version of LilyPond?
The input syntax changes occasionally as LilyPond improves. Most changes can be done au-
tomatically with convert-ly, but some changes might require manual assistance. LilyPond
input fles can be structured in order to be easier (or harder) to update.
5.1.1 General suggestions
Here are a few suggestions that can help you to avoid or fx problems:
• Include \version numbers in every fle. Note that all templates contain \version infor-
mation. We highly recommend that you always include the \version, no matter how small
your fle is. Speaking from personal experience, it’s quite frustrating to try to remember
which version of LilyPond you were using a few years ago. convert-ly requires you to
declare which version of LilyPond you used.
• Include checks: Section “Bar and bar number checks” in Notation Reference, Section “Oc-
tave checks” in Notation Reference. If you include checks every so often, then if you make a
mistake, you can pinpoint it quicker. How often is ‘every so often’? It depends on the com-
plexity of the music. For very simple music, perhaps just once or twice. For very complex
music, perhaps every bar.
• One bar per line of text. If there is anything complicated, either in the music itself or in
the output you desire, it’s often good to write only one bar per line. Saving screen space
by cramming eight bars per line just isn’t worth it if you have to ‘debug’ your input fles.
• Comment your input fles. Use either bar numbers (every so often) or references to musical
themes (‘second theme in violins,’ ‘fourth variation,’ etc.). You may not need comments
when you’re writing the piece for the frst time, but if you want to go back to change
something two or three years later, or if you pass the source over to a friend, it will be much
more challenging to determine your intentions or how your fle is structured if you didn’t
comment the fle.
• Indent your braces. A lot of problems are caused by an imbalance in the number of { and
}.
• Explicitly add durations at the beginnings of sections and variables. If you specify c4 d e
at the beginning of a phrase (instead of just c d e) you can save yourself some problems if
you rearrange your music later.
• Separate tweaks from music defnitions. See Section 5.1.4 [Saving typing with variables and
functions], page 133, and Section 5.1.5 [Style sheets], page 134.
Chapter 5: Working on LilyPond projects 132
5.1.2 Typesetting existing music
If you are entering music from an existing score (i.e., typesetting a piece of existing sheet music),
• Enter one manuscript (the physical copy) system at a time (but still only one bar per line
of text), and check each system when you fnish it. You may use the showLastLength
or showFirstLength properties to speed up processing – see Section “Skipping corrected
music” in Notation Reference.
• Defne mBreak = { \break } and insert \mBreak in the input fle whenever the manuscript
has a line break. This makes it much easier to compare the LilyPond music to the original
music. When you are fnished proofreading your score, you may defne mBreak = { } to
remove all those line breaks. This will allow LilyPond to place line breaks wherever it feels
are best.
• When entering a part for a transposing instrument into a variable, it is recommended that
the notes are wrapped in
\transpose c natural-pitch {...}
(where natural-pitch is the open pitch of the instrument) so that the music in the variable
is efectively in C. You can transpose it back again when the variable is used, if required, but
you might not want to (e.g., when printing a score in concert pitch, converting a trombone
part from treble to bass clef, etc.) Mistakes in transpositions are less likely if all the music
in variables is at a consistent pitch.
Also, only ever transpose to/from C. That means that the only other keys you will use are
the natural pitches of the instruments - bes for a B-fat trumpet, aes for an A-fat clarinet,
etc.
5.1.3 Large projects
When working on a large project, having a clear structure to your lilypond input fles becomes
vital.
• Use an variable for each voice, with a minimum of structure inside the defnition. The
structure of the \score section is the most likely thing to change; the violin defnition is
extremely unlikely to change in a new version of LilyPond.
violin = \relative c'' {
g4 c'8. e16
}
...
\score {
\new GrandStaff {
\new Staff {
\violin
}
}
}
• Separate tweaks from music defnitions. This point was made in previously, but for large
projects it is absolutely vital. We might need to change the defnition of fthenp, but then
we only need to do this once, and we can still avoid touching anything inside violin.
fthenp = _\markup{
\dynamic f \italic \small { 2nd } \hspace #0.1 \dynamic p }
violin = \relative c'' {
g4\fthenp c'8. e16
}
Chapter 5: Working on LilyPond projects 133
5.1.4 Saving typing with variables and functions
By this point, you’ve seen this kind of thing:
hornNotes = \relative c'' { c4 b dis c }
\score {
{
\hornNotes
}
}

You may even realize that this could be useful in minimalist music:
fragmentA = \relative c'' { a4 a8. b16 }
fragmentB = \relative c'' { a8. gis16 ees4 }
violin = \new Staff { \fragmentA \fragmentA \fragmentB \fragmentA }
\score {
{
\violin
}
}




However, you can also use these variables (also known as variables, macros, or (user-defned)
command) for tweaks:
dolce = \markup{ \italic \bold dolce }
padText = { \once \override TextScript #'padding = #5.0 }
fthenp=_\markup{ \dynamic f \italic \small { 2nd } \hspace #0.1 \dynamic p }
violin = \relative c'' {
\repeat volta 2 {
c4._\dolce b8 a8 g a b |
\padText
c4.^"hi there!" d8 e' f g d |
c,4.\fthenp b8 c4 c-. |
}
}
\score {
{
\violin
}
\layout{ragged-right=##t}
}
Chapter 5: Working on LilyPond projects 134

f 2nd p

hi there!

dolce

These variables are obviously useful for saving typing. But they’re worth considering even if
you only use them once – they reduce complexity. Let’s look at the previous example without
any variables. It’s a lot harder to read, especially the last line.
violin = \relative c'' {
\repeat volta 2 {
c4._\markup{ \italic \bold dolce } b8 a8 g a b |
\once \override TextScript #'padding = #5.0
c4.^"hi there!" d8 e' f g d |
c,4.\markup{ \dynamic f \italic \small { 2nd }
\hspace #0.1 \dynamic p } b8 c4 c-. |
}
}
So far we’ve seen static substitution – when LilyPond sees \padText, it replaces it with the
stuf that we’ve defned it to be (ie the stuf to the right of padtext=).
LilyPond can handle non-static substitution, too (you can think of these as functions).
padText =
#(define-music-function (parser location padding) (number?)
#{
\once \override TextScript #'padding = #$padding
#})
\relative c''' {
c4^"piu mosso" b a b
\padText #1.8
c4^"piu mosso" d e f
\padText #2.6
c4^"piu mosso" fis a g
}

piu mosso

piu mosso

piu mosso

Using variables is also a good way to reduce work if the LilyPond input syntax changes
(see Section 5.2.1 [Updating old input fles], page 138). If you have a single defnition (such as
\dolce) for all your input fles (see Section 5.1.5 [Style sheets], page 134), then if the syntax
changes, you only need to update your single \dolce defnition, instead of making changes
throughout every .ly fle.
5.1.5 Style sheets
The output that LilyPond produces can be heavily modifed; see Chapter 4 [Tweaking output],
page 80, for details. But what if you have many input fles that you want to apply your tweaks
to? Or what if you simply want to separate your tweaks from the actual music? This is quite
easy to do.
Chapter 5: Working on LilyPond projects 135
Let’s look at an example. Don’t worry if you don’t understand the parts with all the #().
This is explained in Section 4.6.5 [Advanced tweaks with Scheme], page 129.
mpdolce = #(make-dynamic-script (markup #:hspace 1 #:translate (cons 5 0)
#:line(#:dynamic "mp" #:text #:italic "dolce" )))
tempoMark = #(define-music-function (parser location markp) (string?)
#{
\once \override Score . RehearsalMark #'self-alignment-X = #left
\once \override Score . RehearsalMark #'extra-spacing-width = #'(+inf.0 . -inf.0)
\mark \markup { \bold $markp }
#})
\relative c'' {
\tempo 4=50
a4.\mpdolce d8 cis4--\glissando a | b4 bes a2
\tempoMark "Poco piu mosso"
cis4.\< d8 e4 fis | g8(\! fis)-. e( d)-. cis2
}
,

,
/
,
, ,
,
·

,
.
,
,
, ,
,
,
,
·
,
,

,

,
Poco piu mosso
,
,
mp dolce

= 50

,
.
There are some problems with overlapping output; we’ll fx those using the techniques in
Section 4.5.1 [Moving objects], page 109. But let’s also do something about the mpdolce and
tempoMark defnitions. They produce the output we desire, but we might want to use them
in another piece. We could simply copy-and-paste them at the top of every fle, but that’s an
annoyance. It also leaves those defnitions in our input fles, and I personally fnd all the #()
somewhat ugly. Let’s hide them in another fle:
%%% save this to a file called "definitions.ly"
mpdolce = #(make-dynamic-script (markup #:hspace 1 #:translate (cons 5 0)
#:line(#:dynamic "mp" #:text #:italic "dolce" )))
tempoMark = #(define-music-function (parser location markp) (string?)
#{
\once \override Score . RehearsalMark #'self-alignment-X = #left
\once \override Score . RehearsalMark #'extra-spacing-width = #'(+inf.0 . -inf.0)
\mark \markup { \bold $markp }
#})
Now let’s modify our music (let’s save this fle as ‘"music.ly"’).
\include "definitions.ly"
\relative c'' {
\tempo 4=50
a4.\mpdolce d8 cis4--\glissando a | b4 bes a2
\once \override Score.RehearsalMark #'padding = #2.0
\tempoMark "Poco piu mosso"
cis4.\< d8 e4 fis | g8(\! fis)-. e( d)-. cis2
}
Chapter 5: Working on LilyPond projects 136
,
,
·
,
/
,

,
.
,
,
,

,
,

,
,
,
,
·
,

,
Poco piu mosso
,
mp dolce
,
, ,

= 50
.
,
That looks better, but let’s make a few changes. The glissando is hard to see, so let’s make it
thicker and closer to the note heads. Let’s put the metronome marking above the clef, instead
of over the frst note. And fnally, my composition professor hates ‘C’ time signatures, so we’d
better make that ‘4/4’ instead.
Don’t change ‘music.ly’, though. Replace our ‘definitions.ly’ with this:
%%% definitions.ly
mpdolce = #(make-dynamic-script (markup #:hspace 1 #:translate (cons 5 0)
#:line( #:dynamic "mp" #:text #:italic "dolce" )))
tempoMark = #(define-music-function (parser location markp) (string?)
#{
\once \override Score . RehearsalMark #'self-alignment-X = #left
\once \override Score . RehearsalMark #'extra-spacing-width = #'(+inf.0 . -inf.0)
\mark \markup { \bold $markp }
#})
\layout{
\context { \Score
\override MetronomeMark #'extra-offset = #'(-9 . 0)
\override MetronomeMark #'padding = #'3
}
\context { \Staff
\override TimeSignature #'style = #'numbered
}
\context { \Voice
\override Glissando #'thickness = #3
\override Glissando #'gap = #0.1
}
}

= 50
·
,
,
,
,

,
,
·
,

,
,

,
mp dolce
,
,
,
/
,

, ,
,
Poco piu mosso
,
.
4
4
,
,
.
That looks nicer! But now suppose that I want to publish this piece. My composition
professor doesn’t like ‘C’ time signatures, but I’m somewhat fond of them. Let’s copy the
current ‘definitions.ly’ to ‘web-publish.ly’ and modify that. Since this music is aimed at
producing a pdf which will be displayed on the screen, we’ll also increase the overall size of the
output.
%%% definitions.ly
mpdolce = #(make-dynamic-script (markup #:hspace 1 #:translate (cons 5 0)
#:line( #:dynamic "mp" #:text #:italic "dolce" )))
tempoMark = #(define-music-function (parser location markp) (string?)
#{
\once \override Score . RehearsalMark #'self-alignment-X = #left
\once \override Score . RehearsalMark #'extra-spacing-width = #'(+inf.0 . -inf.0)
Chapter 5: Working on LilyPond projects 137
\mark \markup { \bold $markp }
#})
#(set-global-staff-size 23)
\layout{
\context { \Score
\override MetronomeMark #'extra-offset = #'(-9 . 0)
\override MetronomeMark #'padding = #'3
}
\context { \Staff
}
\context { \Voice
\override Glissando #'thickness = #3
\override Glissando #'gap = #0.1
}
}
·
,
,
Poco piu mosso
,
,
/
, ,
,
,

,
·
,

= 50
mp dolce
, .
, , ,
,

4

Now in our music, I simply replace \include "definitions.ly" with \include
"web-publish.ly". Of course, we could make this even more convenient. We could make
a ‘definitions.ly’ fle which contains only the defnitions of mpdolce and tempoMark,
a ‘web-publish.ly’ fle which contains only the \layout section listed above, and a
‘university.ly’ fle which contains only the tweaks to produce the output that my professor
prefers. The top of ‘music.ly’ would then look like this:
\include "definitions.ly"
%%% Only uncomment one of these two lines!
\include "web-publish.ly"
%\include "university.ly"
This approach can be useful even if you are only producing one set of parts. I use half
a dozen diferent ‘style sheet’ fles for my projects. I begin every music fle with \include
"../global.ly", which contains
%%% global.ly
\version "2.12.3"
#(ly:set-option 'point-and-click #f)
\include "../init/init-defs.ly"
\include "../init/init-layout.ly"
\include "../init/init-headers.ly"
\include "../init/init-paper.ly"
Chapter 5: Working on LilyPond projects 138
5.2 When things don’t work
5.2.1 Updating old input fles
The LilyPond input syntax occasionally changes. As LilyPond itself improves, the syntax (input
language) is modifed accordingly. Sometimes these changes are made to make the input easier
to read and write or sometimes the changes are made to accommodate new features of LilyPond.
LilyPond comes with a fle that makes this updating easier: convert-ly. For details about
how to run this program, see Section “Updating fles with convert-ly” in Application Usage.
Unfortunately, convert-ly cannot handle all input changes. It takes care of simple search-
and-replace changes (such as raggedright becoming ragged-right), but some changes are too
complicated. The syntax changes that convert-ly cannot handle are listed in Section “Updating
fles with convert-ly” in Application Usage.
For example, in LilyPond 2.4 and earlier, accents and non-English letters were entered using
LaTeX – for example, No\"el (this would print the French word for ‘Christmas’). In LilyPond 2.6
and above, the special ¨e must be entered directly into the LilyPond fle as an UTF-8 character.
convert-ly cannot change all the LaTeX special characters into UTF-8 characters; you must
manually update your old LilyPond input fles.
5.2.2 Troubleshooting (taking it all apart)
Sooner or later, you will write a fle that LilyPond cannot compile. The messages that LilyPond
gives may help you fnd the error, but in many cases you need to do some investigation to
determine the source of the problem.
The most powerful tools for this purpose are the single line comment (indicated by %) and
the block comment (indicated by %{ ... %}). If you don’t know where a problem is, start
commenting out huge portions of your input fle. After you comment out a section, try compiling
the fle again. If it works, then the problem must exist in the portion you just commented. If it
doesn’t work, then keep on commenting out material until you have something that works.
In an extreme case, you might end up with only
\score {
<<
% \melody
% \harmony
% \bass
>>
\layout{}
}
(in other words, a fle without any music)
If that happens, don’t give up. Uncomment a bit – say, the bass part – and see if it works.
If it doesn’t work, then comment out all of the bass music (but leave \bass in the \score
uncommented.
bass = \relative c' {
%{
c4 c c c
d d d d
%}
}
Now start slowly uncommenting more and more of the bass part until you fnd the problem
line.
Another very useful debugging technique is constructing Section 5.2.3 [Minimal examples],
page 139.
Chapter 5: Working on LilyPond projects 139
5.2.3 Minimal examples
A minimal example is an example which is as small as possible. These examples are much easier
to understand than long examples. Minimal examples are used for
• Bug reports
• Sending a help request to mailing lists
• Adding an example to the LilyPond Snippet Repository
To construct an example which is as small as possible, the rule is quite simple: remove
anything which is not necessary. When trying to remove unnecessary parts of a fle, it is a very
good idea to comment out lines instead of deleting them. That way, if you discover that you
actually do need some lines, you can uncomment them, instead of typing them in from scratch.
There are two exceptions to the “as small as possible” rule:
• Include the \version number.
• If possible, use \paper{ ragged-right=##t } at the top of your example.
The whole point of a minimal example is to make it easy to read:
• Avoid using complicated notes, keys, or time signatures, unless you wish to demonstrate
something is about the behavior of those items.
• Do not use \override commands unless that is the point of the example.
5.3 Scores and parts
TODO: this is really old stuf from the really old tutorial. Rewrite, fx, etc. Or maybe delete
entirely. -gp Include section on tags -td and then move to section 5. Working ... -td
In orchestral music, all notes are printed twice. Once in a part for the musicians, and once in
a full score for the conductor. Variables can be used to avoid double work. The music is entered
once, and stored in a variable. The contents of that variable is then used to generate both the
part and the full score.
It is convenient to defne the notes in a special fle. For example, suppose that the fle
‘horn-music.ly’ contains the following part of a horn/bassoon duo
hornNotes = \relative c {
\time 2/4
r4 f8 a cis4 f e d
}
Then, an individual part is made by putting the following in a fle
\include "horn-music.ly"
\header {
instrument = "Horn in F"
}
{
\transpose f c' \hornNotes
}
The line
\include "horn-music.ly"
substitutes the contents of ‘horn-music.ly’ at this position in the fle, so hornNotes is defned
afterwards. The command \transpose f c' indicates that the argument, being \hornNotes,
should be transposed by a ffth upwards. Sounding f is denoted by notated c', which corresponds
with the tuning of a normal French Horn in F. The transposition can be seen in the following
output
Chapter 5: Working on LilyPond projects 140

4
2

In ensemble pieces, one of the voices often does not play for many measures. This is denoted
by a special rest, the multi-measure rest. It is entered with a capital R followed by a duration
(1 for a whole note, 2 for a half note, etc.). By multiplying the duration, longer rests can be
constructed. For example, this rest takes 3 measures in 2/4 time
R2*3
When printing the part, multi-rests must be condensed. This is done by setting a run-time
variable
\set Score.skipBars = ##t
This command sets the property skipBars in the Score context to true (##t). Prepending the
rest and this option to the music above, leads to the following result

4
2

3

The score is made by combining all of the music together. Assuming that the other voice is
in bassoonNotes in the fle ‘bassoon-music.ly’, a score is made with
\include "bassoon-music.ly"
\include "horn-music.ly"
<<
\new Staff \hornNotes
\new Staff \bassoonNotes
>>
leading to

4
2

4
2

Appendix A: Templates 141
Appendix A Templates
This section of the manual contains templates with the LilyPond score already set up for you.
Just add notes, run LilyPond, and enjoy beautiful printed scores!
A.1 Single staf
A.1.1 Notes only
This very simple template gives you a staf with notes, suitable for a solo instrument or a melodic
fragment. Cut and paste this into a fle, add notes, and you’re fnished!
\version "2.12.3"
melody = \relative c' {
\clef treble
\key c \major
\time 4/4
a4 b c d
}
\score {
\new Staff \melody
\layout { }
\midi { }
}

A.1.2 Notes and lyrics
This small template demonstrates a simple melody with lyrics. Cut and paste, add notes, then
words for the lyrics. This example turns of automatic beaming, which is common for vocal
parts. To use automatic beaming, change or comment out the relevant line.
\version "2.12.3"
melody = \relative c' {
\clef treble
\key c \major
\time 4/4
a4 b c d
}
text = \lyricmode {
Aaa Bee Cee Dee
}
\score{
<<
\new Voice = "one" {
Appendix A: Templates 142
\autoBeamOff
\melody
}
\new Lyrics \lyricsto "one" \text
>>
\layout { }
\midi { }
}

Dee

Bee Aaa Cee

A.1.3 Notes and chords
Want to prepare a lead sheet with a melody and chords? Look no further!
melody = \relative c' {
\clef treble
\key c \major
\time 4/4
f4 e8[ c] d4 g
a2 ~ a
}
harmonies = \chordmode {
c4:m f:min7 g:maj c:aug
d2:dim b:sus
}
\score {
<<
\new ChordNames {
\set chordChanges = ##t
\harmonies
}
\new Staff \melody
>>
\layout{ }
\midi { }
}
Fm
7

D
o

C+ G

Cm

B
Appendix A: Templates 143
A.1.4 Notes, lyrics, and chords.
This template allows the preparation of a song with melody, words, and chords.
melody = \relative c' {
\clef treble
\key c \major
\time 4/4
a4 b c d
}
text = \lyricmode {
Aaa Bee Cee Dee
}
harmonies = \chordmode {
a2 c
}
\score {
<<
\new ChordNames {
\set chordChanges = ##t
\harmonies
}
\new Voice = "one" { \autoBeamOff \melody }
\new Lyrics \lyricsto "one" \text
>>
\layout { }
\midi { }
}
C A

Dee

Aaa

Bee Cee
A.2 Piano templates
A.2.1 Solo piano
Here is a simple piano staf with some notes.
upper = \relative c'' {
\clef treble
\key c \major
\time 4/4
a4 b c d
}
Appendix A: Templates 144
lower = \relative c {
\clef bass
\key c \major
\time 4/4
a2 c
}
\score {
\new PianoStaff <<
\set PianoStaff.instrumentName = #"Piano "
\new Staff = "upper" \upper
\new Staff = "lower" \lower
>>
\layout { }
\midi { }
}

Piano

A.2.2 Piano and melody with lyrics
Here is a typical song format: one staf with the melody and lyrics, with piano accompaniment
underneath.
melody = \relative c'' {
\clef treble
\key c \major
\time 4/4
a b c d
}
text = \lyricmode {
Aaa Bee Cee Dee
}
upper = \relative c'' {
\clef treble
\key c \major
\time 4/4
a4 b c d
}
lower = \relative c {
\clef bass
Appendix A: Templates 145
\key c \major
\time 4/4
a2 c
}
\score {
<<
\new Voice = "mel" { \autoBeamOff \melody }
\new Lyrics \lyricsto mel \text
\new PianoStaff <<
\new Staff = "upper" \upper
\new Staff = "lower" \lower
>>
>>
\layout {
\context { \RemoveEmptyStaffContext }
}
\midi { }
}

Bee

Aaa

Cee

Dee

A.2.3 Piano centered lyrics
Instead of having a full staf for the melody and lyrics, lyrics can be centered between the staves
of a piano staf.
upper = \relative c'' {
\clef treble
\key c \major
\time 4/4
a4 b c d
}
lower = \relative c {
\clef bass
\key c \major
\time 4/4
a2 c
Appendix A: Templates 146
}
text = \lyricmode {
Aaa Bee Cee Dee
}
\score {
\new GrandStaff <<
\new Staff = upper { \new Voice = "singer" \upper }
\new Lyrics \lyricsto "singer" \text
\new Staff = lower { \lower }
>>
\layout {
\context {
\GrandStaff
\accepts "Lyrics"
}
\context {
\Lyrics
\consists "Bar_engraver"
}
}
\midi { }
}

Aaa

Bee Dee

Cee

A.2.4 Piano centered dynamics
Many piano scores have the dynamics centered between the two staves. This requires a bit of
tweaking to implement, but since the template is right here, you don’t have to do the tweaking
yourself.
global = {
\key c \major
\time 4/4
}
upper = \relative c'' {
\clef treble
a4 b c d
}
lower = \relative c {
\clef bass
a2 c
Appendix A: Templates 147
}
dynamics = {
s2\fff\> s4 s\!\pp
}
pedal = {
s2\sustainOn s\sustainOff
}
\score {
\new PianoStaff = "PianoStaff_pf" <<
\new Staff = "Staff_pfUpper" << \global \upper >>
\new Dynamics = "Dynamics_pf" \dynamics
\new Staff = "Staff_pfLower" << \global \lower >>
\new Dynamics = "pedal" \pedal
>>
\layout {
% define Dynamics context
\context {
\type "Engraver_group"
\name Dynamics
\alias Voice
\consists "Output_property_engraver"
\consists "Piano_pedal_engraver"
\consists "Script_engraver"
\consists "New_dynamic_engraver"
\consists "Dynamic_align_engraver"
\consists "Text_engraver"
\consists "Skip_event_swallow_translator"
\consists "Axis_group_engraver"
pedalSustainStrings = #'("Ped." "*Ped." "*")
pedalUnaCordaStrings = #'("una corda" "" "tre corde")
\override DynamicLineSpanner #'Y-offset = #0
\override TextScript #'font-size = #2
\override TextScript #'font-shape = #'italic
\override VerticalAxisGroup #'minimum-Y-extent = #'(-1 . 1)
}
% modify PianoStaff context to accept Dynamics context
\context {
\PianoStaff
\accepts Dynamics
}
}
}
\score {
\new PianoStaff = "PianoStaff_pf" <<
\new Staff = "Staff_pfUpper" << \global \upper \dynamics \pedal >>
\new Staff = "Staff_pfLower" << \global \lower \dynamics \pedal >>
Appendix A: Templates 148
>>
\midi { }
}

pp

fff

A.3 String quartet
A.3.1 String quartet
This template demonstrates a simple string quartet. It also uses a \global section for time and
key signatures
global= {
\time 4/4
\key c \major
}
violinOne = \new Voice \relative c'' {
\set Staff.instrumentName = #"Violin 1 "
c2 d
e1
\bar "|."
}
violinTwo = \new Voice \relative c'' {
\set Staff.instrumentName = #"Violin 2 "
g2 f
e1
\bar "|."
}
viola = \new Voice \relative c' {
\set Staff.instrumentName = #"Viola "
\clef alto
e2 d
c1
\bar "|."
}
Appendix A: Templates 149
cello = \new Voice \relative c' {
\set Staff.instrumentName = #"Cello "
\clef bass
c2 b
a1
\bar "|."
}
\score {
\new StaffGroup <<
\new Staff << \global \violinOne >>
\new Staff << \global \violinTwo >>
\new Staff << \global \viola >>
\new Staff << \global \cello >>
>>
\layout { }
\midi { }
}

Cello
Viola
Violin 1
Violin 2

A.3.2 String quartet parts
The "String quartet template" snippet produces a nice string quartet, but what if you needed
to print parts? This new template demonstrates how to use the \tag feature to easily split a
piece into individual parts.
You need to split this template into separate fles; the flenames are contained in comments
at the beginning of each fle. piece.ly contains all the music defnitions. The other fles –
score.ly, vn1.ly, vn2.ly, vla.ly, and vlc.ly – produce the appropriate part.
Do not forget to remove specifed comments when using separate fles!
%%%%% piece.ly
%%%%% (This is the global definitions file)
global= {
\time 4/4
\key c \major
Appendix A: Templates 150
}
Violinone = \new Voice { \relative c''{
\set Staff.instrumentName = #"Violin 1 "
c2 d e1
\bar "|." }} %*********************************
Violintwo = \new Voice { \relative c''{
\set Staff.instrumentName = #"Violin 2 "
g2 f e1
\bar "|." }} %*********************************
Viola = \new Voice { \relative c' {
\set Staff.instrumentName = #"Viola "
\clef alto
e2 d c1
\bar "|." }} %*********************************
Cello = \new Voice { \relative c' {
\set Staff.instrumentName = #"Cello "
\clef bass
c2 b a1
\bar "|."}} %**********************************
music = {
<<
\tag #'score \tag #'vn1 \new Staff { << \global \Violinone >> }
\tag #'score \tag #'vn2 \new Staff { << \global \Violintwo>> }
\tag #'score \tag #'vla \new Staff { << \global \Viola>> }
\tag #'score \tag #'vlc \new Staff { << \global \Cello>> }
>>
}
%%% These are the other files you need to save on your computer
%%%%% score.ly
%%%%% (This is the main file)
%\include "piece.ly" %%% uncomment this line when using a separate file
#(set-global-staff-size 14)
\score {
\new StaffGroup \keepWithTag #'score \music
\layout { }
\midi { }
}
Appendix A: Templates 151
%{ Uncomment this block when using separate files
%%%%% vn1.ly
%%%%% (This is the Violin 1 part file)
\include "piece.ly"
\score {
\keepWithTag #'vn1 \music
\layout { }
}
%%%%% vn2.ly
%%%%% (This is the Violin 2 part file)
\include "piece.ly"
\score {
\keepWithTag #'vn2 \music
\layout { }
}
%%%%% vla.ly
%%%%% (This is the Viola part file)
\include "piece.ly"
\score {
\keepWithTag #'vla \music
\layout { }
}
%%%%% vlc.ly
%%%%% (This is the Cello part file)
\include "piece.ly"
\score {
\keepWithTag #'vlc \music
\layout { }
}
%}
Appendix A: Templates 152

Cello
Viola
Violin 2
Violin 1

A.4 Vocal ensembles
A.4.1 SATB vocal score
Here is a standard four-part SATB vocal score. With larger ensembles, it is often useful to include
a section which is included in all parts. For example, the time signature and key signature are
almost always the same for all parts. Like in the "Hymn" template, the four voices are regrouped
on only two staves.
global = {
\key c \major
\time 4/4
}
sopMusic = \relative c'' {
c4 c c8[( b)] c4
}
sopWords = \lyricmode {
hi hi hi hi
}
altoMusic = \relative c' {
e4 f d e
}
altoWords = \lyricmode {
ha ha ha ha
}
tenorMusic = \relative c' {
g4 a f g
}
tenorWords = \lyricmode {
hu hu hu hu
}
bassMusic = \relative c {
c4 c g c
}
bassWords = \lyricmode {
ho ho ho ho
}
\score {
\new ChoirStaff <<
\new Lyrics = sopranos { s1 }
Appendix A: Templates 153
\new Staff = women <<
\new Voice = "sopranos" {
\voiceOne
<< \global \sopMusic >>
}
\new Voice = "altos" {
\voiceTwo
<< \global \altoMusic >>
}
>>
\new Lyrics = "altos" { s1 }
\new Lyrics = "tenors" { s1 }
\new Staff = men <<
\clef bass
\new Voice = "tenors" {
\voiceOne
<< \global \tenorMusic >>
}
\new Voice = "basses" {
\voiceTwo << \global \bassMusic >>
}
>>
\new Lyrics = basses { s1 }
\context Lyrics = sopranos \lyricsto sopranos \sopWords
\context Lyrics = altos \lyricsto altos \altoWords
\context Lyrics = tenors \lyricsto tenors \tenorWords
\context Lyrics = basses \lyricsto basses \bassWords
>>
\layout {
\context {
% a little smaller so lyrics
% can be closer to the staff
\Staff
\override VerticalAxisGroup #'minimum-Y-extent = #'(-3 . 3)
}
}
}
ha
hi

ha
hu

ho

hi
hu

ho ho

hu
ha

ho

hu
ha

hi

hi
Appendix A: Templates 154
A.4.2 SATB vocal score and automatic piano reduction
This template adds an automatic piano reduction to the standard SATB vocal score demon-
strated in "Vocal ensemble template". This demonstrates one of the strengths of LilyPond –
you can use a music defnition more than once. If any changes are made to the vocal notes (say,
tenorMusic), then the changes will also apply to the piano reduction.
global = {
\key c \major
\time 4/4
}
sopMusic = \relative c'' {
c4 c c8[( b)] c4
}
sopWords = \lyricmode {
hi hi hi hi
}
altoMusic = \relative c' {
e4 f d e
}
altoWords =\lyricmode {
ha ha ha ha
}
tenorMusic = \relative c' {
g4 a f g
}
tenorWords = \lyricmode {
hu hu hu hu
}
bassMusic = \relative c {
c4 c g c
}
bassWords = \lyricmode {
ho ho ho ho
}
\score {
<<
\new ChoirStaff <<
\new Lyrics = sopranos { s1 }
\new Staff = women <<
\new Voice = sopranos { \voiceOne << \global \sopMusic >> }
\new Voice = altos { \voiceTwo << \global \altoMusic >> }
>>
\new Lyrics = altos { s1 }
\new Lyrics = tenors { s1 }
\new Staff = men <<
\clef bass
\new Voice = tenors { \voiceOne <<\global \tenorMusic >> }
Appendix A: Templates 155
\new Voice = basses { \voiceTwo <<\global \bassMusic >> }
>>
\new Lyrics = basses { s1 }
\context Lyrics = sopranos \lyricsto sopranos \sopWords
\context Lyrics = altos \lyricsto altos \altoWords
\context Lyrics = tenors \lyricsto tenors \tenorWords
\context Lyrics = basses \lyricsto basses \bassWords
>>
\new PianoStaff <<
\new Staff <<
\set Staff.printPartCombineTexts = ##f
\partcombine
<< \global \sopMusic >>
<< \global \altoMusic >>
>>
\new Staff <<
\clef bass
\set Staff.printPartCombineTexts = ##f
\partcombine
<< \global \tenorMusic >>
<< \global \bassMusic >>
>>
>>
>>
\layout {
\context {
% a little smaller so lyrics
% can be closer to the staff
\Staff
\override VerticalAxisGroup #'minimum-Y-extent = #'(-3 . 3)
}
}
}
Appendix A: Templates 156

ho

ho

hi

ha
hu

ha

hi

ho

hu

hi

ha

hu

hi

ha
hu

ho

A.4.3 SATB with aligned contexts
This template is basically the same as the simple "Vocal ensemble" template, with the exception
that here all the lyrics lines are placed using alignAboveContext and alignBelowContext.
global = {
\key c \major
\time 4/4
}
sopMusic = \relative c'' {
c4 c c8[( b)] c4
}
sopWords = \lyricmode {
hi hi hi hi
}
altoMusic = \relative c' {
e4 f d e
}
altoWords = \lyricmode {
ha ha ha ha
}
tenorMusic = \relative c' {
g4 a f g
}
tenorWords = \lyricmode {
hu hu hu hu
}
bassMusic = \relative c {
c4 c g c
}
bassWords = \lyricmode {
ho ho ho ho
Appendix A: Templates 157
}
\score {
\new ChoirStaff <<
\new Staff = women <<
\new Voice = "sopranos" { \voiceOne << \global \sopMusic >> }
\new Voice = "altos" { \voiceTwo << \global \altoMusic >> }
>>
\new Lyrics \with { alignAboveContext = women } \lyricsto sopranos \sopWords
\new Lyrics \with { alignBelowContext = women } \lyricsto altos \altoWords
% we could remove the line about this with the line below, since we want
% the alto lyrics to be below the alto Voice anyway.
% \new Lyrics \lyricsto altos \altoWords
\new Staff = men <<
\clef bass
\new Voice = "tenors" { \voiceOne << \global \tenorMusic >> }
\new Voice = "basses" { \voiceTwo << \global \bassMusic >> }
>>
\new Lyrics \with { alignAboveContext = men } \lyricsto tenors \tenorWords
\new Lyrics \with { alignBelowContext = men } \lyricsto basses \bassWords
% again, we could replace the line above this with the line below.
% \new Lyrics \lyricsto basses \bassWords
>>
\layout {
\context {
% a little smaller so lyrics
% can be closer to the staff
\Staff
\override VerticalAxisGroup #'minimum-Y-extent = #'(-3 . 3)
}
}
}

hi
ha

hu

hu
ho

hu
ho

hi
ha

ho

hi
ha

hi
ha

hu
ho
A.5 Ancient notation templates
Appendix A: Templates 158
A.5.1 Transcription of mensural music
When transcribing mensural music, an incipit at the beginning of the piece is useful to indicate
the original key and tempo. While today musicians are used to bar lines in order to faster
recognize rhythmic patterns, bar lines were not yet invented during the period of mensural
music; in fact, the meter often changed after every few notes. As a compromise, bar lines are
often printed between the staves rather than on the staves.
global = {
\set Score.skipBars = ##t
% incipit
\once \override Score.SystemStartBracket #'transparent = ##t
\override Score.SpacingSpanner #'spacing-increment = #1.0 % tight spacing
\key f \major
\time 2/2
\once \override Staff.TimeSignature #'style = #'neomensural
\override Voice.NoteHead #'style = #'neomensural
\override Voice.Rest #'style = #'neomensural
\set Staff.printKeyCancellation = ##f
\cadenzaOn % turn off bar lines
\skip 1*10
\once \override Staff.BarLine #'transparent = ##f
\bar "||"
\skip 1*1 % need this extra \skip such that clef change comes
% after bar line
\bar ""
% main
\revert Score.SpacingSpanner #'spacing-increment % CHECK: no effect?
\cadenzaOff % turn bar lines on again
\once \override Staff.Clef #'full-size-change = ##t
\set Staff.forceClef = ##t
\key g \major
\time 4/4
\override Voice.NoteHead #'style = #'default
\override Voice.Rest #'style = #'default
% FIXME: setting printKeyCancellation back to #t must not
% occur in the first bar after the incipit. Dto. for forceClef.
% Therefore, we need an extra \skip.
\skip 1*1
\set Staff.printKeyCancellation = ##t
\set Staff.forceClef = ##f
\skip 1*7 % the actual music
% let finis bar go through all staves
\override Staff.BarLine #'transparent = ##f
% finis bar
\bar "|."
}
Appendix A: Templates 159
discantusNotes = {
\transpose c' c'' {
\set Staff.instrumentName = #"Discantus "
% incipit
\clef "neomensural-c1"
c'1. s2 % two bars
\skip 1*8 % eight bars
\skip 1*1 % one bar
% main
\clef "treble"
d'2. d'4 |
b e' d'2 |
c'4 e'4.( d'8 c' b |
a4) b a2 |
b4.( c'8 d'4) c'4 |
\once \override NoteHead #'transparent = ##t c'1 |
b\breve |
}
}
discantusLyrics = \lyricmode {
% incipit
IV-
% main
Ju -- bi -- |
la -- te De -- |
o, om --
nis ter -- |
ra, __ om- |
"..." |
-us. |
}
altusNotes = {
\transpose c' c'' {
\set Staff.instrumentName = #"Altus "
% incipit
\clef "neomensural-c3"
r1 % one bar
f1. s2 % two bars
\skip 1*7 % seven bars
\skip 1*1 % one bar
% main
\clef "treble"
r2 g2. e4 fis g | % two bars
a2 g4 e |
Appendix A: Templates 160
fis g4.( fis16 e fis4) |
g1 |
\once \override NoteHead #'transparent = ##t g1 |
g\breve |
}
}
altusLyrics = \lyricmode {
% incipit
IV-
% main
Ju -- bi -- la -- te | % two bars
De -- o, om -- |
nis ter -- ra, |
"..." |
-us. |
}
tenorNotes = {
\transpose c' c' {
\set Staff.instrumentName = #"Tenor "
% incipit
\clef "neomensural-c4"
r\longa % four bars
r\breve % two bars
r1 % one bar
c'1. s2 % two bars
\skip 1*1 % one bar
\skip 1*1 % one bar
% main
\clef "treble_8"
R1 |
R1 |
R1 |
r2 d'2. d'4 b e' | % two bars
\once \override NoteHead #'transparent = ##t e'1 |
d'\breve |
}
}
tenorLyrics = \lyricmode {
% incipit
IV-
% main
Ju -- bi -- la -- te | % two bars
"..." |
-us. |
}
Appendix A: Templates 161
bassusNotes = {
\transpose c' c' {
\set Staff.instrumentName = #"Bassus "
% incipit
\clef "bass"
r\maxima % eight bars
f1. s2 % two bars
\skip 1*1 % one bar
% main
\clef "bass"
R1 |
R1 |
R1 |
R1 |
g2. e4 |
\once \override NoteHead #'transparent = ##t e1 |
g\breve |
}
}
bassusLyrics = \lyricmode {
% incipit
IV-
% main
Ju -- bi- |
"..." |
-us. |
}
\score {
\new StaffGroup = choirStaff <<
\new Voice =
"discantusNotes" << \global \discantusNotes >>
\new Lyrics =
"discantusLyrics" \lyricsto discantusNotes { \discantusLyrics }
\new Voice =
"altusNotes" << \global \altusNotes >>
\new Lyrics =
"altusLyrics" \lyricsto altusNotes { \altusLyrics }
\new Voice =
"tenorNotes" << \global \tenorNotes >>
\new Lyrics =
"tenorLyrics" \lyricsto tenorNotes { \tenorLyrics }
\new Voice =
"bassusNotes" << \global \bassusNotes >>
\new Lyrics =
"bassusLyrics" \lyricsto bassusNotes { \bassusLyrics }
>>
Appendix A: Templates 162
\layout {
\context {
\Score
% no bars in staves
\override BarLine #'transparent = ##t
% incipit should not start with a start delimiter
\remove "System_start_delimiter_engraver"
}
\context {
\Voice
% no slurs
\override Slur #'transparent = ##t
% Comment in the below "\remove" command to allow line
% breaking also at those barlines where a note overlaps
% into the next bar. The command is commented out in this
% short example score, but especially for large scores, you
% will typically yield better line breaking and thus improve
% overall spacing if you comment in the following command.
%\remove "Forbid_line_break_engraver"
}
}
}
,
.
Ju

,
bi
,
la
.
,
,
la
,
De
.
bi
,
te
.
,
_
.
,
_
.
,
_
te
,
.
IV-

IV-
. ¸
.
Bassus
Tenor
Altus
Discantus

¡
¸
¸
IV-
.
_
_
.
/
,
,
Ju
.
/
,
,
_
/
8
,

,
, , _
,

IV-
.
Appendix A: Templates 163
...
...
...
...
,
,
·
,
bi
,
bi-
,
te
,
om-
,
la
8
/
,
/
,
/
3
, ,
,
-us.
,
-us.
,
-us.
,
-us.
,
om
,
,
,
o,
,
_
.
nis
,
,
,
_
_

om
,
De
.
o,
,
.
ra,
,
ra,
,
,
,
,

Ju
ter
,
nis
,

Ju
.
ter
.

A.5.2 Gregorian transcription template
This example demonstrates how to do modern transcription of Gregorian music. Gregorian
music has no measure, no stems; it uses only half and quarter note heads, and special marks,
indicating rests of diferent length.
\include "gregorian.ly"
chant = \relative c' {
\set Score.timing = ##f
f4 a2 \divisioMinima
g4 b a2 f2 \divisioMaior
g4( f) f( g) a2 \finalis
}
verba = \lyricmode {
Lo -- rem ip -- sum do -- lor sit a -- met
}
\score {
\new Staff <<
\new Voice = "melody" \chant
\new Lyrics = "one" \lyricsto melody \verba
>>
\layout {
\context {
\Staff
\remove "Time_signature_engraver"
\remove "Bar_engraver"
\override Stem #'transparent = ##t
}
\context {
\Voice
\override Stem #'length = #0
}
\context {
\Score
Appendix A: Templates 164
barAlways = ##t
}
}
}
a

sit

met

rem

ip Lo

lor

do

sum

A.6 Jazz combo
This is quite an advanced template, for a jazz ensemble. Note that all instruments are notated in
\key c \major. This refers to the key in concert pitch; the key will be automatically transposed
if the music is within a \transpose section.
\header {
title = "Song"
subtitle = "(tune)"
composer = "Me"
meter = "moderato"
piece = "Swing"
tagline = \markup {
\column {
"LilyPond example file by Amelie Zapf,"
"Berlin 07/07/2003"
}
}
}
%#(set-global-staff-size 16)
\include "english.ly"
%%%%%%%%%%%% Some macros %%%%%%%%%%%%%%%%%%%
sl = {
\override NoteHead #'style = #'slash
\override Stem #'transparent = ##t
}
nsl = {
\revert NoteHead #'style
\revert Stem #'transparent
}
crOn = \override NoteHead #'style = #'cross
crOff = \revert NoteHead #'style
%% insert chord name style stuff here.
jazzChords = { }
%%%%%%%%%%%% Keys'n'thangs %%%%%%%%%%%%%%%%%
Appendix A: Templates 165
global = { \time 4/4 }
Key = { \key c \major }
% ############ Horns ############
% ------ Trumpet ------
trpt = \transpose c d \relative c'' {
\Key
c1 | c | c |
}
trpHarmony = \transpose c' d {
\jazzChords
}
trumpet = {
\global
\set Staff.instrumentName = #"Trumpet"
\clef treble
<<
\trpt
>>
}
% ------ Alto Saxophone ------
alto = \transpose c a \relative c' {
\Key
c1 | c | c |
}
altoHarmony = \transpose c' a {
\jazzChords
}
altoSax = {
\global
\set Staff.instrumentName = #"Alto Sax"
\clef treble
<<
\alto
>>
}
% ------ Baritone Saxophone ------
bari = \transpose c a' \relative c {
\Key
c1
c1
\sl
d4^"Solo" d d d
\nsl
}
bariHarmony = \transpose c' a \chordmode {
\jazzChords s1 s d2:maj e:m7
}
Appendix A: Templates 166
bariSax = {
\global
\set Staff.instrumentName = #"Bari Sax"
\clef treble
<<
\bari
>>
}
% ------ Trombone ------
tbone = \relative c {
\Key
c1 | c | c
}
tboneHarmony = \chordmode {
\jazzChords
}
trombone = {
\global
\set Staff.instrumentName = #"Trombone"
\clef bass
<<
\tbone
>>
}
% ############ Rhythm Section #############
% ------ Guitar ------
gtr = \relative c'' {
\Key
c1
\sl
b4 b b b
\nsl
c1
}
gtrHarmony = \chordmode {
\jazzChords
s1 c2:min7+ d2:maj9
}
guitar = {
\global
\set Staff.instrumentName = #"Guitar"
\clef treble
<<
\gtr
>>
}
%% ------ Piano ------
rhUpper = \relative c'' {
Appendix A: Templates 167
\voiceOne
\Key
c1 | c | c
}
rhLower = \relative c' {
\voiceTwo
\Key
e1 | e | e
}
lhUpper = \relative c' {
\voiceOne
\Key
g1 | g | g
}
lhLower = \relative c {
\voiceTwo
\Key
c1 | c | c
}
PianoRH = {
\clef treble
\global
\set Staff.midiInstrument = #"acoustic grand"
<<
\new Voice = "one" \rhUpper
\new Voice = "two" \rhLower
>>
}
PianoLH = {
\clef bass
\global
\set Staff.midiInstrument = "acoustic grand"
<<
\new Voice = "one" \lhUpper
\new Voice = "two" \lhLower
>>
}
piano = {
<<
\set PianoStaff.instrumentName = #"Piano"
\new Staff = "upper" \PianoRH
\new Staff = "lower" \PianoLH
>>
}
% ------ Bass Guitar ------
Bass = \relative c {
\Key
c1 | c | c
Appendix A: Templates 168
}
bass = {
\global
\set Staff.instrumentName = #"Bass"
\clef bass
<<
\Bass
>>
}
% ------ Drums ------
up = \drummode {
\voiceOne
hh4 <hh sn> hh <hh sn>
hh4 <hh sn> hh <hh sn>
hh4 <hh sn> hh <hh sn>
}
down = \drummode {
\voiceTwo
bd4 s bd s
bd4 s bd s
bd4 s bd s
}
drumContents = {
\global
<<
\set DrumStaff.instrumentName = #"Drums"
\new DrumVoice \up
\new DrumVoice \down
>>
}
%%%%%%%%% It All Goes Together Here %%%%%%%%%%%%%%%%%%%%%%
\score {
<<
\new StaffGroup = "horns" <<
\new Staff = "trumpet" \trumpet
\new Staff = "altosax" \altoSax
\new ChordNames = "barichords" \bariHarmony
\new Staff = "barisax" \bariSax
\new Staff = "trombone" \trombone
>>
\new StaffGroup = "rhythm" <<
\new ChordNames = "chords" \gtrHarmony
\new Staff = "guitar" \guitar
\new PianoStaff = "piano" \piano
\new Staff = "bass" \bass
\new DrumStaff \drumContents
>>
Appendix A: Templates 169
>>
\layout {
\context { \RemoveEmptyStaffContext }
\context {
\Score
\override BarNumber #'padding = #3
\override RehearsalMark #'padding = #2
skipBars = ##t
}
}
\midi { }
}
Song
(tune)
Me
moderato
Swing
Appendix A: Templates 170
,
,
,
,
,
,
,
,
Solo
,
,
,
D
/9
,
,
,
,
B
,
,
, ,
,
,
,
,
,
,
,
,
,
C
,
m
7
,
.
.
Drums
Piano

Guitar
.
.
Bass
Trombone
Bari Sax
Alto Sax
Trumpet
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
/
,
,
,
,
/
,
,
,
/
,
,
,
,
/
,
/
,
,
,
,
,
,
,
,
,
, ,
,
,
,
,
,
,
,
,
,
,
Cm
,
,
,
,
A.7 lilypond-book templates
These templates are for use with lilypond-book. If you’re not familiar with this program,
please refer to Section “LilyPond-book” in Application Usage.
A.7.1 LaTeX
You can include LilyPond fragments in a LaTeX document.
\documentclass[]{article}
\begin{document}
Normal LaTeX text.
\begin{lilypond}
\relative c'' {
a4 b c d
}
\end{lilypond}
More LaTeX text.
Appendix A: Templates 171
\begin{lilypond}
\relative c'' {
d4 c b a
}
\end{lilypond}
\end{document}
A.7.2 Texinfo
You can include LilyPond fragments in Texinfo; in fact, this entire manual is written in Texinfo.
\input texinfo
@node Top
Texinfo text
@lilypond[verbatim,fragment,ragged-right]
a4 b c d
@end lilypond
More Texinfo text
@lilypond[verbatim,fragment,ragged-right]
d4 c b a
@end lilypond
@bye
A.7.3 xelatex
\documentclass{article}
\usepackage{ifxetex}
\ifxetex
%xetex specific stuff
\usepackage{xunicode,fontspec,xltxtra}
\setmainfont[Numbers=OldStyle]{Times New Roman}
\setsansfont{Arial}
\else
%This can be empty if you are not going to use pdftex
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{mathptmx}%Times
\usepackage{helvet}%Helvetica
\fi
%Here you can insert all packages that pdftex also understands
\usepackage[ngerman,finnish,english]{babel}
\usepackage{graphicx}
\begin{document}
\title{A short document with LilyPond and xelatex}
\maketitle
Normal \textbf{font} commands inside the \emph{text} work,
because they \textsf{are supported by \LaTeX{} and XeteX.}
Appendix A: Templates 172
If you want to use specific commands like \verb+\XeTeX+, you
should include them again in a \verb+\ifxetex+ environment.
You can use this to print the \ifxetex \XeTeX{} command \else
XeTeX command \fi which is not known to normal \LaTeX .
In normal text you can easily use LilyPond commands, like this:
\begin{lilypond}
{a2 b c'8 c' c' c'}
\end{lilypond}
\noindent
and so on.
The fonts of snippets set with LilyPond will have to be set from
inside
of the snippet. For this you should read the AU on how to use
lilypond-book.
\selectlanguage{ngerman}
Auch Umlaute funktionieren ohne die \LaTeX -Befehle, wie auch alle
anderen
seltsamen Zeichen: __ ______, wenn sie von der Schriftart
unterst__tzt werden.
\end{document}
Appendix B: Scheme tutorial 173
Appendix B Scheme tutorial
LilyPond uses the Scheme programming language, both as part of the input syntax, and as
internal mechanism to glue modules of the program together. This section is a very brief
overview of entering data in Scheme. If you want to know more about Scheme, see http://www
.schemers.org.
The most basic thing of a language is data: numbers, character strings, lists, etc. Here is a
list of data types that are relevant to LilyPond input.
Booleans Boolean values are True or False. The Scheme for True is #t and False is #f.
Numbers Numbers are entered in the standard fashion, 1 is the (integer) number one, while
-1.5 is a foating point number (a non-integer number).
Strings Strings are enclosed in double quotes,
"this is a string"
Strings may span several lines
"this
is
a string"
Quotation marks and newlines can also be added with so-called escape sequences.
The string a said "b" is entered as
"a said \"b\""
Newlines and backslashes are escaped with \n and \\ respectively.
In a music fle, snippets of Scheme code are introduced with the hash mark #. So, the previous
examples translated in LilyPond are
##t ##f
#1 #-1.5
#"this is a string"
#"this
is
a string"
For the rest of this section, we will assume that the data is entered in a music fle, so we add
#s everywhere.
Scheme can be used to do calculations. It uses prefx syntax. Adding 1 and 2 is written as
(+ 1 2) rather than the traditional 1 + 2.
#(+ 1 2)
⇒ #3
The arrow ⇒ shows that the result of evaluating (+ 1 2) is 3. Calculations may be nested;
the result of a function may be used for another calculation.
#(+ 1 (* 3 4))
⇒ #(+ 1 12)
⇒ #13
These calculations are examples of evaluations; an expression like (* 3 4) is replaced by its
value 12. A similar thing happens with variables. After defning a variable
twelve = #12
variables can also be used in expressions, here
twentyFour = #(* 2 twelve)
the number 24 is stored in the variable twentyFour. The same assignment can be done in
completely in Scheme as well,
Appendix B: Scheme tutorial 174
#(define twentyFour (* 2 twelve))
The name of a variable is also an expression, similar to a number or a string. It is entered as
#'twentyFour
The quote mark ' prevents the Scheme interpreter from substituting 24 for the twentyFour.
Instead, we get the name twentyFour.
This syntax will be used very frequently, since many of the layout tweaks involve assigning
(Scheme) values to internal variables, for example
\override Stem #'thickness = #2.6
This instruction adjusts the appearance of stems. The value 2.6 is put into the thickness
variable of a Stem object. thickness is measured relative to the thickness of staf lines, so these
stem lines will be 2.6 times the width of staf lines. This makes stems almost twice as thick
as their normal size. To distinguish between variables defned in input fles (like twentyFour
in the example above) and variables of internal objects, we will call the latter ‘properties’ and
the former ‘variables.’ So, the stem object has a thickness property, while twentyFour is an
variable.
Two-dimensional ofsets (X and Y coordinates) as well as object sizes (intervals with a left
and right point) are entered as pairs. A pair
1
is entered as (first . second) and, like symbols,
they must be quoted,
\override TextScript #'extra-offset = #'(1 . 2)
This assigns the pair (1, 2) to the extra-offset property of the TextScript object. These
numbers are measured in staf-spaces, so this command moves the object 1 staf space to the
right, and 2 spaces up.
The two elements of a pair may be arbitrary values, for example
#'(1 . 2)
#'(#t . #f)
#'("blah-blah" . 3.14159265)
A list is entered by enclosing its elements in parentheses, and adding a quote. For example,
#'(1 2 3)
#'(1 2 "string" #f)
We have been using lists all along. A calculation, like (+ 1 2) is also a list (containing the
symbol + and the numbers 1 and 2). Normally lists are interpreted as calculations, and the
Scheme interpreter substitutes the outcome of the calculation. To enter a list, we stop the
evaluation. This is done by quoting the list with a quote ' symbol. So, for calculations do not
use a quote.
Inside a quoted list or pair, there is no need to quote anymore. The following is a pair of
symbols, a list of symbols and a list of lists respectively,
#'(stem . head)
#'(staff clef key-signature)
#'((1) (2))
B.1 Tweaking with Scheme
We have seen how LilyPond output can be heavily modifed using commands like \override
TextScript #'extra-offset = ( 1 . -1). But we have even more power if we use Scheme.
For a full explanation of this, see the Appendix B [Scheme tutorial], page 173, and Section
“Interfaces for programmers” in Notation Reference.
We can use Scheme to simply \override commands,
1
In Scheme terminology, the pair is called cons, and its two elements are called car and cdr respectively.
Appendix B: Scheme tutorial 175
TODO Find a simple example
We can use it to create new commands:
tempoMark = #(define-music-function (parser location padding marktext)
(number? string?)
#{
\once \override Score . RehearsalMark #'padding = $padding
\once \override Score . RehearsalMark #'extra-spacing-width = #'(+inf.0 . -inf.0)
\mark \markup { \bold $marktext }
#})
\relative c'' {
c2 e
\tempoMark #3.0 #"Allegro"
g c
}

Allegro
Even music expressions can be passed in:
pattern = #(define-music-function (parser location x y) (ly:music? ly:music?)
#{
$x e8 a b $y b a e
#})
\relative c''{
\pattern c8 c8\f
\pattern {d16 dis} { ais16-> b\p }
}

p

f

Appendix C: GNU Free Documentation License 176
Appendix C GNU Free Documentation License
Version 1.1, March 2000
Copyright c 2000 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
0. PREAMBLE
The purpose of this License is to make a manual, textbook, or other written document free
in the sense of freedom: to assure everyone the efective freedom to copy and redistribute
it, with or without modifying it, either commercially or noncommercially. Secondarily, this
License preserves for the author and publisher a way to get credit for their work, while not
being considered responsible for modifcations made by others.
This License is a kind of ‘copyleft’, which means that derivative works of the document must
themselves be free in the same sense. It complements the GNU General Public License,
which is a copyleft license designed for free software.
We have designed this License in order to use it for manuals for free software, because free
software needs free documentation: a free program should come with manuals providing the
same freedoms that the software does. But this License is not limited to software manuals;
it can be used for any textual work, regardless of subject matter or whether it is published
as a printed book. We recommend this License principally for works whose purpose is
instruction or reference.
1. APPLICABILITY AND DEFINITIONS
This License applies to any manual or other work that contains a notice placed by the copy-
right holder saying it can be distributed under the terms of this License. The ‘Document’,
below, refers to any such manual or work. Any member of the public is a licensee, and is
addressed as ‘you’.
A ‘Modifed Version’ of the Document means any work containing the Document or a
portion of it, either copied verbatim, or with modifcations and/or translated into another
language.
A ‘Secondary Section’ is a named appendix or a front-matter section of the Document that
deals exclusively with the relationship of the publishers or authors of the Document to the
Document’s overall subject (or to related matters) and contains nothing that could fall
directly within that overall subject. (For example, if the Document is in part a textbook
of mathematics, a Secondary Section may not explain any mathematics.) The relationship
could be a matter of historical connection with the subject or with related matters, or of
legal, commercial, philosophical, ethical or political position regarding them.
The ‘Invariant Sections’ are certain Secondary Sections whose titles are designated, as being
those of Invariant Sections, in the notice that says that the Document is released under this
License.
The ‘Cover Texts’ are certain short passages of text that are listed, as Front-Cover Texts or
Back-Cover Texts, in the notice that says that the Document is released under this License.
A ‘Transparent’ copy of the Document means a machine-readable copy, represented in a
format whose specifcation is available to the general public, whose contents can be viewed
and edited directly and straightforwardly with generic text editors or (for images composed
of pixels) generic paint programs or (for drawings) some widely available drawing editor,
and that is suitable for input to text formatters or for automatic translation to a variety of
formats suitable for input to text formatters. A copy made in an otherwise Transparent fle
Appendix C: GNU Free Documentation License 177
format whose markup has been designed to thwart or discourage subsequent modifcation
by readers is not Transparent. A copy that is not ‘Transparent’ is called ‘Opaque’.
Examples of suitable formats for Transparent copies include plain ascii without markup,
Texinfo input format, LaT
E
X input format, SGML or XML using a publicly available DTD,
and standard-conforming simple HTML designed for human modifcation. Opaque formats
include PostScript, PDF, proprietary formats that can be read and edited only by propri-
etary word processors, SGML or XML for which the DTD and/or processing tools are not
generally available, and the machine-generated HTML produced by some word processors
for output purposes only.
The ‘Title Page’ means, for a printed book, the title page itself, plus such following pages
as are needed to hold, legibly, the material this License requires to appear in the title page.
For works in formats which do not have any title page as such, ‘Title Page’ means the text
near the most prominent appearance of the work’s title, preceding the beginning of the
body of the text.
2. VERBATIM COPYING
You may copy and distribute the Document in any medium, either commercially or noncom-
mercially, provided that this License, the copyright notices, and the license notice saying
this License applies to the Document are reproduced in all copies, and that you add no
other conditions whatsoever to those of this License. You may not use technical measures
to obstruct or control the reading or further copying of the copies you make or distribute.
However, you may accept compensation in exchange for copies. If you distribute a large
enough number of copies you must also follow the conditions in section 3.
You may also lend copies, under the same conditions stated above, and you may publicly
display copies.
3. COPYING IN QUANTITY
If you publish printed copies of the Document numbering more than 100, and the Docu-
ment’s license notice requires Cover Texts, you must enclose the copies in covers that carry,
clearly and legibly, all these Cover Texts: Front-Cover Texts on the front cover, and Back-
Cover Texts on the back cover. Both covers must also clearly and legibly identify you as
the publisher of these copies. The front cover must present the full title with all words
of the title equally prominent and visible. You may add other material on the covers in
addition. Copying with changes limited to the covers, as long as they preserve the title of
the Document and satisfy these conditions, can be treated as verbatim copying in other
respects.
If the required texts for either cover are too voluminous to ft legibly, you should put the
frst ones listed (as many as ft reasonably) on the actual cover, and continue the rest onto
adjacent pages.
If you publish or distribute Opaque copies of the Document numbering more than 100,
you must either include a machine-readable Transparent copy along with each Opaque
copy, or state in or with each Opaque copy a publicly-accessible computer-network location
containing a complete Transparent copy of the Document, free of added material, which
the general network-using public has access to download anonymously at no charge using
public-standard network protocols. If you use the latter option, you must take reasonably
prudent steps, when you begin distribution of Opaque copies in quantity, to ensure that
this Transparent copy will remain thus accessible at the stated location until at least one
year after the last time you distribute an Opaque copy (directly or through your agents or
retailers) of that edition to the public.
It is requested, but not required, that you contact the authors of the Document well before
redistributing any large number of copies, to give them a chance to provide you with an
updated version of the Document.
Appendix C: GNU Free Documentation License 178
4. MODIFICATIONS
You may copy and distribute a Modifed Version of the Document under the conditions
of sections 2 and 3 above, provided that you release the Modifed Version under precisely
this License, with the Modifed Version flling the role of the Document, thus licensing
distribution and modifcation of the Modifed Version to whoever possesses a copy of it. In
addition, you must do these things in the Modifed Version:
A. Use in the Title Page (and on the covers, if any) a title distinct from that of the
Document, and from those of previous versions (which should, if there were any, be
listed in the History section of the Document). You may use the same title as a previous
version if the original publisher of that version gives permission.
B. List on the Title Page, as authors, one or more persons or entities responsible for
authorship of the modifcations in the Modifed Version, together with at least fve of
the principal authors of the Document (all of its principal authors, if it has less than
fve).
C. State on the Title page the name of the publisher of the Modifed Version, as the
publisher.
D. Preserve all the copyright notices of the Document.
E. Add an appropriate copyright notice for your modifcations adjacent to the other copy-
right notices.
F. Include, immediately after the copyright notices, a license notice giving the public
permission to use the Modifed Version under the terms of this License, in the form
shown in the Addendum below.
G. Preserve in that license notice the full lists of Invariant Sections and required Cover
Texts given in the Document’s license notice.
H. Include an unaltered copy of this License.
I. Preserve the section entitled ‘History’, and its title, and add to it an item stating at
least the title, year, new authors, and publisher of the Modifed Version as given on the
Title Page. If there is no section entitled ‘History’ in the Document, create one stating
the title, year, authors, and publisher of the Document as given on its Title Page, then
add an item describing the Modifed Version as stated in the previous sentence.
J. Preserve the network location, if any, given in the Document for public access to a
Transparent copy of the Document, and likewise the network locations given in the
Document for previous versions it was based on. These may be placed in the ‘History’
section. You may omit a network location for a work that was published at least four
years before the Document itself, or if the original publisher of the version it refers to
gives permission.
K. In any section entitled ‘Acknowledgments’ or ‘Dedications’, preserve the section’s ti-
tle, and preserve in the section all the substance and tone of each of the contributor
acknowledgments and/or dedications given therein.
L. Preserve all the Invariant Sections of the Document, unaltered in their text and in their
titles. Section numbers or the equivalent are not considered part of the section titles.
M. Delete any section entitled ‘Endorsements’. Such a section may not be included in the
Modifed Version.
N. Do not retitle any existing section as ‘Endorsements’ or to confict in title with any
Invariant Section.
If the Modifed Version includes new front-matter sections or appendices that qualify as
Secondary Sections and contain no material copied from the Document, you may at your
option designate some or all of these sections as invariant. To do this, add their titles to
Appendix C: GNU Free Documentation License 179
the list of Invariant Sections in the Modifed Version’s license notice. These titles must be
distinct from any other section titles.
You may add a section entitled ‘Endorsements’, provided it contains nothing but endorse-
ments of your Modifed Version by various parties—for example, statements of peer review
or that the text has been approved by an organization as the authoritative defnition of a
standard.
You may add a passage of up to fve words as a Front-Cover Text, and a passage of up
to 25 words as a Back-Cover Text, to the end of the list of Cover Texts in the Modifed
Version. Only one passage of Front-Cover Text and one of Back-Cover Text may be added
by (or through arrangements made by) any one entity. If the Document already includes
a cover text for the same cover, previously added by you or by arrangement made by the
same entity you are acting on behalf of, you may not add another; but you may replace the
old one, on explicit permission from the previous publisher that added the old one.
The author(s) and publisher(s) of the Document do not by this License give permission to
use their names for publicity for or to assert or imply endorsement of any Modifed Version.
5. COMBINING DOCUMENTS
You may combine the Document with other documents released under this License, under
the terms defned in section 4 above for modifed versions, provided that you include in the
combination all of the Invariant Sections of all of the original documents, unmodifed, and
list them all as Invariant Sections of your combined work in its license notice.
The combined work need only contain one copy of this License, and multiple identical
Invariant Sections may be replaced with a single copy. If there are multiple Invariant
Sections with the same name but diferent contents, make the title of each such section
unique by adding at the end of it, in parentheses, the name of the original author or
publisher of that section if known, or else a unique number. Make the same adjustment to
the section titles in the list of Invariant Sections in the license notice of the combined work.
In the combination, you must combine any sections entitled ‘History’ in the various original
documents, forming one section entitled ‘History’; likewise combine any sections entitled
‘Acknowledgments’, and any sections entitled ‘Dedications’. You must delete all sections
entitled ‘Endorsements.’
6. COLLECTIONS OF DOCUMENTS
You may make a collection consisting of the Document and other documents released under
this License, and replace the individual copies of this License in the various documents with
a single copy that is included in the collection, provided that you follow the rules of this
License for verbatim copying of each of the documents in all other respects.
You may extract a single document from such a collection, and distribute it individually
under this License, provided you insert a copy of this License into the extracted document,
and follow this License in all other respects regarding verbatim copying of that document.
7. AGGREGATION WITH INDEPENDENT WORKS
A compilation of the Document or its derivatives with other separate and independent
documents or works, in or on a volume of a storage or distribution medium, does not as a
whole count as a Modifed Version of the Document, provided no compilation copyright is
claimed for the compilation. Such a compilation is called an ‘aggregate’, and this License
does not apply to the other self-contained works thus compiled with the Document, on
account of their being thus compiled, if they are not themselves derivative works of the
Document.
If the Cover Text requirement of section 3 is applicable to these copies of the Document, then
if the Document is less than one quarter of the entire aggregate, the Document’s Cover Texts
may be placed on covers that surround only the Document within the aggregate. Otherwise
they must appear on covers around the whole aggregate.
Appendix C: GNU Free Documentation License 180
8. TRANSLATION
Translation is considered a kind of modifcation, so you may distribute translations of the
Document under the terms of section 4. Replacing Invariant Sections with translations
requires special permission from their copyright holders, but you may include translations
of some or all Invariant Sections in addition to the original versions of these Invariant
Sections. You may include a translation of this License provided that you also include the
original English version of this License. In case of a disagreement between the translation
and the original English version of this License, the original English version will prevail.
9. TERMINATION
You may not copy, modify, sublicense, or distribute the Document except as expressly
provided for under this License. Any other attempt to copy, modify, sublicense or distribute
the Document is void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under this License will not
have their licenses terminated so long as such parties remain in full compliance.
10. FUTURE REVISIONS OF THIS LICENSE
The Free Software Foundation may publish new, revised versions of the GNU Free Doc-
umentation License from time to time. Such new versions will be similar in spirit to
the present version, but may difer in detail to address new problems or concerns. See
http://www.gnu.org/copyleft/.
Each version of the License is given a distinguishing version number. If the Document
specifes that a particular numbered version of this License ‘or any later version’ applies
to it, you have the option of following the terms and conditions either of that specifed
version or of any later version that has been published (not as a draft) by the Free Software
Foundation. If the Document does not specify a version number of this License, you may
choose any version ever published (not as a draft) by the Free Software Foundation.
Appendix C: GNU Free Documentation License 181
ADDENDUM: How to use this License for your documents
To use this License in a document you have written, include a copy of the License in the document
and put the following copyright and license notices just after the title page:
Copyright (C) year your name.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.1
or any later version published by the Free Software Foundation;
with the Invariant Sections being list their titles, with the
Front-Cover Texts being list, and with the Back-Cover Texts being list.
A copy of the license is included in the section entitled ‘GNU
Free Documentation License’
.
If you have no Invariant Sections, write ‘with no Invariant Sections’ instead of saying which
ones are invariant. If you have no Front-Cover Texts, write ‘no Front-Cover Texts’ instead of
‘Front-Cover Texts being list’; likewise for Back-Cover Texts.
If your document contains nontrivial examples of program code, we recommend releasing
these examples in parallel under your choice of free software license, such as the GNU General
Public License, to permit their use in free software.
Appendix D: LilyPond index 182
Appendix D LilyPond index
!
! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
#
# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
##f . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
##t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
#'symbol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174
%
% . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
%{ ... %} . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

' . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
(
( ... ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
,
, . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
.
... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
<
< . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
< . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
< ... > . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
<<. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25, 28
<< ... >> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
<< ... \\ ... >>. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
<< \\ >> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
>
> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
>>. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25, 28
[
[ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
[ ... ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
]
] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
^
^ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
_ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
\
\! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
\( ... \) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
\< . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
\> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
\\. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28, 44
\acciaccatura. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
\addlyrics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
\addlyrics example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
\addlyrics, example. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
\appoggiatura. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
\autoBeamOff . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22, 52
\autoBeamOn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
\book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
\book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38, 57
\clef . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
\consists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
\context . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
\f . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
\ff . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
\grace. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
\header . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34, 38
\key . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
\layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38, 67
\lyricmode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
\lyricsto . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
\major. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
\markup. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
\mf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
\midi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
\minor. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
\mp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
\new . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25, 59
\new ChoirStaff. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
\new Lyrics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
\new Staff . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
\new Voice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
\once . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82, 87
\oneVoice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
\override . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
\overrideProperty . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
\p . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
\partial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
\pp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
\relative . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
\remove. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
\revert . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82, 87
\score. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
\score. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
\set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
\set, example of using . . . . . . . . . . . . . . . . . . . . . . . . . . 102
\shiftOff . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
\shiftOn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
\shiftOnn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
\shiftOnnn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
\startTextSpan . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
Appendix D: LilyPond index 183
\stopTextSpan. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
\textLengthOff . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
\textLengthOn. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
\time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
\times. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
\tweak. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
\tweak, example. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83, 84
\unset. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
\version . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
\voiceFour . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
\voiceFourStyle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
\voiceNeutralStyle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
\voiceOne . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
\voiceOneStyle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
\voiceThree . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
\voiceThreeStyle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
\voiceTwo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
\voiceTwoStyle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
\with . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
\with, example. . . . . . . . . . . . . . . . . . . . . . . . 95, 96, 97, 98
~
~ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
A
absolute mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
absolute note names. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
absolute values for pitches . . . . . . . . . . . . . . . . . . . . . . . . 35
accent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
accessing Scheme . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
acciaccatura . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
accidental . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13, 18
Accidental, example of overriding . . . . . . . . . . . . . . . 112
AccidentalPlacement, example of overriding . . . . . 112
accidentals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Accidentals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
accidentals and key signature. . . . . . . . . . . . . . . . . . . . . 18
accidentals and key signatures . . . . . . . . . . . . . . . . . . . . 18
accidentals and relative mode . . . . . . . . . . . . . . . . . . . . 13
adding engravers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
adding text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
addlyrics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
alignAboveContext property, example . . 95, 96, 97, 98
aligning lyrics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
aligning objects on a baseline . . . . . . . . . . . . . . . . . . . 113
alto . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
ambitus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
ambitus engraver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
anacrusis. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
appendices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Application Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8, 9
appoggiatura. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
articulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Articulations and ornamentations . . . . . . . . . . . . . . . . 21
articulations and slurs. . . . . . . . . . . . . . . . . . . . . . . . . . . 105
assigning variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
autoBeamOff . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22, 52
autoBeamOn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
automated engraving . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Automatic accidentals . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
automatic beams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Automatic beams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
B
balance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Bar and bar number checks . . . . . . . . . . . . . . . . . . . . . 131
bar numbers, tweaking placement . . . . . . . . . . . . . . . 104
BarLine, example of overriding . . . . . . . . 91, 92, 93, 94
bass . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
beam. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14, 22
Beam, example of overriding . . . . . . . . . . . . . . . . . . . . 115
beaming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
beaming and lyrics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
beams, automatic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
beams, by hand . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
beams, controlling manually. . . . . . . . . . . . . . . . . . . . . 114
beams, manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
blackness. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
block comment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16, 17
book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38, 57
book block, implicit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
book, example of using . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
bound-details property, example . . . . . . . . . . . . 104, 105
brace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
braces, curly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
bracket types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
bracket, triplet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
bracket, tuplet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
brackets, enclosing vs. marking . . . . . . . . . . . . . . . . . . . 43
brackets, nesting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
break-visibility property. . . . . . . . . . . . . . . . . . . . . . . . . . 92
break-visibility property, example . . . . . . . . . . . . . . . . 92
C
case sensitive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11, 16
center . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
Changing context default settings . . . . . . . . . . . . . 66, 68
Changing defaults . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
changing size of objects . . . . . . . . . . . . . . . . . . . . . . . . . . 95
characters allowed in variables. . . . . . . . . . . . . . . . . . . . 33
charts, reference. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Cheat sheet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
choir staf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26, 52
ChoirStaff . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26, 52
chord . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
ChordNames . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
chords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
chords vs. voices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
clef . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Clef . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Clef, example of overriding. . . . . . . . . 94, 95, 96, 97, 98
clickable examples. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Collision resolution. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
collisions, notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
color property. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
color property, example . . . . . . . . . . . . 82, 83, 84, 93, 94
color property, setting to Scheme procedure . . . . . 129
color, rgb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
color, X11. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
combining expressions in parallel . . . . . . . . . . . . . . . . . 25
comma. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
comment, line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16, 17
compiling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
compound music expression. . . . . . . . . . . . . . . . . . . 24, 39
Appendix D: LilyPond index 184
concurrent music . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
consists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
constructing fles, tips . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
content vs. layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
contents of a score block . . . . . . . . . . . . . . . . . . . . . . . . . 39
context . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
context. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
context properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
context properties, modifying. . . . . . . . . . . . . . . . . . . . . 62
context properties, setting with \context . . . . . . . . . 65
context properties, setting with \with . . . . . . . . . . . . 65
context, fnding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
context, identifying correct . . . . . . . . . . . . . . . . . . . . . . . 86
context, notation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
context, specifying in lyric mode . . . . . . . . . . . . . . . . . 89
context, Voice. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
contexts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Contexts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6, 63, 66
contexts explained . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
Contexts explained. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
contexts, creating . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
contexts, implicit. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
contexts, naming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
controlling tuplets, slurs, phrasing slurs, and beams
manually . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
convert-ly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
Converting from other formats . . . . . . . . . . . . . . . . . . . . 9
creating contexts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
Creating contexts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
Creating MIDI fles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Creating titles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
crescendo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
curly braces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
D
decrescendo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
default properties, reverting to . . . . . . . . . . . . . . . . . . . 87
Difcult tweaks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
direction property, example . . . . . . . . . . . . . 84, 100, 101
Displaying staves . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
distances . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
dotted note . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
double fat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
double sharp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
down . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
duration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
durations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
DynamicLineSpanner, example of overriding . . . . . 113
dynamics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Dynamics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
dynamics, tweaking placement . . . . . . . . . . . . . . . . . . 107
DynamicText, example of overriding . . . . . . . . 108, 113
E
engraver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
engravers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
Engravers and Performers . . . . . . . . . . . . . . . . . . . . . . . . 62
engravers, adding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
engravers, removing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
engraving. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2, 4
engraving multiple voices . . . . . . . . . . . . . . . . . . . . . . . . . . 5
engraving, automated . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
es . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
eses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
evaluating Scheme . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
example of writing a score. . . . . . . . . . . . . . . . . . . . . . . . 76
example, frst . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
examples, clickable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
examples, simple . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
expression, music. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
expressions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
expressions, parallel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
extender line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
extra-ofset property . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
extra-ofset property, example . . . . . . . . . . . . . . . . . . . 114
extra-spacing-width. . . . . . . . . . . . . . . . . . . . . . . . . . . 108
extra-spacing-width property. . . . . . . . . . . . . . . . . . . . 110
extra-spacing-width property, example . . . . . . 108, 113
F
FDL, GNU Free Documentation License. . . . . . . . . 176
fermata, implementing in MIDI . . . . . . . . . . . . . . . . . 125
fle structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
File structure. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
File structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
fles, tips for constructing . . . . . . . . . . . . . . . . . . . . . . . . 17
fles, updating. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
fngering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
fngering example . . . . . . . . . . . . . . . . . . . . . . . . . . 101, 102
Fingering instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
fngering, chords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
Fingering, example of overriding. . . . . . . . . . . . 101, 114
fngering, placement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
fngeringOrientations property, example . . . . . . . . . 102
frst example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
fxing overlapping notation . . . . . . . . . . . . . . . . . . . . . . 111
fat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
fat, double . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
font . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
font-series property, example . . . . . . . . . . . . . . . . . . . . 126
font-shape property, example . . . . . . . . . . . . . . . . 89, 126
font-size property, example . . . . . . . . . . . . . . . . . . . . . . . 83
fontSize property, example . . . . . . . . . . . . . . . . . . . . 97, 98
fontSize, default and setting . . . . . . . . . . . . . . . . . . . . . . 65
force-hshift property . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
force-hshift property, example . . . . . . . . . . . . . . 116, 122
foreign languages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
formatting a score . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
formatting rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
future upgrades . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
G
General input and output . . . . . . . . . . . . . . . . . . . . . . . . . 9
grace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
grace notes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Grace notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
grand staf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
GrandStaff . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
grob . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
grob sizing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
grobs, moving colliding. . . . . . . . . . . . . . . . . . . . . . . . . . 109
grobs, positioning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
grobs, properties of. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
GUILE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
Appendix D: LilyPond index 185
H
half note . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
header . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34, 38
header block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
headers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
hiding objects. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
how to read the manual . . . . . . . . . . . . . . . . . . . . . . . . . . 17
hymn structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
hyphens. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
I
identifers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
idiom . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
implicit book block. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
implicit contexts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
input format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Install . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
integrating LilyPond with other programs . . . . . . . . . 9
interface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80, 88
interface properties. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
Interfaces for programmers . . . . . . . . . . . . . . . . . . . 9, 174
Internals Reference. . . . . . . . . . . . . . . . . . . . . . . . . 8, 10, 84
Internals Reference manual . . . . . . . . . . . . . . . . . . . . . . . 84
Internals Reference, example of using . . . . . . . . . . . . . 85
interval . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
invisible objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
is . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
isis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
italic, example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
J
jargon. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
K
key . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
key signature . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Key signature . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
key signature, setting . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Keyboard and other multi-staf instruments . . . . . . . 27
L
language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
layers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38, 67
layout block, efect of location . . . . . . . . . . . . . . . . . . . . 38
layout object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
layout objects, properties of . . . . . . . . . . . . . . . . . . . . . . 84
layout vs. content . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Learning Manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
left-padding property. . . . . . . . . . . . . . . . . . . . . . . 109, 112
length . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
LilyPond command index . . . . . . . . . . . . . . . . . . . . . . . . . 9
LilyPond index. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
LilyPond Snippet Repository . . . . . . . . . . . . . . . . . . . . . . 9
LilyPond-book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9, 170
line comment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16, 17
LISP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
List of colors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93, 94
Literature list . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
LSR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
lyric mode, specifying context . . . . . . . . . . . . . . . . . . . . 89
lyricmode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
lyrics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
Lyrics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25, 52
lyrics and beaming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
lyrics and multiple staves. . . . . . . . . . . . . . . . . . . . . . . . . 32
Lyrics context, creating . . . . . . . . . . . . . . . . . . . . . . . . . . 52
lyrics, aligning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
lyrics, linking to voice . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
lyrics, multi-syllable words . . . . . . . . . . . . . . . . . . . . . . . 29
lyricsto . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
LyricText, example of overriding. . . . . . . . . . . . . 89, 126
M
MacOS X, running LilyPond . . . . . . . . . . . . . . . . . . . . . 11
macros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
magstep . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
magstep function, example of using. . . . . . . . . . . . . . . 98
major . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
manual beams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Manual beams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
manual, reading. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
manually controlling tuplets, slurs, phrasing slurs,
and beams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
markup. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
markup example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
markup text, allowing collisions . . . . . . . . . . . . . . . . . 106
melisma. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
metronome mark, tweaking placement . . . . . . . . . . . 104
MetronomeMark, example of overriding. . . . . 111, 125
middle C. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
midi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
minor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Modifying context plug-ins . . . . . . . . . . . . . . . . . . . . . . . 68
modifying context properties . . . . . . . . . . . . . . . . . . . . . 62
Modifying properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
modifying templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
moving colliding grobs . . . . . . . . . . . . . . . . . . . . . . . . . . 109
moving colliding objects. . . . . . . . . . . . . . . . . . . . . . . . . 109
moving overlapping objects. . . . . . . . . . . . . . . . . . . . . . 109
MultiMeasureRest, example of overriding . . . . . . . . 113
Multiple scores in a book. . . . . . . . . . . . . . . . . . . . . . . . . 38
multiple staves . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
multiple staves and lyrics. . . . . . . . . . . . . . . . . . . . . . . . . 32
multiple vocal verses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
multiple voices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28, 44
Multiple voices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48, 52
music engraving . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
music expression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
music expression, compound . . . . . . . . . . . . . . . . . . 24, 39
Music Glossary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
music typography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
music, concurrent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
music, simultaneous . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
Musical notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9, 36
musical symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
N
naming contexts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
naming conventions for objects . . . . . . . . . . . . . . . . . . . 81
naming conventions for properties . . . . . . . . . . . . . . . . 81
natural . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Appendix D: LilyPond index 186
nesting music expressions . . . . . . . . . . . . . . . . . . . . . . . . 50
nesting simultaneous constructs . . . . . . . . . . . . . . . . . . 50
nesting voices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
neutral . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
new . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25, 59
new contexts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
new Staff. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
notating durations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
notating rests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
notation context . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Notation manual tables. . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Notation Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8, 9
notation, simple. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
note collisions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
note column . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
note durations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
note durations in chords. . . . . . . . . . . . . . . . . . . . . . . . . . 27
note names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
Note names in other languages. . . . . . . . . . . . . . . . 18, 19
note names, absolute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
note value. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
NoteColumn, example of overriding. . . . . . . . . 116, 122
NoteHead, example of overriding . . . . . 82, 83, 94, 129
notes, spreading out with text . . . . . . . . . . . . . . . . . . . 106
O
object. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
object collision within a staf . . . . . . . . . . . . . . . . . . . . 113
object properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
object, layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
objects, aligning on a baseline . . . . . . . . . . . . . . . . . . . 113
objects, changing size of . . . . . . . . . . . . . . . . . . . . . . . . . . 95
objects, hiding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
objects, invisible . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
objects, making invisible . . . . . . . . . . . . . . . . . . . . . . . . 124
objects, moving colliding . . . . . . . . . . . . . . . . . . . . . . . . 109
objects, naming conventions . . . . . . . . . . . . . . . . . . . . . . 81
objects, outside-staf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
objects, positioning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
objects, removing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
objects, size of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
objects, within-staf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
octave . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Octave checks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
once . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82, 87
once override. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
oneVoice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
optical spacing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
ossia . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41, 95
Ossia staves . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
ossias . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
ottava bracket . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
outside-staf objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
outside-staf-priority property, example . . . . . . . . . . 106
overlapping notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
override . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
override command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
override example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
override syntax. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
overrideProperty . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
overrideProperty command. . . . . . . . . . . . . . . . . . . . . . . 82
overriding once only. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
P
padding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109, 111
padding property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
padding property, example . . . . . . . . . . . . . . . . . . . . . . 111
Painting objects white . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
parallel expressions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
parallel expressions and relative notes . . . . . . . . . . . . 25
partial. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
partial measure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
PDF fle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
phrasing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
phrasing slur . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Phrasing slurs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
phrasing slurs, controlling manually . . . . . . . . . . . . . 114
PhrasingSlur, example of overriding . . . . . . . . . . . . . 114
piano staf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
PianoStaff . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
pickup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
pitch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13, 18
Pitch names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
pitches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
pitches, absolute values. . . . . . . . . . . . . . . . . . . . . . . . . . . 35
plate engraving. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
plug-in. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
polyphony . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
polyphony . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
polyphony. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28, 44
polyphony and relative note entry . . . . . . . . . . . . . . . . 46
positioning grobs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
positioning objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
positions property. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
positions property, example. . . . . . . . . . . . . . . . . 114, 115
properties in interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
properties of grobs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
properties of layout objects . . . . . . . . . . . . . . . . . . . . . . . 84
properties operating in contexts . . . . . . . . . . . . . . . . . . 62
properties vs. variables . . . . . . . . . . . . . . . . . . . . . . . . . . 174
properties, naming conventions . . . . . . . . . . . . . . . . . . . 81
properties, object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
property types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
Q
quarter note . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
quote, single . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
quoting in Scheme . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174
R
reading the manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
recursive structures. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
reference charts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
regular rhythms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
regular spacing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
rehearsal marks, tweaking placement . . . . . . . . . . . . 104
relative . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
relative mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
relative mode, and accidentals . . . . . . . . . . . . . . . . . . . . 13
relative note entry and polyphony . . . . . . . . . . . . . . . . 46
relative notes and parallel expressions . . . . . . . . . . . . 25
relative notes and simultaneous music . . . . . . . . . . . . 25
remove. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
removing engravers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
removing objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
Appendix D: LilyPond index 187
rest . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
rest, spacer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
revert . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82, 87
revert command. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
reverting to a single voice . . . . . . . . . . . . . . . . . . . . . . . . 49
rgb colors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
rgb-color . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
rhythms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
right-padding property . . . . . . . . . . . . . . . . . . . . . 109, 112
right-padding property, example. . . . . . . . . . . . . . . . . 112
Running LilyPond. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
running LilyPond under MacOS X . . . . . . . . . . . . . . . 11
running LilyPond under Unix . . . . . . . . . . . . . . . . . . . . 11
running LilyPond under Windows . . . . . . . . . . . . . . . . 11
S
SATB structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
SATB template . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
scale . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Scheme . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
Scheme programming language . . . . . . . . . . . . . . . . . . . . 4
Scheme, in-line code . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
score . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
score . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Score . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
score block, contents of . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
score formatting. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Score layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
score, example of writing . . . . . . . . . . . . . . . . . . . . . . . . . 76
scores, multiple . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Script, example of overriding . . . . . . . . . . . . . . . . . . . . 111
self-alignment-X property . . . . . . . . . . . . . . . . . . . . . . . 110
self-alignment-X property, example . . . . . . . . . . . . . . 113
set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
setting properties within contexts . . . . . . . . . . . . . . . . 62
Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
sharp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
sharp, double . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
shift commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
shiftOff . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
shiftOn. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
shiftOnn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
shiftOnnn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
simple examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
simple notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
simultaneous music. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
simultaneous music and relative notes . . . . . . . . . . . . 25
Simultaneous notes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
single staf polyphony . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
size of objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
size, changing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
sizing grobs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
Skipping corrected music . . . . . . . . . . . . . . . . . . . . . . . . 132
slur . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
slur . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Slur example of overriding. . . . . . . . . . . . . . . . . . . . . . . . 86
Slur, example of overriding . . . . . . . . . . . . . . . . . . . 87, 88
slur, phrasing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Slurs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
slurs and articulations. . . . . . . . . . . . . . . . . . . . . . . . . . . 105
slurs and outside-staf-priority. . . . . . . . . . . . . . . . . . . 105
slurs crossing brackets . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
slurs versus ties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
slurs, controlling manually . . . . . . . . . . . . . . . . . . . . . . 114
Snippet List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8, 9
snippets. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
songs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
spacer rest . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
Spacing issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
spacing notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
spacing, regular . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
spanner . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
Specialist notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
staccato. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Staff . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
staf group . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
staf line spacing, changing . . . . . . . . . . . . . . . . . . . . . . . 98
staf, choir . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
staf, grand . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
staf, piano. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
staf, positioning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
staf-padding property . . . . . . . . . . . . . . . . . . . . . . . . . . 109
staf-padding property, example . . . . . . . . . . . . . . . . . 113
staf-position property . . . . . . . . . . . . . . . . . . . . . . . . . . 110
staf-position property, example . . . . . . . . . . . . 113, 121
staf-space property, example . . . . . . . . . . . . . . . . . . . . . 98
StafSymbol, example of overriding . . . . . . . . . . . 94, 98
startTextSpan. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
staves, multiple . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
staves, temporary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
stem directions and voices . . . . . . . . . . . . . . . . . . . . . . . . 48
stem down . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
stem length, changing . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
stem up. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
Stem, example of overriding. . . . . . . . 94, 100, 122, 124
stencil property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
stencil property, example . . . . 91, 93, 95, 98, 112, 125
stencil property, use of . . . . . . . . . . . . . . . . . . . . . . . . . . 125
stopTextSpan. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
StringNumber, example of overriding . . . . . . . . . . . . 113
Structure of a score . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
T
template, modifying. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
template, SATB. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
template, writing your own. . . . . . . . . . . . . . . . . . . . . . . 76
templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
temporary staves . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
tenor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
terminology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Text editor support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
text editors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
text property, example . . . . . . . . . . . . . . . . . . . . . . 84, 112
text spanner . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
Text spanners . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
text, adding. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
textLengthOff. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
textLengthOn. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
TextScript, example of overriding . . . . . . . . . . . . . . . 106
TextSpanner, example of overriding. . . . . . . . . 104, 105
The tweak command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
thickness . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
thickness property, example . . . . . . . . . . . . . . . 86, 87, 88
tie . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19, 20
Tie, example of overriding. . . . . . . . . . . . . . . . . . . . . . . 121
Appendix D: LilyPond index 188
Ties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
ties crossing brackest . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
time signature . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Time signature. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
times . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
TimeSignature, example of overriding. . . . . 92, 93, 94,
95, 96, 97, 98
tips for constructing fles . . . . . . . . . . . . . . . . . . . . . . . . . 17
title. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
Top. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8, 9, 10
transparency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
transparent property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
transparent property, example . . 84, 92, 122, 124, 125
transparent property, use of . . . . . . . . . . . . . . . . . . . . . 124
transposition. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
treble . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
triplet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
triplet bracket . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
triplets. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
triplets, nested . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
Tunable context properties . . . . . . . . . . . . . . . . . . . 63, 66
tuplet beams, controlling manually . . . . . . . . . . . . . . 114
tuplet bracket . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
tuplet-number function, example . . . . . . . . . . . . . . . . . 84
TupletBracket. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
TupletNumber, example of overriding. . . . . . . . . . . . . 84
tuplets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Tuplets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
tuplets, nested . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
tweak . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
tweak command. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
tweaking bar number placement . . . . . . . . . . . . . . . . . 104
tweaking dynamics placement . . . . . . . . . . . . . . . . . . . 107
tweaking methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
tweaking metronome mark placement . . . . . . . . . . . 104
tweaking rehearsal mark placement . . . . . . . . . . . . . . 104
tweaks, using variables for. . . . . . . . . . . . . . . . . . . . . . . 126
tying notes across voices . . . . . . . . . . . . . . . . . . . . . . . . 124
typography. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
typography, music . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
U
underscore . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Unix, running LilyPond . . . . . . . . . . . . . . . . . . . . . . . . . . 11
unset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
Upbeats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
updating fles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
Updating fles with convert-ly . . . . . . . . . . . . . . . 34, 138
upgrades . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
using variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
using variables for tweaks . . . . . . . . . . . . . . . . . . . . . . . 126
V
variables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33, 38, 133
variables vs. properties . . . . . . . . . . . . . . . . . . . . . . . . . . 174
variables, characters allowed in . . . . . . . . . . . . . . . . . . . 33
variables, defning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
variables, using . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
variables, using for tweaks. . . . . . . . . . . . . . . . . . . . . . . 126
verse and refrain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
verses, multiple vocal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
version. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
version number . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
versioning. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
viewing music . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Vocal music. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32, 33, 58
vocal score structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
vocal scores with multiple verses. . . . . . . . . . . . . . . . . . 53
Voice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Voice context . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
voice contexts, creating. . . . . . . . . . . . . . . . . . . . . . . . . . . 48
voiceFour . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
voiceOne . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
voices and stem directions . . . . . . . . . . . . . . . . . . . . . . . . 48
voices crossing brackets . . . . . . . . . . . . . . . . . . . . . . . . . . 45
voices vs. chords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
voices, more on one staf . . . . . . . . . . . . . . . . . . . . . . . . . 28
voices, multiple . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
voices, naming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
voices, nesting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
voices, reverting to single. . . . . . . . . . . . . . . . . . . . . . . . . 49
voices, temporary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
voiceThree . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
voiceTwo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
W
whitespace insensitive . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
whole note . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Windows, running LilyPond. . . . . . . . . . . . . . . . . . . . . . 11
with . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
within-staf objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
words with multiple syllables in lyrics . . . . . . . . . . . . 29
writing a score, example. . . . . . . . . . . . . . . . . . . . . . . . . . 76
Writing pitches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Writing rests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Writing rhythms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Writing text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
X
X11 colors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
x11-color . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
x11-color function, example of using . . . . . . . . . . . . . 129
x11-color, example of using. . . . . . . . . . . . . . . . . . . . . . . 94

i

Table of Contents
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.1 Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 Engraving . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 Automated engraving . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 What symbols to engrave? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Music representation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Example applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 1.2 About the documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 About the Learning Manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 About the Music Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 About the Notation Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 About the Application Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 About the Snippet List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 About the Internals Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 Other documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

2

Tutorial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.1 First steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.1.1 Compiling a file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.1.2 Simple notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.1.3 Working on input files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.1.4 How to read the manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.2 Single staff notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.2.1 Accidentals and key signatures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.2.2 Ties and slurs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.2.3 Articulation and dynamics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.2.4 Adding text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.2.5 Automatic and manual beams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.2.6 Advanced rhythmic commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.3 Multiple notes at once . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.3.1 Music expressions explained . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.3.2 Multiple staves . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.3.3 Staff groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.3.4 Combining notes into chords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.3.5 Single staff polyphony . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.4 Songs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.4.1 Setting simple songs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.4.2 Aligning lyrics to a melody . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.4.3 Lyrics to multiple staves . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.5 Final touches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.5.1 Organizing pieces with variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.5.2 Version number. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.5.3 Adding titles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.5.4 Absolute note names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.5.5 After the tutorial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 11 12 16 17 18 18 19 20 22 22 23 24 24 25 26 27 28 28 28 29 32 33 33 34 34 35 36

ii

3

Fundamental concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
3.1 How LilyPond input files work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.1.1 Introduction to the LilyPond file structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.1.2 Score is a (single) compound musical expression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.1.3 Nesting music expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.1.4 On the un-nestedness of brackets and ties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.2 Voices contain music . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.2.1 I’m hearing Voices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.2.2 Explicitly instantiating voices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.2.3 Voices and vocals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.3 Contexts and engravers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.3.1 Contexts explained . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.3.2 Creating contexts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.3.3 Engravers explained . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.3.4 Modifying context properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.3.5 Adding and removing engravers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.4 Extending the templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.4.1 Soprano and cello . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.4.2 Four-part SATB vocal score . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.4.3 Building a score from scratch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 37 39 41 43 44 44 48 52 58 58 59 61 62 66 68 69 72 76

4

Tweaking output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
4.1 Tweaking basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 4.1.1 Introduction to tweaks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 4.1.2 Objects and interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 4.1.3 Naming conventions of objects and properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 4.1.4 Tweaking methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 4.2 The Internals Reference manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84 4.2.1 Properties of layout objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84 4.2.2 Properties found in interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 4.2.3 Types of properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90 4.3 Appearance of objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 4.3.1 Visibility and color of objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 4.3.2 Size of objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 4.3.3 Length and thickness of objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 4.4 Placement of objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99 4.4.1 Automatic behavior . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99 4.4.2 Within-staff objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 4.4.3 Outside-staff objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 4.5 Collisions of objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109 4.5.1 Moving objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109 4.5.2 Fixing overlapping notation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111 4.5.3 Real music example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 4.6 Further tweaking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124 4.6.1 Other uses for tweaks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124 4.6.2 Using variables for tweaks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126 4.6.3 Other sources of information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127 4.6.4 Avoiding tweaks with slower processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128 4.6.5 Advanced tweaks with Scheme . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129

. . A. . . . . . . . .1 Suggestions for writing LilyPond input files . . . . .1 String quartet . .1. . . . . . . . . .1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A. . . . . . . . . . . . .5. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1 SATB vocal score . . . . . . . . . . . . . . . . . . . . .1 Notes only . . . . . . . . . . . . . . . . . . . . . . . .3 Scores and parts . . . . . . . . . .5 Style sheets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176 LilyPond index . . . . . . . . . . . . . . . . . . . . .5. . . . . . . . . . . . . . . . . . . . . . . 5. . . . . . . . . . . . . . . . . . . . . . . . . . . . A. . . . . . . . . . . . . . A. . . . . . . .5 Ancient notation templates . .1 Single staff . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . lyrics. . . . . . . . . . . . . A. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3 SATB with aligned contexts .3 xelatex . . . . . . . . . . . . . .7. A. . . . . . . . . . . . . . . . . . . . . . . . .3 Large projects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .iii 5 Working on LilyPond projects . . . . . . . . . . . . . . A. . . . 5. . . . . . . . 5. . . . . . . . . . . . . . . .2 String quartet parts . . . . . . . . . . . . . . 5. . . . . A. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2 When things don’t work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A. . . . . . . . . . . . . . . .2 Gregorian transcription template . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1. . . . . . . . . . . . . 173 GNU Free Documentation License . . . . . . .7 lilypond-book templates . . . . . . . . . . . . . . . . . . . . . . .4. 131 131 132 132 133 134 138 138 138 139 139 Appendix A Templates . . . . . . . . . . . . . . . . . 174 . . . A. . A. . . . . . . 5. . . . . . . . . . . . . . . . . 5. . . . . . . . . . .1 LaTeX . . . . . . . . . . . . . . . . . . . . . . . . . . . .4. . . . . . . .1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1 General suggestions . . . 5. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1. . . A. . . . . . . . . . . . . . . . . .1 Tweaking with Scheme. . . . . . . . . . . . . . . . . Appendix B Appendix C Appendix D Scheme tutorial . . .1. . .1 Transcription of mensural music. . . . . . . . . . . . . . . . .4 Saving typing with variables and functions . . . . .2 Notes and lyrics . . . .2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2. . . . . . . . . . . . . .4 Piano centered dynamics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A. .4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2 Typesetting existing music. . . . . A. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6 Jazz combo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1. . . . . . . . . . . . .4 Vocal ensembles . . . .3. . . . . . . . . . . . . . . . A. . . . . . . . . . . . . . . . A. . . A. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3 Piano centered lyrics . . . 131 5. . . . . . and chords. . . . . . . . . . . . . .2 Piano templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A. . . . . . . . . . . . . .2. . . . . . . . .4 Notes. . . . . . . . . . . . . . . . . . . .2 Piano and melody with lyrics . . . 5. . . . . . . . . . . . . . . . . . . . . . . . . A. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2. . . . . . . . . . . . . . . . . . . . . . . . . .7. A. . . . . . . . 182 B. . . . . . . . . .3 String quartet . . . . . . . . . . . . . . . . .1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1 Solo piano . . . . . .2 SATB vocal score and automatic piano reduction . .7. . . . . . . . A. . . . . . . . . . . . . 5. . . . . . . . . . . . . . . . . . .3 Notes and chords . . . . . . . . . . . . . . . . . . . . . . . A. . . . . . . . . .2. . . . . . . . . . . . . . . . . . . . . .3 Minimal examples . . . . . . . . . 5. . . . . . . 141 141 141 141 142 143 143 143 144 145 146 148 148 149 152 152 154 156 157 158 163 164 170 170 171 171 A. . . . .1 Updating old input files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2 Texinfo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3. . . . . . A. . . . . .2 Troubleshooting (taking it all apart) . . . . . . . . . . . . . . . . . . . . . . . . . . .2. . . . . . . . . . A. . . . . . . . . . . . . . .

so we would like to thank all users that sent us bug reports. In the beginning. and we keep doing it. it has become a part of our life. somewhere in 1995 that Jan. but you keep playing. working on LilyPond can be dull work. and if you are not motivated by others – teachers. Some days it comes naturally. When we browse around the net we find many people who use LilyPond. and the things you cannot do are challenging. Programming together is a lot of fun. After lots of philosophizing and heated email exchanges. In some ways. As it happened. so he started looking at the software. After the initial excitement. but ultimately. about the grand new project he was working on. told Han-Wen. and it is wonderful. and gradually playing becomes a part of your life. You continue. . and helping people is deeply satisfying. Han-Wen started LilyPond in 1996. you have to practice and practice. Han-Wen accidentally wanted to print out some parts from a score. many of them also help us by giving suggestions and sending bug reports. Scales and studies can be dull. conductors or audience – it is very tempting to give up. July 2002.Preface 1 Preface It must have been during a rehearsal of the EJE (Eindhoven Youth Orchestra). It was decided that MPP was a dead end. and he quickly got hooked. one of the cranked violists. Playing and printing music is more than a nice analogy. and on some days it feels like plodding through a morass of bugs. working on LilyPond is a way to express our deep love for music. The Netherlands. and produce impressive pieces of sheet music. Seeing that feels unreal. It was an automated system for printing music (to be precise. This time. discovering how it works is fun. and on some days it just does not work. Like making music. Nevertheless. a preprocessor for MusiXTeX). day after day. it was MPP. Jan got sucked into Han-Wen’s new project. one of the distorted French horn players. but in a very pleasant way. Our users not only give us good vibes by using our program. gave suggestions or contributed in any other way to LilyPond. developing a computer program is like learning to play an instrument. Probably the most important motivation is that our program actually does something useful for people. May it help you create lots of beautiful music! Han-Wen and Jan Utrecht/Eindhoven.

The term derives from the traditional process of music printing. The plate would be inked. the distribution of space should reflect the durations between notes.1 Background This section covers the overall goals and architecture of LilyPond. Making a correction was cumbersome. if possible at all. and its weight harmonizes with the thickness of our staff lines. The images below illustrate the difference between traditional engraving and typical computer output. Engraving was a highly specialized skill. Henle (2000) B¨renreiter (1950) a LilyPond Feta font (2003) In spacing. this one. which makes them unpleasant to play from. the pervasive use of computers has also decreased the graphical quality of scores. It is rounded. and once with corrections. Our flat symbol is designed after. 1. Unfortunately. so the engraving had to be perfect in one go. a craftsman had to complete around five years of training before earning the title of master engraver. The left scan illustrates typical a flaws of computer print: the staff lines are thin. among others.Chapter 1: Introduction 2 1 Introduction This chapter introduces readers to LilyPond and the documentation. sheet music was made by cutting and stamping the music into a zinc or pewter plate in mirror image. By contrast. This has obvious advantages. Just a few decades ago. and another five years of experience were necessary to become truly skilled. and editorial work can be delivered by email. In the next example a motive is printed twice: once using exact mathematical spacing. almost voluptuous rounded look. The left picture shows a scan of a flat symbol from an edition published in 2000. which leads to poor results. many modern scores adhere to the durations with mathematical precision. Nowadays. all newly printed music is produced with computers. Can you spot which fragment is which? . The stamping and cutting was completely done by hand. mechanical look. prints are cheaper to make. An image was formed by pressing paper to the plate. and the third picture shows how LilyPond mimics the traditional look. However. The center depicts a symbol from a hand-engraved B¨renreiter edition of the same music. the depressions caused by the cutting and stamping would hold ink. the B¨renreiter flat has a a bold. which are also much thicker than lines in the computer edition. the weight of the flat symbol matches the light lines and it has a straight layout with sharp corners. Computer printouts have a bland. Engraving The art of music typography is called (plate) engraving.

spacing corrections lead to subtle variations in the layout of every line. the software can be refined to do more and more things automatically. and make it available to normal musicians. Layout should be pretty. the lines might lose their place on the page. this will be a huge improvement over existing software. If LilyPond solves most of the common situations correctly. the eye deceives us a little. and program settings to produce prints that match the quality of the old editions we love to see and love to play from. A careful distribution of white space allows music to be set very tightly without cluttering symbols together. the definitions of typographical style must also be accessible to the user. and that producing it requires considerable expertise. the user must have access to the formatting engine. If a musician looks away once or has a lapse in concentration. This is a common characteristic of typography. which musicians usually do not have. the strong visual look of bold symbols on heavy staff lines stands out better when the music is far away from the reader. However. LilyPond is our effort to bring the graphical excellence of hand-engraved music to the computer age. we wrote the LilyPond program entirely in the C++ programming language. Similarly. Therefore.Chapter 1: Introduction 3 Each bar in the fragment only uses notes that are played in a constant rhythm. When we started. the program’s functionality was set in stone by the developers. giving each one a distinct visual signature. The spacing should reflect that. if it is on a music stand. users can disagree with our personal decisions. and therefore a matter of taste. and the notes of a down-stem/up-stem combination should be put closer together. better typography translates to better performances. The result minimizes the number of page turns. the more they can focus on playing the music. so manual overrides are less and less necessary. it also takes into account the distance between consecutive stems. the lower two measures without. and they become like a labyrinth. so people cannot be replaced completely. Musicians are usually more absorbed with performing than with studying the looks of a piece of music. Automated engraving How do we go about implementing typography? If craftsmen need over ten years to become true masters. which is a great advantage. much of the dull work can be automated. Therefore. • Engraving is a matter of visual judgment. Without this signature all lines would look the same. The less attention they need for reading. font-designs. Typography relies on human judgment of appearance. but especially because it helps the reader in her task. the notes of an up-stem/down-stem combination should be put farther apart. These examples demonstrate that music typography is an art that is subtle and complex. forming down-stem/up-stem clumps of notes. In larger pieces with monotonous rhythms. The remaining cases can be tuned by hand. this is of double importance: musicians have a limited amount of attention. Over the course of years. That proved to be unsatisfactory for a number of reasons: • When LilyPond makes mistakes. But it is not. Hence. rules and settings cannot be fixed by us at compile-time but must be accessible for users at run-time. not only for its own sake. all depending on the combined vertical positions of the notes. . The upper two measures are printed with this correction. how could we simple hackers ever write a program to take over their jobs? The answer is: we cannot. As knowledgeable as we are. In other words. As a result. We have tuned our algorithms. For performance material like sheet music. users need to override formatting decisions. so nitpicking about typographical details may seem academical. for example. Unfortunately. not only does it notice the distance between note heads.

Common music notation is a system of recording music that has evolved over the past 1000 years. You are free to alter this value. the graphical objects have all directions down (or left). The second chord has all directions up (right). the rule which note head objects are used to produce their symbol is changed during the music fragment. the details still evolve to express the innovations of contemporary notation. we continually refine the formatting algorithms. These procedures perform the actual formatting. These problems have been addressed by integrating an interpreter for the Scheme programming language and rewriting parts of LilyPond in Scheme. 2 4 F D G 2 c2 m m bla c c What symbols to engrave? The formatting process decides where to place symbols. it encompasses some 500 years of music. the thickness of many lines – a characteristic of typographical style – is a variable with a preset value. For example. The current formatting architecture is built around the notion of graphical objects. . note heads on a 5-line staff) has not changed. so we need a flexible approach to rules. Although the basic form (i. The form that is now in common use dates from the early renaissance. In the first chord. Here you see two chords. Scheme variables control layout decisions. The process of formatting a score consists of reading and writing the variables of graphical objects. described by Scheme variables and functions. This architecture encompasses formatting rules. In the following example. with accents and arpeggios. we can change the appearance of objects. giving your score a different typographical impression. Some variables have a preset value. Its applications range from monophonic melodies to monstrous counterpoints for large orchestras. For example. and by substituting different ones.. Formatting rules are also preset variables: each object has variables containing procedures. However. The user has direct access to most of these controls. this can only be done once it is decided what symbols should be printed.e.Chapter 1: Introduction 4 • Finally. many graphical objects have a direction variable that encodes the choice between up and down (or left and right). in other words what notation to use. The C++ language forces a certain method of grouping rules that do not match well with how music notation works. Hence. typographical style and individual formatting decisions.

By adding engravers for beams. typography) into digestible and programmable chunks: every type of symbol is handled by a separate module. The engravers for note heads.. but the stems. for a chord) note head is seen. are private to each voice. the accidentals and staff are shared. Every time one (or more. bar lines. accents. slurs. a stem object is created and connected to the note head. and key signature. the Note_ heads_engraver. beams. and force it into the confines of a computer program? Our solution is to break up the problem of notation (as opposed to engraving. engravers should be grouped.e. In the following example. The Stem_engraver is notified of any note head coming along. Such plug-ins are called engravers. This system works well for monophonic music. Each plug-in is completely modular and independent. we get a complete piece of notation. so each can be developed and improved separately. but what about polyphony? In polyphonic notation. Hence. accidentals.Chapter 1: Introduction 5 How can we get a grip on such a many-headed beast. many voices can share a staff. Then a Staff_symbol_engraver adds the staff the Clef_engraver defines a reference point for the staff and the Stem_engraver adds stems. time signature. a so-called plug-in. slurs. we see how we start out with a plug-in for note heads. . stems.. by analogy with craftsmen who translate musical ideas to graphic symbols. etc. i. In this situation.

etc. accidental. The Score context is the top level notation context. multiple Staff contexts can be put into a single Score context.. a single Staff context contains more than one Voice context. Our program serves as a formal definition of a music document. bar. When the format can no longer be trimmed down.. we have reversed the question. syntax also needs structure. go into a group called ‘Staff context. Similarly. the input format for any high-level formatting system is an abstract description of the content. In this case. such syntax is easy to use. more complex music can be expressed. For example f4 Simultaneous notes can be constructed by enclosing them with << and >>: <<c4 d4 e4>> . This poses a formidable problem: how can we define what music really is? Instead of trying to find an answer. How else can you enter complex pieces like symphonies and operas? The structure is formed by the concept of music expressions: by combining small fragments of music into larger ones. that would be the music itself. We write a program capable of producing sheet music. On a microscopic scale. etc. go into a group called ‘Voice context.’ while the engravers for key. by definition we are left with content itself.Chapter 1: Introduction 6 slurs. hence it is easy to type: { c'4 d'8 } to create a quarter note C1 (middle C) and an eighth note D1 (D above middle C).’ In the case of polyphony. and adjust the format to be as lean as possible. See also Internals Reference: Section “Contexts” in Internals Reference. The syntax is also the user-interface for LilyPond. On a larger scale. Music representation Ideally.

. They are partly a matter of taste. and >>: << g2 \\ { f4 <<c4 d4 e4>> } >> Such recursive structures can be specified neatly and formally in a context-free grammar. while writing decent formatting code is much harder. the syntax of LilyPond is clearly and unambiguously defined. Random complex notation Han-Wen Nienhuys Screech and boink . In the larger picture of LilyPond. the importance of input syntax is small: inventing neat syntax is easy. In other words. and also subject of much discussion. This is also illustrated by the line-counts for the respective components: parsing and representation take up less than 10% of the source code. The simplest application is printing notes. The following example combines some more exotic constructs. Although discussions on taste do have their merit. }: { f4 <<c4 d4 e4>> } The above is also an expression. and so it may be combined again with another simultaneous expression (a half note) using <<.Chapter 1: Introduction 7 This expression is put in sequence by enclosing it in curly braces { . User-interfaces and syntax are what people see and deal with most. 2 4 By adding chord names and lyrics we obtain a lead sheet. The parsing code is also generated from this grammar. they are not very productive.. \\. Example applications We have written LilyPond as an experiment of how to condense the art of music engraving into a computer program. the program can now be used to perform useful tasks. C C F C 2 4 twin kle twin kle lit tle star Polyphonic notation and piano music can also be printed. Thanks to all that hard work.

page 2: explains the background and overall goal of LilyPond. page 37: explains some general concepts about the LilyPond file format. the input fragments can be replaced by music images in the resulting PDF or HTML output files. For example. Since the formatting engine is mostly automatic.Chapter 1: Introduction 8 4 8 3 4 8 The fragments shown above have all been written by hand. and can therefore be easily A embedded in other text-based formats such as L TEX. If you are not certain where to place a command. HTML. First time users should start here. the programming language that music functions use. . page 173: presents a short introduction to Scheme. This is material for advanced tweaks. • Chapter 3 [Fundamental concepts]. when you have read all of the Learning Manual. By means of a special program. You should read these chapters in a linear fashion. it can serve as an output means for other programs that manipulate music. or in the case of this manual. and includes translations to various languages. it can also be used to convert databases of musical fragments to images for use on websites and multimedia presentations. page 80: shows how to change the default engraving that LilyPond produces. many users never touch Scheme at all. it is highly advisable to consult the glossary. read this chapter! • Chapter 4 [Tweaking output]. 1. They may be useful for later viewing: • Appendix A [Templates]. page 11: gives a gentle introduction to typesetting music. Just cut and paste a template into a file. add notes. • Chapter 1 [Introduction]. you may want to read some sections again and follow cross-references for further reading. This makes it easy to mix music and text in documents. page 131: discusses practical uses of LilyPond and how to avoid some common problems. as well as explaining some key concepts in easy terms. This manual also shows an application: the input format is text. and you’re done! • Appendix B [Scheme tutorial]. There is a paragraph See also at the end of each section. Texinfo. About the Music Glossary Section “Music glossary” in Music Glossary this explains musical terms. If you are not familiar with music notation or music terminology (especially if you are a non-native English speaker). • Chapter 5 [Working on LilyPond projects]. Read this before undertaking large projects! The Learning Manual also contains appendices which are not part of the recommended linear reading. About the Learning Manual This book explains how to begin learning LilyPond. but that is not a requirement.2 About the documentation This section explains the different portions of the documentation. which contains cross-references to other sections: you should not follow these cross-references at first reading. page 141: shows ready-made templates of LilyPond pieces. • Chapter 2 [Tutorial].

• Section “Converting from other formats” in Application Usage: explains how to run the conversion programs. • Section “General input and output” in Notation Reference: discusses general information about LilyPond input files and controlling output. This section gives details about special notation that will only be useful for particular instrument (or vocal) groups. • Section “Musical notation” in Notation Reference: discusses topics grouped by notation construct. • Section “Spacing issues” in Notation Reference: discusses issues which affect the global output. and convert a variety of music formats to the .ly format. • Section “Cheat sheet” in Notation Reference: is a handy reference of the most common LilyPond commands. . such as selecting paper size or specifying page breaks. • Section “Running LilyPond” in Application Usage: shows how to run LilyPond and its helper programs. • Section “Notation manual tables” in Notation Reference: are a set of tables showing the chord names. such as using special environments for certain text editors. a list of color names. The Notation Reference also contains appendices with useful reference charts. In addition. • Section “Changing defaults” in Notation Reference: explains how to tweak LilyPond to produce exactly the notation you want. • Section “Literature list” in Notation Reference: contains a set of useful reference books for those who wish to know more on notation and engraving. All the snippets are in the public domain. • Section “Interfaces for programmers” in Notation Reference: explains how to create music functions with scheme. including compilation if desired. It assumes that readers are familiar with the concepts in the Learning Manual. MIDI instruments. • Section “LilyPond index” in Notation Reference: a complete index. • Section “LilyPond command index” in Notation Reference: an index of all LilyPond \commands. • Section “Install” in Application Usage: explains how to install LilyPond. These programs are supplied with the LilyPond package. • Section “Setup” in Application Usage: describes how to configure your computer for optimum LilyPond usage. • Section “Specialist notation” in Notation Reference: discusses topics grouped by notation construct.Chapter 1: Introduction 9 About the Notation Reference This book explains all the LilyPond commands which produce notation. • Section “LilyPond-book” in Application Usage: explains the details behind creating documents with in-line music examples. and the Feta font. About the Application Usage This book explains how to execute the programs and how to integrate LilyPond notation with other programs. this section explains how to upgrade input files from previous versions of LilyPond. like this manual. About the Snippet List Section “LilyPond Snippet List” in Snippets: this shows a selected set of LilyPond snippets from the LilyPond Snippet Repository (LSR). This section gives details about basic notation that will be useful in almost any notation project.

the answer might be in these archives. and function. so any snippet which demonstrates new features of a development version must be added separately. the documentation and examples can typically be found somewhere below ‘/usr/share/doc/lilypond/’. distances. • The lilypond-devel mailist archives: this is a collection of previous emails sent to the developer’s list. most variables that control thickness values. About the Internals Reference Section “Internals Reference” in Internals Reference: this is a set of heavily cross linked HTML pages which document the nitty-gritty details of each and every LilyPond class.3 [Other sources of information]. The list of snippets for each subsection of the Notation Reference are also linked from the See also portion. ‘input/lsr/dirname/bla. can be changed in input files. etc. for example ‘scm/lily. see Section 4. Initialization files. On occasion. the exact LilyPond input that was used to produce that image can be viewed by clicking the image. Other documentation There are a number of other sources of information which may be very valuable. For example.ly’. . For more details. • Init files: the location of the documentation files that are mentioned here can vary from system to system.scm’. It is produced directly from the formatting definitions in the source code. and all of them are described in this document. or ‘ly/engraver-init.Chapter 1: Introduction 10 Please note that this document is not an exact subset of LSR.ly’. For example. Almost all formatting functionality that is used internally is available directly to the user. • Embedded music fragments: in all HTML documents that have music fragments embedded. LSR is running a stable LilyPond version. there is a very good chance that if you have a question. On binary packages for the UNIX platform. page 127. we refer to input files relative to the top-directory of the source archive. object.y/input/ lsr/dirname/bla.ly’ may refer to the file ‘lilypond2. Each section of the Notation Reference has a See also subsection. Throughout this manual. are usually found in the directory ‘/usr/share/lilypond/’. The discussion here is more technical. the answer might be found in these archives..6. if you have an advanced question about lilypond internals. Many questions have been asked multiple times. There are a huge number of formatting options. this manual refers to initialization and example files. which refers to the generated documentation. These are stored in ‘input/new/’ in the LilyPond source tree. • News: this is a summary of important changes and new features in LilyPond since the previous version.x. these subsections have clickable links. In the HTML document. • The lilypond-user mailist archives: this is a collection of previous emails sent to the user list.

ly’ on your Desktop. © In addition. { C D E } will produce an error message. LilyPond input files are simple text files. Entering music and viewing output In this section we will explain what commands to run and how to view or print the output. page 17.1 Compiling a file “Compiling” is the term used for processing an input file in LilyPond format to produce a file which can be printed and (optionally) a MIDI file which can be played. Note that there are several other text editors available with better support for LilyPond. 2.1. see Section 2.1.app. After this. LilyPond will be much faster! © MacOS X If you double click LilyPond.4 [How to read the manual]. To create sheet music. it may take a minute or two because all of the system fonts have to be analyzed first. The resulting PDF file will be displayed on your screen. The first example shows what a simple input file looks like. see Section “Text editor support” in Application Usage. For example. we write an input file that specifies the notation. { c d e } is valid input. for example. The braces should also be surrounded by a space unless they are at the beginning or end of a line to avoid ambiguities.  ¨  Note: The first time you ever run LilyPond.1 First steps This section gives a basic introduction to working with LilyPond. The braces may be omitted in some examples in this manual. and then process it with the menu command Compile > Typeset File. . Save it.Chapter 2: Tutorial 11 2 Tutorial This tutorial starts with an introduction to the LilyPond music language and explains how to produce printed music. it will open with an example file. LilyPond input is case sensitive. For more information. 2. if we write: { c' e' g' e' } the result looks like this:  ¨  Note: Notes and lyrics in LilyPond input must always be surrounded by { curly braces }. to ‘test. but don’t forget them in your own music! For more information about the display of examples in the manual. After this first contact we will explain how to create beautiful printed music containing common musical notation.

.Text Document”. proceed as follows: lilypond test..12.. change its name to a name of your choice and change the file extension to . Windows On Windows. 2. Save it. An alternative method to process the ‘test. If any errors occur in processing.ps'.. but also produces a ‘.. Double-clicking the file does not only result in a PDF file.. UNIX Create a text file called ‘test. Layout output to `test.ly GNU LilyPond 2.ly’ on your Desktop and then double-click on the file to process it (the file icon looks like a note). To edit an existing ‘...ly’ file is to drag and drop it onto the LilyPond icon using your mouse pointer..ly You will see something resembling: lilypond test. Double-click on this PDF file to view the typeset score. Finding the ideal number of pages.. Converting to `test. please see the log window.ly' Parsing..ly. Drawing systems.ly’ file. if you double-click in the LilyPond icon on the Desktop..ly’ and enter: { c' e' g' e' } To process ‘test..log’ file that contains some information on what LilyPond has done to the file. to ‘test. time signature. but LilyPond has added a clef.Chapter 2: Tutorial 12 For future use of LilyPond. After some seconds. Double-click the icon to type in your LilyPond source code as before.pdf'. To get an empty file to start from. If any errors occur. and rhythms. please examine this file. you should begin by selecting ‘New’ or ‘Open’. In the next example.. right-click on it and select “Edit source”.3 Processing `test.. or right-click on the desktop and select “New.ly’. Preprocessing graphical objects. Fitting music on 1 page.1. Interpreting music. You must save your file before typesetting it. run the editor as described above and use “New” in the “File” menu.pdf’ on your desktop.2 Simple notation LilyPond will add some notation elements automatically. { c' e' g' e' } . we have only specified four pitches. you will get a file ‘test.. it will open a simple text editor with an example file. for example..

Let us see how this relative calculation works in practice.Chapter 2: Tutorial 13 This behavior may be altered. The easiest way to enter notes is by using \relative mode.. Section “accidental” in Music Glossary. Section “scale” in Music Glossary. and an A. D or E it will be assumed to be above the B. We begin by entering the most elementary piece of music.e. the first note – the d – is the closest D to middle C. Section “octave” in Music Glossary. So if the note following a B is a C. in which every note is within just one staff space of the previous note. . a scale. Each successive note is placed closest to the previous note – in other words. which is on the middle line in a treble clef. Starting from a B. it is to be placed in the octave which is within three staff spaces of the previous note. but in most cases these automatic values are useful. from the \relative c' { command. we can change the starting octave: % one octave above middle C \relative c'' { e c a c } Relative mode can be confusing initially. We can create melodies which have larger intervals. still using only \relative mode: \relative c' { d f a g c b f d } It is not necessary for the first note of the melody to start on the note which specifies the starting pitch. G or F will be assumed to be below. This is followed by the closest D to the previous note. the first c is the closest C to middle C. Pitches Music Glossary: Section “pitch” in Music Glossary. you can reach a C. Section “interval” in Music Glossary. In the previous example. i. the octave is chosen automatically by assuming the following note is always to be placed closest to the previous note. D and E within 3 staff spaces going up. G and F within 3 staff spaces going down. By adding (or removing) quotes ' or commas . but is the easiest way to enter most melodies. and an A. Section “middle C” in Music Glossary. In this mode. % set the starting point to middle C \relative c' { c d e f g a b c } The initial note is middle C.

Section “quarter note” in Music Glossary. we can raise the octave by adding a single quote ' (or apostrophe) to the note name. We can lower the octave by adding a comma . 1 for a whole note. 4 for a quarter note and so on. Section “dotted note” in Music Glossary. we use multiple '' or . \relative c'' { a1 a2 a4 a8 a a16 a a a a32 a a a a64 a a a a a a a a2 } . c' f. so is the d 4 down. so is the e 1 down. Beams are added automatically.. the previous duration is used for the next note. If you do not specify a duration. Precisely the same staff space counting is done from a note at any other position on the staff. The duration of the first note defaults to a quarter.. Durations (rhythms) Music Glossary: Section “beam” in Music Glossary. g g'' a.Chapter 2: Tutorial 14 \relative c'' b c % c is b d % d is b e % e is b a % a is b g % g is b f % f is } { 1 2 3 6 5 4 staff up or up or up or up or up or space up. so is the 5 down. Section “whole note” in Music Glossary. so is the f c above above above below below below Exactly the same happens even when any of these notes are sharpened or flattened. \relative c'' { a a. – but be careful that you use two single quotes '' and not one double quote " ! The initial value in \relative c' may also be modified like this. Section “duration” in Music Glossary. The duration of a note is specified by a number after the note name. Section “half note” in Music Glossary. so is the g 3 down. f' } To change a note by two (or more!) octaves. Accidentals are totally ignored in the calculation of relative position. 2 for a half note. To add intervals that are larger than three staff spaces. so is the a 2 down. to the note name.

a8 a8.. A rest is entered just like a note with the name r : \relative c'' { a r r2 r8 a r4 r4. The clef can be set using the \clef command: \relative c' { \clef treble c1 \clef alto c1 . a8 a4. to the duration number. a16 a a8.e. } Rests Music Glossary: Section “rest” in Music Glossary.Chapter 2: Tutorial 3 15 To create dotted notes. add a dot . The duration of a dotted note must be stated explicitly (i. with a number). The time signature can be set with the \time command: \relative c'' { \time 3/4 a4 a a \time 6/8 a4. r8 } Time signature Music Glossary: Section “time signature” in Music Glossary. a \time 4/4 a4 a a a } 3 4 Clef 6 8 Music Glossary: Section “clef” in Music Glossary. \relative c'' { a a a4.

b. Section “Clef” in Notation Reference. These braces tell LilyPond that the input is a single music expression. T).3 Working on input files LilyPond input files are similar to source files in many common programming languages. Expressions are formed with curly braces { }. a. { c d e } means the same thing as { c d e } and: { c d e } Of course. s. B. and white-space is generally ignored.g. Notes are lower case: { c d e } is valid input.1.g. { \time 3/4 \clef bass c2 e8 c' g'2.. • Whitespace insensitive: it does not matter how many spaces (or new lines) you add. { C D E } will produce an error message. A. A good rule of thumb is to indent code blocks with either a tab or two spaces: { c d e } • Expressions: every piece of LilyPond input needs to have { curly braces } placed around the input. Section “Writing rhythms” in Notation Reference. and comments are denoted with % or %{ . Section “Writing rests” in Notation Reference. the previous example is hard to read. S.. t) or upper case (e. They are case sensitive. Section “Time signature” in Notation Reference. don’t worry! We’ll explain what all these terms mean: • Case sensitive: it matters whether you enter a letter in lower case (e. just like .Chapter 2: Tutorial 16 \clef tenor c1 \clef bass c1 } All together Here is a small example showing all these elements together: \relative c. r4 } 3 4 See also Notation Reference: Section “Writing pitches” in Notation Reference. %}. If the previous sentences sound like nonsense. f4 e d c4 c. 2.

If you try. you may copy and paste the displayed input. . }. For these examples. it is ignored while parsing.3 [Working on input files].. it does not make sense to add \relative c'' { } – you should not place a \relative inside another \relative! If we included \relative c'' { } around every example. so it has no effect on the printed output. Clickable examples Many people learn programs by trying and fiddling around with the program. The percent symbol % introduces a line comment. Anything that is enclosed in %{ and %} is ignored. most examples will omit this. To replicate the examples. This is also possible with LilyPond. } Why omit the braces? Most examples in this manual can be inserted into the middle of a longer piece of music. There are two types of comments... Try it on this image: Click here. block comments do not ‘nest’. f f e e d d c2 %} 2. If you click on a picture in the HTML version of this manual. The braces should be surrounded by a space unless they are at the beginning or end of a line to avoid ambiguities.4 How to read the manual LilyPond input must be surrounded by { } marks or a \relative c'' { . A LilyPond command followed by a simple expression in braces (such as \relative { }) also counts as a single music expression. By convention. since they are in a block comment. you will see the exact LilyPond input that was used to generate that image. Most people want to add material to an existing piece. anything after % on that line is ignored. as we saw in Section 2. but you must add the \relative c'' { } like this: \relative c'' { . The following fragment shows possible uses for comments: % notes for twinkle twinkle follow c4 c g' g a a g2 %{ This line. you would not be able to copy a small documentation example and paste it inside a longer piece of your own. page 16. the first %} will terminate both block comments.. However.. a line comment is placed above the code it refers to. a4 a a a % this comment refers to the Bs b2 b A block comment marks a whole section of music input as a comment. • Comments: a comment is a remark for the human reader of the music input. so we format the manual this way. This means that you cannot place a block comment inside another block comment. and the notes below are ignored.Chapter 2: Tutorial 17 parentheses () in mathematics.1. example goes here..1. For the rest of this manual.

and a flat pitch by adding es. \key d \major a1 \key c \minor a Warning: key signatures and pitches Music Glossary: Section “accidental” in Music Glossary. you have a starting template for experiments. page 131. like German and Dutch. Section “flat” in Music Glossary.Chapter 2: Tutorial 18 By cutting and pasting everything in the “ly snippet” section. see Section “Note names in other languages” in Notation Reference.1 [Suggestions for writing LilyPond input files]. Section “natural” in Music Glossary. Section “major” in Music Glossary. 2. Section “pitch” in Music Glossary. Section “key signature” in Music Glossary. Section “minor” in Music Glossary. The key signature is set with the command \key followed by a pitch and \major or \minor. To see exactly the same output (line-width and all). This syntax is derived from note naming conventions in Nordic and Germanic languages. aeses Key signatures Music Glossary: Section “key signature” in Music Glossary. . cis1 ees fisis. As you might expect. 2. LilyPond examines the pitches and the key signature. Section “sharp” in Music Glossary.1 Accidentals and key signatures Accidentals Music Glossary: Section “sharp” in Music Glossary. Section “double sharp” in Music Glossary. not the note’s pitch! This is a feature that often causes confusion to newcomers. a double sharp or double flat is made by adding isis or eses. The key signature only affects the printed accidentals. To determine whether to print an accidental. Section “flat” in Music Glossary. A sharp pitch is made by adding is to the name. Section “double flat” in Music Glossary. so let us explain it in more detail. Section “transposition” in Music Glossary. copy everything from “Start cut-&-pastable section” to the bottom of the file. Section “accidental” in Music Glossary.2 Single staff notation This section introduces common notation that is used for one voice on one staff. But it might be best to read through the rest of the tutorial first. To use other names for accidentals.2. See also There are more tips for constructing input files in Section 5.

Chapter 2: Tutorial 19 LilyPond makes a sharp distinction between musical content and layout. A tie is created by appending a tilde ~ to the first note being tied. 2. For some examples how accidentals can be printed according to different rules. it does get an accidental: \key aes \major b Adding all alterations explicitly might require a little more effort when typing. The code b does not mean “print a black dot just on the middle line of the staff. In this example: \key d \major d cis fis No note has a printed accidental. Section “Key signature” in Notation Reference.2. Section “Accidentals” in Notation Reference. natural sign or sharp) of a note is part of the pitch. but the advantage is that transposing is easier. The alteration (flat. See also Notation Reference: Section “Note names in other languages” in Notation Reference. but you must still add is and type cis and fis in the input file. Music Glossary: Section “Pitch names” in Music Glossary. so accidentals are printed automatically according to those rules. Section “Automatic accidentals” in Notation Reference. g4~ g c2~ c4 ~ c8 a8 ~ a2 .” In the key of A-flat major.2 Ties and slurs Ties Music Glossary: Section “tie” in Music Glossary. Layout is something that follows rules. and you must enter what you want to hear.” Rather. Whether an accidental (a printed flat. so they will not be added automatically. and is therefore musical content. and accidentals can be printed according to different conventions. natural or sharp sign) is printed in front of the corresponding note is a question of layout. see Section “Automatic accidentals” in Notation Reference. The pitches in your music are works of art. it means “there is a note with pitch B-natural.

ties Music Glossary: Section “articulation” in Music Glossary. Section “slur” in Music Glossary. Common articulations can be added to a note using a dash . Section “phrasing” in Music Glossary. Slurs and ties can be nested. A slur is a curve drawn across many notes. A slur looks like a tie. You can have both slurs and phrasing slurs at the same time. Slurs indicate the articulation of notes.2. c2~( c8 fis fis4 ~ fis2 g2) See also Notation Reference: Section “Ties” in Notation Reference. and can be used on larger groups of notes. a8(\( ais b c) cis2 b'2 a4 cis. d4( c16) cis( d e c cis d) e( d4) Phrasing slurs Music Glossary: Section “slur” in Music Glossary. Section “tie” in Music Glossary. Section “Slurs” in Notation Reference. Slurs to indicate longer phrasing can be entered with \( and \). Section “Phrasing slurs” in Notation Reference.Chapter 2: Tutorial 20 Slurs Music Glossary: Section “slur” in Music Glossary.and a single character: c-. but you cannot have simultaneous slurs or simultaneous phrasing slurs. c-. and can only be used on pairs of notes with the same pitch.3 Articulation and dynamics Articulations Music Glossary: Section “articulation” in Music Glossary.\) Warnings: slurs vs. but it has a different meaning. A tie simply makes the first note longer. The starting note and ending note are marked with ( and ) respectively. 2.c-> c-^ c-+ c-_ .

Section “decrescendo” in Music Glossary. f^4_2-> e^-_+ 1 4 2 Dynamics Music Glossary: Section “dynamics” in Music Glossary. but you can specify a direction by replacing the dash (-) with ^ (up) or _ (down). or the command \! can be used: c2\< c2\ff\> c2 c2\! ff See also Notation Reference: Section “Articulations and ornamentations” in Notation Reference. . You can also use multiple articulations on the same note. Section “Fingering instructions” in Notation Reference. Dynamic signs are made by adding the markings (with a backslash) to the note: c\ff c\mf c\p c\pp ffmf p pp Crescendi and decrescendi are started with the commands \< and \>. in most cases it is best to let LilyPond determine the articulation directions. Section “crescendo” in Music Glossary. will end the (de)crescendo.Chapter 2: Tutorial 21 Fingerings Music Glossary: Section “fingering” in Music Glossary. However. for example \f. Similarly. The next dynamics sign. c_-^1 d^. Section “Dynamics” in Notation Reference. fingering indications can be added to a note using a dash (-) and the digit to be printed: c-3 e-5 b-2 a-1 3 5 2 1 Articulations and fingerings are usually placed automatically.

1 \dynamic p } espr f 2nd p See also Notation Reference: Section “Writing text” in Notation Reference. they may be overridden manually.Chapter 2: Tutorial 22 2. c16 b4 \autoBeamOn a8 c b4 d8. a8[ ais] d[ ees r d] a b If you want to turn off automatic beaming entirely or for an extended section of music. use the command \autoBeamOff to turn off automatic beaming and \autoBeamOn to turn it on again.4 Adding text Text may be added to your scores: c1^"espr" a_"legato" espr legato Extra formatting may be added with the \markup command: c1^\markup{ \bold espr} a1_\markup{ \dynamic f \italic \small { 2nd } \hspace #0. 2. All beams are drawn automatically: a8 ais d ees r d c16 b a8 If you do not like the automatic beams. c16 b4 .5 Automatic and manual beams Music Glossary: Section “beam” in Music Glossary. \autoBeamOff a8 c b4 d8.2.2. To correct just an occasional beam mark the first note to be beamed with [ and the last one with ].

Section “appoggiatura” in Music Glossary.6 Advanced rhythmic commands Partial measure Music Glossary: Section “anacrusis” in Music Glossary. so a triplet has 2/3 as its fraction \times \times \times \times 2/3 2/3 2/3 2/3 { { { { f8 g a } c r c } f. . The duration of the piece of music is multiplied by the fraction. \partial 8 f8 c2 d Tuplets Music Glossary: Section “note value” in Music Glossary. Section “Tuplets” in Notation Reference.Chapter 2: Tutorial 23 See also Notation Reference: Section “Automatic beams” in Notation Reference. Tuplets are made with the \times keyword. Section “triplet” in Music Glossary. although they can also be created by prefixing a music expression with the keyword \appoggiatura or \acciaccatura: c2 \grace { a32[ b] } c2 c2 \appoggiatura b16 c2 c2 \acciaccatura b16 c2 See also Notation Reference: Section “Grace notes” in Notation Reference.8 g16[ a g a] } d4 a8 } 3 3 3 3 Grace notes Music Glossary: Section “grace notes” in Music Glossary.2. Section “Manual beams” in Notation Reference. A pickup (or anacrusis) is entered with the keyword \partial. Section “Upbeats” in Notation Reference. It is followed by a duration: \partial 4 is a quarter note pickup and \partial 8 an eighth note. Triplets make notes occupy 2/3 of their notated duration. 2. Section “acciaccatura” in Music Glossary. It takes two arguments: a fraction and a piece of music. Grace notes are created with the \grace command.

which is necessary for complex music like polyphonic scores. 2. piano). notes) in braces means that they are in sequence (i. Such formulas are called expressions. 1 1 + 2 (1 + 2) * 3 ((1 + 2) * 3) / (4 * 5) This is a sequence of expressions.e. For example. music is represented by music expressions. and they can contain other expressions. each one follows the previous one). Polyphony in LilyPond refers to having more than one voice on the same staff. where each expression is contained in the next (larger) one. and chords.3.Chapter 2: Tutorial 24 2. . and larger ones are made by combining expressions with operators (like +. Polyphony in music refers to having more than one voice occurring in a piece of music.1 Music expressions explained In LilyPond input files. multiple staves for a single instrument (i. The simplest expressions are numbers.e. A single note is a music expression: a4 Enclosing a note in braces creates a compound music expression.g. The result is another music expression: { { a4 g } f g } Analogy: mathematical expressions This mechanism is similar to mathematical formulas: a big formula is created by composing small formulas. * and /) and parentheses. Like mathematical expressions. Here we have created a compound music expression with two notes: { a4 g4 } Putting a group of music expressions (e. so you can make arbitrarily complex and large expressions.3 Multiple notes at once This section introduces having more than one note at the same time: multiple instruments. music expressions can be nested arbitrarily deep.

A ‘simultaneous’ music expression is formed by enclosing expressions inside << and >>.3.3. LilyPond creates multiples staves. it is easier to see what happens if we create each staff explicitly. not relative to the c'' in the initial \relative command. if there is a simultaneous expression. as we saw in Section 2. In the following example.2 Multiple staves LilyPond input files are constructed out of music expressions. If is a single note.  ¨  Note: each note is relative to the previous note in the input. This technique is useful for polyphonic music. If the score begins with simultaneous music expressions. but indenting LilyPond code like this makes it much easier for humans to read. However.1 [Music expressions explained]. To indicate that two voices should play at the same time. . page 24. To enter music with more voices or more staves. simply enter a simultaneous combination of music expressions. LilyPond does not care how much (or little) space there is at the beginning of a line. © Simultaneous music expressions: single staff To determine the number of staves in a piece. there is more than one staff. there is one staff. \relative c'' { c2 <<c e>> << { e f } { c <<b d>> } >> } 2. LilyPond looks at the beginning of the first expression. we combine expressions in parallel. three sequences (all containing two separate notes) are combined simultaneously: \relative c'' { << { a4 g } { f e } { d b } >> } Note that we have indented each level of the input with a different amount of space.Chapter 2: Tutorial 25 Simultaneous music expressions: multiple staves Music Glossary: Section “polyphony” in Music Glossary.

\relative c'' { << \new Staff { \clef treble \key d \major \time 3/4 c } \new Staff { \clef bass c. For more complex pieces. Printing such a staff is similar to the polyphonic example in Section 2. each piece of music that makes up a staff is marked by adding \new Staff before it.. On the other hand.2 [Multiple staves]. such notation contexts are created automatically.. prepending \new to a music expression creates a bigger music expression.. Staff. } >> } 3 4 3 4 2. The formula (4 + 5) is an expression. Time signatures entered in one staff affects all other staves by default. Piano music is typeset in two staves connected by a brace.3. while Lyrics sets lyric texts and ChordNames prints chord names. Score.’ A notation context is an environment in which musical events (like notes or \clef commands) are interpreted.. and Voice handle melodic notation. it is best to mark contexts explicitly. These Staff elements are then combined in parallel with << and >>: \relative c'' { << \new Staff { \clef treble c } \new Staff { \clef bass c. In terms of syntax. This different default behavior is because scores with transposing instruments are more common than polyrhythmic scores.3 Staff groups Music Glossary: Section “brace” in Music Glossary. page 25. } >> } The command \new introduces a ‘notation context. the key signature of one staff does not affect other staves. .Chapter 2: Tutorial 26 To print more than one staff. However. so −(4 + 5) is a bigger expression. There are several types of contexts.3. For simple pieces. In this way it resembles the minus sign in mathematics. now this entire expression is inserted inside a PianoStaff: \new PianoStaff << \new Staff .

For example. >> Here is a small example: \relative c'' { \new PianoStaff << \new Staff { \time 2/4 c4 e g g.. We saw earlier how notes can be combined into chords by indicating they are simultaneous by enclosing them in double angle brackets. and that the duration is placed after the closing bracket. These staff groups each form another type of context. and \new ChoirStaff. Section “Displaying staves” in Notation Reference.3. r4 <c e g>8[ <c f a>]~ <c f a>2 r4 <c e g>8( <c e g>\> <c e g>4 <c f a>\!) . the normal way of indicating a chord is to surround the pitches with single angle brackets. 2.. and everything must go outside the angle brackets. suitable for vocal scores. See also Notation Reference: Section “Keyboard and other multi-staff instruments” in Notation Reference.. c' e c } >> } 2 4 2 4 Other staff groupings are introduced with \new GrandStaff. r4 <c e g>4 <c f a>2 Think of chords as almost equivalent to single notes: almost everything you can attach to a single note can be attached to a chord.Chapter 2: Tutorial 27 \new Staff . However.4 Combining notes into chords Music Glossary: Section “chord” in Music Glossary. They must be placed outside the angle brackets. Note that all the notes in a chord must have the same duration. you can combine markings like beams and ties with chords. suitable for orchestral scores. } \new Staff { \clef bass c. one that generates the brace at the left end of every system and also controls the extent of bar lines.

5 Single staff polyphony Polyphonic music in lilypond.Chapter 2: Tutorial 28 2. << \relative c'' { \key g \major \time 6/8 d4 b8 c4 a8 d4 b8 g4 } \addlyrics { Girls and boys come out to play. . and the double angle brackets << . Lyrics are entered by separating each syllable with a space. See also Learning Manual: Section 3. Notation Reference: Section “Simultaneous notes” in Notation Reference. combining both with the \addlyrics keyword. Instead. uses concepts that we haven’t discussed yet. so we’re not going to introduce them here.3.. Girls and boys come out to play: \relative c'' { \key g \major \time 6/8 d4 b8 c4 a8 d4 b8 g4 } 6 8 The lyrics can be set to these notes.. Note the curly brackets delimiting both the music and the lyrics. } >> 6 8 Girls and boys come out to play.2 [Voices contain music]. the following sections introduce these concepts and explain them thoroughly.4 Songs This section introduces vocal music and simple song sheets.1 Setting simple songs Music Glossary: Section “lyrics” in Music Glossary. Here is the start of the melody to a nursery rhyme. 2. while not difficult. 2. page 44. >> around the whole piece to show that the music and lyrics are to occur at the same time.4.

The next line in the nursery rhyme is The moon doth shine as bright as day. the simplest being to add a slur across them. } \addlyrics { Girls and boys come out to play. } >> 6 8 Girls 3 and boys come out to play. This is called a melisma. The moon doth shine as bright as day.4. Section “extender line” in Music Glossary.Chapter 2: Tutorial 29 2. The moon doth shine as bright as day. } \addlyrics { Girls and boys come out to play. see Section 2.2. } >> 6 8 Girls and boys come out to play. We see the extra lyrics do not align properly with the notes. There are several ways to spread a syllable over multiple notes.2 Aligning lyrics to a melody Music Glossary: Section “melisma” in Music Glossary.2 [Ties and slurs]. The moon doth shine as bright as day. page 19: << \relative c'' { \key g \major \time 6/8 d4 b8 c4 a8 d4 b8 g4 g8 a4 b8 c( b) a d4 b8 g4. for details. not one. Let’s extend it: << \relative c'' { \key g \major \time 6/8 d4 b8 c4 a8 d4 b8 g4 g8 a4 b8 c b a d4 b8 g4. a single syllable sung to more than one note. The word shine should be sung on two notes. The .

Chapter 2: Tutorial 3 30 moon doth shine as bright as day. As an alternative to using slurs. } \addlyrics { Girls and boys come out to play. } \addlyrics { Girls and boys come out to play. << \relative c'' { \key g \major \time 6/8 d4 b8 c4 a8 d4 b8 g4 g8 a4 b8 c([ b]) a d4 b8 g4. page 22. The moon doth shine as bright as day. We can correct this by inserting manual beaming commands to override the automatic beaming here. The moon doth shine _ as bright as day. } >> 6 8 Girls and boys come out to play. but the automatic beaming for the notes above shine as does not look right.2.5 [Automatic and manual beams]. } >> 6 8 Girls 3 and boys come out to play. for details. The . The moon doth shine as bright as day. The words now line up correctly with the notes. see Section 2. the melismata may be indicated in just the lyrics by using an underscore _ for each note that should be included in the melisma: << \relative c'' { \key g \major \time 6/8 d4 b8 c4 a8 d4 b8 g4 g8 a4 b8 c[ b] a d4 b8 g4.

ger.( bes8 a4. no __ crib for a bed. where al has to be sung on the same note as the go of Largo in Figaro’s aria Largo al factotum: . Here’s an example from Rossini’s Figaro. None of the examples so far have involved words containing more than one syllable. with hyphens between syllables. It is entered as two underscores __. require the opposite: setting more than one syllable to a single note. Here is an example from the first three bars of Dido’s Lament. __ } >> 3 4 A way in a man ger.way in a __ man -. g8 fis4. or enclosing them in quotes. If a syllable extends over several notes or a single very long note an extender line is usually drawn from the syllable extending under all the notes for that syllable.Chapter 2: Tutorial 3 31 moon doth shine as bright as day. especially those in Italian. from Purcell’s Dido and Æneas: << \relative c'' { \key g \minor \time 3/2 g2 a bes bes( a) b c4. resulting in a centered hyphen between the syllables. Such hyphens are entered as two dashes. am laid __ in earth. This is achieved by linking the syllables together with a single underscore _ (with no spaces). no crib for a bed. << \relative c' { \key g \major \time 3/4 \partial 4 d4 g4 g a8( b) g4 g4 b8( c) d4 d e4 c2 } \addlyrics { A -. Some lyrics. Here is an example showing this and everything we have learned so far about aligning lyrics to notes. am laid in earth. } >> 3 2 When I am laid.) g8 fis1 } \addlyrics { When I am laid. Such words are usually split one syllable to a note.

dorn. Here is an example from Handel’s Judas Maccabæus: << \relative c'' { \key f \major \time 6/8 \partial 8 c8 c([ bes]) a a([ g]) f f'4.cy flocks the hills a -.cy flocks the hills a -.la cit -.go_al fac -. } >> . __ } \relative c' { \key f \major \time 6/8 \partial 8 r8 r4. r4 c8 a'([ g]) f f([ e]) d e([ d]) c bes'4 } \addlyrics { Let flee -.dorn.4.t` a } >> 6 8 Lar go al fac to tum del la cit tà See also Notation Reference: Section “Vocal music” in Notation Reference.to -. 2. c4.Chapter 2: Tutorial 32 << \relative c' { \clef bass \key c \major \time 6/8 c4.~ c4 } \addlyrics { Let flee -.~ c8 d b c([ d]) b c d b c } \addlyrics { Lar -.3 Lyrics to multiple staves The simple approach using \addlyrics can be used for placing lyrics under more than one staff.tum del -. b.

We can reduce this confusion by using variables. A variable is assigned as follows: namedMusic = { . 2. Scores any more complex than this simple example are better produced by separating out the score structure from the notes and lyrics with variables. See also Notation Reference: Section “Vocal music” in Notation Reference.. we can break up complex music expressions. the input files can become very confusing. just like a normal LilyPond command). and provides an introduction to the rest of the manual. 6 8 Let flee cy flocks the hills a dorn. In polyphonic music with many staves. violin = \new Staff { \relative c'' { a4 b c b } } cello = \new Staff { \relative c { \clef bass e2 d } } { << \violin \cello >> } .5. With variables (also known as identifiers or macros).5 Final touches This is the final section of the tutorial. it demonstrates how to add the final touches to simple pieces. These are discussed in Section 2.1 Organizing pieces with variables When all of the elements discussed earlier are combined to produce larger files. the music expressions get a lot bigger. } The contents of the music expression namedMusic can be used later by placing a backslash in front of the name (\namedMusic..Chapter 2: Tutorial 33 6 8 Let flee cy flocks the hills a dorn.1 [Organizing pieces with variables]. 2. page 33.5.

This exists outside of the main music expression. and it uses \version to determine what rules to apply. or dashes. see Section “Updating files with convert-ly” in Application Usage. the variable can be used in different places.3 Adding titles The title. underscores. The following example uses the above variables: \paper { \aFivePaper line-width = \width } { c4^\name } 2. and similar information are entered in the \header block.8 e g } barA = { \tripletA \tripletA \tripletA \tripletA } \relative c'' { \barA \barA } 3 3 3 3 3 3 3 3 Variables may be used for many other types of objects in the input. this is placed at the top of your LilyPond file. but may be used as many times as required anywhere after they have been defined. For example.3" By convention.5. Changes in the syntax are handled with a special program. . For details. 2. They may even be used in a later definition of another variable. These annotations make future upgrades of LilyPond go more smoothly. Variables must be defined before the main music expression. composer. giving a way of shortening the input if a section of music is repeated many times. width = 4. opus number. no numbers.12.2 Version number The \version statement records the version of LilyPond that was used to write the file: \version "2. convert-ly. the \header block is usually placed underneath the version number.Chapter 2: Tutorial 34 The name of a variable must have alphabetic characters only.5\cm name = "Wendy" aFivePaper = \paper { paperheight = 21. tripletA = \times 2/3 { c.5.0 \cm } Depending on its contents.

the title and composer are printed above the music. f. This is the easiest way to enter most music... d.12. b.Chapter 2: Tutorial 35 \version "2. A c' will always mean middle C. More information on titling can be found in Section “Creating titles” in Notation Reference.. 9" } { . will always mean the note on the bottom staff of the bass clef. g. e. music . and a g. a b will always mean the note one step below middle C. c d e f g a b c' d' \clef treble e' f' g' a' b' c'' d'' e'' f'' g'' a'' b'' c'''1 } 5 . g. LilyPond treats all pitches as absolute values. g. { \clef bass c' b g. } When the file is processed.3" \header { title = "Symphony" composer = "Me" opus = "Op. If you omit the \relative. 2. f.4 Absolute note names So far we have always used \relative to define pitches. f c' } Here is a four-octave scale: { \clef bass c. but another way of defining pitches exists: absolute mode.5.. a.

there is a paragraph See also at the end of each section. a single mistake will not be as visible. If you have not done so already. look at the Notation Reference. absolute mode is useful for music which has large intervals. when you have read all of the Learning Manual. and is extremely useful for computer-generated LilyPond files. of course! However. please read Section 1. which contains cross-references to other sections: you should not follow these cross-references at first reading. the rest of the Learning Manual assumes that you are familiar with LilyPond input. cis16 b8 d4 d8 } With 6 8 If you make a mistake with an octave mark (' or . Start by adding notes to one of the Appendix A [Templates].2 [About the documentation]. There is a lot of information about LilyPond. and come back to them after you have more experience. the previous example is much easier to read and type: \relative c'' { \key a \major \time 6/8 cis8. However. you might save yourself hours of frustration looking in the wrong places! .4 [Extending the templates]. If you want to write for an instrument ensemble that is not covered in the templates. writing a melody in the treble clef involves a lot of quote ' marks. take a look at Section 3.5 After the tutorial After finishing the tutorial. so newcomers often do not know where they should look for help. you may want to read some sections again and follow cross-references for further reading. \relative. You may wish to skim these chapters right now.) while working in \relative mode. If you need any notation that was not covered in the tutorial. If you spend five minutes reading that section carefully. There’s nothing wrong with reading it now. page 8. cis''16 b'8 d''4 d''8 } 6 8 All these quotes makes the input less readable and they are a source of errors. page 141. page 68. d''16 cis''8 e''4 e''8 b'8. and will not be as easy to find.5.Chapter 2: Tutorial 36 As you can see. Consider this fragment from Mozart: { \key a \major \time 6/8 cis''8. it is very obvious – many notes will be in the wrong octave. 2. When working in absolute mode. read the rest of the Learning Manual (chapters 3-5). d16 cis8 e4 e8 b8. Once you have written a few short pieces. In this tutorial and in the rest of the Learning Manual. starting with Section “Musical notation” in Notation Reference. you should probably try writing a piece or two.

especially when additional commands are used.1 How LilyPond input files work The LilyPond input format is quite free-form. if the input contains a single music expression.12. LilyPond will interpret the file as though the music expression was wrapped up inside the commands shown above. This section will explain some of this structure... leaving them to be created implicitly.. LilyPond treats input like this: \relative c'' { c4 a d c } as shorthand for this: \book { \score { \new Staff { \new Voice { \relative c'' { c4 a b c } } } \layout { } } } In other words. the implicit creation of contexts can give surprising results. 3.Chapter 3: Fundamental concepts 37 3 Fundamental concepts You’ve seen in the Tutorial how to produce beautifully printed music from a simple text file. A word of warning! Many of the examples in the LilyPond documentation will omit the \new Staff and \new Voice commands. giving experienced users a lot of flexibility to structure their files however they wish..1 Introduction to the LilyPond file structure A basic example of a LilyPond input file is \version "2.3" \header { } \score { . Up to this point none of the examples you have seen has used a \score{} command.1. but this example serves as a useful starting place. For a complete description of the input format.compound music expression. \layout { } \midi { } } % all the music goes here! There are many variations of this basic pattern. This section introduces the concepts and techniques required to produce equally beautiful but more complex scores. but may gloss over some details in favor of simplicity. For simple examples this works well. maybe creating extra unwanted . but for more complex examples. This is because LilyPond automatically adds the extra commands which are needed when you give it simple input. 3. see Section “File structure” in Notation Reference. But this flexibility can make things confusing for new users.

. either explicitly or implicitly) will affect every \score in that \book.Chapter 3: Fundamental concepts 38 staves. In summary: Every \book block creates a separate output file (e. as the example at the beginning of this section shows. In fact.  ¨  Note: When entering more than a few lines of music it is advisable to always create staves and voices explicitly. The way to create contexts explicitly is explained in Section 3. a \layout block inside a \score block affects only that \score block. if you would like separate output files from one . So they may be placed inside a \score block or outside it.e.. page 58. though. If these appear as shown they will cause LilyPond to produce a printed output and a MIDI output respectively. Remember that a music expression could be anything from a single note to a huge compound expression like { \new StaffGroup << . Every \score block is a separate chunk of music within a \book block.3 [Contexts and engravers].ly file then the \book command should be used to separate the different sections: each \book block will produce a separate output file. let us return to the first example and examine the \score command. but a \layout block outside of a \score block (and thus in a \book block. it counts as one music expression. All the templates use this . the \score block can contain other things. \header is often placed above the \score command. They are described fully in the Notation Reference – Section “Score layout” in Notation Reference. For details see Section “Multiple scores in a book” in Notation Reference.. leaving the others to default. a PDF file). Every \layout block affects the \score or \book block in which it appears – i.g. You may code multiple \score blocks. such as \score { { c'4 a \header \layout \midi { } b c' } { } { } } Note that these three commands – \header. As we saw previously. A \score block must always contain just one music expression... © For now.. \layout and \midi – are special: unlike many other commands which begin with a backward slash (\) they are not music expressions and are not part of any music expression. Each will be treated as a separate score. >> } Since everything is inside { . and Section “Creating MIDI files” in Notation Reference. LilyPond wraps your entire input code in a \book block implicitly. these commands are commonly placed outside the \score block – for example. However.insert the whole score of a Wagner opera in here. If you haven’t explicitly added one... A \book command is not necessary – one will be implicitly created. but they will be all combined into a single output file. and this must appear immediately after the \score command. Two more commands you have not previously seen are \layout { } and \midi {}. Another great shorthand is the ability to define variables. }.

Section 2. or foofoobarbaz. it takes the value of melody (everything after the equals sign) and inserts it whenever it sees \melody.insert the whole score of a Wagner opera in here. Remember that you can use almost any name you like as long as it contains just alphabetic characters and is distinct from LilyPond command names.Chapter 3: Fundamental concepts 39 melody = \relative c' { c4 a b c } \score { \melody } When LilyPond looks at this file. We do need a singer and a piano. so we shall remove it. Now we’re going to start from a big music expression and work our way down. which simply groups a number of staves together with a bracket at the left. then chords. \score { << \new Staff = "singer" << >> \new PianoStaff = "piano" << >> >> \layout { } . The exact limitations on variable names are detailed in Section “File structure” in Notation Reference. global.2 Score is a (single) compound musical expression We saw the general organization of LilyPond input files in the previous section. etc. you may find it useful to review the tutorial. But we seemed to skip over the most important part: how do we figure out what to write after \score? We didn’t skip over it at all. we saw how to build big music expressions from small pieces – we started from notes. Section 3. so let’s just add a singer and piano. page 24. See also For a complete definition of the input format.1 [Introduction to the LilyPond file structure].1. page 133. see Section 5. We don’t need a StaffGroup for this ensemble. >> } % this brace ends the overall compound music expression \layout { } } A whole Wagner opera would easily double the length of this manual. though. For more details...3. TimeKey. To understand what is meant by a music expression and a compound music expression. pianorighthand. page 37. see Section “File structure” in Notation Reference. In that section.1 [Music expressions explained].1.4 [Saving typing with variables and functions].1. This line explains it all: A \score block must begin with a compound music expression. 3. There’s nothing special about the names – it could be melody. \score { { % this brace begins the overall compound music expression \new StaffGroup << .. The big mystery is simply that there is no mystery..

c4 r } text = \lyricmode { And God said.. >> construct is not really necessary for the Singer staff.>2~ <g d g. We’ll add some real music later. } upper = \relative c'' { <g d g. however. we could start writing \relative c'' { r4 d8\noBeam g.. for now let’s just put in some dummy notes and lyrics. or a Voice with lyrics. we now have a piece of real music: melody = \relative c'' { r4 d8\noBeam g. this term refers to a set of notes. we could start filling in notes. \score { << \new Staff = "singer" << \new Voice = "vocal" { c'1 } \addlyrics { And } >> \new PianoStaff = "piano" << \new Staff = "upper" { c'1 } \new Staff = "lower" { c'1 } >> >> \layout { } } And Now we have a lot more details. the \score section would get pretty long. These were introduced at the end of the previous section. We have the singer’s staff: it contains a Voice (in LilyPond. using << . and it would be harder to understand what was happening. So let’s use variables instead. not necessarily vocal notes – for example.. At this stage. We also have a piano staff: it contains an upper staff (right hand) and a lower staff (left hand). c4 r } But if we did that. two simultaneous Voices. not one after the other! Note that the << .. e. adding a few notes. as it contains only one sequential music expression.g. >> instead of braces is still necessary if the music in the Staff is made of two simultaneous expressions.. } to show simultaneous music. a violin generally plays one voice) and some lyrics.Chapter 3: Fundamental concepts 40 } Remember that we use << . Inside the curly braces next to \new Voice = "vocal"..> } lower = \relative c { b2 e2 } . And we definitely want to show the vocal part and piano part at the same time.. >> instead of { . remember? So..

just take it slowly and carefully. Here is a simple example showing how to introduce a new staff temporarily for the duration of three notes: \new Staff { \relative g' { r4 g8 g c4 c8 d | e4 r8 .Chapter 3: Fundamental concepts 41 \score { << \new Staff = "singer" << \new Voice = "vocal" { \melody } \addlyrics { \text } >> \new PianoStaff = "piano" << \new Staff = "upper" { \upper } \new Staff = "lower" { \clef "bass" \lower } >> >> \layout { } } And God said. Start with the outer level. These are essential to tell LilyPond to interpret the following content as music and text respectively. which are introduced with \lyricmode.3 Nesting music expressions It is not essential to declare all staves at the beginning. It also really helps to be strict with indentation – make sure that each item on the same level starts on the same horizontal position in your text editor.1. This is particularly useful for creating ossia sections – see Section “ossia” in Music Glossary. then work on each smaller level. See also Notation Reference: Section “Structure of a score” in Notation Reference. When writing (or reading) a \score section. and lyrics. 3. they may be introduced temporarily at any point. which are introduced with \relative or which are directly included in a music expression. Be careful about the difference between notes.

3. These require further commands which have not yet been introduced. The ossia section may be placed above the staff as follows: \new Staff = "main" { \relative g' { r4 g8 g c4 c8 d | e4 r8 << { f c c } \new Staff \with { alignAboveContext = #"main" } { f8 f c } >> r4 | } } This example uses \with. It is a means of modifying the default behavior of a single Staff. . See also Ossia are often written without clef and without time signature and are usually in a smaller font. which will be explained more fully later. This is usual for clefs printed in the middle of a line. and Section “Ossia staves” in Notation Reference. Here it says that the new staff should be placed above the staff called “main” instead of the default position which is below.Chapter 3: Fundamental concepts 42 << { f c c } \new Staff { f8 f c } >> r4 | } } Note that the size of the clef is the same as a clef printed following a clef change – slightly smaller than the clef at the beginning of the line.2 [Size of objects]. page 95. See Section 4.

}. and a phrasing slur extending out of a tuplet (lines 3 and 4). the conventional use of brackets requires the different types to be properly nested. a phrasing slur can start before a manually inserted beam and end before the end of the beam – not very musical. perhaps. do not have to nest properly with any of the brackets.1.. a tie crossing two tuplets..}. These obey different rules which can be confusing at first.. ) Marks the start and end of a slur \( . ] Marks the start and end of a manual beam To these we should add other constructs which generate lines between or across notes: ties (marked by a tilde. these are not brackets in the sense that they enclose something – they are simply markers to indicate where something starts and ends. This example shows a beam extending into a tuplet (line 1).. ) } ] >>.\) } 3 3 3 2 5 . This is a requirement for the three types of bracket described by the word ‘Encloses’ in the table above – they must nest properly.4 On the un-nestedness of brackets and ties You have already met a number of different types of bracket in writing the input file to LilyPond. but possible: { g8\( a b[ c b\) a] } In general. and those implied by tuplets. with the closing brackets being encountered in exactly the opposite order to the opening brackets... ties and grace notes. Bracket Type Function { .. for example. However. Outside LilyPond. a beam and a slur extending into a tuplet. > Encloses the notes of a chord << . the remaining brackets.Chapter 3: Fundamental concepts 43 3. \) Marks the start and end of a phrasing slur [ . different kinds of brackets. described with the word ‘Marks’ in the table above together with ties and tuplets. may be mixed freely. So. { r16[ g16 \times 2/3 {r16 e'8] } g16( a \times 2/3 {b d) e' } g8[( a \times 2/3 {b d') e'~]} \times 4/5 {e'32\( a b d' e'} a'4. ~).. Before we explain the rules let’s first review the different types of bracket. >> Encloses simultaneous music expressions ( . << [ { ( . } Encloses a sequential segment of music < . like this. In fact. tuplets written as \times x/y {. and grace notes written as \grace{.. a slur extending into a tuplet (line 2).

Chapter 3: Fundamental concepts 44 3. a Voice layer or context is the only one which can contain music. and combine them simultaneously with angle brackets. as we saw at the beginning of this chapter. \\.2 Voices contain music Singers need voices to sing. Voices are sometimes called ‘layers’ in other notation packages. Here’s how we split the chords above into two voices and add both the passing note and a slur: \key g \major % Voice "1" << { g4 fis8( g) a4 g } Voice "2" \\ { d4 d d d } >> | Notice how the stems of the second voice now point down. the notes would be entered into a single voice. and so does LilyPond. But suppose the F-sharp were actually an eighth-note followed by an eighth-note G. and for this just a single voice is needed. most fundamental or innermost layers in a LilyPond score are called ‘Voice contexts’ or just ‘Voices’ for short. of course. If a Voice context is not explicitly declared one is created automatically.2. < . so when exactly are multiple voices needed? Look first at this example of four chords: \key g \major <d g>4 <d fis> <d a'> <d g> This can be expressed using just the single angle bracket chord symbols. In fact. This technique is particularly suited to pieces of music which are largely monophonic with occasional short sections of polyphony.. This is when two voices are required. >. Here’s another simple example: .>>. A single voice can contain many notes in a chord. Music written for such instruments is monophonic and requires just a single voice.}). <<. The easiest way to enter fragments with more than one voice on a staff is to enter each voice as a sequence (with {. Instruments which can play more than one note at a time like the piano will often require multiple voices to encode the different concurrent notes and rhythms they are capable of playing. to place them in separate voices. 3... Let us see how this is done in LilyPond input syntax. Some instruments such as an Oboe can play only one note at a time. Without these.1 I’m hearing Voices The lowest.. a passing note on the way to the A? Now we have two notes which start at the same time but have different durations: the quarter-note D and the eighth-note F-sharp.. which would usually cause errors. The fragments must also be separated with double backward slashes.. And they cannot be written as two sequential notes as they need to start at the same time. How are these to be coded? They cannot be written as a chord because all the notes in a chord must have the same duration. The actual music for all instruments in a score is contained in Voices – the most fundamental of all LilyPond’s concepts.

r4 } \\ { fis2. but the same construct may be used to encode three or more voices by adding more back-slash separators.2 d4 g | g4 g g8( a) g4 | fis2.. "2". For music with few notes in each bar this layout can help the legibility of the code. . but if there are many notes in each bar it may be better to split out each voice separately.. In each of these contexts. etc. >> construct.Chapter 3: Fundamental concepts 45 \key % << { << { << { d \minor Voice "1" Voice "2" r4 g g4. Slurs and ties may only connect notes within the same voice. like this: \key d \minor << { % Voice "1" r4 g g4. s4 } >> | It is not necessary to use a separate << \\ >> construct for each bar. r4 | } \\ { % Voice "2" d. a8 | bes4 bes c bes | a2. so slurs and ties cannot go into or out of a simultaneous construct. Let’s call this the simultaneous construct. the vertical direction of slurs. s4 | } >> This example has just two voices. ties. stems. \new Staff \relative c' { % Main voice c16 d e f % Voice "1" Voice "2" Voice "3" << { g4 f e } \\ { r8 e4 d c8 ~ } >> | << { d2 e2 } \\ { c8 b16 a b8 g ~ g2 } \\ { s4 b4 c2 } >> | } These voices are all separate from the main voice that contains the notes just outside the << . The Voice contexts bear the names "1". dynamics etc. a8 } \\ { d. is set appropriately.2 d4 g } >> | bes4 bes c bes } \\ { g4 g g8( a) g4 } >> | a2.

and voice four (not used here) to magenta crosses. voice two to blue triangles. and the style of the note head. the stem and the beams. page 126.Chapter 3: Fundamental concepts 46 Conversely.2 [Using variables for tweaks]. Voice one is set to red diamonds. shown here in the blue triangle voice. Note that changes in one voice do not affect other voices. so that the voices may be easily distinguished. . parallel voices from separate simultaneous constructs on the same staff are the same voice. but they do persist in the same voice later. or to the first note of the preceding chord. We shall see later how commands like these may be created by the user. not noteA.6. Each note is still calculated relative to the note immediately preceding it. See Section 4. They modify the color of the note head. Other voice-related properties also carry across simultaneous constructs. page 91 and Section 4. Note also that tied notes may be split across the same voices in two constructs. Here is the same example. with different colors and note heads for each voice. So in \relative c' { noteA << < noteB noteC > \\ noteD >> noteE } noteB is relative to noteA noteC is relative to noteB.3. \voiceNeutralStyle (also not used here) reverts the style back to the default. \new Staff \relative c' { % Main voice c16 d e f << % Bar 1 { \voiceOneStyle g4 f e } \\ { \voiceTwoStyle r8 e4 d c8 ~ } >> << % Bar 2 % Voice 1 continues { d2 e2 } \\ % Voice 2 continues { c8 b16 a b8 g ~ g2 } \\ { \voiceThreeStyle s4 b4 c2 } >> } The commands \voiceXXXStyle are mainly intended for use in educational documents such as this one. Polyphony does not change the relationship of notes within a \relative { } block.1 [Visibility and color of objects]. voice three to green crossed circles.

which may be clearer if the notes in the voices are widely separated. where we have used different note heads and colors for the three voices.. not noteA or noteC. as they must start at the same time. These cannot be written as a chord as all the notes in a chord must have the same duration. Here the stems of the highest notes are all pointing up and the stems of the lower notes are all pointing down. As we shall see. and the normal practice would be to write the whole bar as three voices. } Let us finally analyze the voices in a more complex piece of music. the F is a quarter note and the D-flat is a half note. } << \relative c'' { < noteB noteC > .. This is the first indication that more than one voice is required. this encounters some difficulties. This section of the bar requires three voices. But the real need for multiple voices arises when notes which start at the same time have different durations.Chapter 3: Fundamental concepts 47 noteD is relative to noteB. Let us try to encode this music from scratch. not noteA. } >> \relative c' { noteE . The direction of the stems is often used to indicate the continuity of two simultaneous melodic lines. } \\ \relative g' { noteD .. We begin as we have learnt. The A-flat is a dotted quarter note. Neither can they be written as sequential notes. as shown below. so ignore anything you do not understand.. Here are the notes from the first two bars of the second of Chopin’s Deux Nocturnes. noteE is relative to noteD. the code behind this example will be explained later. An alternative way.. This example will be used at later stages in this and the next chapter to illustrate several techniques for producing notation. so please ignore for now anything in the underlying code which looks mysterious and concentrate just on the music and the voices – the complications will all be explained in later sections. Op 32.. using the << \\ >> construct to enter the music of the first bar in three voices: \new Staff \relative c'' { \key aes \major << { c2 aes4. Look at the notes which start at beat three in the first bar. Again... is to place a \relative command at the start of each voice: \relative c' { noteA . bes8 } \\ { aes2 f4 fes } \\ { <ees c>2 des2 } >> <c ees aes c>1 } .

2 Explicitly instantiating voices Voice contexts can also be created manually inside a << >> block to create polyphonic music. bes8 } \\ % Voice two { aes2 f4 fes } \\ % Omit Voice three \\ % Voice four { <ees c>2 des2 } >> | <c ees aes c>1 | } We see that this fixes the stem direction.. but the stems in voice 3 should go down in this particular piece of music. so we shall leave this problem until a later section — see the force-hshift property in Section 4. slurs. See also Notation Reference: Section “Multiple voices” in Notation Reference..5. \voiceFour to indicate the required directions of stems. LilyPond provides several ways to adjust the horizontal placing of notes. We are not quite ready yet to see how to correct this. but in this example the notes of the lowest voice are clearly not well placed by default. but the notes from the third and fourth voices are displaced.2 [Fixing overlapping notation]. but exposes a problem sometimes encountered with multiple voices – the stems of the notes in one voice can collide with the note heads in other voices. to avoid the note heads colliding. We can correct this simply by missing out voice three and placing the music in voice four: \new Staff \relative c'' { \key aes \major << % Voice one { c2 aes4. In laying out the notes. etc. the construct << \\ >> which we used in the previous section: \new Staff { \relative c' { << { e4 f g a } \\ { c. as it permits the voices to be separated and to be given more descriptive names. This usually works well. if necessary.Chapter 3: Fundamental concepts 48 The stem directions are automatically assigned with the odd-numbered voices taking upward stems and the even-numbered voices downward ones. In longer scores this method is clearer. The stems for voices 1 and 2 are right. Specifically. 3.2. using \voiceOne . LilyPond allows the notes or chords from two voices to occupy the same vertical note column provided the stems are in opposite directions. page 111.4 d e f } >> } } is equivalent to \new Staff << \new Voice = "1" { \voiceOne \relative c' { e4 f g a } } .

\voiceOne and voiceTwo have on markup. articulations. ties. each of which is advantageous in different circumstances. and dynamics: \relative c'{ % Default behavior or behavior after \oneVoice c d8 ~ d e4 ( f g a ) b-> c } \relative c'{ \voiceOne c d8 ~ d e4 ( f g a ) b-> c \oneVoice c. d8 ~ d e4 ( f g a ) b-> c } \relative c'{ \voiceTwo c d8 ~ d e4 ( f g a ) b-> c \oneVoice c. text annotations. . Let us see in some simple examples exactly what effect \oneVoice. d8 ~ d e4 ( f g a ) b-> c } Now let’s look at three different ways to notate the same passage of polyphonic music. augmentation dots of dotted notes. slurs. The command \oneVoice reverts the settings back to the normal values for a single voice. These commands also generate a horizontal shift for each voice when this is required to avoid clashes of note heads. while \voiceTwo and \voiceFour make them point downwards. ties. \voiceOne and \voiceThree make these objects point upwards. slurs. and fingerings.Chapter 3: Fundamental concepts 49 \new Voice = "2" { \voiceTwo \relative c' { c4 d e f } } >> Both of the above would produce The \voiceXXX commands set the direction of stems. using the example from the previous section.

\new Staff \relative c' { \voiceOneStyle % The following notes are monophonic c16^( d e f % Start simultaneous section of three voices << % Continue the main voice in parallel { g4 f e | d2 e2) } % Initiate second voice \new Voice { % Set stems. Here is a more correct rendition of our example. permitting a phrasing slur to be drawn over them. not in a << \\ >> construct). etc. down \voiceTwo r8 e4 d c8 ~ | c8 b16 a b8 g ~ g2 } % Initiate third voice \new Voice { % Set stems. etc. This is useful when extra voices appear while the main voice is playing.Chapter 3: Fundamental concepts 50 An expression that appears directly inside a << >> belongs to the main voice (but. and if a voice appears only briefly this might be a more natural way to typeset the music: \new Staff \relative c' { c16^( d e f << { g4 f e | d2 e2) } \new Voice { \voiceTwo r8 e4 d c8 ~ | << {c8 b16 a b8 g ~ g2} \new Voice { \voiceThree s4 b4 c2 } >> } >> . The red diamond-shaped notes demonstrate that the main melody is now in a single voice context. | s4 b4 c2 } >> } More deeply nested polyphony constructs are possible. up \voiceThree s2. note.

By default. using spacing notes to step over sections where the voice is silent. or notes occurring at the same time in different voices.5. the outer voices (normally voices one and two) have \shiftOff specified. page 116. \shiftOnn. as here: \new Staff \relative c' << % Initiate first voice \new Voice { \voiceOne c16^( d e f g4 f e | d2 e2) | } % Initiate second voice \new Voice { % Set stems. but when the whole staff is largely polyphonic it can be clearer to use multiple voices throughout. . etc. \shiftOnnn. etc. occasionally more. There are separate columns for each voice. The \shiftOn. \shiftOnn and \shiftOnnn define further shift levels which may be specified temporarily to resolve collisions in complex situations – see Section 4.Chapter 3: Fundamental concepts 51 } This method of nesting new voices briefly is useful when only small sections of the music are polyphonic. down \voiceTwo s4 r8 e4 d c8 ~ | c8 b16 a b8 g ~ g2 | } % Initiate third voice \new Voice { % Set stems. voices one and three are shifted to the right and voices two and four to the left. while the inner voices (three and four) have \shiftOn specified. When a shift is applied. In bar 2 the C in voice two is shifted to the right relative to the D in voice one. and in the final chord the C in voice three is also shifted to the right relative to the other notes. are arranged in two. up \voiceThree s1 | s4 b4 c2 | } >> Note columns Closely spaced notes in a chord. columns to prevent the note heads overlapping. and the currently specified voice-dependent shift is applied to the note column if there would otherwise be a collision. This can be seen in the example above. These are called note columns. and \shiftOff commands specify the degree to which notes and chords of the voice should be shifted if a collision would otherwise occur.3 [Real music example].

~ c4 } SopTwoMusic = \relative c' { r8 | r4.dorn. | c4. not a Staff context. but not so well for music with lyrics.dorn.cy flocks the | hills a -.cy flocks the | hills a -. global = { \time 6/8 \partial 8 \key f \major} SopOneMusic = \relative c'' { c8 | c([ bes)] a a([ g)] f | f'4. Let us reuse the earlier example from Judas Maccabæus to illustrate this more flexible technique.rows grow. a16 g4. This is a case where it is necessary to create Staff and Voice contexts explicitly. We first recast it to use variables so the music and lyrics can be separated from the staff structure. You have already seen the \addlyrics{} command. } . the error message “Too many clashing note columns” will be produced. If notes from two voices which have their stems in the same direction are placed at the same position and both voices have no shift or the same shift specified.3 Voices and vocals Vocal music presents a special difficulty: we need to combine two expressions – notes and lyrics. The lyrics themselves must be introduced with \lyricmode to ensure they are interpreted as lyrics rather than music. f8 e4 d c2 } \new Lyrics \lyricsto "one" { No more let sins and sor -. We also introduce a ChoirStaff bracket. In the example above we use the command \autoBeamOff to turn off the automatic beaming. The automatic beaming which LilyPond uses by default works well for instrumental music. using the name assigned to the Voice. } >> 2 4 No more let sins and sor rows grow. 3. r4 c8 | a'([ g)] f f([ e)] d | e([ d)] c bes' } SopOneLyrics = \lyricmode { Let | flee -. See also Notation Reference: Section “Multiple voices” in Notation Reference. b.2. However. __ } SopTwoLyrics = \lyricmode { Let | flee -. For more complex music. Note that the lyrics must be linked to a Voice context. this technique is quite limited. where beaming is either not required at all or is used to indicate melismata in the lyrics. << \new Voice = "one" \relative c'' { \autoBeamOff \time 2/4 c4 b8. you must introduce the lyrics in a Lyrics context using \new Lyrics and explicitly link the lyrics to the notes with \lyricsto{}. which handles simple scores well.Chapter 3: Fundamental concepts 52 A note column can contain just one note (or chord) from a voice with stems up and one note (or chord) from a voice with stems down.

Note how we use variables to separate the music notation and words from the staff structure. e8 g4 g | a a g } AltoMusic = \relative c' { c4 | c4. } VerseTwo = \lyricmode { O | Christ. whose voice the | wa -. | strong to save.ters heard. more voices may be added to the staves. b8 | a8 b c d e4 } BassMusic = \relative c { c4 | c4. In other examples this is often called ‘global’.ther.ly Spi -. c8 c4 c | f8 g a b c4 } VerseOne = \lyricmode { E -. g8 c4.rit. is used to hold several commands for use within the two staves. In this case the words for all four parts are the same. Here is an example of the first line of a hymn with four verses. which we have chosen to call ‘TimeKey’. See too how a variable. More staves may be added as required.Chapter 3: Fundamental concepts 53 \score { \new ChoirStaff << \new Staff << \new Voice = "SopOne" \global \SopOneMusic } \new Lyrics \lyricsto \SopOneLyrics } >> \new Staff << \new Voice = "SopTwo" \global \SopTwoMusic } \new Lyrics \lyricsto \SopTwoLyrics } >> >> } { "SopOne" { { "SopTwo" { 6 8 Let flee cy flocks the hills a dorn. | who didst brood } . set for SATB. } VerseThree = \lyricmode { O | Ho -. more verses may be added to the lyrics. c8 e4 e | f f e } TenorMusic = \relative c { e4 | g4. This is the basic structure of all vocal scores.nal fa -. TimeKey = { \time 4/4 \partial 4 \key c \major} SopMusic = \relative c' { c4 | e4. and the variables containing the music can easily be placed in separate files should they become too long.| ter -. 6 8 Let flee cy flocks the hills a dorn.

Chapter 3: Fundamental concepts

54

VerseFour = \lyricmode { O | Tri -- ni -- ty of | love and pow'r } \score { \new ChoirStaff << \new Staff << \clef "treble" \new Voice = "Sop" { \voiceOne \TimeKey \SopMusic } \new Voice = "Alto" { \voiceTwo \AltoMusic } \new Lyrics \lyricsto "Sop" { \VerseOne } \new Lyrics \lyricsto "Sop" { \VerseTwo } \new Lyrics \lyricsto "Sop" { \VerseThree } \new Lyrics \lyricsto "Sop" { \VerseFour } >> \new Staff << \clef "bass" \new Voice = "Tenor" { \voiceOne \TimeKey \TenorMusic } \new Voice = "Bass" { \voiceTwo \BassMusic } >> >> }

nal E ter fa ther, strong to save, O Christ, whose voice the wa ters heard, O Ho ly Spi rit, who didst brood O Tri ni ty of love and pow'r

We end with an example to show how we might code a solo verse which continues into a two-part refrain in two staves. The positioning of the sequential and simultaneous sections to achieve this within a single score is quite tricky, so follow the explanation carefully! Let’s start with a score block containing a ChoirStaff, as we would like the brace to appear at the start of the chorus. Normally you would need angle brackets after \new ChoirStaff to bring in all the staves in parallel, but here we want to defer the parallelism during the solo so we use braces, although angle brackets here wouldn’t hurt. Inside the ChoirStaff we want first the staff which will contain the verse. This must contain notes and lyrics in parallel, so here we need angle brackets around the \new Voice and \new Lyrics to start them at the same time: versenotes = \relative c'' { \clef "treble" \key g \major \time 3/4 g g g b b b } versewords = \lyricmode { One two three four five six

Chapter 3: Fundamental concepts

55

} \score { \new ChoirStaff { \new Staff << \new Voice = "verse" { \versenotes \break } \new Lyrics \lyricsto verse { \versewords } >> } }

3 4
One two three four five six
That gives the verse line. Now we want to continue with refrainA on the same staff while a second staff is introduced in parallel with it for refrainB, so this is a parallel section which must be positioned immediately following the \break in the verse Voice. Yes, within the verse Voice! Here’s that parallel section. More staves could be introduced here in the same way. << \refrainnotesA \new Lyrics \lyricsto verse { \refrainwordsA } \new Staff << \new Voice = "refrainB" { \refrainnotesB } \new Lyrics \lyricsto "refrainB" { \refrainwordsB } >> >> Here’s the final result with two staves in the chorus showing how the parallel section is positioned within the verse Voice: versenotes = \relative c'' { \clef "treble" \key g \major \time 3/4 g g g b b b } refrainnotesA = \relative c'' { \time 2/4 c c g g \bar "|." } refrainnotesB = \relative c { \clef "bass"

Chapter 3: Fundamental concepts

56

\key g \major c e d d } versewords = \lyricmode { One two three four five six } refrainwordsA = \lyricmode { la la la la } refrainwordsB = \lyricmode { dum dum dum dum } \score { \new ChoirStaff { \new Staff << \new Voice = "verse" { \versenotes \break << \refrainnotesA \new Lyrics \lyricsto "verse" { \refrainwordsA } \new Staff << \new Voice = "refrainB" { \refrainnotesB } \new Lyrics \lyricsto "refrainB" { \refrainwordsB } >> >> } \new Lyrics \lyricsto "verse" { \versewords } >> } }

3 4
One two three four five six

2 4

as follows: versenotes = \relative c'' { \clef "treble" \key g \major \time 3/4 g g g b b b } refrainnotesA = \relative c'' { \time 2/4 c c g g \bar "|. although this is an interesting and useful exercise to help you to understand how sequential and simultaneous blocks work." } refrainnotesB = \relative c { \clef "bass" \key g \major c e d d } versewords = \lyricmode { One two three four five six } refrainwordsA = \lyricmode { la la la la } refrainwordsB = \lyricmode { dum dum dum dum } \score { \new Staff << \new Voice = "verse" { \versenotes } \new Lyrics \lyricsto "verse" { \versewords } >> } \score { \new ChoirStaff << \new Staff << \new Voice = "refrainA" { \refrainnotesA } \new Lyrics \lyricsto "refrainA" { . in practice one would perhaps choose to code this as two \score blocks within an implicit \book block.Chapter 3: Fundamental concepts 3 57 2 4 la la la la 2 4 dum dum dum dum However.

many notational elements which do not appear explicitly in the input file must be added to the output.3 Contexts and engravers Contexts and engravers have been mentioned informally in earlier sections. 3. similar to reading a score from left to right.3. g4 The input is rather sparse.Chapter 3: Fundamental concepts 58 \refrainwordsA } >> \new Staff << \new Voice = "refrainB" { \refrainnotesB } \new Lyrics \lyricsto "refrainB" { \refrainwordsB } >> >> } 3 4 One two three four five six 2 4 la la la la 2 4 dum dum dum dum See also Notation Reference: Section “Vocal music” in Notation Reference. compare the input and output of the following example: cis4 cis2. we now must look at these concepts in more detail. clef. the program .1 Contexts explained When music is printed. For example. accidentals. While reading the input. and time signature have been added. bar lines. but in the output. 3. as they are important in the fine-tuning of LilyPond output. When LilyPond interprets the input the musical information is inspected in time order.

they must be created explicitly to make sure that you get as many staves as you need. contexts are created implicitly. in simple scores. and which pitches require explicit accidentals. and a Score context can contain many Staff contexts. As another example. Staff and Voice contexts there are contexts which fit between the score and staff levels to control staff groups. In addition to the Score. and that they are in the correct order. See also Notation Reference: Section “Contexts explained” in Notation Reference. figured bass.2 Creating contexts There can be only one top level context: the Score context. It is prepended to a music expression. Each context has the responsibility for enforcing some notation rules. we must modify the default settings of the Score and Staff contexts. for example \new type music-expression where type is a context name (like Staff or Voice). There are also alternative staff and voice contexts. . the Voice and Staff contexts may be left to be created automatically. This information must be held on several levels. such as anything with more than one staff. e. For example: a Staff context can contain many Voice contexts. This command creates a new context. For scores with only one voice and one staff. For very simple scores. In such cases. it is usual to modify existing. the single top-level Score context is introduced with \score. Note that there is no \new Score command. creating some notation objects and maintaining the associated properties. it is created automatically.g. and you need not be aware of them. However. fret boards. such as the PianoStaff and ChoirStaff contexts.Chapter 3: Fundamental concepts 59 remembers where measure boundaries are. Others are the Staff and Score contexts. This is created with the \score command. For typesetting pieces with specialized notation. the synchronization of bar lines is. GregorianTranscriptionStaff. etc. For example. these rules and bits of information are grouped in Contexts. in some music we may not want the bar lines to be synchronized – consider a polymetric score in 4/4 and 3/4 time. by default. The names of all context types are formed from one or more words. Contexts are hierarchical to reflect the hierarchical nature of a musical score. or. and starts interpreting the music-expression within that context. while a bar line must be synchronized across the entire score. and contexts for lyrics. For example. We have already met the Voice context.. The simplest command that does this is \new.3. contexts. the effect of an accidental is limited to a single staff. handled in the Score context. the Voice context may introduce an accidental and then the Staff context maintains the rule to show or suppress the accidental for the remainder of the measure. or even to define totally new. each word being capitalized and joined immediately to the preceding word with no hyphen or underscore. For larger pieces. but for more complex scores it is necessary to create them by hand. percussion. Within LilyPond. 3.

or double angle brackets. and any unmatched brackets will be obvious. but to remind you how these commands are used in practice. <g c> | } % end of LH voice one notes } % end of LH voice one \new Voice { % create LH voice two \voiceTwo \relative g { % start of LH voice two notes g4 ees | g4 ees | } % end of LH voice two notes } % end of LH voice two >> % end of LH staff >> % end of simultaneous staves section } % end of single compound music expression 2 4 2 4 (Note how all the statements which open a block with either a curly bracket. following this practice will greatly reduce the number of ‘unmatched bracket’ errors. and the corresponding closing bracket is indented by exactly the same amount. While this is not required. <g c> | g8 <bes d> ees.Chapter 3: Fundamental concepts 60 You have seen many practical examples which created new Staff and Voice contexts in earlier sections. It enables the structure of the music to be seen at a glance. {. are indented by two further spaces. needs two simultaneous voices \key g \minor \clef "bass" \new Voice { % create LH voice one \voiceOne \relative g { % start of LH voice one notes g8 <bes d> ees. <<. Note too how the LH staff is created using double angle brackets because it requires two . | } % end of RH notes } % end of RH voice } % end of RH staff \new Staff << % create LH staff. | d4 ees16 c8. here’s an annotated real-music example: \score { % start of single compound music expression << % start of simultaneous staves section \time 2/4 \new Staff { % create RH staff \key g \minor \clef "treble" \new Voice { % create voice for RH notes \relative c'' { % start of RH notes d4 ees16 c8. and is strongly recommended.

the Clef_engraver determines and sets the pitch reference point on the staff by drawing a clef symbol. 3. See also Notation Reference: Section “Creating contexts” in Notation Reference. Engravers live and operate in Contexts.3 [Voices and vocals]. like the properties associated with contexts. Engravers all have compound names formed from words which describe their function. etc. whereas the RH staff is created with a single music expression surrounded by curly brackets because it requires only one voice. but then it has to be placed in quotes.Chapter 3: Fundamental concepts 61 voices for its music. Staff. and the remainder are joined to it with underscores. page 52. Thus there is an engraver to print staves.) The \new command may also give a identifying name to the context to distinguish it from other contexts of the same type. which can be any sequence of letters invented by the user. one for beams. Digits and spaces can also be used in the identifying name. operate in the highest level context – the Score context. and the identifying name of a particular instance of that type. for most scores it is not necessary to know about more than a few. You will see it is usually easy to guess the function from the name. The Clef_engraver and Key_engraver are to be found in every Staff Context. the lowest level context of all. Here are some of the most common engravers together with their function. The Note_heads_engraver and Stem_engraver live in every Voice context. Voice. Engraver Accidental engraver Beam engraver Clef engraver Completion heads engraver New dynamic engraver Forbid line break engraver Key engraver Metronome mark engraver Note heads engraver Function Makes accidentals.2. as different staves may require different clefs and keys. Each engraver processes the particular objects associated with its function. i. see Section 3. These properties. Thus the Staff_symbol_engraver is responsible for creating the lines of the staff. The identifying name is used to refer back to that particular instance of a context. and for simple scores you do not need to know about any. etc. In total there are over 120 such engravers! Fortunately. or vice versa.3 Engravers explained Every mark on the printed output of a score produced by LilyPond is produced by an Engraver. cautionary and suggested accidentals Engraves beams Engraves clefs Splits notes which cross bar lines Creates hairpins and dynamic texts Prevents line breaks if a musical element is still active Creates the key signature Engraves metronome marking Engraves note heads .e.3. Just the first word is capitalized. \new Staff = "MyStaff 1" music-expression . may be modified to change the operation of the engraver or the appearance of those elements in the printed score. We saw this in use in the section on lyrics. one for stems. \new type = id music-expression Note the distinction between the name of the context type. etc. one to print note heads. Engravers such as the Metronome_mark_engraver. and maintains the properties that relate to that function. whose action and output apply to the score as a whole.

##t. Sometimes this is obvious.Chapter 3: Fundamental concepts 62 Rest engraver Staff symbol engraver Stem engraver Time signature engraver Engraves rests Engraves the five (by default) lines of the staff Creates stems and single-stem tremolos Creates time signatures We shall see later how the output of LilyPond can be changed by modifying the action of Engravers. 3. See also Internals reference: Section “Engravers and Performers” in Internals Reference. a Real is a positive or negative decimal number. Here are a few examples of some commonly used ones.. Many of them can be changed to influence the interpretation of the input and so change the appearance of the output.4 "2" where a Boolean is either True (#t) or False (#f). the instrumentName clearly lives in the Staff context. since it is the staff that is to be named. Note the occurrence of hash signs. So when a Boolean is being entered you need to code two hash signs. and text is enclosed in double apostrophes. in two different places – as part of the Boolean value before the t or f. print slurs both above and below notes Set the name to be placed at the start of the staff Increase or decrease the font size Set the text to print before the start of a verse Example Value #t. (#).g. << \new Staff \relative c'' { \set Staff. all except the first having a capital letter.4 Modifying context properties Contexts are responsible for holding the values of a number of context properties. For example. and before value in the \set statement. Before we can set any of these properties we need to know in which context they operate. In this example the first staff is labelled. This takes the form \set ContextName. no error message is produced. There are many more. but the expected action will not take place. If the wrong context is specified.propertyName = #value Where the ContextName is usually Score. The names of context properties consist of words joined together with no hyphens or underscores. but not the second. e. They are changed by the \set command. It may be omitted. #f "Cello I" 2. because we omitted the context name. set extra natural signs before accidentals Set the current bar number If true. propertyName extraNatural currentBarNumber doubleSlurs instrumentName fontSize stanza Type Boolean Integer Boolean Text Real Text Function If true. an Integer is a positive whole number. in which case Voice is assumed. Staff or Voice.instrumentName = #"Soprano" c4 c } . #f 50 #t. but occasionally it can be tricky.3.

you can set any (fictitious) ‘property’ using any name you like in any context that exists by using the \set command. Some text editors with special support for LilyPond input files document property names with bullets when you hover them with the mouse. If it is set to ##f (false) in one particular Staff context it applies just to the accidentals on that staff. the property extraNatural is by default set to ##t (true) for all staves. or Section “Contexts” in Internals Reference. like JEdit with LilyPondTool. The instrumentName property will take effect only if it is set in the Staff context. and clearly the expected action cannot be performed. Similarly. but some properties can be set in more than one context. no further action took place. In fact. it is recommended to check the property name in the Internals Reference: see Section “Tunable context properties” in Internals Reference.extraNatural = ##f ais4 aes } >> and this turns them off in all staves: . like ConTEXT. But if the name is not known to LilyPond it will not cause any action to be taken. or highlight unknown property names differently. So this turns off extra naturals in one staff: << \new Staff \relative c'' { ais4 aes } \new Staff \relative c'' { \set Staff. For example. and no error message is logged in the log file. so the second \set command set the property instrumentName in the Voice context to “Alto”. If you do not use an editor with such features. but as LilyPond does not look for any such property in the Voice context. This is not an error. if the property name is mis-spelt no error message is produced. If it is set to false in the Score context it applies to all staves.Chapter 3: Fundamental concepts 63 \new Staff \relative c' { \set instrumentName = #"Alto" d4 d } >> % Wrong! Soprano Remember the default context name is Voice.

Note that integers and numbers are always preceded by a hash sign.Chapter 3: Fundamental concepts 64 << \new Staff \relative c'' { ais4 aes } \new Staff \relative c'' { \set Score. effectively removes the property from the context. as above. A text property should be enclosed in double quotation signs. while a true or false value is specified by ##t and ##f. #. not the most recently set value. although we shall see later that text can actually be specified in a much more general way by using the very powerful markup command. which causes most properties to revert to their default value. Usually \unset is not required as a new \set command will achieve what is wanted. if clefOctavation is set in the Score context this immediately changes the value of the octavation in all current staves and sets a new default value which will be applied to all staves. c4 % make note heads smaller \set fontSize = #-4 d e % make note heads larger \set fontSize = #2. with two hash signs. The change is from the default value.5 f g % return to default size \unset fontSize a b We have now seen how to set the values of several different types of property. The opposite command. Let’s try changing the font size. which affects the size of the note heads (among other things) several times.extraNatural = ##f ais4 aes } >> As another example. \unset. . The \set and \unset commands can appear anywhere in the input file and will take effect from the time they are encountered until the end of the score or until the property is \set or \unset again.

prefixed by a back-slash: \Staff. this new default value may be restored with the \unset fontSize command.. if we wish to suppress the printing of extra naturals for the duration of a staff we would write: \new Staff \with { extraNatural = ##f } like this: << \new Staff \relative c'' { gis ges aes ais } \new Staff \with { extraNatural = ##f } \relative c'' { gis ges aes ais } >> Properties set in this way may still be changed dynamically using \set and returned to their default value with \unset. } block in which the property values are set.Chapter 3: Fundamental concepts 65 Setting context properties with \with Context properties may also be set at the time the context is created. The statement which sets the property value is the same as that in a \with block. Setting context properties with \context The values of context properties may be set in all contexts of a particular type. If this is set in a \with clause it effectively resets the default value of the font size. When a context is created with a \new command it may be followed immediately by a \with { . The fontSize property is treated differently. If it is later changed with \set. Sometimes this is a clearer way of specifying a property value if it is to remain fixed for the duration of the context. with a single command. such as all Staff contexts. For example. Here is a example to show the format: \score { \new Staff { \relative c'' { cis4 e d ces } } \layout { \context { \Staff extraNatural = ##t . like Staff. introduced above. The context type is identified by using its type name. It is placed in a \context block within a \layout block. Each \context block will affect all contexts of the type specified throughout the \score or \book block in which the \layout block appears.

5 % make note heads larger f g \unset fontSize % return to default size a b } Engravers can also be added to individual contexts. as in the previous section. which is not normally included in any context. As an illustration. The command to do this is \consists Engraver_name . etc. If an engraver is removed from a context. let’s repeat an example from the previous section with the staff lines removed. Changing a single context To remove an engraver from a single context we use the \with command placed immediately after the context creation command. Remember that the staff lines are produced by the Staff_symbol_engraver. See also Notation Reference: Section “Changing context default settings” in Notation Reference. 3. like bar lines. Section “Tunable context properties” in Internals Reference. note heads. stems. \new Staff \with { \remove Staff_symbol_engraver } \relative c' { c4 \set fontSize = #-4 % make note heads smaller d e \set fontSize = #2. it can no longer produce its output.5 Adding and removing engravers We have seen that contexts each contain several engravers. This is a crude way of modifying the output. Some vocal scores have an ambitus placed at the beginning of a staff to indicate the range of notes in that staff – see Section “ambitus” in Music Glossary. The ambitus is produced by the Ambitus_engraver.3.Chapter 3: Fundamental concepts 66 } } } Context properties set in this way may be overridden for particular instances of contexts by statements in a \with block. and by \set commands embedded in music statements. each of which is responsible for producing a particular part of the output. but it can sometimes be useful. If we add it to the Voice context. it calculates the range from that voice only: . Internals Reference: Section “Contexts” in Internals Reference. staves. placed inside a \with block.

we could write \score { << \new Staff << \relative c'' { c a b g } . if we wanted to show an ambitus for every staff in a four-staff score. For example. it calculates the range from all the notes in all the voices on that staff: \new Staff \with { \consists Ambitus_engraver } << \new Voice \relative c'' { \voiceOne c a b g } \new Voice \relative c' { \voiceTwo c e d f } >> Changing all contexts of the same type The examples above show how to remove or add engravers to individual contexts. It is also possible to remove or add engravers to every context of a specific type by placing the commands in the appropriate context in a \layout block.Chapter 3: Fundamental concepts 67 \new Staff << \new Voice \with { \consists Ambitus_engraver } \relative c'' { \voiceOne c a b g } \new Voice \relative c' { \voiceTwo c e d f } >> but if we add the ambitus engraver to the Staff context.

But how can you get the staves that you want? Well. page 141) which may give you a start. you understand the fundamental concepts. you can find lots of templates (see Appendix A [Templates]. See also Notation Reference: Section “Modifying context plug-ins” in Notation Reference. But what if you want something that isn’t covered there? Read on. .Chapter 3: Fundamental concepts 68 >> \new Staff << \relative c' { c a b g } >> \new Staff << \clef "G_8" \relative c' { c a b g } >> \new Staff << \clef "bass" \relative c { c a b g } >> >> \layout { \context { \Staff \consists Ambitus_engraver } } } 8 The values of context properties may also be set for all contexts of a particular type by including the \set command in a \context block in the same way.4 Extending the templates You’ve read the tutorial. Section “Changing context default settings” in Notation Reference. 3. you know how to write music.

we’d get the two parts separately. This would not generate an error. .3" melody = \relative c' { \clef treble \key c \major \time 4/4 a4 b c d } \score { \new Staff \melody \layout { } \midi { } } We don’t need two \version commands.1 Soprano and cello Start off with the template that seems closest to what you want to end up with. We want them together. let’s rename text to be sopranoLyrics.Chapter 3: Fundamental concepts 69 3.3" melody = \relative c' { \clef treble \key c \major \time 4/4 a4 b c d } text = \lyricmode { Aaa Bee Cee Dee } \score { << \new Voice = "one" { \autoBeamOff \melody } \new Lyrics \lyricsto "one" \text >> \layout { } \midi { } } Now we want to add a cello part. Let’s say that you want to write something for soprano and cello. \version "2. In this case. we would end up with two melody definitions.12. but the second one would be used for both melodies. Let’s look at the ‘Notes only’ example: \version "2. While we’re doing this. Remember to rename both instances of all these names – both the initial definition (the melody = \relative c' { part) and the name’s use (in the \score section). If we simply cut and paste the melody section.12.4. We’ll need the melody section. We’ll call the section for the soprano sopranoMusic and the section for the cello celloMusic. So let’s rename them to make them distinct. Within the \score section. We don’t want two \score sections – if we had two \scores. we don’t need two \layout or \midi. we would start with ‘Notes and lyrics’ (for the soprano part). as a duet.

\version "2. let’s change the cello part’s staff – celli normally use bass clef. but the cello part won’t appear in the score – we haven’t used it in the \score section. two Staves) happening at once. We’ll also give the cello some different notes. We also need to add << and >> around the music – that tells LilyPond that there’s more than one thing (in this case.3" sopranoMusic = \relative c' { \clef treble \key c \major \time 4/4 a4 b c d } sopranoLyrics = \lyricmode { Aaa Bee Cee Dee } celloMusic = \relative c { \clef bass \key c \major \time 4/4 d4 g fis8 e d4 } \score { << \new Voice = "one" { \autoBeamOff \sopranoMusic } \new Lyrics \lyricsto "one" \sopranoLyrics >> \layout { } \midi { } } This is looking promising.Chapter 3: Fundamental concepts 70 While we’re doing this. The \score looks like this now: \score { << << \new Voice = "one" { \autoBeamOff \sopranoMusic } \new Lyrics \lyricsto "one" \sopranoLyrics >> \new Staff \celloMusic >> \layout { } . If we want the cello part to appear under the soprano part.12. we need to add \new Staff \celloMusic underneath the soprano stuff.

Here’s the complete soprano and cello template.1 [Single staff]. see Section A.12.3" sopranoMusic = \relative c' { \clef treble \key c \major \time 4/4 a4 b c d } sopranoLyrics = \lyricmode { Aaa Bee Cee Dee } celloMusic = \relative c { \clef bass \key c \major \time 4/4 d4 g fis8 e d4 } \score { << << \new Voice = "one" { \autoBeamOff \sopranoMusic } \new Lyrics \lyricsto "one" \sopranoLyrics >> \new Staff \celloMusic >> \layout { } \midi { } } Aaa Bee Cee Dee See also The starting templates can be found in the ‘Templates’ appendix.Chapter 3: Fundamental concepts 71 \midi { } } This looks a bit messy. That is easily fixed. . \version "2. the indentation is messed up now. page 141.

The variables holding the music and words for the vocal parts are fine. The nearest is ‘SATB vocal score and automatic piano reduction’ – see Section A. with a piano reduction of the orchestral accompaniment underneath. The way in which lyrics are specified in the template has not yet been encountered so we need to use the method with which we are familiar. We need to rearrange them so there are four staves with the words written directly underneath the notes for each part. We also need to specify the tenor clef for the tenors. Doing this gives for our ChoirStaff: \new ChoirStaff << \new Staff = "sopranos" << \set Staff.4. but we shall need to add variables for the piano reduction. The order in which the contexts appear in the ChoirStaff of the template do not correspond with the order in the vocal score shown above. page 152 – but we need to change the layout and add a piano accompaniment which is not derived automatically from the vocal parts. so the \voiceXXX commands should be removed. All the voices should be \voiceOne. which is the default.4 [Vocal ensembles].instrumentName = #"Soprano" \new Voice = "sopranos" { \global \sopranoMusic } >> \new Lyrics \lyricsto "sopranos" { \sopranoWords } . We should also add the names of each staff. Here’s an example from Handel’s Messiah: Soprano Wor thy is the lamb that was slain Alto Wor thy is the lamb that was slain Tenor 8 Wor thy is the lamb that was slain Bass Wor thy is the lamb that was slain Piano None of the templates provides this layout exactly.2 Four-part SATB vocal score Most vocal scores of music written for four-part mixed choir with orchestral accompaniment such as Mendelssohn’s Elijah or Handel’s Messiah have the choral music and words on four staves. one for each of SATB.Chapter 3: Fundamental concepts 72 3.

Chapter 3: Fundamental concepts 73 \new Staff = "altos" << \set Staff.instrumentName = #"Bass" \new Voice = "basses" { \global \bassMusic } >> \new Lyrics \lyricsto "basses" { \bassWords } >> % end ChoirStaff Next we must work out the piano part.instrumentName = #"Tenor" \new Voice = "tenors" { \global \tenorMusic } >> \new Lyrics \lyricsto "tenors" { \tenorWords } \new Staff = "basses" << \set Staff. The ChoirStaff and PianoStaff must be combined using angle brackets as we want them to be stacked one above the other: << % combine ChoirStaff and PianoStaff one above the other \new ChoirStaff << \new Staff = "sopranos" << \new Voice = "sopranos" { \global \sopranoMusic } >> \new Lyrics \lyricsto "sopranos" { \sopranoWords } \new Staff = "altos" << \new Voice = "altos" { \global \altoMusic } >> \new Lyrics \lyricsto "altos" { \altoWords } \new Staff = "tenors" << \clef "G_8" % tenor clef \new Voice = "tenors" { \global \tenorMusic } >> \new Lyrics \lyricsto "tenors" { \tenorWords } \new Staff = "basses" << \clef "bass" \new Voice = "basses" { \global \bassMusic } >> \new Lyrics \lyricsto "basses" { \bassWords } >> % end ChoirStaff \new PianoStaff << \set PianoStaff.instrumentName = #"Piano" \new Staff = "upper" \upper .instrumentName = #"Alto" \new Voice = "altos" { \global \altoMusic } >> \new Lyrics \lyricsto "altos" { \altoWords } \new Staff = "tenors" << \set Staff.we just pull out the piano part from the ‘Solo piano’ template: \new PianoStaff << \set PianoStaff.instrumentName = #"Piano " \new Staff = "upper" \upper \new Staff = "lower" \lower >> and add the variable definitions for upper and lower. This is easy .

Chapter 3: Fundamental concepts 74 \new Staff = "lower" \lower >> >> Combining all these together and adding the music for the three bars of the example above gives: \version "2. <d fis d'>8 <a d a'>2 | <g cis g'>4 <a d fis> <a cis e>2 | } lower = \relative c.3" global = { \key d \major \time 4/4 } sopranoMusic = \relative c'' { \clef "treble" r4 d2 a4 | d4. d8 a2 | cis4 d cis2 | } sopranoWords = \lyricmode { Wor -.12. b8 fis2 | e4 d a'2 | } bassWords = \sopranoWords upper = \relative a' { \clef "treble" \global r4 <a d fis>2 <a e' a>4 | <d fis d'>4. fis8 a2 | g4 fis fis2 | } altoWords = \sopranoWords tenorMusic = \relative c' { \clef "G_8" r4 fis2 e4 | d4.thy is the lamb that was slain } altoMusic = \relative a' { \clef "treble" r4 a2 a4 | fis4. d8 d2 | e4 a. { \clef "bass" \global <d d'>4 <d d'>2 <cis cis'>4 | <b b'>4. <b' b'>8 <fis fis'>2 | <e e'>4 <d d'> <a' a'>2 | } \score { << % combine ChoirStaff and PianoStaff in parallel \new ChoirStaff << \new Staff = "sopranos" << \set Staff. cis2 | } tenorWords = \sopranoWords bassMusic = \relative c' { \clef "bass" r4 d2 cis4 | b4.instrumentName = #"Soprano" \new Voice = "sopranos" { \global \sopranoMusic } >> .

instrumentName = #"Piano \new Staff = "upper" \upper \new Staff = "lower" \lower >> >> } " Soprano Wor thy is the lamb that was slain Alto Wor thy is the lamb that was slain Tenor 8 Wor thy is the lamb that was slain Bass Wor thy is the lamb that was slain Piano .Chapter 3: Fundamental concepts 75 \new Lyrics \lyricsto "sopranos" { \sopranoWords } \new Staff = "altos" << \set Staff.instrumentName = #"Tenor" \new Voice = "tenors" { \global \tenorMusic } >> \new Lyrics \lyricsto "tenors" { \tenorWords } \new Staff = "basses" << \set Staff.instrumentName = #"Bass" \new Voice = "basses" { \global \bassMusic } >> \new Lyrics \lyricsto "basses" { \bassWords } >> % end ChoirStaff \new PianoStaff << \set PianoStaff.instrumentName = #"Alto" \new Voice = "altos" { \global \altoMusic } >> \new Lyrics \lyricsto "altos" { \altoWords } \new Staff = "tenors" << \set Staff.

Let’s see how to put together the score for an organ prelude as an example. s1.3" \header { title = "Jesu. The first manual part needs two voices and the second manual part just one. and compile it to see what errors it generates. Organ music is usually written on three staves. you may find that it is easier to build a score from scratch rather than modifying one of the templates. Let’s start with these in outline and fill in the details later. then come any variable definitions. \new PianoStaff << \new Staff = "ManualOne" << \new Voice { \ManualOneVoiceOneMusic } \new Voice { \ManualOneVoiceTwoMusic } >> % end ManualOne Staff context \new Staff = "ManualTwo" << \new Voice { \ManualTwoMusic } >> % end ManualTwo Staff context >> % end PianoStaff context Next we need to add a staff for the pedal organ. We begin with a header section. and finally the score block. so we need angle brackets around the two.4. This goes underneath the PianoStaff. We’ll add that later. Next let’s see what should go in the score block. so we need to use a PianoStaff for them. Missing these out would generate an error in the log file.Chapter 3: Fundamental concepts 76 3. meine Freude" composer = "J S Bach" } TimeKey = { \time 4/4 \key c \minor } ManualOneVoiceOneMusic = {s1} ManualOneVoiceTwoMusic = {s1} ManualTwoMusic = {s1} PedalOrganMusic = {s1} \score { } For now we’ve just used a spacer note.3 Building a score from scratch After gaining some facility with writing LilyPond code. We simply mirror the staff structure we want. The manual staves should be bracketed together.12. instead of the real music. << % PianoStaff and Pedal Staff must be simultaneous \new PianoStaff << \new Staff = "ManualOne" << \new Voice { \ManualOneVoiceOneMusic } \new Voice { \ManualOneVoiceTwoMusic } >> % end ManualOne Staff context . name of composer. So we need four music definitions and one to define the time signature and key: \version "2. meine Freude which is written for two manuals and pedal organ. remove these angle brackets. We’ll use the first two bars of Bach’s prelude based on Jesu. You can see these two bars of music at the bottom of this section. the lower and pedal organ one each. You can also develop your own style this way to suit the sort of music you like. etc. but it must be simultaneous with it. The top manual part has two voices. It’s a common mistake which you’ll make sooner or later! Try copying the final example at the end of this section. one for each manual and one for the pedals. Here go the title.

Let’s add this structure to the score block. although the number of voices may vary. Any three-staff organ music will have a similar structure. ties and slurs in each voice on the upper staff point to the right direction with \voiceOne and \voiceTwo. The opposite is true for Voices: these should habitually be followed by braces { . meine Freude" composer = "J S Bach" } TimeKey = { \time 4/4 \key c \minor } ManualOneVoiceOneMusic = \relative g' { g4 g f ees | d2 c2 | . \version "2.Chapter 3: Fundamental concepts 77 \new Staff = "ManualTwo" << \new Voice { \ManualTwoMusic } >> % end ManualTwo Staff context >> % end PianoStaff context \new Staff = "PedalOrgan" << \new Voice { \PedalOrganMusic } >> >> It is not necessary to use the simultaneous construct << . but it does no harm. \score { << % PianoStaff and Pedal Staff must be simultaneous \new PianoStaff << \new Staff = "ManualOne" << \TimeKey % set time signature and key \clef "treble" \new Voice { \voiceOne \ManualOneVoiceOneMusic } \new Voice { \voiceTwo \ManualOneVoiceTwoMusic } >> % end ManualOne Staff context \new Staff = "ManualTwo" << \TimeKey \clef "bass" \new Voice { \ManualTwoMusic } >> % end ManualTwo Staff context >> % end PianoStaff context \new Staff = "PedalOrgan" << \TimeKey \clef "bass" \new Voice { \PedalOrganMusic } >> % end PedalOrgan Staff >> } % end Score context That completes the structure. } in case your music is coded in several variables which need to run consecutively. since they contain only one music expression. We also add the appropriate clefs. and always using angle brackets after \new Staff is a good habit to cultivate in case there are multiple voices... \TimeKey. >> for the manual two staff and the pedal organ staff. and adjust the indenting.12. ensure stems.3" \header { title = "Jesu. All that remains now is to add the music. and enter the time signature and key to each staff using our predefined variable. and combine all the parts together.

Chapter 3: Fundamental concepts 78 } ManualOneVoiceTwoMusic = \relative c' ees16 d ees8~ ees16 f ees d c8 d~ d c c4 b8 c8.2 | } { c~ | ees | f ees d | b c8 | \score { << % PianoStaff and Pedal Staff must be simultaneous \new PianoStaff << \new Staff = "ManualOne" << \TimeKey % set time signature and key \clef "treble" \new Voice { \voiceOne \ManualOneVoiceOneMusic } \new Voice { \voiceTwo \ManualOneVoiceTwoMusic } >> % end ManualOne Staff context \new Staff = "ManualTwo" << \TimeKey \clef "bass" \new Voice { \ManualTwoMusic } >> % end ManualTwo Staff context >> % end PianoStaff context \new Staff = "PedalOrgan" << \TimeKey \clef "bass" \new Voice { \PedalOrganMusic } >> % end PedalOrgan Staff context >> } % end Score context Jesu. g16 c b c d | } ManualTwoMusic = \relative c' { c16 b c8~ c16 b c g a8 g~ g16 g aes f ees f d g aes g f ees d e8~ ees16 } PedalOrganMusic = \relative c { r8 c16 d ees d ees8~ ees16 a. meine Freude J S Bach . b g c r16 g ees f g f g8 c.

Chapter 3: Fundamental concepts 2 79 .

1 Introduction to tweaks ‘Tweaking’ is a LilyPond term for the various methods available to the user for modifying the actions taken during interpretation of the input file and modifying the appearance of the printed output. note heads. There are many other groupings of common properties like this. page 58. Objects with an extended shape like these are called ‘Spanners’. etc are called ‘Layout objects’. such as their position. dynamics. ottava marks. Many objects. For example. 4. a position. such as Voice objects. To simplify these internal operations these common actions and properties are grouped together in an object called a grob-interface.3 [Contexts and engravers]. etc. Similarly. stems. all grobs have a color. often known as ‘Graphical Objects’. or ‘Grobs’ for short. In this section we cover the basic concepts required to understand tweaking. slurs. a size. etc. color. etc. But taken together the methods available for tweaking permit almost any desired appearance of the printed music to be achieved. and so they too all have properties associated with them.1 Tweaking basics 4. size.1. So when a command like \new Staff is encountered a new object of type Staff is constructed. Engravers. fingering. for example. share common features which need to be processed in the same way. ties. Phrasing slurs. virtually every fragment of output may be changed.2 Objects and interfaces Tweaking involves modifying the internal operation and structures of the LilyPond program. clefs. Every object has its own set of property values. 4. and maybe other properties concerned with their shape. there are objects to hold the properties of all other contexts.Chapter 4: Tweaking output 80 4 Tweaking output This chapter discusses how to modify output. These are still objects in the generic sense above. That Staff object then holds all the properties associated with that particular staff. Before starting on this Chapter you may wish to review the section Section 3. and all these properties are processed in the same way during LilyPond’s interpretation of the input file. together with details of the engravers which have been assigned to operate within that staff’s context. so we must first introduce some terms which are used to describe those internal operations and structures. and the Properties contained within them are fundamental to understanding and constructing Tweaks. crescendo hairpins. others are more complex. Score objects. Later we give a variety of ready-made commands which can simply be copied to obtain the same effect in your own scores. The term ‘Object’ is a generic term used to refer to the multitude of internal structures built by LilyPond during the processing of an input file. Some layout objects are still more specialized. Objects which represent items of notation on the printed output such as note heads. Lyrics objects. an ending point. each one given a name ending . Some tweaks are very easy to use.1. even though they are quite different. It remains to explain what ‘Interfaces’ are. and many other grobs are not localized in a single place – they have a starting point. as Contexts. and at the same time we show how these commands may be constructed so that you may learn how to develop your own tweaks. Some types of object are given special names. its name and its key signature. as well as objects to represent all notational elements such as bar lines. LilyPond is extremely configurable. ties.

Because this command has to modify internal properties deep within LilyPond its syntax is not as simple as the commands you have met so far.1.1. breakaligned-interface Context Properties aaa or aaaAaaaAaaa alignAboveContext. which is a member of the Context context. We shall see later when it must be specified. The Context can be omitted (and usually is) when the required context is unambiguously implied and is one of lowest level contexts. We now must meet some more important commands. These. page 66. beam-thickness As we shall see shortly. in Section 3.3. Voice.Chapter 4: Tweaking output 81 in interface. In total there are over 100 such interfaces. i. We have used ‘A’ to stand for any capitalized alphabetic character and ‘aaa’ to stand for any number of lower-case alphabetic characters. For now. and most of the rest of this chapter will be directed to . page 58. and we shall omit it in many of the following examples.e. NoteHead Clef engraver. 4. the properties of different types of object are modified by different commands. skipBars Layout Object Properties aaa or aaa-aaa-aaa direction. and the #. Other characters are used verbatim. Object/property type Contexts Layout Objects Engravers Examples Staff.3 [Contexts and engravers]. used to change the properties of contexts and to remove and add engravers. Later sections deal comprehensively with properties and their values. which must precede the layout property. to the value value. don’t worry about the #'. so it is useful to be able to recognize the type of object from the names of its properties. page 62. We shall see later why this is of interest and use to the user.5 [Adding and removing engravers]. This is the most common command used in tweaking.4 Tweaking methods \override command We have already met the commands \set and \with. GrandStaff Slur. Note heads engraver Interfaces aaa-aaa-interface grob-interface. It needs to know precisely which property of which object in which context has to be modified. but to illustrate the format and use of these commands we shall use just a few simple properties and values which are easily understood. These must always be present in exactly this form. and Section 3.LayoutObject #'layout-property = #value This will set the property with the name layout-property of the layout object with the name LayoutObject.3 Naming conventions of objects and properties We met some object naming conventions previously. Naming convention Aaaa or AaaaAaaaAaaa Aaaa or AaaaAaaaAaaa Aaaa aaa engraver 4. which must precede the value. Let’s see how this is done.. The general syntax of this command is: \override Context .3. Here for reference is a list of the most common object and property types together with the conventions for naming them and a couple of examples of some real names. are the main terms relating to objects which we shall use in this chapter. in Section 3. then. ChordNames or Lyrics. The command to change the properties of layout objects is \override.4 [Modifying context properties]. and what its new value is to be.

Using the same example. Here we revert the color of the note head to the default value for the final two notes: c d \override NoteHead #'color = #red e f g \override NoteHead #'color = #green a \revert NoteHead #'color b c \once prefix Both the \override and the \set commands may be prefixed by \once.LayoutObject #'layout-property Again. the property retains its new value until it is overridden again or a \revert command is encountered. note.Chapter 4: Tweaking output 82 presenting examples of how it is used. The \revert command has the following syntax and causes the value of the property to revert to its original default value. \revert Context . not its previous value if several \override commands have been issued. we can change the color of a single note like this: c d \once \override NoteHead #'color = #red e f g \once \override NoteHead #'color = #green a b c \overrideProperty command . Context is often not needed. just like Context in the \override command. This causes the following \override or \set command to be effective only during the current musical moment before the property reverts back to its default value. It will be omitted in many of the following examples. Here is a simple example to change the color of the note head: c d \override NoteHead #'color = #red e f g \override NoteHead #'color = #green a b c \revert command Once overridden.

when it is applied to note heads these must be within a chord. \overrideProperty. so to tweak a single note the \tweak command must be placed inside single angle brackets with the note. However. Note also that an equals sign should not be present. \tweak command The final tweaking command which is available is \tweak. So to return to our example. These are both implied by the following item in the input stream.. and the action of \once is to apply the override to all layout objects of the type specified which occur at the same musical moment as the \override command itself. We mention it here for completeness. Let’s first see what \once \override would do: <c e g>4 \once \override NoteHead #'font-size = #-3 <c e g> <c e g> We see the override affects all the note heads in the chord. it would generate an error to do so. The \tweak command operates in a different way. but for details see Section “Difficult tweaks” in Notation Reference. within single angle brackets. whereas \tweak affects just the following item in the input stream. Using \override would affect all the notes within a chord. essentially note heads and articulations. i. in fact. which is occasionally required. as shown here: a ^Black -\tweak #'color #red ^Red -\tweak #'color #green _Green . Neither the context nor the layout object should be specified. This is because all the notes of a chord occur at the same musical moment.e. the size of the middle note of a chord would be changed in this way: <c e g>4 <c \tweak #'font-size #-3 e g>4 Note that the syntax of \tweak is different from that of the \override command. Furthermore. So the general syntax of the \tweak command is simply \tweak #'layout-property #value A \tweak command can also be used to modify just one in a series of articulations. such as the notes within a chord. This should be used to change the properties of objects which occur at the same musical moment.Chapter 4: Tweaking output 83 There is another form of the override command. Suppose we wish to change the size of the middle note head (the E) in a C major chord. Here’s an example. objects such as stems and accidentals are created later and cannot be tweaked in this way. it is effective only on objects which are created directly from the input stream. It acts on the immediately following item in the input stream.

\tweak is used to distinguish between them. the long tuplet bracket and the first of the three short brackets begin at the same musical moment.Chapter 4: Tweaking output 84 Red Black Green Note that the \tweak command must be preceded by an articulation mark as if it were an articulation itself. appears too thin and you’d like to draw it a little heavier. \tweak #'direction #up \times 4/3 { \tweak #'color #red \times 2/3 { c8[ c8 c8] } \times 2/3 { c8[ c8 c8] } \times 2/3 { c8[ c8 c8] } } 3 3 3 3 If nested tuplets do not begin at the same moment. their appearance may be modified in the usual way with \override commands: \times 2/3 { c8[ c c]} \once \override TupletNumber #'text = #tuplet-number::calc-fraction-text \times 2/3 { c[ c] c[ c] \once \override TupletNumber #'transparent = ##t \times 2/3 { c8[ c c] } \times 2/3 { c8[ c c]} } 3 3:2 3 See also Notation Reference: Section “The tweak command” in Notation Reference. In the following example. The \tweak command must also be used to change the appearance of one of a set of nested tuplets which begin at the same musical moment. 4.2.1 Properties of layout objects Suppose you have a slur in a score which. In the example. to your mind. and you would probably guess . The first \tweak command specifies that the long tuplet bracket is to be placed above the notes and the second one specifies that the tuplet number is to be printed in red on the first short tuplet bracket.2 The Internals Reference manual 4. so any \override command would apply to both of them. How do you go about doing this? You know from the statements earlier about the flexibility of LilyPond that such a thing should be possible.

This Slur page in the IR tells us first that Slur objects are created by the Slur engraver. For the next few paragraphs to make sense you will need to actually do this as you read. generally measured in line-thickness . An alternative way of finding this page is from the Notation Reference.Chapter 4: Tweaking output 85 that an \override command would be needed. and the properties of Slurs are listed. which is where information about layout objects is to be found. Let’s use a concrete example with a simple fragment of real music: { \time 6/8 { r4 b8 b[( g]) g | g[( e]) e d[( f]) a | a g } \addlyrics { The man who feels love's sweet e -.org. it is easier to go straight to the IR and search there. Don’t worry! The guidance and explanation presented here will enable you to extract the information from the Internals Reference for yourself with just a little practice. Note these are not in alphabetic order. which means there is little or no explanation contained within it: its purpose is to present information precisely and concisely. For learning purposes you should use the standard HTML version. The IR for the version of LilyPond you are using may be found on the LilyPond website at http://lilypond. Browse down them looking for a property that might control the heaviness of slurs. in alphabetic order. Under the heading Top you will see five links. There.mo -. Is this possible? The slur is certainly a layout object. This is a reference document. and if there is. This link will take you directly to this page. under the heading Backend. and you should find thickness (number) 1. Select the link to Slur. select the link to All layout objects. The page that appears lists all the layout objects used in your version of LilyPond.tion } } 6 8 The man who feels love's sweet e mo tion Suppose now that we decide we would like the slurs to be a little heavier. Select the link to the Backend. Then it lists the standard settings. so the question is. or IR for short. ‘Is there a property belonging to a slur which controls the heaviness?’ To answer this we must look in the Internals Reference. It contains all the information you might need to construct this and all other \override commands. Go to the documentation page and click on the Internals Reference link. not the ‘one big page’ or the PDF.2 Line thickness. This means it might look daunting at first sight. Before we look at the Internals Reference a word of warning. On one of the pages that deals with slurs you may find a link to the Internals Reference. but if you have an idea about the name of the layout object to be tweaked. But is there a heaviness property for a slur. how might it be modified? This is where the Internals Reference manual comes in.

so our guess was correct. This is provided in the examples which follow. We see that the name of the layout object is Slur. where it says ‘Slur objects are created by: Slur engraver’. We can now construct the \override command by simply substituting the values we have found for the names. but you now know all the essentials required to make up your own – but you will still need some practice.’ Let’s do that: { \time 6/8 { % Increase thickness of all following slurs from 1. but we already have enough information to try changing the slur thickness. Voice. so we can be sure the command is working. And because Voice is one of the lowest level contexts which is implied unambiguously by the fact that we are entering notes.2. Follow the link to the Slur_engraver page.Chapter 4: Tweaking output 86 This looks a good bet to change the heaviness. As we said earlier. So slurs will be created in whichever context the Slur_engraver is in. Finding the context But first.tion } } 6 8 The man who feels love's sweet e mo tion and we see that the slur is indeed heavier.2 to 5.0 Don’t forget the #' preceding the property name and a # preceding the new value! The final question is. as they are clearly closely associated with individual lines of music. . but can we be sure? To find out. including the standard voice context. omitting the context. that the name of the property to change is thickness and that the new value should be a number somewhat larger than 1. ‘Where should this command be placed?’ While you are unsure and learning. There are a few more complications that we shall meet in later sections. Let’s use a very large value for the thickness at first. At the very bottom it tells us that Slur_engraver is part of five Voice contexts. and that the units are in another property called line-thickness. that the default value is 1. the best answer is.0 r4 b8 b[( g]) g | g[( e]) e d[( f]) a | a g } \addlyrics { The man who feels love's sweet e -.2 if we are to make slurs thicker. ‘Within the music. before the first slur and close to it.mo -. It tells us that the value of thickness is a simple number. go back to the top of the IR page describing the Slur. we can omit it in this location. there are few to no explanations in the IR. So this is the basic way of constructing \override commands. what if we had needed to specify the Context? What should it be? We could guess that slurs are in the Voice context.0 \override Slur #'thickness = #5. We get: \override Slur #'thickness = #5.

Placed immediately before the \override command it causes it to change only the slur which begins on the immediately following note. what if we wanted just the first two slurs to be heavier? Well.tion } } 6 8 The man who feels love's sweet e mo tion Now only the first slur is made heavier. each preceded by \once placed immediately before each of the notes where the slurs begin: { \time 6/8 { r4 b8 % Increase thickness of immediately following slur only \once \override Slur #'thickness = #5. The \once command can also be used before the \set command. If the immediately following note does not begin a slur the command has no effect at all – it is not remembered until a slur is encountered.0 b[( g]) g | % Increase thickness of immediately following slur only \once \override Slur #'thickness = #5. we could use two commands.0 g[( e]) e d[( f]) a | a g } \addlyrics { The man who feels love's sweet e -. all the slurs are thicker in the final example above.mo -.mo -. But what if we wanted just the first slur to be thicker? This is achieved with the \once command.Chapter 4: Tweaking output 87 Overriding once only As you can see.tion } } . Reverting Finally. So the command with \once must be repositioned as follows: { \time 6/8 { r4 b8 % Increase thickness of immediately following slur only \once \override Slur #'thickness = #5.0 b[( g]) g | g[( e]) e d[( f]) a | a g } \addlyrics { The man who feels love's sweet e -. it is simply discarded.

2. The list has several items.0 \override Slur #'thickness = #5. as before. it is grouped together with other similar common properties and placed in an Interface. What form of \override command do we need to do this? We first look in the IR page listing ‘All layout objects’. which looks right. 4. This is because the shape property is one that is common to all font objects. but nothing that might give an italic shape. and look for an object that might control lyrics. and to discover what objects use these interface properties. Look again at the IR page which describes LyricText. Now we see all the user-settable properties which control fonts.Chapter 4: Tweaking output 88 6 8 The man who feels love's sweet e mo tion or we could omit the \once command and use the \revert command to return the thickness property to its default value after the second slur: { \time 6/8 { r4 b8 % Increase thickness of all following slurs from 1. So now we need to learn how to find the properties of interfaces. rather than including it in every layout object. You may use whichever method best suits what you want to do.2 \revert Slur #'thickness e d[( f]) a | a g } \addlyrics { The man who feels love's sweet e -. Clicking on this shows the settable properties for lyric text. These include the font-series and font-size. Several examples follow in the later sections of this Chapter. partly to introduce you to some of the additional features of the IR. That concludes our introduction to the IR. including fontshape(symbol). and partly to give you more practice in extracting information from it. and the basic method of tweaking. including fontinterface. . including LyricText. where symbol can be set to upright. At the bottom of the page is a list of clickable interfaces which LyricText supports. We find LyricText.0 b[( g]) g | g[( e]) % Revert thickness of all following slurs to default of 1.tion } } 6 8 The man who feels love's sweet e mo tion The \revert command can be used to return any property changed with \override back to its default value. which are also properties of all the objects which support it. the font-interface.2 Properties found in interfaces Suppose now that we wish to print the lyrics in italics.mo -. italics or caps. These examples will contain progressively fewer words of guidance and explanation. so.2 to 5. Clicking on this brings up the properties associated with this interface.

Symbols are then read internally by LilyPond. All other characters are included as part of the syllable. Note the distinction from arbitrary text strings. spaces must be inserted before and after the period or dot. ‘. like thickness or font-shape. Let’s see if we can now construct the \override command to change the lyrics to italics. Some of them are the names of properties. A syllable entered in lyricmode is terminated by either a space. although it is an important one. the property is font-shape and the value is italic. '. The object is LyricText. a newline or a digit.’. That is why apostrophes are needed before thickness in the earlier example and font-shape. others are used as values that can be given to properties. if you try specifying the context in the format given earlier the command will fail. As an aside.Chapter 4: Tweaking output 89 You will notice that font-series and font-size are also listed there. note that because the values of font-shape are symbols they must be introduced with a single apostrophe. which would appear as "a text string". see Appendix B [Scheme tutorial]. For this reason a space or newline must appear before the terminating } to prevent it being included as part of the final syllable. This immediately raises the question: Why are the common font properties font-series and font-size listed under LyricText as well as under the interface font-interface but font-shape is not? The answer is that font-series and font-size are changed from their global default values when a LyricText object is created. Specifying the context in lyric mode In the case of lyrics. The entries in LyricText then tell you the values for those two properties which apply to LyricText. we’ll omit the context.mo -. like italic. but font-shape is not. page 173. So the command should be: \override Lyrics . Ok. Other objects which support font-interface will set these properties differently when they are created. These are both symbols too.tion } } 6 8 The man who feels love's sweet e mo tion and the lyrics are all printed in italics. for more details about symbols and strings. As before. as otherwise the two names are run together and the interpreter cannot recognize them. so the \override command we need to print the lyrics in italics should be \override LyricText #'font-shape = #'italic and this should be placed just in front of and close to the lyrics which it should affect. like this: { \time 6/8 { r4 b8 b[( g]) g | g[( e]) e d[( f]) a | a g } \addlyrics { \override LyricText #'font-shape = #'italic The man who feels love's sweet e -. separating the context name from the object name. LyricText #'font-shape = #'italic . Similarly.

#f '#(#t #t #f) See also Learning Manual: Appendix B [Scheme tutorial]. © See also Learning Manual: Appendix B [Scheme tutorial]. together with the rules for that type. 4. to the front of these values when they are entered in the \override command. or #f to cause no action Examples #t.45 '(2 . UP. -3.3 Types of properties So far we have seen two types of property: number and symbol.5. 1 '(left-edge staff-bar). #. CENTER.5. The type of property is always shown in brackets after the property name in the IR.1 . of course. You must always add a hash symbol. 0." } (ly:make-moment 1 4). 1.2. preceded by an apostrophe A procedure. bend::print.25 0. Here is a list of the types you may need.5) \markup { \italic "cresc.Chapter 4: Tweaking output  ¨ 90   Note: In lyrics always leave whitespace between the final syllable and the terminating brace. Property type Boolean Dimension (in staff space) Direction Rules Either True or False. page 173. -2. #f 2. and some examples. '#. represented by #t or #f A positive decimal number (in units of staff space) A valid direction constant or its numerical equivalent (decimal values between -1 and 1 are allowed) A positive whole number A set of values separated by spaces. page 173. 'inside Unknown Vector A list of three items enclosed in parentheses and preceded by apostrophe-hash.2) Markup Moment Number Pair (of numbers) Symbol 'italic.5). -1 Integer List 3.0 0. the value given to a property must be of the correct type and obey the rules for that type.34 LEFT. © ¨  Note: In overrides in lyrics always place spaces around the dot between the context name and the object name. To be valid. enclosed in parentheses and preceded by an apostrophe Any valid markup A fraction of a whole note constructed with the make-moment function Any positive or negative decimal value Two numbers separated by a ‘space . 3. space’ and enclosed in brackets preceded by an apostrophe Any of the set of permitted symbols for that property. (ly:make-moment 3 8) 3. . '(1). '(1. ly:textinterface::print. '(0.

At the top of the page it says “Barline objects are created by: Bar engraver”. How do we prevent them printing? Before we tackle this. In common with many other properties. it can be set to print nothing by setting its value to #f.2. Barline also supports a number of interfaces. many other layout objects too. What is wrong? Go back to the IR and look again at the page giving the properties of BarLine. The interfaces which contain the properties used by a particular grob are listed in the IR at the bottom of the page describing that grob. where we find the transparent and the color properties. As a simple example. including the grob-interface. We explained how to find information about grobs in Section 4. stencil This property controls the appearance of the bar lines by specifying the symbol (glyph) which should be printed. others use them from other interfaces. All of these can affect the visibility of bar lines (and. But the bar lines are normally inserted automatically. a16 b8 c d4 e16 | e8 } 12 16 The bar lines are still printed. 4. so the reason the \override command failed to work as expected is because Barline is not in the default Voice context.1 [Properties of layout objects]. the command simply does not work. of course.) Let’s consider each of these in turn. Some objects then use the properties in some interfaces. Going via Backend and All layout objects we find there is a layout object called BarLine. This is simply to group together those properties that may be used together to tweak a graphical object – if one of them is allowed for an object. who is required to supply them. and nothing is logged in the log file. All of them are of the type Staff.3. by extension.3 Appearance of objects Let us now put what we have learned into practice with a few examples which show how tweaks may be used to change the appearance of the printed music.Chapter 4: Tweaking output 91 4. page 84. let us remember that object properties are grouped in what are called interfaces – see Section 4. Let’s try it. Go to the Bar_engraver page. omitting the implied Context. page 88.2. so are the others. as before.2 [Properties found in interfaces].1 Visibility and color of objects In the educational use of music we might wish to print a score with certain elements omitted as an exercise for the student. Let’s try correcting it by adding the correct context: { \time 12/16 . we go to the IR to find the layout object which prints bar lines. At the bottom it gives a list of Contexts in which the bar engraver operates. Voice: { \time 12/16 \override BarLine #'stencil = ##f c4 b8 c d16 c d8 | g. and those properties may be viewed by looking at those interfaces. let us suppose the exercise is to supply the missing bar lines in a piece of music. Its properties include two that control its visibility: break-visibility and stencil. No error message is produced. Using the same approach. If the context is specified wrongly.

a16 b8 c d4 e16 | e8 } .BarLine #'stencil = ##f c4 b8 c d16 c d8 | g. These control respectively whether bar lines are printed at the end of a line. Note also that in writing this value we have #'# before the opening bracket. This should be set to #t to make the grob transparent. The '# is required as part of the value to introduce a vector.BarLine #'break-visibility = #'#(#f #f #f) c4 b8 c d16 c d8 | g. so the value we need is '#(#f #f #f). as always. a16 b8 c d4 e16 | e8 } 12 16 And we see this too removes all the bar lines. This is produced by the Time_ signature_engraver which you can check also lives in the Staff context and also supports the grob-interface. Back to the ‘All layout objects’ page in the IR to find the properties of the TimeSignature layout object.Chapter 4: Tweaking output 92 \override Staff. a16 b8 c d4 e16 | e8 } 12 16 Now the bar lines have vanished. transparent We see from the properties specified in the grob-interface page in the IR that the transparent property is a boolean. remembering to include the Staff context. and at the beginning of lines. To do this we need to find the grob name for the time signature. In this next example let us make the time signature invisible rather than the bar lines. Let’s try that.TimeSignature #'transparent = ##t c4 b8 c d16 c d8 | g. break-visibility We see from the BarLine properties in the IR that the break-visibility property requires a vector of three booleans. For our example we want all bar lines to be suppressed. So the command to make the time signature transparent is: { \time 12/16 \override Staff. in the middle of lines. to precede the value itself in the \override command. and the first # is required. { \time 12/16 \override Staff.

the stencil for the time signature should be set to #f instead: { \time 12/16 \override Staff. but a function. Maybe this is what is wanted for an exercise for the student to fill it in. a16 b8 c d4 e16 | e8 } and the difference is obvious: setting the stencil to #f removes the object entirely. You may see in some of the examples below that this happens unpredictably. . but there is no explanation of what that list should be. (There is a difficulty with this in that the white bar line may or may not blank out the staff lines where they cross. The list it requires is actually a list of values in internal units. The other colors in the normal list are functions too. making the object transparent leaves it where it is. so please just accept this limitation for now. The details of why this is so and how to control it are covered in Section “Painting objects white” in Notation Reference. To convince yourself this is working you might like to change the color to one of the other functions in the list.BarLine #'color = #white c4 b8 c d16 c d8 | g. color Finally let us try making the bar lines invisible by coloring them white. to avoid having to know what these are. To set the bar lines to white we write: { \time 12/16 \override Staff. but this command leaves a gap where the time signature should be. but makes it invisible. But at the moment we are learning about color. To remove it. but.TimeSignature #'stencil = ##f c4 b8 c d16 c d8 | g. several ways are provided to specify colors. The first way is to use one of the ‘normal’ colors listed in the first table in Section “List of colors” in Notation Reference. a16 b8 c d4 e16 | e8 } 12 16 and again. we see the bar lines are not visible. Note that white is not preceded by an apostrophe – it is not a symbol. it provides the list of internal values required to set the color to white.Chapter 4: Tweaking output 93 The time signature is gone. but in other circumstances a gap might be undesirable. When called.) The grob-interface specifies that the color property value is a list.

these must be preceded by another function. so the symbol must be preceded by an apostrophe and the two enclosed in brackets. 'grey100. This takes three arguments giving the intensities of the red.StaffSymbol #'color = #(x11-color 'grey30) \override Staff. There is yet a third function. Let’s illustrate this by setting all the layout objects in our example to various shades of grey: { \time 12/16 \override Staff. These take values in the range 0 to 1. x11-color.BarLine #'color = #(x11-color 'grey10) c4 b8 c d16 c d8 | g. 'grey0'. to white. green and blue colors. like this: { \time 12/16 \override Staff.NoteHead #'color = #(x11-color 'grey85) \override Voice.BarLine #'color = #(rgb-color 1 1 1) c4 b8 c d16 c d8 | g.Clef #'color = #(x11-color 'grey60) \override Voice.TimeSignature #'color = #(x11-color 'grey60) \override Staff. there is also a grey scale available as part of the X11 set of colors. a16 b8 c d4 e16 | e8 } 12 16 Note that in this case the function x11-color takes a symbol as an argument.Chapter 4: Tweaking output 94 The second way of changing the color is to use the list of X11 color names in the second list in Section “List of colors” in Notation Reference. in steps of 1. These range from black. However.Stem #'color = #(x11-color 'grey85) \override Staff.BarLine #'color = #(x11-color 'white) c4 b8 c d16 c d8 | g. a16 b8 c d4 e16 | e8 } 12 16 . one which converts RGB values into internal colors – the rgbcolor function. which converts X11 color names into the list of internal values. a16 b8 c d4 e16 | e8 } 12 16 Finally. So to set the color to red the value should be (rgb-color 1 0 0) and to white it should be (rgb-color 1 1 1): { \time 12/16 \override Staff.

and on the engraver page in the IR it tells you in which context the engraver will normally be found.3. \new Staff ="main" { \relative g' { r4 g8 g c4 c8 d | e4 r8 << { f c c } \new Staff \with { alignAboveContext = #"main" } { f8 f c } >> r4 | } } Ossia are normally written without clef and time signature. as follows: \new Staff ="main" { \relative g' { r4 g8 g c4 c8 d | e4 r8 << { f c c } \new Staff \with { alignAboveContext = #"main" } { \override Staff. as in an Section “ossia” in Music Glossary.Clef #'stencil = ##f \override Staff.2 Size of objects Let us begin by looking again at the earlier example see Section 3. 4. or the commands will not work! Remember. It is important to get these right.1.TimeSignature #'stencil = ##f { f8 f c } } >> r4 | } .3 [Nesting music expressions].Chapter 4: Tweaking output 95 Note the contexts associated with each of the layout objects. The default context for engravers can be found by starting from the layout object. page 41) which showed how to introduce a new temporary staff. We already know now how to remove the clef and time signature – we simply set the stencil of each to #f. and are usually printed slightly smaller than the main staff. going from there to the engraver which produces it. the context is the one in which the appropriate engraver is placed.

and remain in force as the default values for the duration of that context. since this is unambiguously defined as the context which the \with clause is modifying. The default values of layout object properties can also be set in \with clauses. alignBelowContext. which will be the ones set in the \with clause. So we could replace the example above with \new Staff ="main" { \relative g' { r4 g8 g c4 c8 d | e4 r8 << { f c c } \new Staff \with { alignAboveContext = #"main" % Don't print clefs in this staff \override Clef #'stencil = ##f % Don't print time signatures in this staff \override TimeSignature #'stencil = ##f } { f8 f c } >> r4 | } } . If fact. are two such properties – once the staff has been created its alignment is decided and it would make no sense to try to change it later. If changes are unset or reverted using \unset or \revert they return to their default values. or if none have been set there. Simply use the normal \override command leaving out the context name. Some context properties can be modified only in \with clauses. the normal default values. But what is the difference between modifying the staff context by using \with and modifying the stencils of the clef and the time signature with \override? The main difference is that changes made in a \with clause are made at the time the context is created. alignAboveContext and its partner.Chapter 4: Tweaking output 96 } where the extra pair of braces after the \with clause are required to ensure the enclosed overrides and music are applied to the ossia staff. These are those properties which cannot sensibly be changed after the context has been created. whereas \set or \override commands embedded in the music are dynamic – they make changes synchronized with a particular point in the music. an error will be generated if a context is specified in this location.

Their size is changed by modifying the font-size property. thickness of beams and other lines. \set fontSize = #-2 Both of these statements would cause the font size to be reduced by 2 steps from its previous value. like NoteHeads with commands like \override NoteHead #'font-size = #-2 or we can change the size of all fonts by setting a special property. spanner objects – are drawn individually. Some layout objects are created as glyphs selected from a typeface font. These include note heads. and the separation of staff lines all need to be modified in special ways. using \set. let us first change the font-size. accidentals. or by including it in a \with clause (but without the \set).Chapter 4: Tweaking output 97 Finally we come to changing the size of layout objects. fontSize. Other layout objects such as slurs and ties – in general. dynamics and lyrics. so usually there is no need to change their size manually. Let’s try it in our ossia example: \new Staff ="main" { \relative g' { r4 g8 g c4 c8 d | e4 r8 << { f c c } \new Staff \with { alignAboveContext = #"main" \override Clef #'stencil = ##f \override TimeSignature #'stencil = ##f % Reduce all font sizes by ~24% fontSize = #-2 } { f8 f c } >> r4 | } } . where each step reduces or increases the size by approximately 12%. clefs. so there is no font-size associated with them. We can do this in two ways. Still other properties such as the length of stems and bar lines. Returning to the ossia example. as we shall shortly see. These objects generally derive their size from the objects to which they are attached. time signatures. We can either change the size of the fonts of each object type. markup.

Chapter 4: Tweaking output

98

This is still not quite right. The note heads and flags are smaller, but the stems are too long in proportion and the staff lines are spaced too widely apart. These need to be scaled down in proportion to the font reduction. The next sub-section discusses how this is done.

4.3.3 Length and thickness of objects
Distances and lengths in LilyPond are generally measured in staff-spaces, the distance between adjacent lines in the staff, (or occasionally half staff spaces) while most thickness properties are measured in units of an internal property called line-thickness. For example, by default, the lines of hairpins are given a thickness of 1 unit of line-thickness, while the thickness of a note stem is 1.3. Note, though, that some thickness properties are different; for example, the thickness of beams is measured in staff-spaces. So how are lengths to be scaled in proportion to the font size? This can be done with the help of a special function called magstep provided for exactly this purpose. It takes one argument, the change in font size (#-2 in the example above) and returns a scaling factor suitable for reducing other objects in proportion. It is used like this: \new Staff ="main" { \relative g' { r4 g8 g c4 c8 d | e4 r8 << { f c c } \new Staff \with { alignAboveContext = #"main" \override Clef #'stencil = ##f \override TimeSignature #'stencil = ##f fontSize = #-2 % Reduce stem length and line spacing to match \override StaffSymbol #'staff-space = #(magstep -2) } { f8 f c } >> r4 | } }

Since the length of stems and many other length-related properties are always calculated relative to the value of the staff-space property these are automatically scaled down in length too. Note that this affects only the vertical scale of the ossia – the horizontal scale is determined by the layout of the main music in order to remain synchronized with it, so it is not affected by any of these changes in size. Of course, if the scale of all the main music were changed in this way then the horizontal spacing would be affected. This is discussed later in the layout section. This, then, completes the creation of an ossia. The sizes and lengths of all other objects may be modified in analogous ways. For small changes in scale, as in the example above, the thickness of the various drawn lines such as bar lines, beams, hairpins, slurs, etc does not usually require global adjustment. If

Chapter 4: Tweaking output

99

the thickness of any particular layout object needs to be adjusted this can be best achieved by overriding its thickness property. An example of changing the thickness of slurs was shown above in Section 4.2.1 [Properties of layout objects], page 84. The thickness of all drawn objects (i.e., those not produced from a font) may be changed in the same way.

4.4 Placement of objects
4.4.1 Automatic behavior
There are some objects in musical notation that belong to the staff and there are other objects that should be placed outside the staff. These are called within-staff objects and outside-staff objects respectively. Within-staff objects are those that are located on the staff – note heads, stems, accidentals, etc. The positions of these are usually fixed by the music itself – they are vertically positioned on specific lines of the staff or are tied to other objects that are so positioned. Collisions of note heads, stems and accidentals in closely set chords are normally avoided automatically. There are commands and overrides which can modify this automatic behavior, as we shall shortly see. Objects belonging outside the staff include things such as rehearsal marks, text and dynamic markings. LilyPond’s rule for the vertical placement of outside-staff objects is to place them as close to the staff as possible but not so close that they collide with any other object. LilyPond uses the outside-staff-priority property to determine the order in which the objects should be placed, as follows. First, LilyPond places all the within-staff objects. Then it sorts the outside-staff objects according to their outside-staff-priority. The outside-staff objects are taken one by one, beginning with the object with the lowest outside-staff-priority, and placed so that they do not collide with any objects that have already been placed. That is, if two outside-staff grobs are competing for the same space, the one with the lower outside-staff-priority will be placed closer to the staff. If two objects have the same outside-staff-priority the one encountered first will be placed closer to the staff. In the following example all the markup texts have the same priority (since it is not explicitly set). Note that ‘Text3’ is automatically positioned close to the staff again, nestling under ‘Text2’. c2^"Text1" c^"Text2" c^"Text3" c^"Text4"

Text2 Text4 Text1 Text3

Staves are also positioned, by default, as closely together as possible (subject to a minimum separation). If notes project a long way towards an adjacent staff they will force the staves further apart only if an overlap of the notation would otherwise occur. The following example demonstrates this ‘nestling’ of the notes on adjacent staves: << \new Staff { \relative c' { c a, } } \new Staff { \relative c'''' { c a, }

Chapter 4: Tweaking output

100

} >>

4.4.2 Within-staff objects
We have already seen how the commands \voiceXXX affect the direction of slurs, ties, fingering and everything else which depends on the direction of the stems. These commands are essential when writing polyphonic music to permit interweaving melodic lines to be distinguished. But occasionally it may be necessary to override this automatic behavior. This can be done for whole sections of music or even for an individual note. The property which controls this behavior is the direction property of each layout object. We first explain what this does, and then introduce a number of ready-made commands which avoid your having to code explicit overrides for the more common modifications. Some layout objects like slurs and ties curve, bend or point either up or down; others like stems and flags also move to right or left when they point up or down. This is controlled automatically when direction is set. The following example shows in bar 1 the default behavior of stems, with those on high notes pointing down and those on low notes pointing up, followed by four notes with all stems forced down, four notes with all stems forced up, and finally four notes reverted back to the default behavior. a4 g c a \override Stem #'direction = #DOWN a g c a \override Stem #'direction = #UP a g c a \revert Stem #'direction a g c a

Here we use the constants DOWN and UP. These have the values -1 and +1 respectively, and these numerical values may be used instead. The value 0 may also be used in some cases. It is simply treated as meaning UP for stems, but for some objects it means ‘center’. There is a constant, CENTER which has the value 0. However, these explicit overrides are not usually used, as there are simpler equivalent predefined commands available. Here is a table of the commonest. The meaning of each is stated where it is not obvious. Down/Left Up/Right Revert \arpeggioArrowDown\arpeggioArrowUp\arpeggioNormal Effect Arrow is at bottom, at top, or no arrow

First.Chapter 4: Tweaking output 101 \dotsDown \dotsUp \dotsNeutral Direction of movement to avoid staff lines \dynamicDown \dynamicUp \dynamicNeutral \phrasingSlurDown \phrasingSlurUp \phrasingSlurNeutralNote: distinct from slur commands \slurDown \slurUp \slurNeutral \stemDown \stemUp \stemNeutral \textSpannerDown \textSpannerUp \textSpannerNeutral Text entered as spanner is below/above staff \tieDown \tieUp \tieNeutral \tupletDown \tupletUp \tupletNeutral Tuplets are below/above notes Note that these predefined commands may not be preceded by \once. By default. Here is the previous example using this method: c-5 a-3 f-1 c'-5 c_5 a_3 f_1 c'_5 c^5 a^3 f^1 c'^5 5 3 1 5 5 3 1 5 5 3 1 5 The direction property is ignored for chords. _ and ^ do work. and the following two bars shows the effect of specifying DOWN and UP: c-5 a-3 f-1 c'-5 \override Fingering #'direction = #DOWN c-5 a-3 f-1 c'-5 \override Fingering #'direction = #UP c-5 a-3 f-1 c'-5 5 3 1 5 5 3 1 5 5 3 1 5 However. the fingering is automatically placed both above and below the notes of a chord. If you wish to limit the effect to a single note you must either use the equivalent \once \override command or use the predefined command followed after the affected note by the corresponding \xxxNeutral command. here’s the effect of direction on the fingering attached to single notes. to the left or to the right of each note. The first bar shows the default behaviour. but changing direction has no effect on chords. as shown: . using _ or ^ instead of .before the fingering number is usually preferable. As we shall see. overriding the direction property is not the easiest way of manually setting the fingering above or below the notes. there are special commands which allow the fingering of individual notes of chords to be controlled. Fingering The placement of fingering on single notes can also be controlled by the direction property. but the directional prefixes. with the fingering being placed above. below.

LilyPond takes these constraints and works out the best placement for the fingering of the notes of the following chords. The property may be set to a list of one to three values. The format of this command is: \set fingeringOrientations = #'([up] [left/right] [down]) \set is used because fingeringOrientations is a property of the Voice context. if a location is not listed. created and used by the New_fingering_engraver.Chapter 4: Tweaking output 102 <c-5 g-3> <c-5 g-3 e-2> <c-5 g-3 e-2 c-1> 5 5 5 3 3 3 2 2 1 but this may be overriden to manually force all or any of the individual fingering numbers above or below: <c-5 g-3 e-2 c-1> <c^5 g_3 e_2 c_1> <c^5 g^3 e^2 c_1> 5 5 3 3 5 2 2 3 1 1 2 1 Even greater control over the placement of fingering of the individual notes in a chord is possible by using the \set fingeringOrientations command. © Here are a few examples: \set fingeringOrientations <f-2> < c-1 e-2 g-3 b-5 > 4 \set fingeringOrientations <f-2> < c-1 e-2 g-3 b-5 > 4 \set fingeringOrientations <f-2> < c-1 e-2 g-3 b-5 > 4 \set fingeringOrientations = #'(left) = #'(left) = #'(up left down) = #'(up left) . or to the right (if right appears). Note that left and right are mutually exclusive – fingering may be placed only on one side or the other. It controls whether fingerings may be placed above (if up appears in the list). to the left (if left appears. no fingering is placed there.  ¨  Note: To control the placement of the fingering of a single note using this command it is necessary to write it as a single note chord by placing angle brackets round it. Conversely. not both. below (if down appears).

3 Outside-staff objects Outside-staff objects are automatically placed to avoid collisions. and other outside-staff objects are then raised as far as necessary to avoid collisions.4. Layout Object MultiMeasureRestText TextScript OttavaBracket TextSpanner DynamicLineSpanner VoltaBracketSpanner Priority 450 450 400 350 250 100 Controls position of: Text over full-bar rests Markup text Ottava brackets Text spanners All dynamic markings Volta brackets . so let’s try -7: \override Fingering #'font-size = #-7 \set fingeringOrientations = #'(left) <f-2> < c-1 e-2 g-3 b-5 > 4 \set fingeringOrientations = #'(left) <f-2> < c-1 e-2 g-3 b-5 > 4 \set fingeringOrientations = #'(up left down) <f-2> < c-1 e-2 g-3 b-5 > 4 \set fingeringOrientations = #'(up left) <f-2> < c-1 e-2 g-3 b-5 > 4 \set fingeringOrientations = #'(right) <f-2> < c-1 e-2 g-3 b-5 > 4 2 2 5 3 2 1 2 5 3 2 1 3 2 1 5 2 3 2 1 5 2 5 3 2 1 4. by default. By default it is set to #f for all within-staff objects. The outside-staff-priority is defined in the grob-interface and so is a property of all layout objects. Objects with the lower value of the outside-staff-priority property are placed nearer to the staff. placed in the Staff or Voice contexts. The default value can be seen from the Fingering object in the IR to be -5. and to a numerical value appropriate to each outside-staff object when the object is created. The following table shows the default numerical values for some of the commonest outside-staff objects which are.Chapter 4: Tweaking output 103 <f-2> < c-1 e-2 g-3 b-5 > 4 \set fingeringOrientations = #'(right) <f-2> < c-1 e-2 g-3 b-5 > 4 2 5 2 5 5 3 2 2 2 1 5 3 2 1 3 2 1 3 2 1 5 2 3 2 1 If the fingering seems a little crowded the font-size could be reduced.

c c c 8va Text Slower pp ff This example also shows how to create Text Spanners – text with extender lines above a section of music. If you wish to place bar numbers. By default these are created in the Score context and their outside-staff-priority is ignored relative to the layout objects which are created in the Staff context. metronome marks or rehearsal marks in accordance with the value of their outside-staffpriority the Bar_number_engraver. It also shows how ottava brackets are created. Note that bar numbers. All we need to do is to look up the . Metronome_mark_engraver or Mark_engraver respectively should be removed from the Score context and placed in the top Staff context. and the format of the text is defined by the \override TextSpanner command. these marks will be given the following default outside-staff-priority values: Layout Object RehearsalMark MetronomeMark BarNumber Priority 1500 1000 100 If the default values of outside-staff-priority do not give you the placing you want.Chapter 4: Tweaking output 104 TrillSpanner 50 Spanning trills Here is an example showing the default placement of some of these. For more details see Section “Text spanners” in Notation Reference. If this is done. Suppose we would like the ottava bracket to be placed below the text spanner in the example above. the priority of any of the objects may be overridden. metronome marks and rehearsal marks are not shown. The spanner extends from the \startTextSpan command to the \stopTextSpan command. % Set details for later Text Spanner \override TextSpanner #'(bound-details left text) = \markup { \small \bold Slower } % Place dynamics above staff \dynamicUp % Start Ottava Bracket \ottava #1 c' \startTextSpan % Add Dynamic Text c\pp % Add Dynamic Line Spanner c\< % Add Text Script c^Text c c % Add Dynamic Text c\ff c \stopTextSpan % Stop Ottava Bracket \ottava #0 c.

OttavaBracket #'outside-staff-priority = #340 % Start Ottava Bracket \ottava #1 c' \startTextSpan % Add Dynamic Text c\pp % Add Dynamic Line Spanner c\< % Add Text Script c^Text c c % Add Dynamic Text c\ff c \stopTextSpan % Stop Ottava Bracket \ottava #0 c. but the avoid-slur property is effective only if the outside-staff-priority is also set to #f. as the slur will be placed first.Chapter 4: Tweaking output 105 priority of OttavaBracket in the IR or in the tables above. Here’s an example showing the effect of the two methods: c4( c^\markup\tiny\sharp d4.) c8 \once \override Slur #'outside-staff-priority = #500 c4( c^\markup\tiny\sharp d4. but they often appear above the staff if the notes to which they are attached are high on the staff.) c8 c4( \once \override TextScript #'avoid-slur = #'inside \once \override TextScript #'outside-staff-priority = ##f c^\markup\tiny\sharp d4. Alternatively. The avoid-slur property of the articulation can be set to 'inside to bring the articulation inside the slur.) c8 . and reduce it to a value lower than that of a TextSpanner. the outside-staff-priority of the slur can be set to a numerical value to cause it to be placed along with other outside-staff objects according to that value. This can push outside-staff objects such as articulations too high. remembering that OttavaBracket is created in the Staff context: % Set details for later Text Spanner \override TextSpanner #'(bound-details left text) = \markup { \small \bold Slower } % Place dynamics above staff \dynamicUp %Place following Ottava Bracket below Text Spanners \once \override Staff. c c c 8va Slower Text pp ff Slurs by default are classed as within-staff objects.

Suppose we would like “Text3” to be placed above “Text4” in the example under Automatic behavior. All we need to do is to look up the priority of TextScript in the IR or in the tables above.4. \textLengthOn By default. Here’s an example to show how markup text interacts with such notes. so cannot be used with \textLengthOn. Perhaps this is not so good. page 99). causing the notes to be spaced out as far as is necessary to accommodate the text: \textLengthOn % Cause notes to space out to accommodate text c2^"Text1" c^"Text2" c^"Text3" c^"Text4" Text1 Text2 Text3 Text4 The command to revert to the default behavior is \textLengthOff. we clearly will need to space the notes out horizontally to make more room for the text. so it is displaced upwards .1 [Automatic behavior]. the automatic displacement upwards may be turned off by setting the priority to #f. Remember \once only works with \override. If this is not desired. \revert or unset. Markup text will also avoid notes which project above the staff. To do this. What we would really like to do is to position all the annotation at the same distance above the staff. % This markup is short enough to fit without collision c2^"Tex" c''2 R1 % This is too long to fit. This is done using the textLengthOn command. and increase the priority of “Text3” to a higher value: c2^"Text1" c^"Text2" \once \override TextScript #'outside-staff-priority = #500 c^"Text3" c^"Text4" Text3 Text2 Text1 Text4 This certainly lifts “Text3” above “Text4” but it also lifts it above “Text2”. above (see Section 4. although the results may not always be desirable. The \textLengthOn command reverses this behavior. and “Text4” now drops down. \set.Chapter 4: Tweaking output 106 Changing the outside-staff-priority can also be used to control the vertical placement of individual objects. text produced by markup takes up no horizontal space as far as laying out the music is concerned.

Chapter 4: Tweaking output

107

c,,2^"Text" c''2 R1 % Turn off collision avoidance \once \override TextScript #'outside-staff-priority = ##f c,,2^"Long Text " c''2 R1 % Turn off collision avoidance \once \override TextScript #'outside-staff-priority = ##f \textLengthOn % and turn on textLengthOn c,,2^"Long Text " % Spaces at end are honored c''2

Text Tex Long Text Long Text

Dynamics
Dynamic markings will normally be positioned beneath the staff, but may be positioned above with the dynamicUp command. They will be positioned vertically relative to the note to which they are attached, and will float below (or above) all within-staff objects such as phrasing slurs and bar numbers. This can give quite acceptable results, as this example shows: \clef "bass" \key aes \major \time 9/8 \dynamicUp bes4.~\f\< \( bes4 bes8 des4\ff\> c16 bes\! | ees,2.~\)\mf ees4 r8 |

f 9 8

ff

mf

However, if the notes and attached dynamics are close together the automatic placement will avoid collisions by displacing later dynamic markings further away, but this may not be the optimum placement, as this rather artificial example shows: \dynamicUp a4\f b\mf c\mp b\p

mp f mf p
Should a similar situation arise in ‘real’ music, it may be preferable to space out the notes a little further, so the dynamic markings can all fit at the same vertical distance from the staff.

Chapter 4: Tweaking output

108

We were able to do this for markup text by using the \textLengthOn command, but there is no equivalent command for dynamic marks. So we shall have to work out how to do this using \override commands.

Grob sizing
First we must learn how grobs are sized. All grobs have a reference point defined within them which is used to position them relative to their parent object. This point in the grob is then positioned at a horizontal distance, X-offset, and at a vertical distance, Y-offset, from its parent. The horizontal extent of the object is given by a pair of numbers, X-extent, which say where the left and right edges are relative to the reference point. The vertical extent is similarly defined by a pair of numbers, Y-extent. These are properties of all grobs which support the grob-interface. By default, outside-staff objects are given a width of zero so that they may overlap in the horizontal direction. This is done by the trick of adding infinity to the leftmost extent and minus infinity to the rightmost extent by setting the extra-spacing-width to '(+inf.0 . inf.0). So to ensure they do not overlap in the horizontal direction we must override this value of extra-spacing-width to '(0 . 0) so the true width shines through. This is the command to do this for dynamic text: \override DynamicText #'extra-spacing-width = #'(0 . 0) Let’s see if this works in our previous example: \dynamicUp \override DynamicText #'extra-spacing-width = #'(0 . 0) a4\f b\mf c\mp b\p

f mfmp p

Well, it has certainly stopped the dynamic marks being displaced, but two problems remain. The marks should be spaced a little further apart and it would be better if they were all the same distance from the staff. We can solve the first problem easily. Instead of making the extra-spacing-width zero we could add a little more to it. The units are the space between two staff lines, so moving the left edge half a unit to the left and the right edge half a unit to the right should do it: \dynamicUp % Extend width by 1 staff space \override DynamicText #'extra-spacing-width = #'(-0.5 . 0.5) a4\f b\mf c\mp b\p

f mf mp p

This looks better, but maybe we would prefer the dynamic marks to be aligned along the same baseline rather than going up and down with the notes. The property to do this is staffpadding which is covered in the following section.

Chapter 4: Tweaking output

109

4.5 Collisions of objects
4.5.1 Moving objects
This may come as a surprise, but LilyPond is not perfect. Some notation elements can overlap. This is unfortunate, but in fact rather rare. Usually the need to move objects is for clarity or aesthetic reasons – they would look better with a little more or a little less space around them. There are three main approaches to resolving overlapping notation. They should be considered in the following order: 1. The direction of one of the overlapping objects may be changed using the predefined commands listed above for within-staff objects (see Section 4.4.2 [Within-staff objects], page 100). Stems, slurs, beams, ties, dynamics, text and tuplets may be repositioned easily in this way. The limitation is that you have a choice of only two positions, and neither may be suitable. 2. The object properties, which LilyPond uses when positioning layout objects, may be modified using \override. The advantages of making changes to this type of property are (a) that some other objects will be moved automatically if necessary to make room and (b) the single override can apply to all instances of the same type of object. Such properties include: • direction This has already been covered in some detail – see Section 4.4.2 [Within-staff objects], page 100. • padding, left-padding, right-padding, staff-padding As an object is being positioned the value of its padding property specifies the gap that must be left between itself and the nearest edge of the object against which it is being positioned. Note that it is the padding value of the object being placed that is used; the padding value of the object which is already placed is ignored. Gaps specified by padding can be applied to all objects which support the side-position-interface. Instead of padding, the placement of groups of accidentals is controlled by left-padding and right-padding. These properties are to be found in the AccidentalPlacement object which, note, lives in the staff context. In the type-setting process the note heads are type-set first and then the accidentals, if any, are added to the left of the note heads using the right-padding property to determine the separation from the note heads. So only the right-padding property of the AccidentalPlacement object has any effect on the placement of the accidentals. The staff-padding property is closely related to the padding property: padding controls the minimum amount of space between any object which supports the sideposition-interface and the nearest other object (generally the note or the staff lines); staff-padding applies only to those objects which are always set outside the staff – it controls the minimum amount of space that should be inserted between that object and the staff. Note that staff-padding has no effect on objects which are positioned relative to the note rather than the staff, even though it may be overridden without error for such objects – it is simply ignored. To discover which padding property is required for the object you wish to reposition, you need to return to the IR and look up the object’s properties. Be aware that the padding properties might not be located in the obvious object, so look in objects that appear to be related. All padding values are measured in staff spaces. For most objects, this value is set by default to be around 1.0 or less (it varies with each object). It may be overridden if a larger (or smaller) gap is required.

the Accidental object only takes notice of the first (left edge) number. viz. 3. It should be used in complex situations where the normal \shiftOn commands (see Section 3. the first is added to the leftmost extent and the second is added to the rightmost extent. For example. But the main difficulty with this approach is that the repositioning values may need to be reworked if the music is later modified. It takes two numbers. or to center it with respect to the parent object’s reference point. • extra-spacing-width This property is available for all objects which support the item-interface.2 [Explicitly instantiating voices]. These are called note columns. and moving the notes into or out of a NoteColumn affects other actions such as merging note heads. It specifies the vertical position of the object relative to the center line of the staff in half staff-spaces. to the right. It is useful in resolving collisions between layout objects like multi-measure rests. It is preferable to the extra-offset property for this purpose as there is no need to work out the distance in staff-spaces. Changing it permits a note column to be moved in units appropriate to a note column. Numerical values greater than 1 may be specified to move the text even further to the left. objects may be manually repositioned relative to the staff center line vertically. and an object called NoteColumn is created to lay out the notes in that column. RIGHT or CENTER. are arranged in two. positive to the right. the second positive. The properties that can be used for this type of manual repositioning are: extra-offset This property applies to any layout object supporting the grob-interface. page 48) do not resolve the note conflict. • staff-position staff-position is a property of the staff-symbol-referencer-interface. Negative numbers move the edge to the left. so to widen an object the first number must be negative. The extra displacement is made after the typeset- . The units are staff-spaces. and. • force-hshift Closely spaced notes in a chord. the user is responsible for avoiding any collisions that might ensue. columns to prevent the note heads overlapping. Finally. often by trial and error. because the movement is done after LilyPond has placed all other objects. It takes a pair of numbers which specify the extra displacement in the horizontal and vertical directions. the note head width of the first voice note. A change of 1 in the value corresponds to a movement of half the text’s length. which is supported by objects which are positioned relative to the staff.2. The disadvantages are that the correct values for the repositioning have to be worked out. Note that not all objects honor both numbers. It may be used with all objects which support the self-alignment-interface. The force-hshift property is a property of a NoteColumn (actually of the notecolumn-interface). a numerical value between -1 and +1 may be specified. or by displacing them by any distance to a new position. +1 is right-aligned. The values are LEFT. Alternatively. and numbers in between move the text progressively from left-aligned to right-aligned. Negative numbers move the object to the left or down. where -1 is left-aligned. ties and notes in different voices. or notes occurring at the same time in different voices.Chapter 4: Tweaking output 110 • self-alignment-X This property can be used to align the object to the left. In general these are objects that contain text. when all else fails. occasionally more. or less than -1 to move the text even further to the right. for every object individually.

5. positions This is most useful for manually adjusting the slope and height of beams. ^"text" Ties Tuplets Object name Script Beam DynamicLineSpanner DynamicText Fingering RehearsalMark Slur TextScript Tie TupletBracket 4. If the positions property has been overridden the slur that is closest to the requested positions is selected from the list. A particular object may not have all of these properties. LilyPond first generates a list of possible positions for the slur and by default finds the slur that “looks best”. slurs. It takes a pair of numbers giving the position of the left and right ends of the beam. slur. Here is a list of the objects which are most likely to be involved in collisions. c2\fermata \override Script #'padding = #3 b2\fermata % This will not work. see below: \override MetronomeMark #'padding = #3 \tempo 4=120 c1 % This works: \override Score. relative to the center line of the staff. It is necessary to go to the IR to look up which properties are available for the object in question. Note.2 Fixing overlapping notation Let’s now see how the properties in the previous section can help to resolve overlapping notation. together with the name of the object which should be looked up in the IR in order to discover which properties should be used to move them. padding property The padding property can be set to increase (or decrease) the distance between symbols that are printed above or below notes.MetronomeMark #'padding = #3 .Chapter 4: Tweaking output 111 ting of objects is finished. though.g. etc. Units are staff-spaces. so an object may be repositioned anywhere without affecting anything else. and tuplets. that slurs and phrasing slurs cannot be repositioned by arbitrarily large amounts. Object type Articulations Beams Dynamics (vertically) Dynamics (horizontally) Fingerings Rehearsal / Text marks Slurs Text e.

property changes in the Voice context will not be noticed. Since the MetronomeMark object is handled in the Score context.AccidentalPlacement #'right-padding = #1. One way of achieving this is to override the accidental stencil with a markup containing the natural and flat symbols in the order we would like. which itself is set to be a natural sign followed by a flat sign. Suppose we wish to show a chord containing both a B-natural and a B-flat. Here are a few attempts to do this: <b bes> <b! bes> <b? bes> None work. . like this: naturalplusflat = \markup { \natural \flat } \relative c'' { \once \override Accidental #'stencil = #ly:text-interface::print \once \override Accidental #'text = #naturalplusflat \once \override Score. then that object and all objects outside it are moved. here changed to print the contents of the text property of Accidental. see Section “Modifying properties” in Notation Reference. with the second two showing bad collisions between the two signs. left-padding and right-padding The right-padding property affects the spacing between the accidental and the note to which it applies.5 <b bes> } This necessarily uses an override for the accidental stencil which will not be covered until later.Chapter 4: Tweaking output 112 \tempo 4=80 d1 = 120 = 80 Note in the second example how important it is to figure out what context handles a certain object. The stencil type must be a procedure. If the padding property of an object is increased when that object is in a stack of objects being positioned according to their outside-staff-priority. It is not often required. For more details. To avoid ambiguity we would like to precede the notes with both a natural and a flat sign. These are then moved further away from the note head by overriding right-padding. but the following example shows one situation where it is needed.

The default in \voiceTwo (i.5 .Chapter 4: Tweaking output 113 staff-padding property staff-padding can be used to align objects such as dynamics along a baseline at a fixed height above the staff. since the rest is in voice two. Here’s an example of a collision of this type: << {c c c c} \\ {R1} >> The best solution here is to move the multimeasure rest down. including those created as extended spanners.. so we need to move it.. in the second voice of a <<{. four half-staff spaces down to -8..5) % Align dynamics to a base line 2 units above staff \override DynamicLineSpanner #'staff-padding = #2 a4\f b\mf c\mp b\p f mf mp p self-alignment-X property The following example shows how this can resolve the collision of a string fingering object with a note’s stem by aligning the right edge with the reference point of the parent note: \voiceOne < a \2 > \once \override StringNumber #'self-alignment-X = #RIGHT < a \2 > 2 2 staff-position property Multimeasure rests in one voice can collide with notes in another.} \\ {. Since these rests are typeset centered between the bar lines. It is not a property of DynamicText but of DynamicLineSpanner. 0. since all the current collision handling between notes and between notes and rests is done only for notes and rests that occur at the same time. say.e. << {c c c c} \\ . it would require significant effort for LilyPond to figure out which other notes might collide with it. This is because the baseline should apply equally to all dynamics.. So this is the way to align the dynamic marks in the example taken from the previous section: \dynamicUp % Extend width by 1 unit \override DynamicText #'extra-spacing-width = #'(-0.}>> construct) is that staff-position is set to -4 for MultiMeasureRest. rather than at a height dependent on the position of the note to which they are attached.

r4 \acciaccatura e8\( d8 c ~c d c d\) We could simply move the phrasing slur above the notes. extra-offset property The extra-offset property provides complete control over the positioning of an object both horizontally and vertically.Chapter 4: Tweaking output 114 \override MultiMeasureRest #'staff-position = #-8 {R1} >> This is better than using. the second fingering is moved a little to the left. slurs. extra-offset. and this would be the preferred solution: r4 \phrasingSlurUp \acciaccatura e8\( d8 c ~c d c d\) But if there were some reason why this could not be done the other alternative would be to move the left end of the phrasing slur down a little using the positions property. for example.8) f-5 5 5 positions property The positions property allows the position and slope of tuplets. In the following example.3 . and 1. Here’s an example which has an ugly phrasing slur due to its trying to avoid the slur on the acciaccatura. phrasing slurs and beams to be controlled manually. This also resolves the rather nasty shape. -1.8 staff space downwards: \stemUp f-5 \once \override Fingering #'extra-offset = #'(-0. because the ledger line above the rest is inserted automatically. .

bes8 } \\ { aes2 f4 fes } \\ .8 ais. g. g. say. b. g e.} \\ {e. g e. g} >> << {b.2.8 ais. b. g.1 [I’m hearing Voices]. which was left looking like this: \new Staff \relative c'' { \key aes \major << { c2 aes4. g} >> } Note that the override continues to apply in the first voice of the second block of quavers. b. b. 3: { \clef "bass" << \override Beam #'positions = #'(3 . g e. g} >> << {b. -3) \acciaccatura e8\( d8 c ~c d c d\) Here’s a further example taken from the opening of the left-hand staff of Chopin’s Prelude Op 28 No. g} >> } This can be resolved by manually moving both ends of the beam up from their position at 2 staff-spaces above the center line to. page 44. g e.8 ais.} \\ {e.8 ais. but not to any of the beams in the second voice. force-hshift property We can now see how to apply the final corrections to the Chopin example introduced at the end of Section 3.} \\ {e. 2. 3) {b. g.} \\ {e.Chapter 4: Tweaking output 115 r4 \once \override PhrasingSlur #'positions = #'(-4 . We see that the beam collides with the upper notes: { \clef "bass" << {b.

difficulties like these are not very common! The example is from Chopin’s Premi`re Ballade.Chapter 4: Tweaking output 116 { \voiceFour <ees c>2 des2 } >> | <c ees aes c>1 | } The lower two notes of the first chord (i.3 Real music example We end this section on Tweaks by showing the steps to be taken to deal with a tricky example which needs several tweaks to produce the desired output. those in the third voice) should not be shifted away from the note column of the higher two notes. The example has been deliberately chosen to illustrate the use of the Notation Reference to resolve unusual problems with notation. fingering and pedalling. To correct this we set force-hshift. bes8 } \\ { aes2 f4 fes } \\ { \voiceFour \once \override NoteColumn #'force-hshift = #0 <ees c>2 \once \override NoteColumn #'force-hshift = #0. of these notes to zero.e. ie half a note head’s width to the right of the note column of the higher notes. . the transition from the e opening Lento to Moderato. which is a property of NoteColumn.5 des2 } >> | <c ees aes c>1 | } 4.5. Op. We achieve this by setting force-hshift of this note to 0. 23. Here’s the final result: \new Staff \relative c'' { \key aes \major << { c2 aes4. The lower note of the second chord is best placed just to the right of the higher notes.5. is what we want the output to look like. Here. but to avoid over-complicating the example too much we have left out the dynamics. so please do not let these difficulties put you off! Fortunately. bars 6 to 9. first. It is not representative of more usual engraving process.

d. the half-note D which is merged with the eighth note D. so the easiest way is to introduce these four voices temporarily at the time they are needed. d>1 | r2.8~ c2 | } \\ {s8 d2 | } \\ {s4 fis4.1 [I’m hearing Voices]. Everything else is in a single voice. If you have forgotten how to do this. | } >> g2. and see what LilyPond produces by default: rhMusic = \relative c'' { r2 c4. These are the five beamed eighth notes.Chapter 4: Tweaking output 117 Moderato 6 4 6 4 We note first that the right hand part in the third bar requires four voices. which is also merged with the eighth note at the same pitch.4 r4 r | r4 } \score { \new PianoStaff << \new Staff = "RH" << \key g \minor \rhMusic >> \new Staff = "LH" << \key g \minor \clef "bass" \lhMusic >> >> } . Let us begin by entering the notes as two variables and setting up the staff structure in a score block. g8 | bes1~ | \time 6/4 bes2.8 d fis bes a | } \\ {c.2. the tied C. and the dotted quarter note F-sharp. look at Section 3.. } lhMusic = \relative c' { r2 <c g ees>2 | <d g. r8 % Start polyphonic section of four voices << {c. page 44.

\( g8 | bes1~ | \time 6/4 bes2. but the appearance is far from satisfactory.\) } lhMusic = \relative c' { r2 <c g ees>2( | <d g. and we can easily add the left hand slur and the right hand phrasing slur.. The tie clashes with the change in time signature. r8 % Start polyphonic section of four voices << {c. the beaming in the third bar is wrong. d. We can correct the beaming by inserting a beam manually. since these were all covered in the Tutorial. and several notation elements are missing. Let’s first deal with the easier things.4 r4 r | r4 } \score { \new PianoStaff << \new Staff = "RH" << \key g \minor \rhMusic >> \new Staff = "LH" << \key g \minor \clef "bass" \lhMusic >> >> } . Doing this gives: rhMusic = \relative c'' { r2 c4.8~ c2 | } \\ {s8 d2 | } \\ {s4 fis4. | } >> g2.Chapter 4: Tweaking output 118 6 4 6 4 All the notes are right. d>1) | r2.8[ d fis bes a] | } \\ {c. the notes are not merged together.

\) } lhMusic = \relative c' { r2 <c g ees>2( | <d g. page 109.5. giving: rhMusic = \relative c'' { r2 c4.8[ d fis bes a] | } \\ {c. d. which says that objects positioned relative to the staff can be moved by overriding their staffposition property. | } >> g2. Looking up ‘arpeggio’ and ‘bar line’ in the index quickly shows us that an arpeggio is produced by appending \arpeggio to a chord..\( g8 | \once \override Tie #'staff-position = #3. d>1)\arpeggio | r2. and a double bar line is produced by the \bar "||" command.Chapter 4: Tweaking output 119 6 4 6 4 The first bar is now correct. as they have not been mentioned in this Learning Manual? This is where we need to turn to the Notation Reference. How do we do these. We next need to correct the collision of the tie with the time signature.5 This completes bar two. which is specified in half staff spaces relative to the center line of the staff. That’s easily done.5 bes1~ | \bar "||" \time 6/4 bes2.4 r4 r | r4 } \score { \new PianoStaff << \new Staff = "RH" \key g \minor \rhMusic >> << .8~ c2 | } \\ {s8 d2 | } \\ {s4 fis4.5 half staff spaces above the center line: \once \override Tie #'staff-position = #3. Moving objects was covered earlier in Section 4. This is best done by moving the tie upwards.1 [Moving objects]. r8 % Start polyphonic section of four voices << {c. The second bar contains an arpeggio and is terminated by a double bar line. So the following override placed just before the first tied note would move the tie up to 3.

so using the information we find in the Notation Reference we add \mergeDifferentlyHeadedOn \mergeDifferentlyDottedOn to the start of that section and \mergeDifferentlyHeadedOff \mergeDifferentlyDottedOff to the end.8[ d fis bes a] | } \\ {c. giving: rhMusic = \relative c'' { r2 c4. But how do we merge notes in different voices together? This is where we need to turn to the Notation Reference for help. A search for “merge” in the Notation Reference index quickly leads us to the commands for merging differently headed and differently dotted notes in Section “Collision resolution” in Notation Reference. The tutorial showed how to add embolded text with the \markup command. In our example we need to merge both types of note for the duration of the polyphonic section in bar 3.Chapter 4: Tweaking output 120 \new Staff = "LH" << \key g \minor \clef "bass" \lhMusic >> >> } 6 4 6 4 On to bar three and the start of the Moderato section.5 bes1~ | \bar "||" \time 6/4 bes2.^\markup {\bold "Moderato"} r8 \mergeDifferentlyHeadedOn \mergeDifferentlyDottedOn % Start polyphonic section of four voices << {c. | } >> \mergeDifferentlyHeadedOff \mergeDifferentlyDottedOff .\( g8 | \once \override Tie #'staff-position = #3. so adding ‘Moderato’ in bold is easy.8~ c2 | } \\ {s8 d2 | } \\ {s4 fis4.

Chapter 4: Tweaking output

121

g2.\) } lhMusic = \relative c' { r2 <c g ees>2( | <d g, d>1)\arpeggio | r2. d,,4 r4 r | r4 } \score { \new PianoStaff << \new Staff = "RH" << \key g \minor \rhMusic >> \new Staff = "LH" << \key g \minor \clef "bass" \lhMusic >> >> }

Moderato

6 4 6 4
These overrides have merged the two F-sharp notes, but not the two on D. Why not? The answer is there in the same section in the Notation Reference – notes being merged must have stems in opposite directions and two notes cannot be merged successfully if there is a third note in the same note column. Here the two D’s both have upward stems and there is a third note – the C. We know how to change the stem direction using \stemDown, and the Notation Reference also says how to move the C – apply a shift using one of the \shift commands. But which one? The C is in voice two which has shift off, and the two D’s are in voices one and three, which have shift off and shift on, respectively. So we have to shift the C a further level still using \shiftOnn to avoid it interfering with the two D’s. Applying these changes gives: rhMusic = \relative c'' { r2 c4.\( g8 | \once \override Tie #'staff-position = #3.5 bes1~ | \bar "||" \time 6/4 bes2.^\markup {\bold "Moderato"} r8 \mergeDifferentlyHeadedOn \mergeDifferentlyDottedOn % Start polyphonic section of four voices

Chapter 4: Tweaking output

122

<< {c,8[ d fis bes a] | } \\ % Move the c2 out of the main note column so the merge will work {c,8~ \shiftOnn c2 | } \\ % Stem on the d2 must be down to permit merging {s8 \stemDown d2 | } \\ {s4 fis4. | } >> \mergeDifferentlyHeadedOff \mergeDifferentlyDottedOff g2.\) } lhMusic = \relative c' { r2 <c g ees>2( | <d g, d>1)\arpeggio | r2. d,,4 r4 r | r4 } \score { \new PianoStaff << \new Staff = "RH" << \key g \minor \rhMusic >> \new Staff = "LH" << \key g \minor \clef "bass" \lhMusic >> >> }

Moderato

6 4 6 4
Nearly there. Only two problems remain: The downward stem on the merged D should not be there, and the C would be better positioned to the right of the D’s. We know how to do both of these from the earlier tweaks: we make the stem transparent, and move the C with the force-hshift property. Here’s the final result: rhMusic = \relative c'' { r2

Chapter 4: Tweaking output

123

c4.\( g8 | \once \override Tie #'staff-position = #3.5 bes1~ | \bar "||" \time 6/4 bes2.^\markup {\bold "Moderato"} r8 \mergeDifferentlyHeadedOn \mergeDifferentlyDottedOn << {c,8[ d fis bes a] | } \\ % Reposition the c2 to the right of the merged note {c,8~ \once \override NoteColumn #'force-hshift = #1.0 % Move the c2 out of the main note column so the merge will work \shiftOnn c2} \\ % Stem on the d2 must be down to permit merging {s8 \stemDown \once \override Stem #'transparent = ##t d2} \\ {s4 fis4.} >> \mergeDifferentlyHeadedOff \mergeDifferentlyDottedOff g2.\) } lhMusic = \relative c' { r2 <c g ees>2( | <d g, d>1)\arpeggio | r2. d,,4 r4 r | r4 } \score { \new PianoStaff << \new Staff = "RH" << \key g \minor \rhMusic >> \new Staff = "LH" << \key g \minor \clef "bass" \lhMusic >> >> }

By using two voices. only two notes in the same voice can be connected with ties.Chapter 4: Tweaking output 124 Moderato 6 4 6 4 4.6. Normally.6 Further tweaking 4. << { \once \override Stem #'transparent = ##t \once \override Stem #'length = #8 b8~ b8\noBeam } \\ { b[ g8] } >> . with the tied notes in one of them and blanking the first up-stem in that voice.1 Other uses for tweaks Tying notes across voices The following example demonstrates how to connect notes in different voices using ties. the tie appears to cross voices: << { \once \override Stem #'transparent = ##t b8~ b8\noBeam } \\ { b[ g8] } >> To make sure that the just-blanked stem doesn’t squeeze the tie too much. we can lengthen the stem by setting the length to 8.

Chapter 4: Tweaking output 125 Simulating a fermata in MIDI For outside-staff objects it is usually better to override the object’s stencil property rather than its transparent property when you wish to remove it from the printed output. This means it has no effect on the placement of other objects placed relative to it. We show here the effect of the two methods: \score { \relative c'' { % Visible tempo marking \tempo 4=120 a4 a a \once \override Score. So setting its stencil property to #f would be the best way. if we wished to change the metronome setting in order to simulate a fermata in the MIDI output we would not want the metronome markings to appear in the printed output. and we would not want it to influence the spacing between the two systems or the positions of adjacent annotations on the staff.MetronomeMark #'transparent = ##t % Invisible tempo marking to lengthen fermata in MIDI \tempo 4=80 a\fermata % New tempo for next section \tempo 4=100 a a a a } \layout { } \midi { } } = 100 = 120 \score { \relative c'' { % Visible tempo marking \tempo 4=120 a4 a a \once \override Score. Setting the stencil property of an object to #f will remove that object entirely from the printed output.MetronomeMark #'stencil = ##f % Invisible tempo marking to lengthen fermata in MIDI \tempo 4=80 a\fermata % New tempo for next section \tempo 4=100 a a a a } \layout { } \midi { } } . For example.

Here’s an example of this.ly Spi -. \normal whose voice the | wa -. b8 | a8 b c d e4 } BassMusic = \relative c { c4 | c4. e8 g4 g | a a g } AltoMusic = \relative c' { c4 | c4. \normal | who didst brood VerseFour = \lyricmode { O | \emphasize Tri -.ni -.LyricText #'font-shape \revert Lyrics. and both affect the MIDI timing as required. \normal | strong to sav VerseTwo = \lyricmode { O | \emphasize Christ. If the same overrides are to be used many times it may be worth defining variables to hold them. since they are not being interpreted in \lyricmode directly.LyricText #'font-shape = #'italic \override Lyrics. 4.ters h VerseThree = \lyricmode { O | \emphasize Ho -. c8 e4 e | f f e } TenorMusic = \relative c { e4 | g4. But we can define these as two variables and use those to bracket the words to be emphasized.ther. LyricText #'font-shape \revert Lyrics . together with the word or words to be modified. Another advantage of using variables for these overrides is that the spaces around the dot are not necessary.6. LyricText #'font-shape = #'italic \override Lyrics .LyricText #'font-series } global = { \time 4/4 \partial 4 \key c \major} SopranoMusic = \relative c' { c4 | e4. although in practice we would choose shorter names for the variables to make them quicker to type: emphasize = { \override Lyrics.ty \normal of | love and pow'r } \score { \new ChoirStaff << \new Staff << \clef "treble" \new Voice = "Soprano" { \voiceOne \global \SopranoMusic } . LyricText #'font-series These would also be extremely tedious to enter if there were many words requiring emphasis. g8 c4. As an alternative can we use \override and \revert commands? \override Lyrics .LyricText #'font-series = #'bold } normal = { \revert Lyrics.nal \emphasize Fa -. The need to embed the words themselves prevents their use in simple variables.| ter -. Suppose we wish to emphasize certain words in lyrics by printing them in bold italics.2 Using variables for tweaks Override commands are often long and tedious to type. within a \markup block.Chapter 4: Tweaking output 126 = 120 = 100 Both methods remove the metronome mark which lengthens the fermata from the printed output.rit. LyricText #'font-series = #'bold \revert Lyrics . but the transparent metronome mark in the first line forces the following tempo indication too high while the second (with the stencil removed) does not. and they have to be absolutely correct. c8 c4 c | f8 g a b c4 } VerseOne = \lyrics { E -. which makes them tedious to enter. The \italic and \bold commands only work within lyrics if they are embedded.

3 Other sources of information The Internals Reference documentation contains a lot of information about LilyPond.e.Z /’. • Windows Using Windows Explorer.Chapter 4: Tweaking output 127 \new \new \new \new \new Voice = "Alto" { Lyrics \lyricsto Lyrics \lyricsto Lyrics \lyricsto Lyrics \lyricsto \voiceTwo "Soprano" "Soprano" "Soprano" "Soprano" \AltoMusic } { \VerseOne { \VerseTwo { \VerseThree { \VerseFour } } } } >> \new Staff << \clef "bass" \new Voice = "Tenor" { \voiceOne \TenorMusic } \new Voice = "Bass" { \voiceTwo \BassMusic } >> >> } nal Fa ther. The location of this directory depends (a) on whether you obtained LilyPond by downloading a precompiled binary from lilypond. Within this directory the two interesting subdirectories are . or installed under fink or cygwin) or compiled it from source.app/Contents/Resources/share/lilypond/current/’ by either cd-ing into this directory from the Terminal. and (b) on which operating system it is being used: Downloaded from lilypond. whose voice the wa ters heard. To explore these.Z is the LilyPond version number. strong to E ter save.6. and X. O Christ.Y. who didst brood O Tri ni ty of love and pow'r 4. navigate to ‘INSTALLDIR /LilyPond/usr/share/lilypond/current/’ Installed from a package manager or compiled from source Navigate to ‘PREFIX /share/lilypond/X. but even more information can be gathered by looking at the internal LilyPond files.org • Linux Navigate to ‘INSTALLDIR /lilypond/usr/share/lilypond/current/’ • MacOS X Navigate to ‘INSTALLDIR /LilyPond. you must first find the directory appropriate to your system. where PREFIX is set by your package manager or configure script. distributed with Linux.org or whether you installed it from a package manager (i. or control-clicking on the LilyPond application and selecting ‘Show Package Contents’. O Ho ly Spi rit.Y.

For example.ly’ Specifications of paper-related defaults ‘ly/performer-init.scm’ ‘scm/output-lib. The Scheme programming language is used to provide a programmable interface into LilyPond internal operation.scm’ ‘scm/script.4 Avoiding tweaks with slower processing LilyPond can perform extra checks while it processes input files.1 } If you do not like the default values these predefined commands can be redefined easily. To be effective under all circumstances these checks must be enabled by placing the overrides in a Score \with block. The following are the most useful files to be found in ‘ly/’: Filename Contents ‘ly/engraver-init.ly’ Definitions of all common predefined commands ‘ly/spanner-init.scm (Scheme) files.contains files in LilyPond format • ‘scm/’ .ly files will be fine.scm’ ‘scm/define-grobs. This file contains the definitions of all the standard LilyPond predefined commands. as a knowledge of the Scheme language is required. bar lines. accidentals. You will see that these are nothing more than definitions of variables containing one or a group of \override commands.scm’ ‘scm/midi. page 173). as follows: \new Score \with { % Makes sure text scripts and lyrics are within the paper margins \override PaperColumn #'keep-inside-line = ##t . but fewer manual tweaks may be required to obtain an acceptable result. Users should be warned that a substantial amount of technical knowledge or time is required to understand Scheme and these files (see Appendix B [Scheme tutorial]. These checks will take extra time to perform. If a text script or part of the lyrics extends over the margins these checks will compress that line of the score just enough to fit within the margins. Open ‘ly/property-init. /tieDotted is defined to be: tieDotted = { \override Tie #'dash-period = #0.ly’ Definitions of performer Contexts ‘ly/property-init. rather than in-line in music.scm’ Contents Sub-beaming defaults Default settings for grob properties Specify all markup commands Default settings for MIDI output Settings that affect appearance of frets. colors.Chapter 4: Tweaking output 128 • ‘ly/’ . The one you normally use for . such as \stemUp and \slurDotted.ly’ Definitions of engraver Contexts ‘ly/paper-defaults-init.scm’ ‘scm/parser-clef. just like any other variable.scm’ ‘scm/define-markup-commands.ly’ Definitions of spanner-related predefined commands Other settings (such as the definitions of markup commands) are stored as . at the head of your input file. the Scheme files which may be of interest are: Filename ‘scm/auto-beam. Further explanation of these files is currently outside the scope of this manual.6.contains files in Scheme format Let’s begin by looking at some files in ‘ly/’.75 \override Tie #'dash-fraction = #0.ly’ in a text editor. etc Definitions of supported clefs Default settings for articulations 4. If you have this knowledge.

instead of setting a property to a constant it can be set to a Scheme procedure which is then called whenever that property is accessed by LilyPond.ver the Rain -. The property can then be set dynamically to a value determined by the procedure at the time it is called.where o -.bow. } 4. } Some where o ver the Rain bow. for C ((2) (x11-color 'orange )) . page 173. for E ((4) (x11-color 'green )) . #(define (color-notehead grob) "Color the notehead according to its position on the staff. As an illustration of one of the many possibilities. Return rainbow colors ((1) (x11-color 'red )) . Of course. for A ((0) (x11-color 'violet )) . and an introduction is provided in the Appendix B [Scheme tutorial].5 Advanced tweaks with Scheme Although many things are possible with the \override and \tweak commands. way up high. Code written in the Scheme programming language can be incorporated directly in the internal operation of LilyPond..Chapter 4: Tweaking output 129 \override NonMusicalPaperColumn #'keep-inside-line = ##t } { . way up high. for B ) ) ) \relative c' { % Arrange to obtain color from color-notehead procedure \override NoteHead #'color = #color-notehead c2 c' | b4 g8 a b4 c | c. at least a basic knowledge of programming in Scheme is required to do this. In this example we color the note head in accordance with its position on the staff.2 a' | g1 | } \addlyrics { Some -. for F ((5) (x11-color 'blue )) . .6.. for G ((6) (x11-color 'purple )) . for D ((3) (x11-color 'yellow )) ." (let ((mod-position (modulo (ly:grob-property grob 'staff-position) 7))) (case mod-position . an even more powerful way of modifying the action of LilyPond is available through a programmable interface to the LilyPond internal operation.

1 [Tweaking with Scheme].Chapter 4: Tweaking output 130 Further examples showing the use of these programmable interfaces can be found in Section B. page 174. .

We highly recommend that you always include the \version. • What if you want to share your input files with somebody else? In fact.Chapter 5: Working on LilyPond projects 131 5 Working on LilyPond projects This section explains how to solve or avoid certain common problems. . or if you pass the source over to a friend. • Comment your input files. • Explicitly add durations at the beginnings of sections and variables. perhaps just once or twice. it doesn’t matter what your input files look like. no matter how small your file is. but it is still advisable to read this chapter. If you have programming experience. but whole pieces.’ ‘fourth variation. See Section 5. but if you want to go back to change something two or three years later. 5. If you include checks every so often. For very complex music.1. How often is ‘every so often’? It depends on the complexity of the music. 5. • What if you want to upgrade your LilyPond file for use with a later version of LilyPond? The input syntax changes occasionally as LilyPond improves. • One bar per line of text. Saving screen space by cramming eight bars per line just isn’t worth it if you have to ‘debug’ your input files. then if you make a mistake. • Indent your braces.).1 Suggestions for writing LilyPond input files Now you’re ready to begin writing larger LilyPond input files – not just the little examples in the tutorial.1. many of these tips may seem obvious. Use either bar numbers (every so often) or references to musical themes (‘second theme in violins. and Section 5. there are a few other things to consider when writing LilyPond input files. Most changes can be done automatically with convert-ly. You may not need comments when you’re writing the piece for the first time. you can pinpoint it quicker. it will be much more challenging to determine your intentions or how your file is structured if you didn’t comment the file. • What if you make a mistake? The structure of a LilyPond file can make certain errors easier (or harder) to find.1 General suggestions Here are a few suggestions that can help you to avoid or fix problems: • Include \version numbers in every file. what if you want to alter your own input files in a few years? Some LilyPond input files are understandable at first glance.4 [Saving typing with variables and functions]. but some changes might require manual assistance.5 [Style sheets]. However. either in the music itself or in the output you desire. it’s often good to write only one bar per line. If there is anything complicated.’ etc. But how should you go about doing it? As long as LilyPond can understand your input files and produce the output that you want. • Separate tweaks from music definitions.1. page 133. Note that all templates contain \version information. page 134. Section “Octave checks” in Notation Reference. perhaps every bar. others may leave you scratching your head for an hour. If you specify c4 d e at the beginning of a phrase (instead of just c d e) you can save yourself some problems if you rearrange your music later. convert-ly requires you to declare which version of LilyPond you used. LilyPond input files can be structured in order to be easier (or harder) to update. it’s quite frustrating to try to remember which version of LilyPond you were using a few years ago. For very simple music. A lot of problems are caused by an imbalance in the number of { and }. • Include checks: Section “Bar and bar number checks” in Notation Reference. Speaking from personal experience.

You can transpose it back again when the variable is used.3 Large projects When working on a large project. \score { \new GrandStaff { \new Staff { \violin } } } • Separate tweaks from music definitions. but for large projects it is absolutely vital. This point was made in previously. violin = \relative c'' { g4 c'8. You may use the showLastLength or showFirstLength properties to speed up processing – see Section “Skipping corrected music” in Notation Reference. you may define mBreak = { } to remove all those line breaks. converting a trombone part from treble to bass clef. fthenp = _\markup{ \dynamic f \italic \small { 2nd } \hspace #0. Also. with a minimum of structure inside the definition. but then we only need to do this once. • Use an variable for each voice. when printing a score in concert pitch. 5. This makes it much easier to compare the LilyPond music to the original music.. That means that the only other keys you will use are the natural pitches of the instruments ...Chapter 5: Working on LilyPond projects 132 5. aes for an A-flat clarinet. typesetting a piece of existing sheet music). and check each system when you finish it. but you might not want to (e. This will allow LilyPond to place line breaks wherever it feels are best. The structure of the \score section is the most likely thing to change. etc.e.bes for a B-flat trumpet. e16 } . e16 } . only ever transpose to/from C. We might need to change the definition of fthenp. When you are finished proofreading your score.. and we can still avoid touching anything inside violin. it is recommended that the notes are wrapped in \transpose c natural-pitch {.. if required.1 \dynamic p } violin = \relative c'' { g4\fthenp c'8. • Define mBreak = { \break } and insert \mBreak in the input file whenever the manuscript has a line break. the violin definition is extremely unlikely to change in a new version of LilyPond.g.} (where natural-pitch is the open pitch of the instrument) so that the music in the variable is effectively in C. etc. • Enter one manuscript (the physical copy) system at a time (but still only one bar per line of text). • When entering a part for a transposing instrument into a variable.) Mistakes in transpositions are less likely if all the music in variables is at a consistent pitch.1..1.2 Typesetting existing music If you are entering music from an existing score (i. having a clear structure to your lilypond input files becomes vital.

gis16 ees4 } violin = \new Staff { \fragmentA \fragmentA \fragmentB \fragmentA } \score { { \violin } } However.1 \dynamic p } violin = \relative c'' { \repeat volta 2 { c4. macros. you’ve seen this kind of thing: hornNotes = \relative c'' { c4 b dis c } \score { { \hornNotes } } You may even realize that this could be useful in minimalist music: fragmentA = \relative c'' { a4 a8. b16 } fragmentB = \relative c'' { a8.1.^"hi there!" d8 e' f g d | c._\dolce b8 a8 g a b | \padText c4.0 } fthenp=_\markup{ \dynamic f \italic \small { 2nd } \hspace #0.4. you can also use these variables (also known as variables.\fthenp b8 c4 c-. | } } \score { { \violin } \layout{ragged-right=##t} } .Chapter 5: Working on LilyPond projects 133 5.4 Saving typing with variables and functions By this point. or (user-defined) command) for tweaks: dolce = \markup{ \italic \bold dolce } padText = { \once \override TextScript #'padding = #5.

.\markup{ \dynamic f \italic \small { 2nd } \hspace #0. especially the last line.6 c4^"piu mosso" fis a g } piu mosso piu mosso piu mosso Using variables is also a good way to reduce work if the LilyPond input syntax changes (see Section 5. padText = #(define-music-function (parser location padding) (number?) #{ \once \override TextScript #'padding = #$padding #}) \relative c''' { c4^"piu mosso" b a b \padText #1.2._\markup{ \italic \bold dolce } b8 a8 g a b | \once \override TextScript #'padding = #5.Chapter 5: Working on LilyPond projects 134 hi there! dolce f 2nd p These variables are obviously useful for saving typing. violin = \relative c'' { \repeat volta 2 { c4. But what if you have many input files that you want to apply your tweaks to? Or what if you simply want to separate your tweaks from the actual music? This is quite easy to do. | } } So far we’ve seen static substitution – when LilyPond sees \padText. then if the syntax changes. It’s a lot harder to read. page 134). If you have a single definition (such as \dolce) for all your input files (see Section 5. too (you can think of these as functions).5 Style sheets The output that LilyPond produces can be heavily modified. page 80. for details. it replaces it with the stuff that we’ve defined it to be (ie the stuff to the right of padtext=). page 138).4.1. 5.1 [Updating old input files]. see Chapter 4 [Tweaking output].^"hi there!" d8 e' f g d | c. But they’re worth considering even if you only use them once – they reduce complexity.8 c4^"piu mosso" d e f \padText #2. you only need to update your single \dolce definition.5 [Style sheets]. LilyPond can handle non-static substitution. instead of making changes throughout every .1.1 \dynamic p } b8 c4 c-.0 c4. Let’s look at the previous example without any variables.ly file.

We could simply copy-and-paste them at the top of every file. RehearsalMark #'self-alignment-X = #left \once \override Score . mpdolce = #(make-dynamic-script (markup #:hspace 1 #:translate (cons 5 0) #:line(#:dynamic "mp" #:text #:italic "dolce" ))) tempoMark = #(define-music-function (parser location markp) (string?) #{ \once \override Score .5.6.ly" mpdolce = #(make-dynamic-script (markup #:hspace 1 #:translate (cons 5 0) #:line(#:dynamic "mp" #:text #:italic "dolce" ))) tempoMark = #(define-music-function (parser location markp) (string?) #{ \once \override Score .\mpdolce d8 cis4--\glissando a | b4 bes a2 \tempoMark "Poco piu mosso" cis4.5 [Advanced tweaks with Scheme]. page 109.Chapter 5: Working on LilyPond projects 135 Let’s look at an example. e( d)-. But let’s also do something about the mpdolce and tempoMark definitions. RehearsalMark #'self-alignment-X = #left \once \override Score . but that’s an annoyance. They produce the output we desire. e( d)-. we’ll fix those using the techniques in Section 4. cis2 } . It also leaves those definitions in our input files. cis2 } = 50 Poco piu mosso mp dolce There are some problems with overlapping output.0 \tempoMark "Poco piu mosso" cis4. -inf. RehearsalMark #'extra-spacing-width = #'(+inf.ly" \relative c'' { \tempo 4=50 a4.0) \mark \markup { \bold $markp } #}) \relative c'' { \tempo 4=50 a4. \include "definitions.ly"’).\< d8 e4 fis | g8(\! fis)-. page 129.0 . RehearsalMark #'extra-spacing-width = #'(+inf. This is explained in Section 4. Let’s hide them in another file: %%% save this to a file called "definitions.RehearsalMark #'padding = #2. Don’t worry if you don’t understand the parts with all the #().1 [Moving objects].\mpdolce d8 cis4--\glissando a | b4 bes a2 \once \override Score.0) \mark \markup { \bold $markp } #}) Now let’s modify our music (let’s save this file as ‘"music. but we might want to use them in another piece.0 .\< d8 e4 fis | g8(\! fis)-. and I personally find all the #() somewhat ugly. -inf.

Let’s put the metronome marking above the clef. And finally. -inf. we’ll also increase the overall size of the output. but let’s make a few changes. my composition professor hates ‘C’ time signatures. 0) \override MetronomeMark #'padding = #'3 } \context { \Staff \override TimeSignature #'style = #'numbered } \context { \Voice \override Glissando #'thickness = #3 \override Glissando #'gap = #0.0) \mark \markup { \bold $markp } #}) \layout{ \context { \Score \override MetronomeMark #'extra-offset = #'(-9 .1 } } = 50 Poco piu mosso 4 4 mp dolce That looks nicer! But now suppose that I want to publish this piece.ly mpdolce = #(make-dynamic-script (markup #:hspace 1 #:translate (cons 5 0) #:line( #:dynamic "mp" #:text #:italic "dolce" ))) tempoMark = #(define-music-function (parser location markp) (string?) #{ \once \override Score . Since this music is aimed at producing a pdf which will be displayed on the screen. %%% definitions. so we’d better make that ‘4/4’ instead.ly mpdolce = #(make-dynamic-script (markup #:hspace 1 #:translate (cons 5 0) #:line( #:dynamic "mp" #:text #:italic "dolce" ))) tempoMark = #(define-music-function (parser location markp) (string?) #{ \once \override Score . RehearsalMark #'self-alignment-X = #left \once \override Score . The glissando is hard to see. Replace our ‘definitions.Chapter 5: Working on LilyPond projects 136 = 50 Poco piu mosso mp dolce That looks better.ly’. My composition professor doesn’t like ‘C’ time signatures. RehearsalMark #'extra-spacing-width = #'(+inf. though. RehearsalMark #'self-alignment-X = #left \once \override Score .0 .ly’ and modify that. Don’t change ‘music.0 .ly’ with this: %%% definitions. Let’s copy the current ‘definitions. instead of over the first note. -inf.ly’ to ‘web-publish. so let’s make it thicker and closer to the note heads.0) . RehearsalMark #'extra-spacing-width = #'(+inf. but I’m somewhat fond of them.

/init/init-headers.ly" \include "./global. 0) \override MetronomeMark #'padding = #'3 } \context { \Staff } \context { \Voice \override Glissando #'thickness = #3 \override Glissando #'gap = #0./init/init-paper.ly \version "2.. a ‘web-publish.ly".ly’ file which contains only the \layout section listed above. which contains %%% global. we could make this even more convenient.. I simply replace \include "definitions.. Of course.ly" This approach can be useful even if you are only producing one set of parts.ly" \include ". and a ‘university.ly" %%% Only uncomment one of these two lines! \include "web-publish. I use half a dozen different ‘style sheet’ files for my projects.ly" with \include "web-publish.ly" %\include "university.ly’ would then look like this: \include "definitions.1 } } = 50 Poco piu mosso mp dolce 4 Now in our music./init/init-defs.ly" .3" #(ly:set-option 'point-and-click #f) \include ".ly’ file which contains only the definitions of mpdolce and tempoMark.ly" \include ".ly’ file which contains only the tweaks to produce the output that my professor prefers./init/init-layout..ly". We could make a ‘definitions. The top of ‘music.12.Chapter 5: Working on LilyPond projects 137 \mark \markup { \bold $markp } #}) #(set-global-staff-size 23) \layout{ \context { \Score \override MetronomeMark #'extra-offset = #'(-9 .. I begin every music file with \include ".

The syntax changes that convert-ly cannot handle are listed in Section “Updating files with convert-ly” in Application Usage. then keep on commenting out material until you have something that works.3 [Minimal examples]..2 When things don’t work 5. For details about how to run this program.2. Uncomment a bit – say. e convert-ly cannot change all the LaTeX special characters into UTF-8 characters. the syntax (input language) is modified accordingly.2 Troubleshooting (taking it all apart) Sooner or later. . LilyPond comes with a file that makes this updating easier: convert-ly. In LilyPond 2. The most powerful tools for this purpose are the single line comment (indicated by %) and the block comment (indicated by %{ . the bass part – and see if it works.. bass = \relative c' { %{ c4 c c c d d d d %} } Now start slowly uncommenting more and more of the bass part until you find the problem line. accents and non-English letters were entered using LaTeX – for example. The messages that LilyPond gives may help you find the error. It takes care of simple searchand-replace changes (such as raggedright becoming ragged-right). page 139.Chapter 5: Working on LilyPond projects 138 5. then comment out all of the bass music (but leave \bass in the \score uncommented. Another very useful debugging technique is constructing Section 5. %}). you will write a file that LilyPond cannot compile. In an extreme case. don’t give up. but some changes are too complicated. the special ¨ must be entered directly into the LilyPond file as an UTF-8 character. Unfortunately. No\"el (this would print the French word for ‘Christmas’). but in many cases you need to do some investigation to determine the source of the problem. convert-ly cannot handle all input changes.2.4 and earlier.6 and above. you must manually update your old LilyPond input files. in LilyPond 2.1 Updating old input files The LilyPond input syntax occasionally changes. As LilyPond itself improves. start commenting out huge portions of your input file.2. try compiling the file again. a file without any music) If that happens. After you comment out a section. For example. Sometimes these changes are made to make the input easier to read and write or sometimes the changes are made to accommodate new features of LilyPond. see Section “Updating files with convert-ly” in Application Usage. If it works. 5. you might end up with only \score { << % \melody % \harmony % \bass >> \layout{} } (in other words. then the problem must exist in the portion you just commented. If it doesn’t work. If it doesn’t work. If you don’t know where a problem is.

ly" \header { instrument = "Horn in F" } { \transpose f c' \hornNotes } The line \include "horn-music. When trying to remove unnecessary parts of a file. unless you wish to demonstrate something is about the behavior of those items. so hornNotes is defined afterwards. The whole point of a minimal example is to make it easy to read: • Avoid using complicated notes. • If possible. and once in a full score for the conductor. These examples are much easier to understand than long examples.Chapter 5: Working on LilyPond projects 139 5.3 Minimal examples A minimal example is an example which is as small as possible. the rule is quite simple: remove anything which is not necessary. • Do not use \override commands unless that is the point of the example. The contents of that variable is then used to generate both the part and the full score. Minimal examples are used for • Bug reports • Sending a help request to mailing lists • Adding an example to the LilyPond Snippet Repository To construct an example which is as small as possible. -td In orchestral music. For example. The music is entered once.. 5. should be transposed by a fifth upwards. you can uncomment them. keys. Variables can be used to avoid double work.3 Scores and parts TODO: this is really old stuff from the really old tutorial. suppose that the file ‘horn-music. -gp Include section on tags -td and then move to section 5. it is a very good idea to comment out lines instead of deleting them. Once in a part for the musicians. fix.ly’ contains the following part of a horn/bassoon duo hornNotes = \relative c { \time 2/4 r4 f8 a cis4 f e d } Then. Working . The command \transpose f c' indicates that the argument. Or maybe delete entirely. Rewrite. Sounding f is denoted by notated c'.ly’ at this position in the file. which corresponds with the tuning of a normal French Horn in F. use \paper{ ragged-right=##t } at the top of your example. an individual part is made by putting the following in a file \include "horn-music. or time signatures. and stored in a variable. if you discover that you actually do need some lines. That way. It is convenient to define the notes in a special file. The transposition can be seen in the following output . There are two exceptions to the “as small as possible” rule: • Include the \version number. etc.2.ly" substitutes the contents of ‘horn-music. being \hornNotes.. instead of typing them in from scratch. all notes are printed twice.

a score is made with \include "bassoon-music. For example. Assuming that the other voice is in bassoonNotes in the file ‘bassoon-music. By multiplying the duration. This is done by setting a run-time variable \set Score.ly’. It is entered with a capital R followed by a duration (1 for a whole note. longer rests can be constructed. one of the voices often does not play for many measures. etc. the multi-measure rest. This is denoted by a special rest.skipBars = ##t This command sets the property skipBars in the Score context to true (##t).ly" \include "horn-music.Chapter 5: Working on LilyPond projects 140 2 4 In ensemble pieces. 2 for a half note. multi-rests must be condensed. Prepending the rest and this option to the music above. leads to the following result 2 4 3 The score is made by combining all of the music together. this rest takes 3 measures in 2/4 time R2*3 When printing the part.ly" << \new Staff \hornNotes \new Staff \bassoonNotes >> leading to 2 4 2 4 .).

3" melody = \relative c' { \clef treble \key c \major \time 4/4 a4 b c d } \score { \new Staff \melody \layout { } \midi { } } A. change or comment out the relevant line.1 Single staff A. and enjoy beautiful printed scores! A. Just add notes.1. This example turns off automatic beaming.12. To use automatic beaming. then words for the lyrics. \version "2.3" melody = \relative c' { \clef treble \key c \major \time 4/4 a4 b c d } text = \lyricmode { Aaa Bee Cee Dee } \score{ << \new Voice = "one" { . Cut and paste. add notes.12. run LilyPond. Cut and paste this into a file. and you’re finished! \version "2.Appendix A: Templates 141 Appendix A Templates This section of the manual contains templates with the LilyPond score already set up for you. add notes. which is common for vocal parts.1 Notes only This very simple template gives you a staff with notes.2 Notes and lyrics This small template demonstrates a simple melody with lyrics. suitable for a solo instrument or a melodic fragment.1.

3 Notes and chords Want to prepare a lead sheet with a melody and chords? Look no further! melody = \relative c' { \clef treble \key c \major \time 4/4 f4 e8[ c] d4 g a2 ~ a } harmonies = \chordmode { c4:m f:min7 g:maj c:aug d2:dim b:sus } \score { << \new ChordNames { \set chordChanges = ##t \harmonies } \new Staff \melody >> \layout{ } \midi { } } Cm Fm G C+ D 7 o B .1.Appendix A: Templates 142 \autoBeamOff \melody } \new Lyrics \lyricsto "one" \text >> \layout { } \midi { } } Aaa Bee Cee Dee A.

melody = \relative c' { \clef treble \key c \major \time 4/4 a4 b c d } text = \lyricmode { Aaa Bee Cee Dee } harmonies = \chordmode { a2 c } \score { << \new ChordNames { \set chordChanges = ##t \harmonies } \new Voice = "one" { \autoBeamOff \melody } \new Lyrics \lyricsto "one" \text >> \layout { } \midi { } } A C Aaa Bee Cee Dee A. upper = \relative c'' { \clef treble \key c \major \time 4/4 a4 b c d } .4 Notes. lyrics. and chords.2. This template allows the preparation of a song with melody.2 Piano templates A.1. and chords. words.Appendix A: Templates 143 A.1 Solo piano Here is a simple piano staff with some notes.

with piano accompaniment underneath.2 Piano and melody with lyrics Here is a typical song format: one staff with the melody and lyrics.2.Appendix A: Templates 144 lower = \relative c { \clef bass \key c \major \time 4/4 a2 c } \score { \new PianoStaff << \set PianoStaff.instrumentName = #"Piano \new Staff = "upper" \upper \new Staff = "lower" \lower >> \layout { } \midi { } } " Piano A. melody = \relative c'' { \clef treble \key c \major \time 4/4 a b c d } text = \lyricmode { Aaa Bee Cee Dee } upper = \relative c'' { \clef treble \key c \major \time 4/4 a4 b c d } lower = \relative c { \clef bass .

lyrics can be centered between the staves of a piano staff.Appendix A: Templates 145 \key c \major \time 4/4 a2 c } \score { << \new Voice = "mel" { \autoBeamOff \melody } \new Lyrics \lyricsto mel \text \new PianoStaff << \new Staff = "upper" \upper \new Staff = "lower" \lower >> >> \layout { \context { \RemoveEmptyStaffContext } } \midi { } } Aaa Bee Cee Dee A. upper = \relative c'' { \clef treble \key c \major \time 4/4 a4 b c d } lower = \relative c { \clef bass \key c \major \time 4/4 a2 c .2.3 Piano centered lyrics Instead of having a full staff for the melody and lyrics.

Appendix A: Templates 146 } text = \lyricmode { Aaa Bee Cee Dee } \score { \new GrandStaff << \new Staff = upper { \new Voice = "singer" \upper } \new Lyrics \lyricsto "singer" \text \new Staff = lower { \lower } >> \layout { \context { \GrandStaff \accepts "Lyrics" } \context { \Lyrics \consists "Bar_engraver" } } \midi { } } Aaa Bee Cee Dee A. This requires a bit of tweaking to implement. you don’t have to do the tweaking yourself.4 Piano centered dynamics Many piano scores have the dynamics centered between the two staves. global = { \key c \major \time 4/4 } upper = \relative c'' { \clef treble a4 b c d } lower = \relative c { \clef bass a2 c .2. but since the template is right here.

" "*") pedalUnaCordaStrings = #'("una corda" "" "tre corde") \override DynamicLineSpanner #'Y-offset = #0 \override TextScript #'font-size = #2 \override TextScript #'font-shape = #'italic \override VerticalAxisGroup #'minimum-Y-extent = #'(-1 .Appendix A: Templates 147 } dynamics = { s2\fff\> s4 s\!\pp } pedal = { s2\sustainOn s\sustainOff } \score { \new PianoStaff = "PianoStaff_pf" << \new Staff = "Staff_pfUpper" << \global \upper >> \new Dynamics = "Dynamics_pf" \dynamics \new Staff = "Staff_pfLower" << \global \lower >> \new Dynamics = "pedal" \pedal >> \layout { % define Dynamics context \context { \type "Engraver_group" \name Dynamics \alias Voice \consists "Output_property_engraver" \consists "Piano_pedal_engraver" \consists "Script_engraver" \consists "New_dynamic_engraver" \consists "Dynamic_align_engraver" \consists "Text_engraver" \consists "Skip_event_swallow_translator" \consists "Axis_group_engraver" pedalSustainStrings = #'("Ped. 1) } % modify PianoStaff context to accept Dynamics context \context { \PianoStaff \accepts Dynamics } } } \score { \new PianoStaff = "PianoStaff_pf" << \new Staff = "Staff_pfUpper" << \global \upper \dynamics \pedal >> \new Staff = "Staff_pfLower" << \global \lower \dynamics \pedal >> ." "*Ped.

" } viola = \new Voice \relative c' { \set Staff.instrumentName = #"Viola " \clef alto e2 d c1 \bar "|. It also uses a \global section for time and key signatures global= { \time 4/4 \key c \major } violinOne = \new Voice \relative c'' { \set Staff.instrumentName = #"Violin 2 " g2 f e1 \bar "|.instrumentName = #"Violin 1 " c2 d e1 \bar "|." } violinTwo = \new Voice \relative c'' { \set Staff.1 String quartet This template demonstrates a simple string quartet.3.Appendix A: Templates 148 >> \midi { } } fff pp A." } .3 String quartet A.

vn1.ly. the filenames are contained in comments at the beginning of each file.ly.ly.Appendix A: Templates 149 cello = \new Voice \relative c' { \set Staff. vn2.instrumentName = #"Cello " \clef bass c2 b a1 \bar "|.ly – produce the appropriate part. but what if you needed to print parts? This new template demonstrates how to use the \tag feature to easily split a piece into individual parts. The other files – score. You need to split this template into separate files." } \score { \new StaffGroup \new Staff << \new Staff << \new Staff << \new Staff << >> \layout { } \midi { } } << \global \global \global \global \violinOne >> \violinTwo >> \viola >> \cello >> Violin 1 Violin 2 Viola Cello A.ly. piece. vla.ly %%%%% (This is the global definitions file) global= { \time 4/4 \key c \major . Do not forget to remove specified comments when using separate files! %%%%% piece.ly contains all the music definitions. and vlc.2 String quartet parts The "String quartet template" snippet produces a nice string quartet.3.

instrumentName = #"Viola " \clef alto e2 d c1 \bar "|.instrumentName = #"Cello " \clef bass c2 b a1 \bar "|.Appendix A: Templates 150 } Violinone = \new Voice { \relative c''{ \set Staff.ly" %%% uncomment this line when using a separate file #(set-global-staff-size 14) \score { \new StaffGroup \keepWithTag #'score \music \layout { } \midi { } } ." }} %********************************* Cello = \new Voice { \relative c' { \set Staff."}} %********************************** music = { << \tag #'score \tag #'score \tag #'score \tag #'score >> } \tag \tag \tag \tag #'vn1 #'vn2 #'vla #'vlc \new \new \new \new Staff Staff Staff Staff { { { { << << << << \global \global \global \global \Violinone >> } \Violintwo>> } \Viola>> } \Cello>> } %%% These are the other files you need to save on your computer %%%%% score.ly %%%%% (This is the main file) %\include "piece." }} %********************************* Violintwo = \new Voice { \relative c''{ \set Staff.instrumentName = #"Violin 2 " g2 f e1 \bar "|.instrumentName = #"Violin 1 " c2 d e1 \bar "|." }} %********************************* Viola = \new Voice { \relative c' { \set Staff.

ly %%%%% (This is the Cello part file) \include "piece.ly" \score { \keepWithTag #'vla \music \layout { } } %%%%% vlc.ly" \score { \keepWithTag #'vn1 \music \layout { } } %%%%% vn2.ly %%%%% (This is the Violin 2 part file) \include "piece.ly" \score { \keepWithTag #'vn2 \music \layout { } } %%%%% vla.Appendix A: Templates 151 %{ Uncomment this block when using separate files %%%%% vn1.ly" \score { \keepWithTag #'vlc \music \layout { } } %} .ly %%%%% (This is the Viola part file) \include "piece.ly %%%%% (This is the Violin 1 part file) \include "piece.

With larger ensembles. the four voices are regrouped on only two staves.4. the time signature and key signature are almost always the same for all parts.4 Vocal ensembles A. For example.Appendix A: Templates Violin 1 152 Violin 2 Viola Cello A. it is often useful to include a section which is included in all parts.1 SATB vocal score Here is a standard four-part SATB vocal score. Like in the "Hymn" template. global = { \key c \major \time 4/4 } sopMusic = \relative c'' { c4 c c8[( b)] c4 } sopWords = \lyricmode { hi hi hi hi } altoMusic = \relative c' { e4 f d e } altoWords = \lyricmode { ha ha ha ha } tenorMusic = \relative c' { g4 a f g } tenorWords = \lyricmode { hu hu hu hu } bassMusic = \relative c { c4 c g c } bassWords = \lyricmode { ho ho ho ho } \score { \new ChoirStaff << \new Lyrics = sopranos { s1 } .

3) } } } hi hi hi hi ha ha ha ha hu hu hu hu ho ho ho ho .Appendix A: Templates 153 \new Staff = women << \new Voice = "sopranos" { \voiceOne << \global \sopMusic >> } \new Voice = "altos" { \voiceTwo << \global \altoMusic >> } >> \new Lyrics = "altos" { s1 } \new Lyrics = "tenors" { s1 } \new Staff = men << \clef bass \new Voice = "tenors" { \voiceOne << \global \tenorMusic >> } \new Voice = "basses" { \voiceTwo << \global \bassMusic >> } >> \new Lyrics = basses { s1 } \context Lyrics = sopranos \lyricsto sopranos \sopWords \context Lyrics = altos \lyricsto altos \altoWords \context Lyrics = tenors \lyricsto tenors \tenorWords \context Lyrics = basses \lyricsto basses \bassWords >> \layout { \context { % a little smaller so lyrics % can be closer to the staff \Staff \override VerticalAxisGroup #'minimum-Y-extent = #'(-3 .

global = { \key c \major \time 4/4 } sopMusic = \relative c'' { c4 c c8[( b)] c4 } sopWords = \lyricmode { hi hi hi hi } altoMusic = \relative c' { e4 f d e } altoWords =\lyricmode { ha ha ha ha } tenorMusic = \relative c' { g4 a f g } tenorWords = \lyricmode { hu hu hu hu } bassMusic = \relative c { c4 c g c } bassWords = \lyricmode { ho ho ho ho } \score { << \new ChoirStaff << \new Lyrics = sopranos { s1 } \new Staff = women << \new Voice = sopranos { \voiceOne << \global \sopMusic >> } \new Voice = altos { \voiceTwo << \global \altoMusic >> } >> \new Lyrics = altos { s1 } \new Lyrics = tenors { s1 } \new Staff = men << \clef bass \new Voice = tenors { \voiceOne <<\global \tenorMusic >> } . then the changes will also apply to the piano reduction.4.Appendix A: Templates 154 A. tenorMusic). This demonstrates one of the strengths of LilyPond – you can use a music definition more than once.2 SATB vocal score and automatic piano reduction This template adds an automatic piano reduction to the standard SATB vocal score demonstrated in "Vocal ensemble template". If any changes are made to the vocal notes (say.

printPartCombineTexts = ##f \partcombine << \global \tenorMusic >> << \global \bassMusic >> >> >> >> \layout { \context { % a little smaller so lyrics % can be closer to the staff \Staff \override VerticalAxisGroup #'minimum-Y-extent = #'(-3 .Appendix A: Templates 155 \new Voice = basses { \voiceTwo <<\global \bassMusic >> } >> \new Lyrics = basses { s1 } \context Lyrics = sopranos \lyricsto sopranos \sopWords \context Lyrics = altos \lyricsto altos \altoWords \context Lyrics = tenors \lyricsto tenors \tenorWords \context Lyrics = basses \lyricsto basses \bassWords >> \new PianoStaff << \new Staff << \set Staff.printPartCombineTexts = ##f \partcombine << \global \sopMusic >> << \global \altoMusic >> >> \new Staff << \clef bass \set Staff. 3) } } } .

with the exception that here all the lyrics lines are placed using alignAboveContext and alignBelowContext.4.Appendix A: Templates 156 hi hi hi hi ha ha ha ha hu hu hu hu ho ho ho ho A.3 SATB with aligned contexts This template is basically the same as the simple "Vocal ensemble" template. global = { \key c \major \time 4/4 } sopMusic = \relative c'' { c4 c c8[( b)] c4 } sopWords = \lyricmode { hi hi hi hi } altoMusic = \relative c' { e4 f d e } altoWords = \lyricmode { ha ha ha ha } tenorMusic = \relative c' { g4 a f g } tenorWords = \lyricmode { hu hu hu hu } bassMusic = \relative c { c4 c g c } bassWords = \lyricmode { ho ho ho ho .

% \new Lyrics \lyricsto altos \altoWords \new Staff = men << \clef bass \new Voice = "tenors" { \voiceOne << \global \tenorMusic >> } \new Voice = "basses" { \voiceTwo << \global \bassMusic >> } >> \new Lyrics \with { alignAboveContext = men } \lyricsto tenors \tenorWords \new Lyrics \with { alignBelowContext = men } \lyricsto basses \bassWords % again. 3) } } } hi hi hi hi ha ha ha ha hu hu hu hu ho ho ho ho A.5 Ancient notation templates . % \new Lyrics \lyricsto basses \bassWords >> \layout { \context { % a little smaller so lyrics % can be closer to the staff \Staff \override VerticalAxisGroup #'minimum-Y-extent = #'(-3 . we could replace the line above this with the line below.Appendix A: Templates 157 } \score { \new ChoirStaff << \new Staff = women << \new Voice = "sopranos" { \voiceOne << \global \sopMusic >> } \new Voice = "altos" { \voiceTwo << \global \altoMusic >> } >> \new Lyrics \with { alignAboveContext = women } \lyricsto sopranos \sopWords \new Lyrics \with { alignBelowContext = women } \lyricsto altos \altoWords % we could remove the line about this with the line below. since we want % the alto lyrics to be below the alto Voice anyway.

an incipit at the beginning of the piece is useful to indicate the original key and tempo.printKeyCancellation = ##t \set Staff. the meter often changed after every few notes. % Therefore.BarLine #'transparent = ##f \bar "||" \skip 1*1 % need this extra \skip such that clef change comes % after bar line \bar "" % main \revert Score.5.BarLine #'transparent = ##f % finis bar \bar "|.TimeSignature #'style = #'neomensural \override Voice.Appendix A: Templates 158 A.Rest #'style = #'neomensural \set Staff.SystemStartBracket #'transparent = ##t \override Score.forceClef = ##t \key g \major \time 4/4 \override Voice.skipBars = ##t % incipit \once \override Score.NoteHead #'style = #'neomensural \override Voice. While today musicians are used to bar lines in order to faster recognize rhythmic patterns.Rest #'style = #'default % FIXME: setting printKeyCancellation back to #t must not % occur in the first bar after the incipit. bar lines were not yet invented during the period of mensural music. As a compromise.Clef #'full-size-change = ##t \set Staff. Dto.SpacingSpanner #'spacing-increment = #1.forceClef = ##f \skip 1*7 % the actual music % let finis bar go through all staves \override Staff. \skip 1*1 \set Staff. we need an extra \skip.SpacingSpanner #'spacing-increment % CHECK: no effect? \cadenzaOff % turn bar lines on again \once \override Staff.printKeyCancellation = ##f \cadenzaOn % turn off bar lines \skip 1*10 \once \override Staff. in fact." } . for forceClef.NoteHead #'style = #'default \override Voice. global = { \set Score.1 Transcription of mensural music When transcribing mensural music.0 % tight spacing \key f \major \time 2/2 \once \override Staff. bar lines are often printed between the staves rather than on the staves.

Appendix A: Templates 159 discantusNotes = { \transpose c' c'' { \set Staff.te De -.. d'4 | b e' d'2 | c'4 e'4.| ra.| ". om -nis ter -.( d'8 c' b | a4) b a2 | b4.instrumentName = #"Altus % incipit \clef "neomensural-c3" r1 % one bar f1.instrumentName = #"Discantus % incipit \clef "neomensural-c1" c'1.| o.. s2 % two bars \skip 1*8 % eight bars \skip 1*1 % one bar " % main \clef "treble" d'2. e4 fis g | % two bars a2 g4 e | " .( c'8 d'4) c'4 | \once \override NoteHead #'transparent = ##t c'1 | b\breve | } } discantusLyrics = \lyricmode { % incipit IV% main Ju -. __ om. s2 % two bars \skip 1*7 % seven bars \skip 1*1 % one bar % main \clef "treble" r2 g2.bi -. | } altusNotes = { \transpose c' c'' { \set Staff." | -us.| la -.

bi -. | } " .( fis16 e fis4) | g1 | \once \override NoteHead #'transparent = ##t g1 | g\breve | } } altusLyrics = \lyricmode { % incipit IV% main Ju -. | } tenorNotes = { \transpose c' c' { \set Staff." | -us. s2 % two bars \skip 1*1 % one bar \skip 1*1 % one bar % main \clef "treble_8" R1 | R1 | R1 | r2 d'2. d'4 b e' | % two bars \once \override NoteHead #'transparent = ##t e'1 | d'\breve | } } tenorLyrics = \lyricmode { % incipit IV% main Ju -..o.ra.Appendix A: Templates 160 fis g4. om -.la -.te | % two bars "..instrumentName = #"Tenor % incipit \clef "neomensural-c4" r\longa % four bars r\breve % two bars r1 % one bar c'1.la -.." | -us.| nis ter -. | ".bi -..te | % two bars De -.

instrumentName = #"Bassus % incipit \clef "bass" r\maxima % eight bars f1.." | -us.| ". e4 | \once \override NoteHead #'transparent = ##t e1 | g\breve | } } bassusLyrics = \lyricmode { % incipit IV% main Ju -. s2 % two bars \skip 1*1 % one bar " % main \clef "bass" R1 | R1 | R1 | R1 | g2..Appendix A: Templates 161 bassusNotes = { \transpose c' c' { \set Staff. | } \score { \new StaffGroup = choirStaff << \new Voice = "discantusNotes" << \global \discantusNotes >> \new Lyrics = "discantusLyrics" \lyricsto discantusNotes { \discantusLyrics } \new Voice = "altusNotes" << \global \altusNotes >> \new Lyrics = "altusLyrics" \lyricsto altusNotes { \altusLyrics } \new Voice = "tenorNotes" << \global \tenorNotes >> \new Lyrics = "tenorLyrics" \lyricsto tenorNotes { \tenorLyrics } \new Voice = "bassusNotes" << \global \bassusNotes >> \new Lyrics = "bassusLyrics" \lyricsto bassusNotes { \bassusLyrics } >> .bi.

Appendix A: Templates 162 \layout { \context { \Score % no bars in staves \override BarLine #'transparent = ##t % incipit should not start with a start delimiter \remove "System_start_delimiter_engraver" } \context { \Voice % no slurs \override Slur #'transparent = ##t % Comment in the below "\remove" command to allow line % breaking also at those barlines where a note overlaps % into the next bar. %\remove "Forbid_line_break_engraver" } } } Discantus IVAltus Ju bi la te De IVTenor Ju bi la te IVBassus 8 IV- . but especially for large scores. The command is commented out in this % short example score. you % will typically yield better line breaking and thus improve % overall spacing if you comment in the following command.

2 Gregorian transcription template This example demonstrates how to do modern transcription of Gregorian music.Appendix A: Templates 3 163 o. it uses only half and quarter note heads. Ju bi- . -us. indicating rests of different length..ly" chant = \relative c' { \set Score. -us.sum do -. om nis ter ra. om.. 8 Ju bi la te .. \include "gregorian. -us.5. no stems. om nis ter ra. A.timing = ##f f4 a2 \divisioMinima g4 b a2 f2 \divisioMaior g4( f) f( g) a2 \finalis } verba = \lyricmode { Lo -. and special marks....met } \score { \new Staff << \new Voice = "melody" \chant \new Lyrics = "one" \lyricsto melody \verba >> \layout { \context { \Staff \remove "Time_signature_engraver" \remove "Bar_engraver" \override Stem #'transparent = ##t } \context { \Voice \override Stem #'length = #0 } \context { \Score .lor sit a -..rem ip -. Gregorian music has no measure. De o. .. -us..

This refers to the key in concert pitch." "Berlin 07/07/2003" } } } %#(set-global-staff-size 16) \include "english. the key will be automatically transposed if the music is within a \transpose section. for a jazz ensemble.ly" %%%%%%%%%%%% Some macros %%%%%%%%%%%%%%%%%%% sl = { \override NoteHead #'style = #'slash \override Stem #'transparent = ##t } nsl = { \revert NoteHead #'style \revert Stem #'transparent } crOn = \override NoteHead #'style = #'cross crOff = \revert NoteHead #'style %% insert chord name style stuff here. \header { title = "Song" subtitle = "(tune)" composer = "Me" meter = "moderato" piece = "Swing" tagline = \markup { \column { "LilyPond example file by Amelie Zapf.Appendix A: Templates 164 barAlways = ##t } } } Lo rem ip sum do lor sit a met A. Note that all instruments are notated in \key c \major.6 Jazz combo This is quite an advanced template. jazzChords = { } %%%%%%%%%%%% Keys'n'thangs %%%%%%%%%%%%%%%%% .

instrumentName = #"Trumpet" \clef treble << \trpt >> } % -----.Trumpet -----trpt = \transpose c d \relative c'' { \Key c1 | c | c | } trpHarmony = \transpose c' d { \jazzChords } trumpet = { \global \set Staff.Baritone Saxophone -----bari = \transpose c a' \relative c { \Key c1 c1 \sl d4^"Solo" d d d \nsl } bariHarmony = \transpose c' a \chordmode { \jazzChords s1 s d2:maj e:m7 } .instrumentName = #"Alto Sax" \clef treble << \alto >> } % -----.Alto Saxophone -----alto = \transpose c a \relative c' { \Key c1 | c | c | } altoHarmony = \transpose c' a { \jazzChords } altoSax = { \global \set Staff.Appendix A: Templates 165 global = { \time 4/4 } Key = { \key c \major } % ############ Horns ############ % -----.

instrumentName = #"Guitar" \clef treble << \gtr >> } %% -----.instrumentName = #"Trombone" \clef bass << \tbone >> } % ############ Rhythm Section ############# % -----.Piano -----rhUpper = \relative c'' { .Guitar -----gtr = \relative c'' { \Key c1 \sl b4 b b b \nsl c1 } gtrHarmony = \chordmode { \jazzChords s1 c2:min7+ d2:maj9 } guitar = { \global \set Staff.Appendix A: Templates 166 bariSax = { \global \set Staff.Trombone -----tbone = \relative c { \Key c1 | c | c } tboneHarmony = \chordmode { \jazzChords } trombone = { \global \set Staff.instrumentName = #"Bari Sax" \clef treble << \bari >> } % -----.

instrumentName = #"Piano" \new Staff = "upper" \PianoRH \new Staff = "lower" \PianoLH >> } % -----.midiInstrument = #"acoustic grand" << \new Voice = "one" \rhUpper \new Voice = "two" \rhLower >> } PianoLH = { \clef bass \global \set Staff.Appendix A: Templates 167 \voiceOne \Key c1 | c | c } rhLower = \relative c' { \voiceTwo \Key e1 | e | e } lhUpper = \relative c' { \voiceOne \Key g1 | g | g } lhLower = \relative c { \voiceTwo \Key c1 | c | c } PianoRH = { \clef treble \global \set Staff.midiInstrument = "acoustic grand" << \new Voice = "one" \lhUpper \new Voice = "two" \lhLower >> } piano = { << \set PianoStaff.Bass Guitar -----Bass = \relative c { \Key c1 | c | c .

instrumentName = #"Drums" \new DrumVoice \up \new DrumVoice \down >> } %%%%%%%%% It All Goes Together Here %%%%%%%%%%%%%%%%%%%%%% \score { << \new StaffGroup = "horns" << \new Staff = "trumpet" \trumpet \new Staff = "altosax" \altoSax \new ChordNames = "barichords" \bariHarmony \new Staff = "barisax" \bariSax \new Staff = "trombone" \trombone >> \new StaffGroup = "rhythm" << \new ChordNames = "chords" \gtrHarmony \new Staff = "guitar" \guitar \new PianoStaff = "piano" \piano \new Staff = "bass" \bass \new DrumStaff \drumContents >> .Appendix A: Templates 168 } bass = { \global \set Staff.instrumentName = #"Bass" \clef bass << \Bass >> } % -----.Drums -----up = \drummode { \voiceOne hh4 <hh sn> hh <hh sn> hh4 <hh sn> hh <hh sn> hh4 <hh sn> hh <hh sn> } down = \drummode { \voiceTwo bd4 s bd s bd4 s bd s bd4 s bd s } drumContents = { \global << \set DrumStaff.

Appendix A: Templates 169 >> \layout { \context { \RemoveEmptyStaffContext } \context { \Score \override BarNumber #'padding = #3 \override RehearsalMark #'padding = #2 skipBars = ##t } } \midi { } } Song (tune) Me moderato Swing .

If you’re not familiar with this program.1 LaTeX You can include LilyPond fragments in a LaTeX document. A.7 lilypond-book templates These templates are for use with lilypond-book. \documentclass[]{article} \begin{document} Normal LaTeX text. .Appendix A: Templates 170 Trumpet Alto Sax B Solo Bari Sax C m 7 Trombone Cm D Guitar /9 Piano Bass Drums A. \begin{lilypond} \relative c'' { a4 b c d } \end{lilypond} More LaTeX text.7. please refer to Section “LilyPond-book” in Application Usage.

7.fragment.fragment.7.english]{babel} \usepackage{graphicx} \begin{document} \title{A short document with LilyPond and xelatex} \maketitle Normal \textbf{font} commands inside the \emph{text} work. in fact.fontspec.xltxtra} \setmainfont[Numbers=OldStyle]{Times New Roman} \setsansfont{Arial} \else %This can be empty if you are not going to use pdftex \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \usepackage{mathptmx}%Times \usepackage{helvet}%Helvetica \fi %Here you can insert all packages that pdftex also understands \usepackage[ngerman. because they \textsf{are supported by \LaTeX{} and XeteX.3 xelatex \documentclass{article} \usepackage{ifxetex} \ifxetex %xetex specific stuff \usepackage{xunicode. this entire manual is written in Texinfo.ragged-right] d4 c b a @end lilypond @bye A. \input texinfo @node Top Texinfo text @lilypond[verbatim.ragged-right] a4 b c d @end lilypond More Texinfo text @lilypond[verbatim.2 Texinfo You can include LilyPond fragments in Texinfo.Appendix A: Templates 171 \begin{lilypond} \relative c'' { d4 c b a } \end{lilypond} \end{document} A.} .finnish.

you should include them again in a \verb+\ifxetex+ environment. In normal text you can easily use LilyPond commands. wenn sie von der Schriftart unterst__tzt werden. \end{document} . The fonts of snippets set with LilyPond will have to be set from inside of the snippet. For this you should read the AU on how to use lilypond-book. \selectlanguage{ngerman} Auch Umlaute funktionieren ohne die \LaTeX -Befehle. like this: \begin{lilypond} {a2 b c'8 c' c' c'} \end{lilypond} \noindent and so on. wie auch alle anderen seltsamen Zeichen: __ ______.Appendix A: Templates 172 If you want to use specific commands like \verb+\XeTeX+. You can use this to print the \ifxetex \XeTeX{} command \else XeTeX command \fi which is not known to normal \LaTeX .

. character strings. The most basic thing of a language is data: numbers. In a music file. snippets of Scheme code are introduced with the hash mark #. the previous examples translated in LilyPond are ##t ##f #1 #-1. so we add #s everywhere. lists.org. It uses prefix syntax. "this is a string" Strings may span several lines "this is a string" Quotation marks and newlines can also be added with so-called escape sequences. If you want to know more about Scheme. etc. both as part of the input syntax. Calculations may be nested. an expression like (* 3 4) is replaced by its value 12. the result of a function may be used for another calculation. while -1.5 is a floating point number (a non-integer number). Booleans Numbers Strings Boolean values are True or False. #(+ 1 (* 3 4)) ⇒ #(+ 1 12) ⇒ #13 These calculations are examples of evaluations. Scheme can be used to do calculations. see http://www . Strings are enclosed in double quotes. So. This section is a very brief overview of entering data in Scheme. The same assignment can be done in completely in Scheme as well. here twentyFour = #(* 2 twelve) the number 24 is stored in the variable twentyFour. A similar thing happens with variables.schemers. #(+ 1 2) ⇒ #3 The arrow ⇒ shows that the result of evaluating (+ 1 2) is 3. Numbers are entered in the standard fashion. After defining a variable twelve = #12 variables can also be used in expressions. Adding 1 and 2 is written as (+ 1 2) rather than the traditional 1 + 2. The string a said "b" is entered as "a said \"b\"" Newlines and backslashes are escaped with \n and \\ respectively.5 #"this is a string" #"this is a string" For the rest of this section.Appendix B: Scheme tutorial 173 Appendix B Scheme tutorial LilyPond uses the Scheme programming language. 1 is the (integer) number one. we will assume that the data is entered in a music file. The Scheme for True is #t and False is #f. Here is a list of data types that are relevant to LilyPond input. and as internal mechanism to glue modules of the program together.

a list of symbols and a list of lists respectively. We can use Scheme to simply \override commands. there is no need to quote anymore. To enter a list. 2) to the extra-offset property of the TextScript object. To distinguish between variables defined in input files (like twentyFour in the example above) and variables of internal objects. This makes stems almost twice as thick as their normal size. The two elements of a pair may be arbitrary values. A calculation. and 2 spaces up. so this command moves the object 1 staff space to the right.6 This instruction adjusts the appearance of stems. It is entered as #'twentyFour The quote mark ' prevents the Scheme interpreter from substituting 24 for the twentyFour. while twentyFour is an variable. like (+ 1 2) is also a list (containing the symbol + and the numbers 1 and 2). for example \override Stem #'thickness = #2. Two-dimensional offsets (X and Y coordinates) as well as object sizes (intervals with a left and right point) are entered as pairs.14159265) A list is entered by enclosing its elements in parentheses. thickness is measured relative to the thickness of staff lines. for example #'(1 . 3. we stop the evaluation. we will call the latter ‘properties’ and the former ‘variables. For example. 2) #'(#t . similar to a number or a string. and adding a quote. 1 In Scheme terminology. Inside a quoted list or pair. #f) #'("blah-blah" . \override TextScript #'extra-offset = #'(1 .6 times the width of staff lines. second) and. head) #'(staff clef key-signature) #'((1) (2)) B.Appendix B: Scheme tutorial 174 #(define twentyFour (* 2 twelve)) The name of a variable is also an expression. This syntax will be used very frequently. they must be quoted. The value 2. . A pair1 is entered as (first . So. Normally lists are interpreted as calculations. and the Scheme interpreter substitutes the outcome of the calculation. and Section “Interfaces for programmers” in Notation Reference. Instead. the stem object has a thickness property.’ So. and its two elements are called car and cdr respectively. This is done by quoting the list with a quote ' symbol. we get the name twentyFour. For a full explanation of this. for calculations do not use a quote. so these stem lines will be 2. like symbols.6 is put into the thickness variable of a Stem object. #'(stem . since many of the layout tweaks involve assigning (Scheme) values to internal variables. But we have even more power if we use Scheme. see the Appendix B [Scheme tutorial].1 Tweaking with Scheme We have seen how LilyPond output can be heavily modified using commands like \override TextScript #'extra-offset = ( 1 . -1). The following is a pair of symbols. page 173. 2) This assigns the pair (1. These numbers are measured in staff-spaces. #'(1 2 3) #'(1 2 "string" #f) We have been using lists all along. the pair is called cons.

-inf.Appendix B: Scheme tutorial 175 TODO Find a simple example We can use it to create new commands: tempoMark = #(define-music-function (parser location padding marktext) (number? string?) #{ \once \override Score . RehearsalMark #'padding = $padding \once \override Score . RehearsalMark #'extra-spacing-width = #'(+inf.0 .0) \mark \markup { \bold $marktext } #}) \relative c'' { c2 e \tempoMark #3.0 #"Allegro" g c } Allegro Even music expressions can be passed in: pattern = #(define-music-function (parser location x y) (ly:music? ly:music?) #{ $x e8 a b $y b a e #}) \relative c''{ \pattern c8 c8\f \pattern {d16 dis} { ais16-> b\p } } f p .

while not being considered responsible for modifications made by others. and is addressed as ‘you’. 1. 59 Temple Place. regardless of subject matter or whether it is published as a printed book. which is a copyleft license designed for free software. A ‘Secondary Section’ is a named appendix or a front-matter section of the Document that deals exclusively with the relationship of the publishers or authors of the Document to the Document’s overall subject (or to related matters) and contains nothing that could fall directly within that overall subject. MA 02111-1307. It complements the GNU General Public License. whose contents can be viewed and edited directly and straightforwardly with generic text editors or (for images composed of pixels) generic paint programs or (for drawings) some widely available drawing editor. The ‘Document’. or other written document free in the sense of freedom: to assure everyone the effective freedom to copy and redistribute it. The ‘Invariant Sections’ are certain Secondary Sections whose titles are designated. A ‘Modified Version’ of the Document means any work containing the Document or a portion of it. Boston. Secondarily. We have designed this License in order to use it for manuals for free software. either commercially or noncommercially. We recommend this License principally for works whose purpose is instruction or reference. as being those of Invariant Sections. this License preserves for the author and publisher a way to get credit for their work. PREAMBLE The purpose of this License is to make a manual. commercial. 0. The ‘Cover Texts’ are certain short passages of text that are listed. philosophical. it can be used for any textual work. refers to any such manual or work. textbook. But this License is not limited to software manuals. but changing it is not allowed. APPLICABILITY AND DEFINITIONS This License applies to any manual or other work that contains a notice placed by the copyright holder saying it can be distributed under the terms of this License. below. Any member of the public is a licensee. with or without modifying it. and that is suitable for input to text formatters or for automatic translation to a variety of formats suitable for input to text formatters. (For example. a Secondary Section may not explain any mathematics. which means that derivative works of the document must themselves be free in the same sense. ethical or political position regarding them. as Front-Cover Texts or Back-Cover Texts. Suite 330. in the notice that says that the Document is released under this License. A ‘Transparent’ copy of the Document means a machine-readable copy.1. because free software needs free documentation: a free program should come with manuals providing the same freedoms that the software does.) The relationship could be a matter of historical connection with the subject or with related matters. in the notice that says that the Document is released under this License. This License is a kind of ‘copyleft’. USA Everyone is permitted to copy and distribute verbatim copies of this license document. or with modifications and/or translated into another language. A copy made in an otherwise Transparent file . either copied verbatim. or of legal. if the Document is in part a textbook of mathematics. Inc. March 2000 Copyright c 2000 Free Software Foundation. represented in a format whose specification is available to the general public.Appendix C: GNU Free Documentation License 176 Appendix C GNU Free Documentation License Version 1.

Both covers must also clearly and legibly identify you as the publisher of these copies. but not required. under the same conditions stated above. If the required texts for either cover are too voluminous to fit legibly. you should put the first ones listed (as many as fit reasonably) on the actual cover. and continue the rest onto adjacent pages. either commercially or noncommercially. and that you add no other conditions whatsoever to those of this License. provided that this License. legibly. 3. COPYING IN QUANTITY If you publish printed copies of the Document numbering more than 100. plus such following pages as are needed to hold. For works in formats which do not have any title page as such. the title page itself. It is requested. You may not use technical measures to obstruct or control the reading or further copying of the copies you make or distribute. Copying with changes limited to the covers. 2. PDF. you may accept compensation in exchange for copies. VERBATIM COPYING You may copy and distribute the Document in any medium. and you may publicly display copies. and the Document’s license notice requires Cover Texts.Appendix C: GNU Free Documentation License 177 format whose markup has been designed to thwart or discourage subsequent modification by readers is not Transparent. Texinfo input format. and the license notice saying this License applies to the Document are reproduced in all copies. . If you publish or distribute Opaque copies of the Document numbering more than 100. SGML or XML using a publicly available DTD. and standard-conforming simple HTML designed for human modification. you must either include a machine-readable Transparent copy along with each Opaque copy. preceding the beginning of the body of the text. Opaque formats include PostScript. LaTEX input format. The ‘Title Page’ means. proprietary formats that can be read and edited only by proprietary word processors. You may also lend copies. for a printed book. and BackCover Texts on the back cover. as long as they preserve the title of the Document and satisfy these conditions. The front cover must present the full title with all words of the title equally prominent and visible. that you contact the authors of the Document well before redistributing any large number of copies. the material this License requires to appear in the title page. and the machine-generated HTML produced by some word processors for output purposes only. clearly and legibly. to ensure that this Transparent copy will remain thus accessible at the stated location until at least one year after the last time you distribute an Opaque copy (directly or through your agents or retailers) of that edition to the public. you must take reasonably prudent steps. to give them a chance to provide you with an updated version of the Document. Examples of suitable formats for Transparent copies include plain ascii without markup. You may add other material on the covers in addition. you must enclose the copies in covers that carry. However. all these Cover Texts: Front-Cover Texts on the front cover. which the general network-using public has access to download anonymously at no charge using public-standard network protocols. or state in or with each Opaque copy a publicly-accessible computer-network location containing a complete Transparent copy of the Document. SGML or XML for which the DTD and/or processing tools are not generally available. ‘Title Page’ means the text near the most prominent appearance of the work’s title. If you distribute a large enough number of copies you must also follow the conditions in section 3. If you use the latter option. A copy that is not ‘Transparent’ is called ‘Opaque’. when you begin distribution of Opaque copies in quantity. the copyright notices. free of added material. can be treated as verbatim copying in other respects.

as authors. provided that you release the Modified Version under precisely this License. authors. you must do these things in the Modified Version: A. Include. and add to it an item stating at least the title. These may be placed in the ‘History’ section. Section numbers or the equivalent are not considered part of the section titles. year. I. a license notice giving the public permission to use the Modified Version under the terms of this License. with the Modified Version filling the role of the Document. D. K. as the publisher. preserve the section’s title. and its title. be listed in the History section of the Document). if there were any. and publisher of the Modified Version as given on the Title Page. F. thus licensing distribution and modification of the Modified Version to whoever possesses a copy of it. Preserve in that license notice the full lists of Invariant Sections and required Cover Texts given in the Document’s license notice. Use in the Title Page (and on the covers.Appendix C: GNU Free Documentation License 178 4. Such a section may not be included in the Modified Version. In addition. You may omit a network location for a work that was published at least four years before the Document itself. B. together with at least five of the principal authors of the Document (all of its principal authors. List on the Title Page. immediately after the copyright notices. if any. Preserve the network location. create one stating the title. L. G. Do not retitle any existing section as ‘Endorsements’ or to conflict in title with any Invariant Section. if any) a title distinct from that of the Document. and from those of previous versions (which should. Delete any section entitled ‘Endorsements’. or if the original publisher of the version it refers to gives permission. Preserve all the copyright notices of the Document. H. and publisher of the Document as given on its Title Page. unaltered in their text and in their titles. State on the Title page the name of the publisher of the Modified Version. if it has less than five). To do this. add their titles to . Add an appropriate copyright notice for your modifications adjacent to the other copyright notices. M. new authors. given in the Document for public access to a Transparent copy of the Document. in the form shown in the Addendum below. you may at your option designate some or all of these sections as invariant. C. If the Modified Version includes new front-matter sections or appendices that qualify as Secondary Sections and contain no material copied from the Document. year. You may use the same title as a previous version if the original publisher of that version gives permission. J. N. MODIFICATIONS You may copy and distribute a Modified Version of the Document under the conditions of sections 2 and 3 above. then add an item describing the Modified Version as stated in the previous sentence. and likewise the network locations given in the Document for previous versions it was based on. In any section entitled ‘Acknowledgments’ or ‘Dedications’. Preserve the section entitled ‘History’. If there is no section entitled ‘History’ in the Document. Preserve all the Invariant Sections of the Document. one or more persons or entities responsible for authorship of the modifications in the Modified Version. E. and preserve in the section all the substance and tone of each of the contributor acknowledgments and/or dedications given therein. Include an unaltered copy of this License.

but you may replace the old one. to the end of the list of Cover Texts in the Modified Version. The author(s) and publisher(s) of the Document do not by this License give permission to use their names for publicity for or to assert or imply endorsement of any Modified Version. likewise combine any sections entitled ‘Acknowledgments’. You may add a section entitled ‘Endorsements’. under the terms defined in section 4 above for modified versions. and follow this License in all other respects regarding verbatim copying of that document. unmodified. if they are not themselves derivative works of the Document. 7. AGGREGATION WITH INDEPENDENT WORKS A compilation of the Document or its derivatives with other separate and independent documents or works. in or on a volume of a storage or distribution medium.Appendix C: GNU Free Documentation License 179 the list of Invariant Sections in the Modified Version’s license notice. then if the Document is less than one quarter of the entire aggregate. COMBINING DOCUMENTS You may combine the Document with other documents released under this License.’ 6. and distribute it individually under this License. and multiple identical Invariant Sections may be replaced with a single copy. If there are multiple Invariant Sections with the same name but different contents. provided that you follow the rules of this License for verbatim copying of each of the documents in all other respects. provided that you include in the combination all of the Invariant Sections of all of the original documents. provided you insert a copy of this License into the extracted document. You must delete all sections entitled ‘Endorsements. or else a unique number. you may not add another. you must combine any sections entitled ‘History’ in the various original documents. on explicit permission from the previous publisher that added the old one. Otherwise they must appear on covers around the whole aggregate. If the Document already includes a cover text for the same cover. the name of the original author or publisher of that section if known. COLLECTIONS OF DOCUMENTS You may make a collection consisting of the Document and other documents released under this License. and this License does not apply to the other self-contained works thus compiled with the Document. statements of peer review or that the text has been approved by an organization as the authoritative definition of a standard. provided no compilation copyright is claimed for the compilation. make the title of each such section unique by adding at the end of it. on account of their being thus compiled. provided it contains nothing but endorsements of your Modified Version by various parties—for example. and list them all as Invariant Sections of your combined work in its license notice. in parentheses. These titles must be distinct from any other section titles. Such a compilation is called an ‘aggregate’. You may extract a single document from such a collection. Only one passage of Front-Cover Text and one of Back-Cover Text may be added by (or through arrangements made by) any one entity. The combined work need only contain one copy of this License. and any sections entitled ‘Dedications’. Make the same adjustment to the section titles in the list of Invariant Sections in the license notice of the combined work. forming one section entitled ‘History’. the Document’s Cover Texts may be placed on covers that surround only the Document within the aggregate. previously added by you or by arrangement made by the same entity you are acting on behalf of. and replace the individual copies of this License in the various documents with a single copy that is included in the collection. You may add a passage of up to five words as a Front-Cover Text. and a passage of up to 25 words as a Back-Cover Text. . 5. does not as a whole count as a Modified Version of the Document. If the Cover Text requirement of section 3 is applicable to these copies of the Document. In the combination.

parties who have received copies. Such new versions will be similar in spirit to the present version. sublicense or distribute the Document is void.org/copyleft/. so you may distribute translations of the Document under the terms of section 4. . modify. and will automatically terminate your rights under this License. the original English version will prevail. FUTURE REVISIONS OF THIS LICENSE The Free Software Foundation may publish new. If the Document does not specify a version number of this License. you have the option of following the terms and conditions either of that specified version or of any later version that has been published (not as a draft) by the Free Software Foundation. TERMINATION You may not copy. If the Document specifies that a particular numbered version of this License ‘or any later version’ applies to it. In case of a disagreement between the translation and the original English version of this License. Any other attempt to copy. sublicense. Each version of the License is given a distinguishing version number. You may include a translation of this License provided that you also include the original English version of this License. but may differ in detail to address new problems or concerns. you may choose any version ever published (not as a draft) by the Free Software Foundation. modify. but you may include translations of some or all Invariant Sections in addition to the original versions of these Invariant Sections.Appendix C: GNU Free Documentation License 180 8. 10.gnu. TRANSLATION Translation is considered a kind of modification. revised versions of the GNU Free Documentation License from time to time. 9. or distribute the Document except as expressly provided for under this License. However. Replacing Invariant Sections with translations requires special permission from their copyright holders. from you under this License will not have their licenses terminated so long as such parties remain in full compliance. See http://www. or rights.

likewise for Back-Cover Texts. and with the Back-Cover Texts being list .1 or any later version published by the Free Software Foundation. Version 1. A copy of the license is included in the section entitled ‘GNU Free Documentation License’ . we recommend releasing these examples in parallel under your choice of free software license. write ‘no Front-Cover Texts’ instead of ‘Front-Cover Texts being list’. include a copy of the License in the document and put the following copyright and license notices just after the title page: Copyright (C) year your name . with the Invariant Sections being list their titles . write ‘with no Invariant Sections’ instead of saying which ones are invariant. such as the GNU General Public License.Appendix C: GNU Free Documentation License 181 ADDENDUM: How to use this License for your documents To use this License in a document you have written. If you have no Invariant Sections. Permission is granted to copy. to permit their use in free software. with the Front-Cover Texts being list . distribute and/or modify this document under the terms of the GNU Free Documentation License. . If you have no Front-Cover Texts. If your document contains nontrivial examples of program code.

. . . . . . . 66 \revert . . . . . . . .. . . . . . . . . . . . . . 38. . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . .. . . .. . . . . . . . . . . . 21 \grace .. . . . . . . . . . . . . . . . . < . . . . 59 \new ChoirStaff . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 \context . . .. . . . . . . .. . . . . ... . . . . . . . . . . . . . . . . 51 \shiftOn . . . . . .. . ) . . . . . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 # # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 \minor . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . 38. . . . . . . . .. . . . . . . . . . . . . . . . . . 21 \> . .... . . . . . . . . .. . . . . . . . . . 18 \layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ##t . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . 39 \set . . . . . . . . . . . . . . . . . . . . . . . . . 87 \score . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . .. . . . . . . . . . . . . . 18 \mp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . 34. . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . .. . . . . . . . .. . . 104 % % . . . . . . . . . . . . . . . . . . . . . . 102 \shiftOff . . . . . . . . . . . . . . . . 13 ( ( . . . .. . . . . . . . . . . . . . . . . \\ . . . . . . .. . . .. . . .. . . . . . . . . . . . . . . . . .. 82. . . . .. . . . . . . . . . . . . . . 52 \autoBeamOn . . . . . . . . . . . . . . example of using . . . . 87 \oneVoice . . . . . . . . . . . . . . . . . . .. .. . . . . . . . . .. . . . . . . . . . . . . . . . . .. .. . . . . . . . 85 \addlyrics. . . . . . . . .. . . . . . . . . . . . . . . . . . . . . . . . 44 \acciaccatura . . . . . . . . . . . . . . . . . . 52 \new Lyrics . . . . . .. . . . . . . . .. . . . . . . . . . . . 65 \f . . 37 \score . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22. . . . . . . . 52 \new Staff . . . ... . . . . . . . 21 > . . . . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 . . . . . . . . . . . . . . . . . . . . . . .. .. . . . . . . . 18 \markup. . . . . . 28 [ [ . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . 21 27 27 28 25 28 44 > > . . . . . . 82 \p . . 21 \new . . . 16 < < . . . . . . . . .. . . . . . . . . .. . . . . . . . . . . . . 16 %{ . . . . 25 \new Voice . . . . . . . . . . . . .. . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . 51 \startTextSpan . . . . . . . . . . . . . . . . . . . . .. . . . . ##f . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . .. . . . . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . 23 \pp . . . . . . . . . . . . .. . . . . .. 21 \relative . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . .. . . . . .. . . . . . 13 \remove. . . . .. 23 \autoBeamOff . . . . . . . . . . . 22 \mf . . . . . . . . . . .. . . . . . . . . . . . . . . . << . . . . . . . . . . . 23 \addlyrics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . . .. . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . .. .Appendix D: LilyPond index 182 Appendix D LilyPond index ! ! . . . . . . . 67 \lyricmode . . . . . . . . . . . . . . . .. . . . . . . . . .. . . . . . . . . . . 173 173 173 174 \ \! . .. . .. . . .. .. . . . . .. . . . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . .. . . . . . . . . . . . . . . . . . . . 23 \header . . . . . . 52 \lyricsto . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. << . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 \consists . .. . . . . . . . . . . . . . . . . . .. . . . . . . . . > . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25. . . ... . . . . . . . . . . . . . . .. . . . . . . .. . . . . . . . 19 \< . . . . . . . . . . . . . . . . . . . . . . . ... 21 \\ . . . . . . . . . . . . . . . .. . . . . . . . < . . . .. . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . 25. . . . . . . . . . . . . . . . . ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . .. . . . . . . . . . . .. . . . . . . . . 19 . . . .. 48 \override . . . . . 62 \set. . . . . . . . . . . . . . . .. . 27 >> . . . . . . . . . . . . . . . . . . . . . . . . . . . ... . . .. . . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 \overrideProperty . . . . . . . . . . . .. . . . . .. . . 22 [ . . . . . .. . . .. . . . . . . .. . . . . . . . . . . . . .. . . . . . . . . . . . . . . .. . . .. .. . . . . . . . .. 21 _ . . . . . . . . . . .. . . . . . .. . . . . .. . . . . . . . . . . .. . . . . . . .. . . . . . . . . . . . . . . .. . . . . .. . . . . . . . . . . . . . . . . . . . \) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . %} . . . . . . . . . . .. . . . .. . . . . . . . 21 \ff . . . . . . . . . . . . .. . . . . . . . . 51 \shiftOnn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . .. . . . . . . . . .. . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . .. . .. . 22 ] ] .. . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . example . .. . . . . . . . . . . . . . . . . . . 21 \midi . . . . . . . . . . . . . . . << . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . 28. . . . 38 \key .. . ... . . . . 21 \( . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 \clef . . . . . . . . . . . . . . . 48 \once . . . . . . . . . . .. . . . . >> . . 22 \book . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . ] . . . . . . . . . . . . 52 \major . . . .. 28 \addlyrics example . . . . . . . . . . . .. . . . . . << \\ >> . . . . . . . . . . . . . . 82. . . . . . . . . . . . . . . . . . . . . . . . . . . 51 \shiftOnnn . . . . . . . . .. . . . . . . . . . . . . . .. . >> . . . 13 . . . . . . 37 \book . . . . . . . . . . . . 16 ’ ' . . . . . . . . . . . . 21 \partial . .. . . . . . . . . . . . . . . .. . . . . . .. . . . 89 \appoggiatura . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . .. . . . . 22 ^ ^ . . . . . . . . . . . . . 25. . . . . . . . . . . . . . . . . . . . . . . . . . #'symbol . . . . . . . . . . . . .

. . . . . . . 11. . . 13 comment. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 bracket types . . . . . . by hand . . . 95 characters allowed in variables . . . . . . . . . 68 Changing defaults . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 bound-details property. . . . . . . . 106 \time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97. . . . example of using . . . . . . . . . . . . . 22. . . . . . . . 46 \voiceNeutralStyle . . . . . . . . . 92 ~ ~ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13. . . . . . . . . . 93. . . 83. . . . . . . . . 83 \tweak. . . 97. . . . notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 Articulations and ornamentations . . . . . . . . . . . . . . 84. . . . . . . 38. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 \voiceFourStyle . . . . . . . . . . . 129 color. . . . . . . . . . . . . . . . . . . . . . . . . . example of overriding . . . 48 \voiceTwoStyle . . . . . . . . . . . . . . . . . . . . . . . . . . . 8. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . tuplet . . . . . 98 aligning lyrics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96. . . . 17 compiling . . . . . . . . . . . . . . . . . . example . . . . . . . . . . . . . . . . . . . 120 collisions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . example . . . . . . . . . . . . . . . . . . . 84 brackets. . . . . . . . . . 23 C case sensitive . . . . . . . . . . . . . . . . . . . . . . 18 accidentals and relative mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 changing size of objects . . . . . . . . . . . . . . . . . . . . . . . . . . . 82. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 ChoirStaff . 66 ambitus engraver . example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 automatic beams . . . . . . . . . . . . . . . . 105 brace . . . . . . . . . . . . . . . . . . . . rgb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 center . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . X11. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 A absolute mode . . . . . . . . . . . . . . . . . . . 92 break-visibility property. . . . . . . . . . . . . . . . . nesting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14. . . . . . . . . . . . . . . . . . . 27 ChordNames . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 \version . . . . . . . . . . . . . . . . . . . 104. . . . . . . . . . . . . . . . . example of overriding . . . . . . . . . . . 22 beaming and lyrics . reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 appoggiatura . . 104 \textLengthOff . . . .Appendix D: LilyPond index 183 \stopTextSpan. . . . . . . . 57 book block. . . . . . . 24. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 beams. . . . . . 18 accidentals and key signatures . . . . . . . . . . . . . . . . . . . . . . . . 28 alignAboveContext property. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . triplet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Cheat sheet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 \tweak . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94 bass . . . . . . . . . . . . . . 22 blackness. . . . . . . . . . . . . . 16 comments . . . . . . . . . . . . . . . . . 16 Clef. . . . . . 52 autoBeamOn . . . . . . . . . . . . 22 addlyrics . . . . . . . . . . . . . . . . . . . . . . . . . . 16. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 \voiceTwo . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 charts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 appendices . . . . . . automatic . . . . . . . . . . . . . . . . . . . . 51 color property . . . . . . . . . . . . . . . . . . . . 2 Bar and bar number checks . . . . . . . . . setting to Scheme procedure . . . . . . . . . . . . 98 B balance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . example of overriding . . . . . . . . . . . . . . . . . 106 \textLengthOn. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97. . . . . . . . . . . . . . . . . . 92. . . . . . 27 chords vs. . . . marking . . 93 combining expressions in parallel . . . . . . . 15 ambitus . . 98 clickable examples . . . . . . . . 25 chords . . . 43 bracket. . . . . . . . . . . . . . . . . . . . . . . . . . 26 braces. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . voices . . . 33 autoBeamOff . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96. . . . 21 articulations and slurs. . . . . . . . . . . . . . . . . . . . . . . example . . . . . 18 Accidental. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 aligning objects on a baseline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 absolute note names. . . . . . . . 113 alto . . . . . . . . . . . . . . . . . . . . 22 Beam. . . . . . . . . . . . . . 25 comma . . . . . . . 37 book . . . . . 95. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 beams. . . . . 35 accent . . . . . . . . . 115 beaming . . . . . . . . . . . . . . . . . . . . . . . . . 52 beams. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . implicit . . . 2 block comment . . . . . . . . . . . . . . . . . . . . . . . . . 43 break-visibility property . . . . . . . . 23 accidental . . . . . . . . . . . . . . . . . 46 \voiceThree . . . . . . . . . . . . . . . . . . . tweaking placement . . . . . 44 clef . 100 Changing context default settings . . 48 \voiceThreeStyle . . . 95. . controlling manually . . . . . . . . . . . . . . . example of overriding. . . . . . . . . . . . . . . . 15 beam . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 Accidentals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94. . . . . . . . . . . . . . . . . . . . . 13 adding engravers . 35 absolute values for pitches . . . 66 adding text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 chord . . . . . . . . . . . . . . . 104 BarLine. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 Automatic accidentals . . . . . . . . . . . . . . . . 66 anacrusis. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 Automatic beams . . . . . . . . . . . . . . . . . . 65 \with. . . . . 20 accessing Scheme . . . . . . . . . . . . . . . . . . 26. . . 46 \voiceOne . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84 bracket. . . . . . . . . . . . . . . . . . . . . 46 \with . . . . . . . . 112 accidentals . . . . . . . . . . . . . . . . 15 \times . . . . . . . . . . . . . . . . . . . . . . . . 94 color property. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 AccidentalPlacement. . . . . . . . . . . . . . . . . . . 43 brackets. . . . . . . . . 39 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 accidentals and key signature . . . . . . . . . . . . . . . . . . 131 bar numbers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26. . . . . . 9 choir staff . . . . . . line . . . 23 articulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95. . . . . . 38 book. . . . . . . . . . . . . . . . . . manual . . . . . . 17 Collision resolution. . . . . . . . . . . . 15 Clef . . . . . . . . example. 34 \voiceFour . . . . . . . . . . . . . . . example of overriding . . . . . . . . enclosing vs. . . . . 16. . . . . . . . . . . . . . curly . . . . . . . . . . . . . . . . 93. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 assigning variables . . . . . . 11 compound music expression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 beams. . . . . . . . . . . 17 book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 automated engraving . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94 color. . . . . . 84 \unset . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 \voiceOneStyle . . . . . . . . . . . . . . . . 173 acciaccatura . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Application Usage . . . . . . . . . . . . . . . . . . . . . 93 color property. . . . . . . . 91. . . . . . . . . . . . . .

. 8 formatting a score . . . . . . . . . . . . . . . . 34 Converting from other formats . . . 113 F FDL. . . . . . . . . . . . . . . . . . . . . 4 future upgrades . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102 first example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . first . . . . . . . . . . . 14 DynamicLineSpanner. . . 16 es . . . automated . . . . . . . . . . 17 examples. . . . . . . . . . . . . . . . . . 110 extra-offset property. . . . 89. . . . . . . . . . . . . . . . . . music. . . . . . . . . . . . . . . . . . . . . . . . . . . creating . . . . . . . . . . . . . . . . . . 83 direction property. . . . . . . . . . . . . . . . . . . . . . notation . . . . . . . . . 65 force-hshift property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2. example . . . . . . . . . . . . . . 25 context. . . . . . . . . . . . . . . . . . . . . tweaking placement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . example of overriding . . . . . . . . . . . . 21 curly braces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 convert-ly . . . . . . . . . . . . . . . . . . parallel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 G General input and output . . . . . . . . . 108 grobs. . . . . . . . . 37 contexts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 formatting rules . . . example . . . 18 double sharp . . . . . example . . . . . . implicit. . . . . . . . 62 context properties. . . . . . . . . . . . . . . . . . . . 17 files. . . . . . 21 fingering example . . . . . . . slurs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125 file structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 double flat . positioning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 context properties. . 97. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86 context. . . . . . . . . example . . . . . . . . . . . . . . . . . . . . . . . . . 176 fermata. . . . . . . . . . . . . . . . . . . . . 5 engraving. . . . . . . . . . . . 87 Difficult tweaks . . . . . . . . . . . . . . . . example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 DynamicText. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 force-hshift property. . . . . . . . . . . . . . . . . . 21 dynamics. . . . . . . . . . . . . . . . . . . . . . 63. . . . . . . . 21 fingering. . . . . . . . . . . . . . . . . . . . . default and setting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 constructing files. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . moving colliding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 fingeringOrientations property. . . . . . . 65 context. . reverting to . . 84 GUILE . . . . . . . . . . . . . . . . . . . 101. 102 Fingering instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . tips for constructing . . . . . . . . . . . . 18 down . . . updating . . . . . . . . . . . . 108 extra-spacing-width property . adding . . . . . . . . . . . . . . . . . . . . . . . . removing . . . . . . . . . . . . . . . . . . . . . . layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 extra-spacing-width property. . . . . . . . . . . . . . . . . . . . . 23 grace notes. . . . 18 flat. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111 flat . . . . . . . . . . . . . . . . . clickable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 grob sizing . . . . . . . . . . . . . . . . . . . . . 9 grace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 Creating titles . . . . . . . 23 grand staff . . . . . . . . . . . . . . . . . . 62 engravers. . . . . . . . . . . . . 66 engraving . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101. . . . . . . . . . . simple . . . . . . . . . . . . . .Appendix D: LilyPond index 184 concurrent music . . . . . . . . . . . . . . . . . . . . . . . . . . 29 extra-offset property . . . 44 consists . . . . . . . . . . . . . . 6. . . . . . . . . . . . . . . 173 E engraver . . 21 default properties. . . . . 34 fingering . . . 98 dotted note . 37 File structure . . . . . . . . . . . 61 controlling tuplets. . . . . . . . . . . . . . . . and beams manually . . . . . . . . 83 fontSize property. . . . . . . . . 65 context properties. . . . . . . . . . . . . . . . . 18 eses . . . 100 duration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . naming . . . . . . . . . . . . . . . . . . . . . . . 109 grobs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 evaluating Scheme . . . . . . . . . . . . . . . . . . . . . . . . chords . . . . . . . 4 engravers . . . . . . . . . . . . . . . 114 fingering. . . . . . . . . . . . setting with \with . . double . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . identifying correct . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173 example of writing a score . placement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 contents of a score block . 126 font-size property. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . GNU Free Documentation License . . . . . . . . . . . . . . . . 7 expression. . . . . . . . . . . . . . . . . . 5 Contexts . . . . . . . . . . . . . . . . . . . 113 dynamics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86 context. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 crescendo . . . . . . . . . . . . . . 25 extender line . . . . . . . . . 59 Creating contexts . . . . . . . . . . . . . . . . . . . . . . . . example of overriding . . . . . . . . . . . . . . . 17 content vs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 expressions. . . . . . . 100. . . . . . . . . . 14 durations . . . . . . . . . . . tips . . . . . . . . . . . . . . . . . 59 contexts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . example . . . . . . . . . . . . . . . . 26 grob . . . . . . 114 extra-spacing-width . . . . . . . . . . . . . . . . . . . . . . . . . . 84. . . . . 108. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122 foreign languages . . . . . . . . . . . . . . . . . . . . . . . 114 grobs. . . . . . . 23 Grace notes . . . . . . . . . . . . . . . . . finding . . . . . specifying in lyric mode . . 9 creating contexts . . . . . . . . . . . . . . . . . . . . example . . . . . . . . . . . . . . . . . . . . . . . . 39 files. . 98 fontSize. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 Contexts explained . . . . . . . . . . . . . 25 context. . . . . . . . . . . . . . . . . . . . . . . . 27 distances . . . . . . . . . . . 39 context . . . . . . . . . . . . . . . . . 108. . . . . . . . . . . . . . . . . . . . . . . . . . 26 GrandStaff . . . . 11 examples. . . . . . . . . . . . implementing in MIDI . . . . . 37 File structure. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116. . 61 Creating MIDI files . . . 11 fixing overlapping notation . . . . . . . . . . 59 contexts. . . . . . . . . . . . 24 expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 Engravers and Performers . . . . . . . . . . . . . . . . . . . . . . . . 44 contexts. . 66 contexts explained . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 engravers. . . . . . 2 font-series property. . . . . . . . . . . . . . . . . . . Voice . . . . . 126 font-shape property. . . . . . . . . . . . . . . . . . . . . . . . . 65 context properties . . . . properties of. . . . . . . . . . . . . . . . . . . . . . . . . . 18 font . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 Dynamics . . . . . example of overriding . . . . . . modifying. . . . 34 D decrescendo . . . . . . . . 101 Displaying staves . . . . . . . . . . . . . 89 context. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 engraving multiple voices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 example. . . phrasing slurs. . . . . . . . . . . example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . setting with \context . . . . . . . . . . . 101 Fingering. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . 112 length . . . . . . . . . . 39 Music Glossary . Key signature . . . . . . . . . . . . . . . . . . . . . . . 94 Literature list . . . . . . . . . . . . . . . . . 173 List of colors . . . . . . . . . . . 44 music. . 126 M MacOS X. . . . . 88 interface properties . . . . . 10. . . . . . . . . . . . . . . . . . . . . . . . 28. . . . . . . . . . multi-syllable words . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 integrating LilyPond with other programs . . . . . . . . . . . . . . . 8 K key . . example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 isis . . . . . . . 34 headers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48. . . . . . . . . . . . . . . . 17 manually controlling tuplets. . . . 33 magstep . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 implicit contexts . . . . . . . . . . . . . . . . compound . . . . . . . . . . . . . . . . . . . . 16. . . . . . . . . . . . . 2 music. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 layout objects. . . . . . . . . . . . . . . . . . . . . 2 J jargon. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 moving colliding grobs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . allowing collisions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 implicit book block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 invisible objects . effect of location . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111. . . . . . . . . . . . . . . . . . . . . 18 Learning Manual . . . . . . . . . . . . properties of . . . 174 Internals Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 Multiple voices . . . . . . . . . . . . . . . . . . . . . . . . content . . . . . . . . . . . . . . . . . . . phrasing slurs. . . . . . 32 Lyrics context. . . . . . . . . . . . . . . . . . 109 moving overlapping objects. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 lyricmode . . . . . 52 lyrics and multiple staves . . . . . . . . . . . . . . . . . . . . . . . . simultaneous . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 LilyPond index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . example of overriding . 17 LISP . . . 32 multiple vocal verses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 LyricText. . . . . . . . . . . . key signature. . . 9. . . . creating . . . . . . . . . . . . . . reading . . . . . . . . . . . . 29 lyrics. . . . . . . . . . . . 23 manual. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125 middle C . . . . . 9 N naming contexts . . . . . . . . . . . 9 LSR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 header . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 idiom . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 lyric mode. . . . . . . . . . . 89. linking to voice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 italic. . . . . . . . . . . . . 22 Manual beams . . 22 markup example . . . . . . . . . . . . . . . . . 8 left-padding property . . . . . . . . . . . 104 MetronomeMark. . . . . . . . . . . . . . . 9 LilyPond Snippet Repository . . . . . . . . . . . . . . . . . . . . 109. . . . . . . . . . . tweaking placement . setting . 53 hyphens. . . . . . . . . . . . . . . . . . 29 I identifiers . . . . . . . . . . natural . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 layers . . . . . 11 macros . . . . . 37 Install . . . . naming conventions for objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Appendix D: LilyPond index 185 H half note . . . . . . . . . . . . . . . . . 34 hiding objects . . . . . . . . 98 magstep function. . . . . . . . . . . . 29 metronome mark. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 lyrics . . . . . . . 93. . . . . 36 musical symbols . . . . . . . . . . . . . . 88 Interfaces for programmers . . . . . . . . . . . . . . . . . . . . . . . . . 84 layout vs. . . . . . . 53 multiple voices . . . . . 52 lyrics. . . . . . . . . . . 62 Modifying properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 music typography . . . . . . . . . . . . . . . . . . . . . . . 68 modifying context properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 music engraving . . . . . . . . . . . 9. . . . . . . . . . . . . . . . 52 lyrics. . . . . . . . . . . . . . . . . . . . . . . . . . 17 hymn structure . . . . . 44 layout . . . . . . . . . . . . . . example of using . . . . . . . . . . . . . . . . . . . . . . specifying context . . . . . . . . . . . . . . . . . . . . . . . . aligning . . . . . . 24. . . . . . . . . . . . . . 80. . . . . . . . . . . . . . . 25 multiple staves and lyrics . . . . . . . . . . . . . 9 LilyPond-book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124 is . . 98 LilyPond command index . . . key signature . . concurrent . . . 38 minor . . . . . . . . . . . . . . 29 lyricsto . . running LilyPond . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 melisma. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170 line comment . . . . . . . . . . . . . . . . . . . . . . . . . . 18 18 19 18 27 L language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 layout block. . . . 18 Modifying context plug-ins . . . example of overriding . . . 84 Internals Reference. . . . . . . . . . . . . . . . . . . . . . . 13 midi . . . and beams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25. 52 lyrics and beaming . . . . . . . . . . . . 37 input format . . . . . . . . . . . Keyboard and other multi-staff instruments . . . . . . . . . . . . . . . . . . . . . . 44 Musical notation . . . . . . example of using . 114 markup . . . . . . . . . . . . . . . . . . . . . . example of overriding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 major . . . . . . . . . . . . . 109 moving colliding objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9. . . . . . . . . . . . . . . . . . . . . . . 84 Internals Reference manual . . . 38 layout object . . . . . 34. . . . . . . . . . . . . 113 Multiple scores in a book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 music expression. . . . . . . . . . . . . . . . . . . . . . . . . . 8. . . . . . . . . . . . . . 99 markup text. . . . . . . . . 61 81 81 18 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 Lyrics . . . . . . . . . . . . . . . . 18 manual beams . . . . . . . . . . . . . . . 124 how to read the manual . . . . . . . . . . . . . . . 109 MultiMeasureRest. . . . . . . . . . . . . . . . . . . . . . 38 header block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 interval . . . . . . . . . slurs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 music expression . . . . . . naming conventions for properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 multiple staves . . . . 112 modifying templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 note names. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 note value. . . . . . . . . . . 25 relative notes and simultaneous music . . . . . 26 pickup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . aligning on a baseline . 99 objects. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82. . 25 remove . . 82 overriding once only . . . . . . . . . . . . . . . . . . . . . . . . . 111 Painting objects white . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 PhrasingSlur. . . . . . 27 note names . . 104 outside-staff objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 partial. . . . . size of . . . . . . . . . within-staff . . . . . . . 23 PDF file . . . . 114 objects. . . . . . . . . . . . . . . . . . 87 once override . . . . . . . . . . . . . 111 override . . . 66 removing objects . . . . . . . . . . 109. . . . . . . example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 notes. . . . . . . . . . . example of overriding . . . . . and accidentals . . . . . 81 override command . . 124 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . variables . . . . . . . . . tweaking placement . . . . . . . . . . . . . . . . 59 new contexts . . . . . naming conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18. . . . . . . . . . . . . . . 109 padding property. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124 objects. . . . . . . . . . . . 62 properties vs. . . . . . . . . absolute . . . . . 50 nesting voices . . . . . . . . . . . . 106 overlapping notation . . . . . . . hiding . . . . . . . . . . . . . . . . . . . . . 50 neutral . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 parallel expressions and relative notes . . . . . . . . . 2 plug-in . . . . . . 14 quote. . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 NoteColumn. . . . 80 objects. . . . . . . . . . . . . . . . . . . . . . . 174 properties. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 Note names in other languages . . . . . . . . 25 Notation manual tables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 P padding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 positioning objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 removing engravers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 regular spacing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 property types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 objects. . . . . . . . . . . . . . . . . . . . . outside-staff . . . . . . . . . . . . . . . . . . 17 recursive structures. . . . . . . . . . . . . . . . . . . . . . . . . . . moving colliding . . . . . . . . . . 111 positions property. 25. . . . . . . . . . . . . . . . . . . . . . . . . .Appendix D: LilyPond index 186 nesting music expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . removing . . . . . . . . . . . . . . . . . . . . . layout . 59 new Staff . . . . . . . . . . . . . . . . . . . . . . positioning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 objects. . . . . . . . . . . . . . . . . . . 20 phrasing slurs. . . . . . . . . . . . . . . . . . . . . . . . . . . 19 pitches . . . . 14 note durations in chords . 90 O object. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 reference charts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 polyphony . . . . . . . . . . . . . 8. 85 override syntax. . 46 positioning grobs . . . . . . . . . . . 9 notation. . . . . . . . . example. . . . . . . . . . . . . . . . . . . . . 9 regular rhythms . . . . . . object . . . . . . . . . . . . . example . . . . . . . invisible . . . 115 properties in interfaces . . . . . . . . 124 objects. . . 2 ossia . . . . . . . . . . . . 116. . . . . . . . . . . . . . . . . 83. . . . . . . . . . . . . . . . 13 pitches. . . . . . . . . . . 13 Octave checks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 Phrasing slurs . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 polyphony . . 25 notating durations . . . . . . 11 phrasing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 objects. . . . . . . 13 relative mode. . . . . . . . . . . . 26 PianoStaff . . . . . . . . . . . . . . . . . . 87 oneVoice . . . . . . . . . . . . . . . . . . . . . . . . . 81 properties. . naming conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Notation Reference . . . . . . . . . . . . . . . . . . . . 13 quoting in Scheme . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 polyphony and relative note entry . 122 NoteHead. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 object properties . . 95 Ossia staves . . . . . . . . . . . . . 20 phrasing slur . . . . . . . . . . 51 note column . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . making invisible . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131 once . . . . . . . . . . . 124 objects. . . . . . . . . . . 80 object collision within a staff . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . controlling manually . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82. . . . . . . . . . . . . . . . . . . . . . . . . . . spreading out with text . . . . . . . . . . . . . 84 properties operating in contexts . . . . . . . . . . . . . . 5 polyphony . . 94. . . . . . . . . . . . . . . . . . . . example of overriding . . . . 111 padding property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 partial measure . . . . . . . . . . . . . . . . . . 42 ossias . . . . . . . . . . . . . . . . . . . . . . 18 Pitch names . . . . . . . . . . . . . . . 114 piano staff . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 overrideProperty command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 positions property. . . . . 3 rehearsal marks. . . . . . . . 113 objects. . . . . . . . . . . . . . . . . . . . . . . . . . changing size of . . . . . . 35 plate engraving. . . . . . . . . . 12 note collisions . . . . . . . . . . . . . . . . . . 50 nesting simultaneous constructs . . . . . . . . . . . . . . . . . . . . . 23 pitch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 relative notes and parallel expressions . . . . . . . 81 overrideProperty . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109 objects. . . . . . . . . . . . . . . . . . . . . . 99 outside-staff-priority property. . . . 13 relative mode . . . . . . 13 relative note entry and polyphony . . simple . . . . . . . . . . . . . . . . . . . . . . . . . . . . absolute values. . . . 81 override example . . . . . . . . . . . . . . . . . . . 99 octave . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 ottava bracket . . . . . . . . . . . . . . . . example of overriding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174 R reading the manual . 100 new . . . . . 114. . . . . . . . . . . . 88 properties of grobs . . . . . . . . 84 properties of layout objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 note durations . . . . . . . . . . . . . . . . . . . . . . . . 93 parallel expressions . . . . . . . . . . . . 104 relative . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124 objects. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 optical spacing . . . . single . . . . . . . . 87 Q quarter note . . . . . . . . . . . . . . . . . . . . . . 15 notation context . . . . . . . . . . . . . . . 80 object. . . 14 notating rests . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . 87. 106 textLengthOn . . . . . . . . 82 reverting to a single voice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 shift commands . 51 shiftOnnn . 15 rest. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 Slurs . . . . . . . . 106 TextSpanner. 8. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 simple examples . . . . 108 Skipping corrected music . . . . . . . . . 98 startTextSpan. . . . . . . . . . . 4 Scheme. . . . . . . . . . . . . . . . . . . . . . . 112. . . . . . . . . . . . . . . . . . . . . . . . . 18 sharp. . . . . . . . . . . . . 114 Snippet List . . . . . 11 text editors . . . . . . . . . . . piano . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . changing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 Running LilyPond . . . . . . . . . . . 20 Slur example of overriding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 slur . . . . . 112 text spanner . . . . . . . . . . . . . . . . . . . . . . . . 105 slurs crossing brackets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 Script. . . . . . . . . . . . . . . . . . . . . 12 simultaneous music. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . example of overriding . . . . 11 text property. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 staccato. . 109. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . example of overriding . . . . . . . 51 shiftOn. . . . . . 98 sizing grobs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . modifying . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . example . . . . . . . . . 125 stopTextSpan . 20 Staff . . . 76 templates . . . . . . . . . . . . . . . . . . . example . . . . . . . . . . . . multiple . . . . . . . . . . . . . . . . . . 20 Tie. . . . in-line code . . . . . . . . . . . . . . . . . . . . . . . 26 staff. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87. . . . . . . . 84 thickness . . . . 28 single staff polyphony . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 staff. 72 scale . . . . . . . . . . . . . . . . . . . . . . . . 62 setting properties within contexts . . . . 42 staff-padding property . . . . . 28 spacer rest . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 TextScript. . . . . . . . . . . . . . 104. . 110 self-alignment-X property. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 size of objects . . spacer . . . . . 48 Stem. . . . 86. . . . . 20 slurs and articulations. 125 stencil property. . . . 91. . . . . . . . . . . . . . . . . . . . 22 textLengthOff. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . multiple . 104 Text spanners . . . . . . . . . . . . . . . . . . example . . 104 staves. . . . . . . . . . . . . . . 53 SATB template . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . example . 44 simultaneous music and relative notes . . . . . . . . . . . . . . . . . 72 template. . . . . 93. example of overriding . . . . . . . . . . . . 11 S SATB structure . . . . . . . . 51 shiftOff . . . . . . . 48 stem length. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . example of writing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 Specialist notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 thickness property. . . . . . . . . . . . . . . 113. . . . . . . . 76 scores. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 staff-position property. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . writing your own . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 Structure of a score . . . 48 stem down . . 20 slurs. . . . . . . . . . . 94. . . . . . . . . . . . . . . . 87 revert command. . . . . . . . . . . . 95. . . . . . . . . . . . . . . . . . . . . . 121 . . . . . . . . . . . . . . . . . . . . . . . . . 14 right-padding property . . . . . . . phrasing . . . . . . . . . . . . . . . . 132 slur . . . . . . . . . . . . . . . . . . . . . . . . . . . 94 rgb-color . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 spacing. . . . . 98 StaffSymbol. . . . . . . . . . . 26 staff line spacing. . . . . . . . . . . . . . . . . . . 3 spanner . . . . . . . . . . . 28 revert . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 size. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . example of overriding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 staff group . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 slurs and outside-staff-priority . . . . . . 45 slurs versus ties . . . . . 39 Score . . . . . . . . . 9 spacing notes . use of . . . . . . . . . . . . . . . 91 stencil property. . . . . . . . . . . . . . 86 Slur. . . . . . . . . . . . . . . 7 simple notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . choir . . . . . . . . . . 13 Scheme . . . . . . . . . . . . . . . . . . 88 tie . . . . . . . . . . . . . . . . . . . . . 25 staves. . . . . . . . . . . . . . . . . . . . . 94 rhythms . . . . . . . . . . . . . . . . . . . 9 songs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 snippets . . . . . . . 9 running LilyPond under MacOS X . . . . . . . . . . . . . . . . . 9 sharp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . temporary . . . . . . 26 staff. 113 staff-position property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . positioning . . . . . . . controlling manually . . . . . . . . . . . . . . grand . . . . . 173 Scheme programming language . . . . . . 124 stencil property . . . . . . . . . . . . 112 right-padding property. . . . . . . . . . . . . . . . . . . . 11 running LilyPond under Unix . . . . . . . . . . . . . . . . . . . . . . . . 98. . . . . . . . . . . . . . . . . . . . . . 28 Spacing issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . example of overriding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111 self-alignment-X property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Score layout . . . . . . . . . . . . . 19. . . . . . . . . . . . . . . . . . . . . . . . . . . . example of overriding . . . . SATB . . . . . . . . . . . . . . . . . . . . . . . regular . . . . . . . . . . . . 104 text. . . . . . . . . . . . 38 score. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . changing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 stem up . . . . . . . . . . 51 shiftOnn . . . example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 temporary staves . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 stem directions and voices . . . . . . . . . . . adding . . . . . . . . . . . . . . . . . . . . . example of overriding . . 100. . . . . . . . . . . . . . . . changing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 slur. . . . . . . 49 rgb colors . . . . . . . . . . . . . . . . . . . . . . 8 Text editor support . 82. . . . . . . . . . double . . . . . 26 staff. example of overriding . . . . . . . . . . . . . . . . . . . . 39 score formatting . . . . . . . . . . . . . . . . . . .Appendix D: LilyPond index 187 rest . 6 T template. . . . . 173 score . . . . . . . . . . 104 StringNumber. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . example . . . . . . . . . . . . . . . . . 25 Simultaneous notes . . . . . . . . . . . . . 11 running LilyPond under Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 terminology . . . . . . . . . . 94. . . . . . . . . . . . . . . . . . . . . . . . . example . . . . . . . . . . . . . . . . . . . 25 score block. . . . . . . contents of . 41 tenor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 The tweak command . . . . . . . . . . . . . . . . . . . 109 staff-padding property. . . . . . . . . . . . . 69 template. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121 staff-space property. . . . . . . . . . . . . . . . . . . . 37 score . . . . . . . . . example . . . . . . . . . . 84. . . . . . . . . . . . . . . . . . . . . . . .

. . . example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 unset . . . . . . . . . . . . . . . . temporary . . . . . . 92 transparent property. . 8. . . . . . . . . . multiple . . . . . . . . . . . 38. . . . . . . . . . 93 x11-color function. . 34 Top . . . . . . . . . . . . . . . . . . . . . . 84 tuplet-number function. . . . . . . . . . . . . . . . 23 triplet bracket . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 using variables . . . . . . . . . . . . . . . . 34 viewing music . . . . . . . . . . . . . . . . . . . . . . chords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126 verse and refrain . . . . . . . . . . . . . . . . . . . . . . . . . . 23 updating files . more on one staff . . . . . . . . . . . . . . . . . . 29 Unix. . . . . . . . . . . . . . . 18 treble . . . . . . . . . . . . . . . . 48 voiceFour . 33 variables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95. . . . . . .Appendix D: LilyPond index 188 Ties . . . . . . . . . . . . . 53 Voice . Writing rests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . example of overriding . . . . . . . . . . 44 voices. . . . . . example of using . . . . . . . . . . . . . . 133 variables vs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84 TupletNumber. . . . . . . . . . . . . . 17 title . . properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 triplets. . . . . . . . . . example . . . . . . . . . . . . . . . . . . . . . . . . 84 triplets. . . . . . . . . . . . . 94 . . . . . . . . 9. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 voice contexts. . . . 23 Tuplets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 vocal scores with multiple verses. . . . . . . . . . . . . . . . . . 93 x11-color . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . characters allowed in . . . . . . . 84 tuplets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . example of using . . . . . . . . . . . . . . . . . 11 Vocal music. . . . 28 voices. . creating. . . . . . . . . . . . . . . . . . . 44 voices. . . . . . . . . . . . . . . . . . . . . . . . example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63. . . . . . . . . . . . . . . . . . . . . . writing a score. . . . . . . . 15 Time signature . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . running LilyPond . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 transparency . . . . . . . . . . . 93. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 x11-color. . . . 83 tweaking bar number placement . . . 96. . . . . . . . . . . . . . . . . 48 voices and stem directions . . . . . . . . . . . . . . . 15 triplet . . . 49 voices. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . words with multiple syllables in lyrics . . . . . . . . . . . 45 voices. nested . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92 transparent property . . . . . . . . . . . . . . . . . . . . . . . . . . 25 Voice context . . . . . . . 124 typography. . . . . . . . . . . . . . . . . multiple vocal. . . . 62 up . 125 transparent property. . . . . . . 33 variables. 124. . . . . . . . . . . 84 Tunable context properties . . . . . . . . . . . . . . . . . . 84 tweak . . . . . . . . . . . 54 verses. . . . . . . . . . . . . . 15 time signature . . . . . . . . . . . . . . . . . using variables for . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Writing rhythms . . . . . . . . . . . . . . 33 variables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Writing pitches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . example of overriding . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122. . . . . . music . . . . . . . . . . . . . . . . . . . . . . . . 34 versioning . . . . . . . . . . . whole note . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 version number . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . running LilyPond . . . . . . . . . . . . controlling manually . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . within-staff objects . . 20 ties crossing brackest . . . . . . . . . . . . . . . . . . . . . 50 voiceThree . . . . . 48 voiceOne . . . . . . . 104 tweaking rehearsal mark placement . . . . . . 92. . . . . . . . . . . . . . . . . . . . . . 107 tweaking methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104 tweaking dynamics placement . . . . . . . . . . . . 48 voiceTwo . . . . . 83 tweak command . . . . . . . . . . . . . . . . . . . . . . 50 voices. . . . . 126 tying notes across voices . . 97. . . . . . . . . . . . . . . . . . . using for tweaks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . naming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . nested . . . . . . . . . . . . . . . . . . . . . . . 23 TimeSignature. . . . . . 94. . . . . . . . . . . . . . . . using . . . . . . . . . . . . . . . . . . . . . . . 33. . . . . 33. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Writing text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 tuplet bracket . . . . . . . . . 84. . . . . . . use of . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 version. . . . . . . . . . . . . . 126 X X11 colors . . . . . . . . . . . . . . . . . . . . 2 V variables . . . . . . . . . . . . . . . . . . . . . . . defining . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . reverting to single . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 using variables for tweaks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 tuplet beams. . Windows. . . . . . . . . . . . . . . . . . . . . . 100 Upbeats . . . . . . 16 times . . nesting . . . . . . . . . . . . . 48 voices crossing brackets . . . . . . . . . . . 45 voices vs. . . . . . . . . . . . . . . . . . . . . 84 TupletBracket . . . . . . . . . . . . . . . . . . . . . . . . . . 124 transposition . . . . . . . . . . . . . . . . . . . 34 Updating files with convert-ly . . . . . . . . . 34. 98 tips for constructing files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 14 11 65 99 29 76 16 16 16 22 U underscore . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 tuplets. . . . . . . . . . . . . . 104 tweaks. . . . . . . . . . with . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 W whitespace insensitive . . . . . . . . . . . . . . . . . . . . . 174 variables. . . . . . . . . . . . . . . . 138 upgrades . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 vocal score structure . . . . . . . . . . . . . . 81 tweaking metronome mark placement . . . . . . . . 4 typography. . . . . . . . . . . . . .

Sign up to vote on this title
UsefulNot useful