1 #LyX 2.3 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 \use_dash_ligatures false
30 \default_output_format default
32 \bibtex_command default
33 \index_command default
34 \paperfontsize default
37 \pdf_title "LilyPond-book and LyX"
38 \pdf_author "The LyX Team"
40 \pdf_bookmarksnumbered true
41 \pdf_bookmarksopen true
42 \pdf_bookmarksopenlevel 1
47 \pdf_pdfusetitle false
48 \pdf_quoted_options "linkcolor=blue,urlcolor=blue,pdfstartview=XYZ"
51 \use_package amsmath 1
52 \use_package amssymb 1
55 \use_package mathdots 1
56 \use_package mathtools 1
58 \use_package stackrel 1
59 \use_package stmaryrd 1
60 \use_package undertilde 1
62 \cite_engine_type default
66 \paperorientation portrait
80 \paragraph_separation indent
81 \paragraph_indentation default
83 \math_numbering_side default
87 \paperpagestyle default
88 \tracking_changes false
99 LilyPond-book and \SpecialChar LyX
112 \begin_layout Abstract
113 This document explains and demonstrates the inclusion of musical snippets
114 in a \SpecialChar LyX
115 document, using the LilyPond syntax for music notation and the LilyPond-b
116 ook utility for processing.
119 \begin_layout Section
123 \begin_layout Standard
124 LilyPond is an open-source project that renders possible the creation of
125 beautiful computer-generated musical scores.
126 The project consists of a text-based music notation language, and a program
127 to process this notation into musical scores.
130 \begin_layout Standard
131 While LilyPond itself supports the display of title, author information,
132 footnotes, endnotes, etc., its primary focus is on music typesetting.
133 For text typesetting, other programs are generally better suited.
134 LilyPond-book is a utility provided by the LilyPond project that helps
135 incorporate musical scores using the LilyPond notation into \SpecialChar LaTeX
140 \begin_layout Standard
141 This document describes the use of the LilyPond music notation within \SpecialChar LyX
143 that use a \SpecialChar LaTeX
144 -based layout, thus combining the beauty and quality of the
145 typesetting achieved by both \SpecialChar LaTeX
147 While a basic understanding of the LilyPond syntax for music notation is
148 in order, knowledge of \SpecialChar LaTeX
149 is not necessary when using \SpecialChar LyX
153 \begin_layout Standard
155 \begin_inset CommandInset ref
157 reference "sec:Using-LilyPond-code"
161 explains the requirements, usage instructions, and shortcomings of LilyPond
162 music notation within \SpecialChar LyX
165 \begin_inset CommandInset ref
167 reference "sec:LilyPond-examples"
171 demonstrates the beauty and quality of the typesetting with a few examples.
174 \begin_layout Section
175 Using LilyPond code within \SpecialChar LyX
177 \begin_inset CommandInset label
179 name "sec:Using-LilyPond-code"
186 \begin_layout Standard
187 Support for LilyPond music notation (LilyPond code) within \SpecialChar LyX
189 adding the LilyPond module to your document.
190 This is done from the menu
192 Document\SpecialChar menuseparator
195 , then selecting LilyPond in the list of modules.
196 You can use any \SpecialChar LaTeX
197 -based \SpecialChar LyX
198 layout and use the regular preview and export mechanism
200 will take care of processing the mixed \SpecialChar LaTeX
201 /LilyPond code through LilyPond-book
203 LilyPond-book can also handle DocBook and HTML documents, but the integration
204 of these document types with LilyPond-book and \SpecialChar LyX
205 is missing at the moment.
208 \begin_layout Subsection
212 \begin_layout Standard
213 LilyPond-book version 2.13 or newer.
217 \begin_layout Plain Layout
218 LilyPond-book supports \SpecialChar LaTeX
219 output since version 2.1.
220 However, some features used by \SpecialChar LyX
221 are available only in recent versions:
222 PDF\SpecialChar LaTeX
223 support (version 2.9), the
227 flag (version 2.11) and especially the
239 \begin_layout Subsection
243 \begin_layout Standard
244 The module provides a LilyPond inset which you insert from the menu
246 Insert\SpecialChar menuseparator
254 This inset is for typing the LilyPond code which will be typeset into your
256 First, let us try a simple scale:
259 \begin_layout Standard
260 \begin_inset Flex LilyPond
263 \begin_layout Plain Layout
265 \begin_inset Argument 1
268 \begin_layout Plain Layout
277 \begin_layout Plain Layout
284 \begin_layout Plain Layout
289 \begin_layout Plain Layout
299 \begin_layout Standard
301 The previous \SpecialChar LyX
302 inset produces the following \SpecialChar LaTeX
306 \begin_layout LyX-Code
309 begin{lilypond}[staffsize=28]
312 \begin_layout LyX-Code
316 \begin_layout LyX-Code
322 \begin_layout LyX-Code
326 \begin_layout LyX-Code
330 \begin_layout LyX-Code
336 \begin_layout Standard
337 What appear first inside square brackets are options to pass to LilyPond-book.
338 This is inserted in \SpecialChar LyX
343 menu, in the same way that the LilyPond inset itself is inserted.
344 Here, we set the dimension of the staff to 28
345 \begin_inset space \thinspace{}
349 Other options can be added by separating them by a comma, for example:
352 [staffsize=28,verbatim]
355 A list of music fragment options is available in the LilyPond documentation.
356 This whole block can be omitted when the default settings are desired.
359 \begin_layout Standard
360 What follows after the options block is the textual representation in LilyPond
361 syntax of a musical fragment.
362 This code is not, in fact, processed by \SpecialChar LaTeX
363 , but is preprocessed by LilyPond-book,
364 which creates the graphics files and includes them in the \SpecialChar LaTeX
366 replacing the above with a
370 includegraphics{\SpecialChar ldots
376 \begin_layout Standard
377 Thus, the conversion process is as follow:
380 \SpecialChar menuseparator
381 LilyPond-book\SpecialChar menuseparator
387 creates a .lytex file, LilyPond-book creates a .tex files and the accompanying
388 image files, and \SpecialChar LaTeX
389 creates the final document.
390 Every step of the tool chain obeys your spacing, so whether you put the
391 musical extract inline, or in its own paragraph, centered, left-aligned,
392 etc., what you see in the \SpecialChar LyX
393 window should be respected in the final format.
394 An example of inline use may be to display a chord name, such as
395 \begin_inset Flex LilyPond
398 \begin_layout Plain Layout
400 \begin_inset Argument 1
403 \begin_layout Plain Layout
422 , or perhaps a very short snippet.
425 \begin_layout Subsection
429 \begin_layout Standard
430 It is possible to have a direct feedback of what the music notation looks
431 like from within \SpecialChar LyX
433 To do this, wrap a LilyPond inset inside a Preview inset, which you find
436 Insert\SpecialChar menuseparator
440 This only affects the display within \SpecialChar LyX
444 \begin_layout Standard
447 \begin_layout Standard
448 \begin_inset Flex LilyPond
451 \begin_layout Plain Layout
458 \begin_layout Plain Layout
463 \begin_layout Plain Layout
478 \begin_layout Standard
479 Unfortunately, you might find that the preview isn't exactly instantaneous.
480 You need to move the cursor out of the Preview inset to start compilation,
481 and processing time can take a few seconds.
482 Nevertheless, the direct feedback is often worthwhile during editing, and
483 renders the navigation through the document much easier.
486 \begin_layout Subsection
490 \begin_layout Standard
491 A few gotchas that have been experienced with the integration of LilyPond-book
496 \begin_layout Subsubsection
500 \begin_layout Standard
502 document using the LilyPond module cannot have child documents using
504 \begin_inset Quotes eld
508 \begin_inset Quotes erd
513 \begin_inset Quotes eld
517 \begin_inset Quotes erd
521 \begin_inset Quotes eld
525 \begin_inset Quotes erd
530 Insert\SpecialChar menuseparator
531 File\SpecialChar menuseparator
538 , you will get an error when producing output.
539 This is due to the way LilyPond-book automatically processes these input
541 Since there is currently no command-line option to turn off this behavior
542 of LilyPond-book, it is suggested to use the
543 \begin_inset Quotes eld
547 \begin_inset Quotes erd
553 \begin_layout Standard
554 Note that it is possible to insert child documents which make use of the
555 LilyPond module, using either the
556 \begin_inset Quotes eld
560 \begin_inset Quotes erd
564 \begin_inset Quotes eld
568 \begin_inset Quotes erd
571 method, in a master document which does not make use of the LilyPond module.
572 For this to work you might have to add the line
575 \begin_layout LyX-Code
581 \begin_layout Standard
582 to your master document's preamble under
584 Document\SpecialChar menuseparator
590 \begin_layout Subsubsection
594 \begin_layout Standard
595 LilyPond-book searches for a
607 command when it decides if the code is only a fragment.
608 It is possible to include no LilyPond command at all, but in that case
609 {surrounding braces} are required.
610 Thus, in the following code,
613 \begin_layout LyX-Code
619 \begin_layout LyX-Code
625 \begin_layout LyX-Code
631 \begin_layout Standard
632 LilyPond-book gets confused:
635 \begin_layout LyX-Code
636 error: syntax error, unexpected NOTENAME_PITCH
639 \begin_layout LyX-Code
645 \begin_layout Standard
646 With surrounding braces, all is well:
649 \begin_layout Standard
652 \begin_layout Standard
653 \begin_inset Flex LilyPond
656 \begin_layout Plain Layout
658 {ais' f'' g' e''} % no
673 \begin_layout Standard
674 Writing the notes directly within braces without using any LilyPond command
675 is convenient when writing short snippets.
676 Advanced users will probably want to enter their musical content using
677 LilyPond variables and commands, which is of course supported.
680 \begin_layout Subsubsection
684 \begin_layout Standard
685 Another gotcha is with subsequent LilyPond snippets with
694 \begin_layout LyX-Code
700 \begin_layout LyX-Code
705 fret-diagram-terse #"x;3;2;o;1;o;" }
708 \begin_layout LyX-Code
714 \begin_layout LyX-Code
718 \begin_layout LyX-Code
724 \begin_layout LyX-Code
729 fret-diagram-terse #"x;x;o;2;3;2;" }
732 \begin_layout LyX-Code
738 \begin_layout Standard
739 For some reason LilyPond-book version 2.13 barks on this when run in safe
740 mode (which you always should use, unless you know what you are doing).
741 This has been corrected as of version 2.15 (was LilyPond issue #1900).
744 \begin_layout Subsubsection
754 \begin_layout Standard
755 LilyPond-book supports including LilyPond code that resides in external
763 With this command, the LilyPond code is processed as if it was typed inside
764 the document and the output score follows the typesetting determined by
766 with respect to line width, page breaks, and so on.
767 This is in contrast to the long-standing \SpecialChar LyX
768 feature to include LilyPond scores
769 as external material, which calls LilyPond on the external file to produce
770 a rigid figure, and includes this figure in the document, leaving the typesetti
771 ng decisions to LilyPond.
772 Unfortunately, support for the
778 command in \SpecialChar LyX
779 is not implemented yet, but it is possible to use it inside
781 -Code block, provided that one writes the complete, absolute path to
785 \begin_layout Section
787 \begin_inset CommandInset label
789 name "sec:LilyPond-examples"
796 \begin_layout Standard
798 \begin_inset CommandInset ref
800 reference "subsec:Editorial-headword"
804 shows a complex score using many LilyPond constructs; some scheme code
805 has been removed from the original source of this snippet, to be able to
808 \begin_inset CommandInset ref
810 reference "subsec:Tablatures-template"
814 shows another LilyPond output which should be interesting to guitarists.
817 \begin_layout Subsection
819 \begin_inset CommandInset label
821 name "subsec:Editorial-headword"
828 \begin_layout Standard
829 NR 1.7 Editorial annotations Beethoven, Op.
831 3 Piano sonata 18, Movt II, Scherzo Measures 9–14.
834 \begin_layout Standard
839 \begin_layout Standard
840 \begin_inset Flex LilyPond
843 \begin_layout Plain Layout
850 \begin_layout Plain Layout
855 \begin_layout Plain Layout
860 \begin_layout Plain Layout
867 \begin_layout Plain Layout
874 \begin_layout Plain Layout
883 \begin_layout Plain Layout
890 \begin_layout Plain Layout
894 set Staff.fingeringOrientations = #'(up)
897 \begin_layout Plain Layout
901 set Score.currentBarNumber = #9
904 \begin_layout Plain Layout
911 \begin_layout Plain Layout
918 \begin_layout Plain Layout
923 \begin_layout Plain Layout
927 set doubleSlurs = ##t
930 \begin_layout Plain Layout
935 \begin_layout Plain Layout
942 \begin_layout Plain Layout
949 \begin_layout Plain Layout
958 \begin_layout Plain Layout
963 \begin_layout Plain Layout
970 \begin_layout Plain Layout
975 \begin_layout Plain Layout
980 \begin_layout Plain Layout
987 \begin_layout Plain Layout
994 \begin_layout Plain Layout
999 \begin_layout Plain Layout
1004 \begin_layout Plain Layout
1009 \begin_layout Plain Layout
1015 override Script #'script-priority = #-100
1018 \begin_layout Plain Layout
1025 \begin_layout Plain Layout
1036 \begin_layout Plain Layout
1041 \begin_layout Plain Layout
1046 \begin_layout Plain Layout
1051 \begin_layout Plain Layout
1056 \begin_layout Plain Layout
1063 \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
1100 \begin_layout Plain Layout
1107 \begin_layout Plain Layout
1116 \begin_layout Plain Layout
1123 \begin_layout Plain Layout
1127 override Fingering #'direction = #down
1130 \begin_layout Plain Layout
1134 set Staff.fingeringOrientations = #'(down)
1137 \begin_layout Plain Layout
1144 \begin_layout Plain Layout
1151 \begin_layout Plain Layout
1155 set doubleSlurs = ##t
1158 \begin_layout Plain Layout
1163 \begin_layout Plain Layout
1170 \begin_layout Plain Layout
1177 \begin_layout Plain Layout
1184 \begin_layout Plain Layout
1191 \begin_layout Plain Layout
1196 \begin_layout Plain Layout
1200 set doubleSlurs = ##f
1203 \begin_layout Plain Layout
1208 \begin_layout Plain Layout
1213 \begin_layout Plain Layout
1220 \begin_layout Plain Layout
1227 \begin_layout Plain Layout
1232 \begin_layout Plain Layout
1237 \begin_layout Plain Layout
1242 \begin_layout Plain Layout
1249 \begin_layout Plain Layout
1260 \begin_layout Plain Layout
1265 \begin_layout Plain Layout
1270 \begin_layout Plain Layout
1275 \begin_layout Plain Layout
1280 \begin_layout Plain Layout
1287 \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
1319 \begin_layout Plain Layout
1333 \begin_layout Standard
1336 \begin_inset Flex URL
1339 \begin_layout Plain Layout
1341 http://lsr.di.unimi.it/LSR/Item?id=627
1346 ; scheme code removed, centering applied through the paragraph settings]
1349 \begin_layout Subsection
1351 \begin_inset CommandInset label
1353 name "subsec:Tablatures-template"
1360 \begin_layout Standard
1361 \begin_inset Preview
1363 \begin_layout Standard
1364 \begin_inset Flex LilyPond
1367 \begin_layout Plain Layout
1374 \begin_layout Plain Layout
1380 \begin_layout Plain Layout
1385 \begin_layout Plain Layout
1392 \begin_layout Plain Layout
1397 \begin_layout Plain Layout
1402 \begin_layout Plain Layout
1409 \begin_layout Plain Layout
1416 \begin_layout Plain Layout
1420 new Staff = "guitar" <<
1423 \begin_layout Plain Layout
1427 context Voice = "upper guitar" {
1436 \begin_layout Plain Layout
1440 context Voice = "lower guitar" {
1449 \begin_layout Plain Layout
1454 \begin_layout Plain Layout
1458 new TabStaff = "tab" <<
1461 \begin_layout Plain Layout
1465 context TabVoice = "upper tab" {
1474 \begin_layout Plain Layout
1478 context TabVoice = "lower tab" {
1487 \begin_layout Plain Layout
1492 \begin_layout Plain Layout
1497 \begin_layout Plain Layout
1512 \begin_layout Standard
1515 \begin_inset Flex URL
1518 \begin_layout Plain Layout
1520 http://lsr.di.unimi.it/LSR/Item?id=634