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 0
58 \use_package stackrel 0
59 \use_package stmaryrd 0
60 \use_package undertilde 0
62 \cite_engine_type default
66 \paperorientation portrait
80 \paragraph_separation indent
81 \paragraph_indentation default
86 \paperpagestyle default
87 \tracking_changes false
97 LilyPond-book and \SpecialChar LyX
110 \begin_layout Abstract
111 This document explains and demonstrates the inclusion of musical snippets
112 in a \SpecialChar LyX
113 document, using the LilyPond syntax for music notation and the LilyPond-b
114 ook utility for processing.
117 \begin_layout Section
121 \begin_layout Standard
122 LilyPond is an open-source project that renders possible the creation of
123 beautiful computer-generated musical scores.
124 The project consists of a text-based music notation language, and a program
125 to process this notation into musical scores.
128 \begin_layout Standard
129 While LilyPond itself supports the display of title, author information,
130 footnotes, endnotes, etc., its primary focus is on music typesetting.
131 For text typesetting, other programs are generally better suited.
132 LilyPond-book is a utility provided by the LilyPond project that helps
133 incorporate musical scores using the LilyPond notation into \SpecialChar LaTeX
138 \begin_layout Standard
139 This document describes the use of the LilyPond music notation within \SpecialChar LyX
141 that use a \SpecialChar LaTeX
142 -based layout, thus combining the beauty and quality of the
143 typesetting achieved by both \SpecialChar LaTeX
145 While a basic understanding of the LilyPond syntax for music notation is
146 in order, knowledge of \SpecialChar LaTeX
147 is not necessary when using \SpecialChar LyX
151 \begin_layout Standard
153 \begin_inset CommandInset ref
155 reference "sec:Using-LilyPond-code"
159 explains the requirements, usage instructions, and shortcomings of LilyPond
160 music notation within \SpecialChar LyX
163 \begin_inset CommandInset ref
165 reference "sec:LilyPond-examples"
169 demonstrates the beauty and quality of the typesetting with a few examples.
172 \begin_layout Section
173 Using LilyPond code within \SpecialChar LyX
175 \begin_inset CommandInset label
177 name "sec:Using-LilyPond-code"
184 \begin_layout Standard
185 Support for LilyPond music notation (LilyPond code) within \SpecialChar LyX
187 adding the LilyPond module to your document.
188 This is done from the menu
190 Document\SpecialChar menuseparator
193 , then selecting LilyPond in the list of modules.
194 You can use any \SpecialChar LaTeX
195 -based \SpecialChar LyX
196 layout and use the regular preview and export mechanism
198 will take care of processing the mixed \SpecialChar LaTeX
199 /LilyPond code through LilyPond-book
201 LilyPond-book can also handle DocBook and HTML documents, but the integration
202 of these document types with LilyPond-book and \SpecialChar LyX
203 is missing at the moment.
206 \begin_layout Subsection
210 \begin_layout Standard
211 LilyPond-book version 2.13 or newer.
215 \begin_layout Plain Layout
216 LilyPond-book supports \SpecialChar LaTeX
217 output since version 2.1.
218 However, some features used by \SpecialChar LyX
219 are available only in recent versions:
220 PDF\SpecialChar LaTeX
221 support (version 2.9), the
225 flag (version 2.11) and especially the
237 \begin_layout Subsection
241 \begin_layout Standard
242 The module provides a LilyPond inset which you insert from the menu
244 Insert\SpecialChar menuseparator
252 This inset is for typing the LilyPond code which will be typeset into your
254 First, let us try a simple scale:
257 \begin_layout Standard
258 \begin_inset Flex LilyPond
261 \begin_layout Plain Layout
263 \begin_inset Argument 1
266 \begin_layout Plain Layout
275 \begin_layout Plain Layout
282 \begin_layout Plain Layout
287 \begin_layout Plain Layout
297 \begin_layout Standard
299 The previous \SpecialChar LyX
300 inset produces the following \SpecialChar LaTeX
304 \begin_layout LyX-Code
307 begin{lilypond}[staffsize=28]
310 \begin_layout LyX-Code
314 \begin_layout LyX-Code
320 \begin_layout LyX-Code
324 \begin_layout LyX-Code
328 \begin_layout LyX-Code
334 \begin_layout Standard
335 What appear first inside square brackets are options to pass to LilyPond-book.
336 This is inserted in \SpecialChar LyX
341 menu, in the same way that the LilyPond inset itself is inserted.
342 Here, we set the dimension of the staff to 28
343 \begin_inset space \thinspace{}
347 Other options can be added by separating them by a comma, for example:
350 [staffsize=28,verbatim]
353 A list of music fragment options is available in the LilyPond documentation.
354 This whole block can be omitted when the default settings are desired.
357 \begin_layout Standard
358 What follows after the options block is the textual representation in LilyPond
359 syntax of a musical fragment.
360 This code is not, in fact, processed by \SpecialChar LaTeX
361 , but is preprocessed by LilyPond-book,
362 which creates the graphics files and includes them in the \SpecialChar LaTeX
364 replacing the above with a
368 includegraphics{\SpecialChar ldots
374 \begin_layout Standard
375 Thus, the conversion process is as follow:
378 \SpecialChar menuseparator
379 LilyPond-book\SpecialChar menuseparator
385 creates a .lytex file, LilyPond-book creates a .tex files and the accompanying
386 image files, and \SpecialChar LaTeX
387 creates the final document.
388 Every step of the tool chain obeys your spacing, so whether you put the
389 musical extract inline, or in its own paragraph, centered, left-aligned,
390 etc., what you see in the \SpecialChar LyX
391 window should be respected in the final format.
392 An example of inline use may be to display a chord name, such as
393 \begin_inset Flex LilyPond
396 \begin_layout Plain Layout
398 \begin_inset Argument 1
401 \begin_layout Plain Layout
420 , or perhaps a very short snippet.
423 \begin_layout Subsection
427 \begin_layout Standard
428 It is possible to have a direct feedback of what the music notation looks
429 like from within \SpecialChar LyX
431 To do this, wrap a LilyPond inset inside a Preview inset, which you find
434 Insert\SpecialChar menuseparator
438 This only affects the display within \SpecialChar LyX
442 \begin_layout Standard
445 \begin_layout Standard
446 \begin_inset Flex LilyPond
449 \begin_layout Plain Layout
456 \begin_layout Plain Layout
461 \begin_layout Plain Layout
476 \begin_layout Standard
477 Unfortunately, you might find that the preview isn't exactly instantaneous.
478 You need to move the cursor out of the Preview inset to start compilation,
479 and processing time can take a few seconds.
480 Nevertheless, the direct feedback is often worthwhile during editing, and
481 renders the navigation through the document much easier.
484 \begin_layout Subsection
488 \begin_layout Standard
489 A few gotchas that have been experienced with the integration of LilyPond-book
494 \begin_layout Subsubsection
498 \begin_layout Standard
500 document using the LilyPond module cannot have child documents using
502 \begin_inset Quotes eld
506 \begin_inset Quotes erd
511 \begin_inset Quotes eld
515 \begin_inset Quotes erd
519 \begin_inset Quotes eld
523 \begin_inset Quotes erd
528 Insert\SpecialChar menuseparator
529 File\SpecialChar menuseparator
536 , you will get an error when producing output.
537 This is due to the way LilyPond-book automatically processes these input
539 Since there is currently no command-line option to turn off this behavior
540 of LilyPond-book, it is suggested to use the
541 \begin_inset Quotes eld
545 \begin_inset Quotes erd
551 \begin_layout Standard
552 Note that it is possible to insert child documents which make use of the
553 LilyPond module, using either the
554 \begin_inset Quotes eld
558 \begin_inset Quotes erd
562 \begin_inset Quotes eld
566 \begin_inset Quotes erd
569 method, in a master document which does not make use of the LilyPond module.
570 For this to work you might have to add the line
573 \begin_layout LyX-Code
579 \begin_layout Standard
580 to your master document's preamble under
582 Document\SpecialChar menuseparator
588 \begin_layout Subsubsection
592 \begin_layout Standard
593 LilyPond-book searches for a
605 command when it decides if the code is only a fragment.
606 It is possible to include no LilyPond command at all, but in that case
607 {surrounding braces} are required.
608 Thus, in the following code,
611 \begin_layout LyX-Code
617 \begin_layout LyX-Code
623 \begin_layout LyX-Code
629 \begin_layout Standard
630 LilyPond-book gets confused:
633 \begin_layout LyX-Code
634 error: syntax error, unexpected NOTENAME_PITCH
637 \begin_layout LyX-Code
643 \begin_layout Standard
644 With surrounding braces, all is well:
647 \begin_layout Standard
650 \begin_layout Standard
651 \begin_inset Flex LilyPond
654 \begin_layout Plain Layout
656 {ais' f'' g' e''} % no
671 \begin_layout Standard
672 Writing the notes directly within braces without using any LilyPond command
673 is convenient when writing short snippets.
674 Advanced users will probably want to enter their musical content using
675 LilyPond variables and commands, which is of course supported.
678 \begin_layout Subsubsection
682 \begin_layout Standard
683 Another gotcha is with subsequent LilyPond snippets with
692 \begin_layout LyX-Code
698 \begin_layout LyX-Code
703 fret-diagram-terse #"x;3;2;o;1;o;" }
706 \begin_layout LyX-Code
712 \begin_layout LyX-Code
716 \begin_layout LyX-Code
722 \begin_layout LyX-Code
727 fret-diagram-terse #"x;x;o;2;3;2;" }
730 \begin_layout LyX-Code
736 \begin_layout Standard
737 For some reason LilyPond-book version 2.13 barks on this when run in safe
738 mode (which you always should use, unless you know what you are doing).
739 This has been corrected as of version 2.15 (was LilyPond issue #1900).
742 \begin_layout Subsubsection
752 \begin_layout Standard
753 LilyPond-book supports including LilyPond code that resides in external
761 With this command, the LilyPond code is processed as if it was typed inside
762 the document and the output score follows the typesetting determined by
764 with respect to line width, page breaks, and so on.
765 This is in contrast to the long-standing \SpecialChar LyX
766 feature to include LilyPond scores
767 as external material, which calls LilyPond on the external file to produce
768 a rigid figure, and includes this figure in the document, leaving the typesetti
769 ng decisions to LilyPond.
770 Unfortunately, support for the
776 command in \SpecialChar LyX
777 is not implemented yet, but it is possible to use it inside
779 -Code block, provided that one writes the complete, absolute path to
783 \begin_layout Section
785 \begin_inset CommandInset label
787 name "sec:LilyPond-examples"
794 \begin_layout Standard
796 \begin_inset CommandInset ref
798 reference "subsec:Editorial-headword"
802 shows a complex score using many LilyPond constructs; some scheme code
803 has been removed from the original source of this snippet, to be able to
806 \begin_inset CommandInset ref
808 reference "subsec:Tablatures-template"
812 shows another LilyPond output which should be interesting to guitarists.
815 \begin_layout Subsection
817 \begin_inset CommandInset label
819 name "subsec:Editorial-headword"
826 \begin_layout Standard
827 NR 1.7 Editorial annotations Beethoven, Op.
829 3 Piano sonata 18, Movt II, Scherzo Measures 9–14.
832 \begin_layout Standard
837 \begin_layout Standard
838 \begin_inset Flex LilyPond
841 \begin_layout Plain Layout
848 \begin_layout Plain Layout
853 \begin_layout Plain Layout
858 \begin_layout Plain Layout
865 \begin_layout Plain Layout
872 \begin_layout Plain Layout
881 \begin_layout Plain Layout
888 \begin_layout Plain Layout
892 set Staff.fingeringOrientations = #'(up)
895 \begin_layout Plain Layout
899 set Score.currentBarNumber = #9
902 \begin_layout Plain Layout
909 \begin_layout Plain Layout
916 \begin_layout Plain Layout
921 \begin_layout Plain Layout
925 set doubleSlurs = ##t
928 \begin_layout Plain Layout
933 \begin_layout Plain Layout
940 \begin_layout Plain Layout
947 \begin_layout Plain Layout
956 \begin_layout Plain Layout
961 \begin_layout Plain Layout
968 \begin_layout Plain Layout
973 \begin_layout Plain Layout
978 \begin_layout Plain Layout
985 \begin_layout Plain Layout
992 \begin_layout Plain Layout
997 \begin_layout Plain Layout
1002 \begin_layout Plain Layout
1007 \begin_layout Plain Layout
1013 override Script #'script-priority = #-100
1016 \begin_layout Plain Layout
1023 \begin_layout Plain Layout
1034 \begin_layout Plain Layout
1039 \begin_layout Plain Layout
1044 \begin_layout Plain Layout
1049 \begin_layout Plain Layout
1054 \begin_layout Plain Layout
1061 \begin_layout Plain Layout
1068 \begin_layout Plain Layout
1073 \begin_layout Plain Layout
1078 \begin_layout Plain Layout
1083 \begin_layout Plain Layout
1088 \begin_layout Plain Layout
1093 \begin_layout Plain Layout
1098 \begin_layout Plain Layout
1105 \begin_layout Plain Layout
1114 \begin_layout Plain Layout
1121 \begin_layout Plain Layout
1125 override Fingering #'direction = #down
1128 \begin_layout Plain Layout
1132 set Staff.fingeringOrientations = #'(down)
1135 \begin_layout Plain Layout
1142 \begin_layout Plain Layout
1149 \begin_layout Plain Layout
1153 set doubleSlurs = ##t
1156 \begin_layout Plain Layout
1161 \begin_layout Plain Layout
1168 \begin_layout Plain Layout
1175 \begin_layout Plain Layout
1182 \begin_layout Plain Layout
1189 \begin_layout Plain Layout
1194 \begin_layout Plain Layout
1198 set doubleSlurs = ##f
1201 \begin_layout Plain Layout
1206 \begin_layout Plain Layout
1211 \begin_layout Plain Layout
1218 \begin_layout Plain Layout
1225 \begin_layout Plain Layout
1230 \begin_layout Plain Layout
1235 \begin_layout Plain Layout
1240 \begin_layout Plain Layout
1247 \begin_layout Plain Layout
1258 \begin_layout Plain Layout
1263 \begin_layout Plain Layout
1268 \begin_layout Plain Layout
1273 \begin_layout Plain Layout
1278 \begin_layout Plain Layout
1285 \begin_layout Plain Layout
1292 \begin_layout Plain Layout
1297 \begin_layout Plain Layout
1302 \begin_layout Plain Layout
1307 \begin_layout Plain Layout
1312 \begin_layout Plain Layout
1317 \begin_layout Plain Layout
1331 \begin_layout Standard
1334 \begin_inset Flex URL
1337 \begin_layout Plain Layout
1339 http://lsr.di.unimi.it/LSR/Item?id=627
1344 ; scheme code removed, centering applied through the paragraph settings]
1347 \begin_layout Subsection
1349 \begin_inset CommandInset label
1351 name "subsec:Tablatures-template"
1358 \begin_layout Standard
1359 \begin_inset Preview
1361 \begin_layout Standard
1362 \begin_inset Flex LilyPond
1365 \begin_layout Plain Layout
1372 \begin_layout Plain Layout
1378 \begin_layout Plain Layout
1383 \begin_layout Plain Layout
1390 \begin_layout Plain Layout
1395 \begin_layout Plain Layout
1400 \begin_layout Plain Layout
1407 \begin_layout Plain Layout
1414 \begin_layout Plain Layout
1418 new Staff = "guitar" <<
1421 \begin_layout Plain Layout
1425 context Voice = "upper guitar" {
1434 \begin_layout Plain Layout
1438 context Voice = "lower guitar" {
1447 \begin_layout Plain Layout
1452 \begin_layout Plain Layout
1456 new TabStaff = "tab" <<
1459 \begin_layout Plain Layout
1463 context TabVoice = "upper tab" {
1472 \begin_layout Plain Layout
1476 context TabVoice = "lower tab" {
1485 \begin_layout Plain Layout
1490 \begin_layout Plain Layout
1495 \begin_layout Plain Layout
1510 \begin_layout Standard
1513 \begin_inset Flex URL
1516 \begin_layout Plain Layout
1518 http://lsr.di.unimi.it/LSR/Item?id=634