1 #LyX 2.2 created this file. For more info see http://www.lyx.org/
5 \save_transient_properties true
6 \origin /systemlyxdir/examples/
8 \use_default_options true
12 \maintain_unincluded_children false
14 \language_package default
17 \font_roman "lmodern" "default"
18 \font_sans "lmss" "default"
19 \font_typewriter "lmtt" "default"
20 \font_math "auto" "auto"
21 \font_default_family default
22 \use_non_tex_fonts false
25 \font_sf_scale 100 100
26 \font_tt_scale 100 100
28 \default_output_format default
30 \bibtex_command default
31 \index_command default
32 \paperfontsize default
35 \pdf_title "LilyPond-book and LyX"
36 \pdf_author "The LyX Team"
38 \pdf_bookmarksnumbered true
39 \pdf_bookmarksopen true
40 \pdf_bookmarksopenlevel 1
45 \pdf_pdfusetitle false
46 \pdf_quoted_options "linkcolor=blue,urlcolor=blue,pdfstartview=XYZ"
49 \use_package amsmath 1
50 \use_package amssymb 1
53 \use_package mathdots 1
54 \use_package mathtools 0
56 \use_package stackrel 0
57 \use_package stmaryrd 0
58 \use_package undertilde 0
60 \cite_engine_type default
64 \paperorientation portrait
78 \paragraph_separation indent
79 \paragraph_indentation default
80 \quotes_language english
83 \paperpagestyle default
84 \tracking_changes false
94 LilyPond-book and \SpecialChar LyX
107 \begin_layout Abstract
108 This document explains and demonstrates the inclusion of musical snippets
109 in a \SpecialChar LyX
110 document, using the LilyPond syntax for music notation and the LilyPond-b
111 ook utility for processing.
114 \begin_layout Section
118 \begin_layout Standard
119 LilyPond is an open-source project that renders possible the creation of
120 beautiful computer-generated musical scores.
121 The project consists of a text-based music notation language, and a program
122 to process this notation into musical scores.
125 \begin_layout Standard
126 While LilyPond itself supports the display of title, author information,
127 footnotes, endnotes, etc., its primary focus is on music typesetting.
128 For text typesetting, other programs are generally better suited.
129 LilyPond-book is a utility provided by the LilyPond project that helps
130 incorporate musical scores using the LilyPond notation into \SpecialChar LaTeX
135 \begin_layout Standard
136 This document describes the use of the LilyPond music notation within \SpecialChar LyX
138 that use a \SpecialChar LaTeX
139 -based layout, thus combining the beauty and quality of the
140 typesetting achieved by both \SpecialChar LaTeX
142 While a basic understanding of the LilyPond syntax for music notation is
143 in order, knowledge of \SpecialChar LaTeX
144 is not necessary when using \SpecialChar LyX
148 \begin_layout Standard
150 \begin_inset CommandInset ref
152 reference "sec:Using-LilyPond-code"
156 explains the requirements, usage instructions, and shortcomings of LilyPond
157 music notation within \SpecialChar LyX
160 \begin_inset CommandInset ref
162 reference "sec:LilyPond-examples"
166 demonstrates the beauty and quality of the typesetting with a few examples.
169 \begin_layout Section
170 Using LilyPond code within \SpecialChar LyX
172 \begin_inset CommandInset label
174 name "sec:Using-LilyPond-code"
181 \begin_layout Standard
182 Support for LilyPond music notation (LilyPond code) within \SpecialChar LyX
184 adding the LilyPond module to your document.
185 This is done from the menu
187 Document\SpecialChar menuseparator
190 , then selecting LilyPond in the list of modules.
191 You can use any \SpecialChar LaTeX
192 -based \SpecialChar LyX
193 layout and use the regular preview and export mechanism
195 will take care of processing the mixed \SpecialChar LaTeX
196 /LilyPond code through LilyPond-book
198 LilyPond-book can also handle DocBook and HTML documents, but the integration
199 of these document types with LilyPond-book and \SpecialChar LyX
200 is missing at the moment.
203 \begin_layout Subsection
207 \begin_layout Standard
208 LilyPond-book version 2.13 or newer.
212 \begin_layout Plain Layout
213 LilyPond-book supports \SpecialChar LaTeX
214 output since version 2.1.
215 However, some features used by \SpecialChar LyX
216 are available only in recent versions:
217 PDF\SpecialChar LaTeX
218 support (version 2.9), the
222 flag (version 2.11) and especially the
234 \begin_layout Subsection
238 \begin_layout Standard
239 The module provides a LilyPond inset which you insert from the menu
241 Insert\SpecialChar menuseparator
249 This inset is for typing the LilyPond code which will be typeset into your
251 First, let us try a simple scale:
254 \begin_layout Standard
255 \begin_inset Flex LilyPond
258 \begin_layout Plain Layout
260 \begin_inset Argument 1
263 \begin_layout Plain Layout
272 \begin_layout Plain Layout
279 \begin_layout Plain Layout
284 \begin_layout Plain Layout
294 \begin_layout Standard
296 The previous \SpecialChar LyX
297 inset produces the following \SpecialChar LaTeX
301 \begin_layout LyX-Code
304 begin{lilypond}[staffsize=28]
307 \begin_layout LyX-Code
311 \begin_layout LyX-Code
317 \begin_layout LyX-Code
321 \begin_layout LyX-Code
325 \begin_layout LyX-Code
331 \begin_layout Standard
332 What appear first inside square brackets are options to pass to LilyPond-book.
333 This is inserted in \SpecialChar LyX
338 menu, in the same way that the LilyPond inset itself is inserted.
339 Here, we set the dimension of the staff to 28
340 \begin_inset space \thinspace{}
344 Other options can be added by separating them by a comma, for example:
347 [staffsize=28,verbatim]
350 A list of music fragment options is available in the LilyPond documentation.
351 This whole block can be omitted when the default settings are desired.
354 \begin_layout Standard
355 What follows after the options block is the textual representation in LilyPond
356 syntax of a musical fragment.
357 This code is not, in fact, processed by \SpecialChar LaTeX
358 , but is preprocessed by LilyPond-book,
359 which creates the graphics files and includes them in the \SpecialChar LaTeX
361 replacing the above with a
365 includegraphics{\SpecialChar ldots
371 \begin_layout Standard
372 Thus, the conversion process is as follow:
375 \SpecialChar menuseparator
376 LilyPond-book\SpecialChar menuseparator
382 creates a .lytex file, LilyPond-book creates a .tex files and the accompanying
383 image files, and \SpecialChar LaTeX
384 creates the final document.
385 Every step of the tool chain obeys your spacing, so whether you put the
386 musical extract inline, or in its own paragraph, centered, left-aligned,
387 etc., what you see in the \SpecialChar LyX
388 window should be respected in the final format.
389 An example of inline use may be to display a chord name, such as
390 \begin_inset Flex LilyPond
393 \begin_layout Plain Layout
395 \begin_inset Argument 1
398 \begin_layout Plain Layout
417 , or perhaps a very short snippet.
420 \begin_layout Subsection
424 \begin_layout Standard
425 It is possible to have a direct feedback of what the music notation looks
426 like from within \SpecialChar LyX
428 To do this, wrap a LilyPond inset inside a Preview inset, which you find
431 Insert\SpecialChar menuseparator
435 This only affects the display within \SpecialChar LyX
439 \begin_layout Standard
442 \begin_layout Standard
443 \begin_inset Flex LilyPond
446 \begin_layout Plain Layout
453 \begin_layout Plain Layout
458 \begin_layout Plain Layout
473 \begin_layout Standard
474 Unfortunately, you might find that the preview isn't exactly instantaneous.
475 You need to move the cursor out of the Preview inset to start compilation,
476 and processing time can take a few seconds.
477 Nevertheless, the direct feedback is often worthwhile during editing, and
478 renders the navigation through the document much easier.
481 \begin_layout Subsection
485 \begin_layout Standard
486 A few gotchas that have been experienced with the integration of LilyPond-book
491 \begin_layout Subsubsection
495 \begin_layout Standard
497 document using the LilyPond module cannot have child documents using
499 \begin_inset Quotes eld
503 \begin_inset Quotes erd
508 \begin_inset Quotes eld
512 \begin_inset Quotes erd
516 \begin_inset Quotes eld
520 \begin_inset Quotes erd
525 Insert\SpecialChar menuseparator
526 File\SpecialChar menuseparator
533 , you will get an error when producing output.
534 This is due to the way LilyPond-book automatically processes these input
536 Since there is currently no command-line option to turn off this behavior
537 of LilyPond-book, it is suggested to use the
538 \begin_inset Quotes eld
542 \begin_inset Quotes erd
548 \begin_layout Standard
549 Note that it is possible to insert child documents which make use of the
550 LilyPond module, using either the
551 \begin_inset Quotes eld
555 \begin_inset Quotes erd
559 \begin_inset Quotes eld
563 \begin_inset Quotes erd
566 method, in a master document which does not make use of the LilyPond module.
567 For this to work you might have to add the line
570 \begin_layout LyX-Code
576 \begin_layout Standard
577 to your master document's preamble under
579 Document\SpecialChar menuseparator
585 \begin_layout Subsubsection
589 \begin_layout Standard
590 LilyPond-book searches for a
602 command when it decides if the code is only a fragment.
603 It is possible to include no LilyPond command at all, but in that case
604 {surrounding braces} are required.
605 Thus, in the following code,
608 \begin_layout LyX-Code
614 \begin_layout LyX-Code
620 \begin_layout LyX-Code
626 \begin_layout Standard
627 LilyPond-book gets confused:
630 \begin_layout LyX-Code
631 error: syntax error, unexpected NOTENAME_PITCH
634 \begin_layout LyX-Code
640 \begin_layout Standard
641 With surrounding braces, all is well:
644 \begin_layout Standard
647 \begin_layout Standard
648 \begin_inset Flex LilyPond
651 \begin_layout Plain Layout
653 {ais' f'' g' e''} % no
668 \begin_layout Standard
669 Writing the notes directly within braces without using any LilyPond command
670 is convenient when writing short snippets.
671 Advanced users will probably want to enter their musical content using
672 LilyPond variables and commands, which is of course supported.
675 \begin_layout Subsubsection
679 \begin_layout Standard
680 Another gotcha is with subsequent LilyPond snippets with
689 \begin_layout LyX-Code
695 \begin_layout LyX-Code
700 fret-diagram-terse #"x;3;2;o;1;o;" }
703 \begin_layout LyX-Code
709 \begin_layout LyX-Code
713 \begin_layout LyX-Code
719 \begin_layout LyX-Code
724 fret-diagram-terse #"x;x;o;2;3;2;" }
727 \begin_layout LyX-Code
733 \begin_layout Standard
734 For some reason LilyPond-book version 2.13 barks on this when run in safe
735 mode (which you always should use, unless you know what you are doing).
736 This has been corrected as of version 2.15 (was LilyPond issue #1900).
739 \begin_layout Subsubsection
749 \begin_layout Standard
750 LilyPond-book supports including LilyPond code that resides in external
758 With this command, the LilyPond code is processed as if it was typed inside
759 the document and the output score follows the typesetting determined by
761 with respect to line width, page breaks, and so on.
762 This is in contrast to the long-standing \SpecialChar LyX
763 feature to include LilyPond scores
764 as external material, which calls LilyPond on the external file to produce
765 a rigid figure, and includes this figure in the document, leaving the typesetti
766 ng decisions to LilyPond.
767 Unfortunately, support for the
773 command in \SpecialChar LyX
774 is not implemented yet, but it is possible to use it inside
776 -Code block, provided that one writes the complete, absolute path to
780 \begin_layout Section
782 \begin_inset CommandInset label
784 name "sec:LilyPond-examples"
791 \begin_layout Standard
793 \begin_inset CommandInset ref
795 reference "subsec:Editorial-headword"
799 shows a complex score using many LilyPond constructs; some scheme code
800 has been removed from the original source of this snippet, to be able to
803 \begin_inset CommandInset ref
805 reference "subsec:Tablatures-template"
809 shows another LilyPond output which should be interesting to guitarists.
812 \begin_layout Subsection
814 \begin_inset CommandInset label
816 name "subsec:Editorial-headword"
823 \begin_layout Standard
824 NR 1.7 Editorial annotations Beethoven, Op.
826 3 Piano sonata 18, Movt II, Scherzo Measures 9–14.
829 \begin_layout Standard
834 \begin_layout Standard
835 \begin_inset Flex LilyPond
838 \begin_layout Plain Layout
845 \begin_layout Plain Layout
850 \begin_layout Plain Layout
855 \begin_layout Plain Layout
862 \begin_layout Plain Layout
869 \begin_layout Plain Layout
878 \begin_layout Plain Layout
885 \begin_layout Plain Layout
889 set Staff.fingeringOrientations = #'(up)
892 \begin_layout Plain Layout
896 set Score.currentBarNumber = #9
899 \begin_layout Plain Layout
906 \begin_layout Plain Layout
913 \begin_layout Plain Layout
918 \begin_layout Plain Layout
922 set doubleSlurs = ##t
925 \begin_layout Plain Layout
930 \begin_layout Plain Layout
937 \begin_layout Plain Layout
944 \begin_layout Plain Layout
953 \begin_layout Plain Layout
958 \begin_layout Plain Layout
965 \begin_layout Plain Layout
970 \begin_layout Plain Layout
975 \begin_layout Plain Layout
982 \begin_layout Plain Layout
989 \begin_layout Plain Layout
994 \begin_layout Plain Layout
999 \begin_layout Plain Layout
1004 \begin_layout Plain Layout
1010 override Script #'script-priority = #-100
1013 \begin_layout Plain Layout
1020 \begin_layout Plain Layout
1031 \begin_layout Plain Layout
1036 \begin_layout Plain Layout
1041 \begin_layout Plain Layout
1046 \begin_layout Plain Layout
1051 \begin_layout Plain Layout
1058 \begin_layout Plain Layout
1065 \begin_layout Plain Layout
1070 \begin_layout Plain Layout
1075 \begin_layout Plain Layout
1080 \begin_layout Plain Layout
1085 \begin_layout Plain Layout
1090 \begin_layout Plain Layout
1095 \begin_layout Plain Layout
1102 \begin_layout Plain Layout
1111 \begin_layout Plain Layout
1118 \begin_layout Plain Layout
1122 override Fingering #'direction = #down
1125 \begin_layout Plain Layout
1129 set Staff.fingeringOrientations = #'(down)
1132 \begin_layout Plain Layout
1139 \begin_layout Plain Layout
1146 \begin_layout Plain Layout
1150 set doubleSlurs = ##t
1153 \begin_layout Plain Layout
1158 \begin_layout Plain Layout
1165 \begin_layout Plain Layout
1172 \begin_layout Plain Layout
1179 \begin_layout Plain Layout
1186 \begin_layout Plain Layout
1191 \begin_layout Plain Layout
1195 set doubleSlurs = ##f
1198 \begin_layout Plain Layout
1203 \begin_layout Plain Layout
1208 \begin_layout Plain Layout
1215 \begin_layout Plain Layout
1222 \begin_layout Plain Layout
1227 \begin_layout Plain Layout
1232 \begin_layout Plain Layout
1237 \begin_layout Plain Layout
1244 \begin_layout Plain Layout
1255 \begin_layout Plain Layout
1260 \begin_layout Plain Layout
1265 \begin_layout Plain Layout
1270 \begin_layout Plain Layout
1275 \begin_layout Plain Layout
1282 \begin_layout Plain Layout
1289 \begin_layout Plain Layout
1294 \begin_layout Plain Layout
1299 \begin_layout Plain Layout
1304 \begin_layout Plain Layout
1309 \begin_layout Plain Layout
1314 \begin_layout Plain Layout
1328 \begin_layout Standard
1331 \begin_inset Flex URL
1334 \begin_layout Plain Layout
1336 http://lsr.di.unimi.it/LSR/Item?id=627
1341 ; scheme code removed, centering applied through the paragraph settings]
1344 \begin_layout Subsection
1346 \begin_inset CommandInset label
1348 name "subsec:Tablatures-template"
1355 \begin_layout Standard
1356 \begin_inset Preview
1358 \begin_layout Standard
1359 \begin_inset Flex LilyPond
1362 \begin_layout Plain Layout
1369 \begin_layout Plain Layout
1375 \begin_layout Plain Layout
1380 \begin_layout Plain Layout
1387 \begin_layout Plain Layout
1392 \begin_layout Plain Layout
1397 \begin_layout Plain Layout
1404 \begin_layout Plain Layout
1411 \begin_layout Plain Layout
1415 new Staff = "guitar" <<
1418 \begin_layout Plain Layout
1422 context Voice = "upper guitar" {
1431 \begin_layout Plain Layout
1435 context Voice = "lower guitar" {
1444 \begin_layout Plain Layout
1449 \begin_layout Plain Layout
1453 new TabStaff = "tab" <<
1456 \begin_layout Plain Layout
1460 context TabVoice = "upper tab" {
1469 \begin_layout Plain Layout
1473 context TabVoice = "lower tab" {
1482 \begin_layout Plain Layout
1487 \begin_layout Plain Layout
1492 \begin_layout Plain Layout
1507 \begin_layout Standard
1510 \begin_inset Flex URL
1513 \begin_layout Plain Layout
1515 http://lsr.di.unimi.it/LSR/Item?id=634