1 #LyX 2.0 created this file. For more info see http://www.lyx.org/
6 \use_default_options true
10 \maintain_unincluded_children false
12 \language_package default
18 \font_default_family default
19 \use_non_tex_fonts false
26 \default_output_format default
28 \bibtex_command default
29 \index_command default
30 \paperfontsize default
33 \pdf_title "LilyPond-book and LyX"
34 \pdf_author "The LyX Team"
36 \pdf_bookmarksnumbered true
37 \pdf_bookmarksopen true
38 \pdf_bookmarksopenlevel 1
43 \pdf_pdfusetitle false
53 \paperorientation portrait
66 \paragraph_separation indent
67 \paragraph_indentation default
68 \quotes_language english
71 \paperpagestyle default
72 \tracking_changes false
89 \begin_layout Abstract
90 This document explains and demonstrates the inclusion of musical snippets
91 in a LyX document, using the LilyPond syntax for music notation and the
92 LilyPond-book utility for processing.
99 \begin_layout Standard
100 LilyPond is an open-source project that renders possible the creation of
101 beautiful computer-generated musical scores.
102 The project consists of a text-based music notation language, and a program
103 to process this notation into musical scores.
106 \begin_layout Standard
107 While LilyPond itself supports the display of title, author information,
108 footnotes, endnotes, etc., its primary focus is on music typesetting.
109 For text typesetting, other programs are generally better suited.
110 LilyPond-book is an utility provided by the LilyPond project that helps
111 incorporate musical scores using the LilyPond notation into LaTeX documents,
115 \begin_layout Standard
116 This document describes the use of the LilyPond music notation within LyX
117 documents that use a LaTeX-based layout, thus combining the beauty and
118 quality of the typesetting achieved by both LaTeX and LilyPond.
119 While a basic understanding of the LilyPond syntax for music notation is
120 in order, knowledge of LaTeX is not necessary when using LyX.
123 \begin_layout Standard
125 \begin_inset CommandInset ref
127 reference "sec:Using-LilyPond-code"
131 explains the requirements, usage instructions, and shortcomings of LilyPond
132 music notation within LyX.
134 \begin_inset CommandInset ref
136 reference "sec:LilyPond-examples"
140 demonstrates the beauty and quality of the typesetting with a few examples.
143 \begin_layout Section
144 Using LilyPond code within LyX
145 \begin_inset CommandInset label
147 name "sec:Using-LilyPond-code"
154 \begin_layout Standard
155 Support for LilyPond music notation (LilyPond code) within LyX is enabled
156 by adding the LilyPond module to your document.
157 This is done from the menu
159 Document\SpecialChar \menuseparator
162 , then selecting LilyPond in the list of modules.
163 You can use any LaTeX-based LyX layout and use the regular preview and
164 export mechanism; LyX will take care of processing the mixed LaTeX/LilyPond
165 code through LilyPond-book for you.
166 LilyPond-book can also handle DocBook and HTML documents, but the integration
167 of these document types with LilyPond-book and LyX is missing at the moment.
170 \begin_layout Subsection
174 \begin_layout Standard
175 LilyPond-book version 2.13 or newer.
179 \begin_layout Plain Layout
180 LilyPond-book supports LaTeX output since version 2.1.
181 However, some features used by LyX are available only in recent versions:
182 PDFLaTeX support (version 2.9), the
186 flag (version 2.11) and especially the
198 \begin_layout Subsection
202 \begin_layout Standard
203 The module provides a LilyPond inset which you insert from the menu
205 Insert\SpecialChar \menuseparator
213 This inset is for typing the LilyPond code which will be typeset into your
215 First, let us try a simple scale:
218 \begin_layout Standard
219 \begin_inset Flex LilyPond
222 \begin_layout Plain Layout
229 \begin_layout Plain Layout
234 \begin_layout Plain Layout
244 \begin_layout Standard
246 The previous LyX inset produces the following LaTeX-lookalike code:
249 \begin_layout LyX-Code
255 \begin_layout LyX-Code
261 \begin_layout LyX-Code
265 \begin_layout LyX-Code
269 \begin_layout LyX-Code
275 \begin_layout Standard
276 This code is not, in fact, processed by LaTeX, but is preprocessed by LilyPond-b
277 ook, which creates the graphics files and includes them in the LaTeX document
278 by replacing the above with a
282 includegraphics{\SpecialChar \ldots{}
288 \begin_layout Standard
289 Thus, the conversion process is as follow:
291 LyX\SpecialChar \menuseparator
292 LilyPond-book\SpecialChar \menuseparator
296 LyX creates a .lytex file, LilyPond-book creates a .tex files and the accompanyin
297 g image files, and LaTeX creates the final document.
298 Every step of the tool chain obeys your spacing, so whether you put the
299 musical extract inline, or in its own paragraph, centered, left-aligned,
300 etc., what you see in the LyX window should be respected in the final format.
301 An example of inline use may be to display a chord name, such as
302 \begin_inset Flex LilyPond
305 \begin_layout Plain Layout
320 , or perhaps a very short snippet.
323 \begin_layout Subsection
327 \begin_layout Standard
328 It is possible to have a direct feedback of what the music notation looks
329 like from within LyX.
330 To do this, wrap a LilyPond inset inside a Preview inset, which you find
333 Insert\SpecialChar \menuseparator
337 This only affects the display within LyX, not the output:
340 \begin_layout Standard
343 \begin_layout Standard
344 \begin_inset Flex LilyPond
347 \begin_layout Plain Layout
354 \begin_layout Plain Layout
359 \begin_layout Plain Layout
374 \begin_layout Standard
375 Unfortunately, you might find that the preview isn't exactly instantaneous.
376 You need to move the cursor out of the Preview inset to start compilation,
377 and processing time can take a few seconds.
378 Nevertheless, the direct feedback is often worthwhile during editing, and
379 renders the navigation through the document much easier.
382 \begin_layout Subsection
386 \begin_layout Standard
387 A few gotchas that have been experienced with the integration of LilyPond-book
388 and LyX are reported here.
391 \begin_layout Subsubsection
395 \begin_layout Standard
396 A LyX document using the LilyPond module cannot have child documents using
398 \begin_inset Quotes eld
402 \begin_inset Quotes erd
407 \begin_inset Quotes eld
411 \begin_inset Quotes erd
415 \begin_inset Quotes eld
419 \begin_inset Quotes erd
424 Insert\SpecialChar \menuseparator
425 File\SpecialChar \menuseparator
432 , you will get an error when producing output.
433 This is due to the way LilyPond-book automatically processes these input
435 Since there is currently no command-line option to turn off this behavior
436 of LilyPond-book, it is suggested to use the
437 \begin_inset Quotes eld
441 \begin_inset Quotes erd
447 \begin_layout Standard
448 Note that it is possible to insert child documents which make use of the
449 LilyPond module, using either the
450 \begin_inset Quotes eld
454 \begin_inset Quotes erd
458 \begin_inset Quotes eld
462 \begin_inset Quotes erd
465 method, in a master document which does not make use of the LilyPond module.
466 For this to work you might have to add the line
469 \begin_layout LyX-Code
475 \begin_layout Standard
476 to your master document's preamble under
478 Document\SpecialChar \menuseparator
484 \begin_layout Subsubsection
488 \begin_layout Standard
489 LilyPond-book searches for a
501 command when it decides if the code is only a fragment.
502 It is possible to include no LilyPond command at all, but in that case
503 {surrounding braces} are required.
504 Thus, in the following code,
507 \begin_layout LyX-Code
513 \begin_layout LyX-Code
519 \begin_layout LyX-Code
525 \begin_layout Standard
526 LilyPond-book gets confused:
529 \begin_layout LyX-Code
530 error: syntax error, unexpected NOTENAME_PITCH
533 \begin_layout LyX-Code
539 \begin_layout Standard
540 With surrounding braces, all is well:
543 \begin_layout Standard
546 \begin_layout Standard
547 \begin_inset Flex LilyPond
550 \begin_layout Plain Layout
552 {ais' f'' g' e''} % no
567 \begin_layout Standard
568 Writing the notes directly within braces without using any LilyPond command
569 is convenient when writing short snippets.
570 Advanced users will probably want to enter their musical content using
571 LilyPond variables and commands, which is of course supported.
574 \begin_layout Subsubsection
578 \begin_layout Standard
579 Another gotcha is with subsequent LilyPond snippets with
588 \begin_layout LyX-Code
594 \begin_layout LyX-Code
599 fret-diagram-terse #"x;3;2;o;1;o;" }
602 \begin_layout LyX-Code
608 \begin_layout LyX-Code
612 \begin_layout LyX-Code
618 \begin_layout LyX-Code
623 fret-diagram-terse #"x;x;o;2;3;2;" }
626 \begin_layout LyX-Code
632 \begin_layout Standard
633 For some reason LilyPond-book version 2.13 barks on this when run in safe
634 mode (which you always should use, unless you know what you are doing).
635 This has been corrected as of version 2.15 (was LilyPond issue #1900).
638 \begin_layout Subsubsection
648 \begin_layout Standard
649 LilyPond-book supports including LilyPond code that resides in external
657 With this command, the LilyPond code is processed as if it was typed inside
658 the document and the output score follows the typesetting determined by
659 LaTeX with respect to line width, page breaks, and so on.
660 This is in contrast to the long-standing LyX feature to include LilyPond
661 scores as external material, which calls LilyPond on the external file
662 to produce a rigid figure, and includes this figure in the document, leaving
663 the typesetting decisions to LilyPond.
664 Unfortunately, support for the
670 command in LyX is not implemented yet, but it is possible to use it inside
671 a TeX-Code block, provided that one writes the complete, absolute path
675 \begin_layout Section
677 \begin_inset CommandInset label
679 name "sec:LilyPond-examples"
686 \begin_layout Standard
688 \begin_inset CommandInset ref
690 reference "sub:Editorial-headword"
694 shows a complex score using many LilyPond constructs; some scheme code
695 has been removed from the original source of this snippet, to be able to
698 \begin_inset CommandInset ref
700 reference "sub:Tablatures-template"
704 shows another LilyPond output which should be interesting to guitarists.
707 \begin_layout Subsection
709 \begin_inset CommandInset label
711 name "sub:Editorial-headword"
718 \begin_layout Standard
719 NR 1.7 Editorial annotations Beethoven, Op.
721 3 Piano sonata 18, Movt II, Scherzo Measures 9--14.
724 \begin_layout Standard
729 \begin_layout Standard
730 \begin_inset Flex LilyPond
733 \begin_layout Plain Layout
740 \begin_layout Plain Layout
745 \begin_layout Plain Layout
750 \begin_layout Plain Layout
757 \begin_layout Plain Layout
764 \begin_layout Plain Layout
773 \begin_layout Plain Layout
780 \begin_layout Plain Layout
784 set Staff.fingeringOrientations = #'(up)
787 \begin_layout Plain Layout
791 set Score.currentBarNumber = #9
794 \begin_layout Plain Layout
801 \begin_layout Plain Layout
808 \begin_layout Plain Layout
813 \begin_layout Plain Layout
817 set doubleSlurs = ##t
820 \begin_layout Plain Layout
825 \begin_layout Plain Layout
832 \begin_layout Plain Layout
839 \begin_layout Plain Layout
848 \begin_layout Plain Layout
853 \begin_layout Plain Layout
860 \begin_layout Plain Layout
865 \begin_layout Plain Layout
870 \begin_layout Plain Layout
877 \begin_layout Plain Layout
884 \begin_layout Plain Layout
889 \begin_layout Plain Layout
894 \begin_layout Plain Layout
899 \begin_layout Plain Layout
905 override Script #'script-priority = #-100
908 \begin_layout Plain Layout
915 \begin_layout Plain Layout
926 \begin_layout Plain Layout
931 \begin_layout Plain Layout
936 \begin_layout Plain Layout
941 \begin_layout Plain Layout
946 \begin_layout Plain Layout
953 \begin_layout Plain Layout
960 \begin_layout Plain Layout
965 \begin_layout Plain Layout
970 \begin_layout Plain Layout
975 \begin_layout Plain Layout
980 \begin_layout Plain Layout
985 \begin_layout Plain Layout
990 \begin_layout Plain Layout
997 \begin_layout Plain Layout
1006 \begin_layout Plain Layout
1013 \begin_layout Plain Layout
1017 override Fingering #'direction = #down
1020 \begin_layout Plain Layout
1024 set Staff.fingeringOrientations = #'(down)
1027 \begin_layout Plain Layout
1034 \begin_layout Plain Layout
1041 \begin_layout Plain Layout
1045 set doubleSlurs = ##t
1048 \begin_layout Plain Layout
1053 \begin_layout Plain Layout
1060 \begin_layout Plain Layout
1067 \begin_layout Plain Layout
1074 \begin_layout Plain Layout
1081 \begin_layout Plain Layout
1086 \begin_layout Plain Layout
1090 set doubleSlurs = ##f
1093 \begin_layout Plain Layout
1098 \begin_layout Plain Layout
1103 \begin_layout Plain Layout
1110 \begin_layout Plain Layout
1117 \begin_layout Plain Layout
1122 \begin_layout Plain Layout
1127 \begin_layout Plain Layout
1132 \begin_layout Plain Layout
1139 \begin_layout Plain Layout
1150 \begin_layout Plain Layout
1155 \begin_layout Plain Layout
1160 \begin_layout Plain Layout
1165 \begin_layout Plain Layout
1170 \begin_layout Plain Layout
1177 \begin_layout Plain Layout
1184 \begin_layout Plain Layout
1189 \begin_layout Plain Layout
1194 \begin_layout Plain Layout
1199 \begin_layout Plain Layout
1204 \begin_layout Plain Layout
1209 \begin_layout Plain Layout
1223 \begin_layout Standard
1226 \begin_inset Flex URL
1229 \begin_layout Plain Layout
1231 http://lsr.dsi.unimi.it/LSR/Item?id=627
1236 ; scheme code removed, centering applied through the paragraph settings]
1239 \begin_layout Subsection
1241 \begin_inset CommandInset label
1243 name "sub:Tablatures-template"
1250 \begin_layout Standard
1251 \begin_inset Preview
1253 \begin_layout Standard
1254 \begin_inset Flex LilyPond
1257 \begin_layout Plain Layout
1264 \begin_layout Plain Layout
1270 \begin_layout Plain Layout
1275 \begin_layout Plain Layout
1282 \begin_layout Plain Layout
1287 \begin_layout Plain Layout
1292 \begin_layout Plain Layout
1299 \begin_layout Plain Layout
1306 \begin_layout Plain Layout
1310 new Staff = "guitar" <<
1313 \begin_layout Plain Layout
1317 context Voice = "upper guitar" {
1326 \begin_layout Plain Layout
1330 context Voice = "lower guitar" {
1339 \begin_layout Plain Layout
1344 \begin_layout Plain Layout
1348 new TabStaff = "tab" <<
1351 \begin_layout Plain Layout
1355 context TabVoice = "upper tab" {
1364 \begin_layout Plain Layout
1368 context TabVoice = "lower tab" {
1377 \begin_layout Plain Layout
1382 \begin_layout Plain Layout
1387 \begin_layout Plain Layout
1402 \begin_layout Standard
1405 \begin_inset Flex URL
1408 \begin_layout Plain Layout
1410 http://lsr.dsi.unimi.it/LSR/Item?id=634