1 #LyX 2.4 created this file. For more info see https://www.lyx.org/
5 \save_transient_properties true
6 \origin /systemlyxdir/examples/Modules/
8 \use_default_options true
12 \maintain_unincluded_children no
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
26 \font_typewriter_osf false
27 \font_sf_scale 100 100
28 \font_tt_scale 100 100
30 \use_dash_ligatures false
32 \default_output_format default
34 \bibtex_command default
35 \index_command default
36 \paperfontsize default
39 \pdf_title "LilyPond-book and LyX"
40 \pdf_author "The LyX Team"
42 \pdf_bookmarksnumbered true
43 \pdf_bookmarksopen true
44 \pdf_bookmarksopenlevel 1
49 \pdf_pdfusetitle false
50 \pdf_quoted_options "linkcolor=blue,urlcolor=blue,pdfstartview=XYZ"
53 \use_package amsmath 1
54 \use_package amssymb 1
57 \use_package mathdots 1
58 \use_package mathtools 1
60 \use_package stackrel 1
61 \use_package stmaryrd 1
62 \use_package undertilde 1
64 \cite_engine_type default
68 \paperorientation portrait
84 \paragraph_separation indent
85 \paragraph_indentation default
87 \math_numbering_side default
92 \paperpagestyle default
94 \tracking_changes false
97 \postpone_fragile_content false
101 \docbook_table_output 0
102 \docbook_mathml_prefix 1
108 LilyPond-book and \SpecialChar LyX
117 \begin_layout Abstract
118 This document explains and demonstrates the inclusion of musical snippets
119 in a \SpecialChar LyX
120 document, using the LilyPond syntax for music notation and the LilyPond-b
121 ook utility for processing.
124 \begin_layout Section
128 \begin_layout Standard
129 LilyPond is an open-source project that renders possible the creation of
130 beautiful computer-generated musical scores.
131 The project consists of a text-based music notation language, and a program
132 to process this notation into musical scores.
135 \begin_layout Standard
136 While LilyPond itself supports the display of title, author information,
137 footnotes, endnotes, etc., its primary focus is on music typesetting.
138 For text typesetting, other programs are generally better suited.
139 LilyPond-book is a utility provided by the LilyPond project that helps
140 incorporate musical scores using the LilyPond notation into \SpecialChar LaTeX
145 \begin_layout Standard
146 This document describes the use of the LilyPond music notation within \SpecialChar LyX
148 that use a \SpecialChar LaTeX
149 -based layout, thus combining the beauty and quality of the
150 typesetting achieved by both \SpecialChar LaTeX
152 While a basic understanding of the LilyPond syntax for music notation is
153 in order, knowledge of \SpecialChar LaTeX
154 is not necessary when using \SpecialChar LyX
158 \begin_layout Standard
160 \begin_inset CommandInset ref
162 reference "sec:Using-LilyPond-code"
166 explains the requirements, usage instructions, and shortcomings of LilyPond
167 music notation within \SpecialChar LyX
170 \begin_inset CommandInset ref
172 reference "sec:LilyPond-examples"
176 demonstrates the beauty and quality of the typesetting with a few examples.
179 \begin_layout Section
180 Using LilyPond code within \SpecialChar LyX
182 \begin_inset CommandInset label
184 name "sec:Using-LilyPond-code"
191 \begin_layout Standard
192 Support for LilyPond music notation (LilyPond code) within \SpecialChar LyX
194 adding the LilyPond module to your document.
195 This is done from the menu
197 Document\SpecialChar menuseparator
200 , then selecting LilyPond in the list of modules.
201 You can use any \SpecialChar LaTeX
202 -based \SpecialChar LyX
203 layout and use the regular preview and export mechanism
205 will take care of processing the mixed \SpecialChar LaTeX
206 /LilyPond code through LilyPond-book
208 LilyPond-book can also handle DocBook and HTML documents, but the integration
209 of these document types with LilyPond-book and \SpecialChar LyX
210 is missing at the moment.
213 \begin_layout Subsection
217 \begin_layout Standard
218 LilyPond-book version 2.13 or newer.
222 \begin_layout Plain Layout
223 LilyPond-book supports \SpecialChar LaTeX
224 output since version 2.1.
225 However, some features used by \SpecialChar LyX
226 are available only in recent versions:
227 PDF\SpecialChar LaTeX
228 support (version 2.9), the
232 flag (version 2.11) and especially the
244 \begin_layout Subsection
248 \begin_layout Standard
249 The module provides a LilyPond inset which you insert from the menu
251 Insert\SpecialChar menuseparator
259 This inset is for typing the LilyPond code which will be typeset into your
261 First, let us try a simple scale:
264 \begin_layout Standard
265 \begin_inset Flex LilyPond
268 \begin_layout Plain Layout
270 \begin_inset Argument 1
273 \begin_layout Plain Layout
283 \begin_layout Plain Layout
290 \begin_layout Plain Layout
295 \begin_layout Plain Layout
305 \begin_layout Standard
307 The previous \SpecialChar LyX
308 inset produces the following \SpecialChar LaTeX
312 \begin_layout LyX-Code
315 begin{lilypond}[staffsize=28]
318 \begin_layout LyX-Code
322 \begin_layout LyX-Code
328 \begin_layout LyX-Code
332 \begin_layout LyX-Code
336 \begin_layout LyX-Code
342 \begin_layout Standard
343 What appear first inside square brackets are options to pass to LilyPond-book.
344 This is inserted in \SpecialChar LyX
349 menu, in the same way that the LilyPond inset itself is inserted.
350 Here, we set the dimension of the staff to 28
351 \begin_inset space \thinspace{}
355 Other options can be added by separating them by a comma, for example:
358 [staffsize=28,verbatim]
361 A list of music fragment options is available in the LilyPond documentation.
362 This whole block can be omitted when the default settings are desired.
365 \begin_layout Standard
366 What follows after the options block is the textual representation in LilyPond
367 syntax of a musical fragment.
368 This code is not, in fact, processed by \SpecialChar LaTeX
369 , but is preprocessed by LilyPond-book,
370 which creates the graphics files and includes them in the \SpecialChar LaTeX
372 replacing the above with a
376 includegraphics{\SpecialChar ldots
382 \begin_layout Standard
383 Thus, the conversion process is as follow:
386 \SpecialChar menuseparator
387 LilyPond-book\SpecialChar menuseparator
393 creates a .lytex file, LilyPond-book creates a .tex files and the accompanying
394 image files, and \SpecialChar LaTeX
395 creates the final document.
396 Every step of the tool chain obeys your spacing, so whether you put the
397 musical extract inline, or in its own paragraph, centered, left-aligned,
398 etc., what you see in the \SpecialChar LyX
399 window should be respected in the final format.
400 An example of inline use may be to display a chord name, such as
401 \begin_inset Flex LilyPond
404 \begin_layout Plain Layout
406 \begin_inset Argument 1
409 \begin_layout Plain Layout
429 , or perhaps a very short snippet.
432 \begin_layout Subsection
436 \begin_layout Standard
437 It is possible to have a direct feedback of what the music notation looks
438 like from within \SpecialChar LyX
440 To do this, wrap a LilyPond inset inside a Preview inset, which you find
443 Insert\SpecialChar menuseparator
447 This only affects the display within \SpecialChar LyX
451 \begin_layout Standard
454 \begin_layout Standard
455 \begin_inset Flex LilyPond
458 \begin_layout Plain Layout
465 \begin_layout Plain Layout
470 \begin_layout Plain Layout
485 \begin_layout Standard
486 Unfortunately, you might find that the preview isn't exactly instantaneous.
487 You need to move the cursor out of the Preview inset to start compilation,
488 and processing time can take a few seconds.
489 Nevertheless, the direct feedback is often worthwhile during editing, and
490 renders the navigation through the document much easier.
493 \begin_layout Subsection
497 \begin_layout Standard
498 A few gotchas that have been experienced with the integration of LilyPond-book
503 \begin_layout Subsubsection
507 \begin_layout Standard
509 document using the LilyPond module cannot have child documents using
511 \begin_inset Quotes eld
515 \begin_inset Quotes erd
520 \begin_inset Quotes eld
524 \begin_inset Quotes erd
528 \begin_inset Quotes eld
532 \begin_inset Quotes erd
537 Insert\SpecialChar menuseparator
538 File\SpecialChar menuseparator
545 , you will get an error when producing output.
546 This is due to the way LilyPond-book automatically processes these input
548 Since there is currently no command-line option to turn off this behavior
549 of LilyPond-book, it is suggested to use the
550 \begin_inset Quotes eld
554 \begin_inset Quotes erd
560 \begin_layout Standard
561 Note that it is possible to insert child documents which make use of the
562 LilyPond module, using either the
563 \begin_inset Quotes eld
567 \begin_inset Quotes erd
571 \begin_inset Quotes eld
575 \begin_inset Quotes erd
578 method, in a master document which does not make use of the LilyPond module.
579 For this to work you might have to add the line
582 \begin_layout LyX-Code
588 \begin_layout Standard
589 to your master document's preamble under
591 Document\SpecialChar menuseparator
597 \begin_layout Subsubsection
601 \begin_layout Standard
602 LilyPond-book searches for a
614 command when it decides if the code is only a fragment.
615 It is possible to include no LilyPond command at all, but in that case
616 {surrounding braces} are required.
617 Thus, in the following code,
620 \begin_layout LyX-Code
626 \begin_layout LyX-Code
632 \begin_layout LyX-Code
638 \begin_layout Standard
639 LilyPond-book gets confused:
642 \begin_layout LyX-Code
643 error: syntax error, unexpected NOTENAME_PITCH
646 \begin_layout LyX-Code
652 \begin_layout Standard
653 With surrounding braces, all is well:
656 \begin_layout Standard
659 \begin_layout Standard
660 \begin_inset Flex LilyPond
663 \begin_layout Plain Layout
665 {ais' f'' g' e''} % no
680 \begin_layout Standard
681 Writing the notes directly within braces without using any LilyPond command
682 is convenient when writing short snippets.
683 Advanced users will probably want to enter their musical content using
684 LilyPond variables and commands, which is of course supported.
687 \begin_layout Subsubsection
691 \begin_layout Standard
692 Another gotcha is with subsequent LilyPond snippets with
701 \begin_layout LyX-Code
707 \begin_layout LyX-Code
712 fret-diagram-terse #"x;3;2;o;1;o;" }
715 \begin_layout LyX-Code
721 \begin_layout LyX-Code
725 \begin_layout LyX-Code
731 \begin_layout LyX-Code
736 fret-diagram-terse #"x;x;o;2;3;2;" }
739 \begin_layout LyX-Code
745 \begin_layout Standard
746 For some reason LilyPond-book version 2.13 barks on this when run in safe
747 mode (which you always should use, unless you know what you are doing).
748 This has been corrected as of version 2.15 (was LilyPond issue #1900).
751 \begin_layout Subsubsection
761 \begin_layout Standard
762 LilyPond-book supports including LilyPond code that resides in external
770 With this command, the LilyPond code is processed as if it was typed inside
771 the document and the output score follows the typesetting determined by
773 with respect to line width, page breaks, and so on.
774 This is in contrast to the long-standing \SpecialChar LyX
775 feature to include LilyPond scores
776 as external material, which calls LilyPond on the external file to produce
777 a rigid figure, and includes this figure in the document, leaving the typesetti
778 ng decisions to LilyPond.
779 Unfortunately, support for the
785 command in \SpecialChar LyX
786 is not implemented yet, but it is possible to use it inside
788 -Code block, provided that one writes the complete, absolute path to
792 \begin_layout Section
794 \begin_inset CommandInset label
796 name "sec:LilyPond-examples"
803 \begin_layout Standard
805 \begin_inset CommandInset ref
807 reference "subsec:Editorial-headword"
811 shows a complex score using many LilyPond constructs; some scheme code
812 has been removed from the original source of this snippet, to be able to
815 \begin_inset CommandInset ref
817 reference "subsec:Tablatures-template"
821 shows another LilyPond output which should be interesting to guitarists.
824 \begin_layout Subsection
826 \begin_inset CommandInset label
828 name "subsec:Editorial-headword"
835 \begin_layout Standard
836 NR 1.7 Editorial annotations Beethoven, Op.
838 3 Piano sonata 18, Movt II, Scherzo Measures 9–14.
841 \begin_layout Standard
846 \begin_layout Standard
847 \begin_inset Flex LilyPond
850 \begin_layout Plain Layout
857 \begin_layout Plain Layout
862 \begin_layout Plain Layout
867 \begin_layout Plain Layout
874 \begin_layout Plain Layout
881 \begin_layout Plain Layout
890 \begin_layout Plain Layout
897 \begin_layout Plain Layout
901 set Staff.fingeringOrientations = #'(up)
904 \begin_layout Plain Layout
908 set Score.currentBarNumber = #9
911 \begin_layout Plain Layout
918 \begin_layout Plain Layout
925 \begin_layout Plain Layout
930 \begin_layout Plain Layout
934 set doubleSlurs = ##t
937 \begin_layout Plain Layout
942 \begin_layout Plain Layout
949 \begin_layout Plain Layout
956 \begin_layout Plain Layout
965 \begin_layout Plain Layout
970 \begin_layout Plain Layout
977 \begin_layout Plain Layout
982 \begin_layout Plain Layout
987 \begin_layout Plain Layout
994 \begin_layout Plain Layout
1001 \begin_layout Plain Layout
1006 \begin_layout Plain Layout
1011 \begin_layout Plain Layout
1016 \begin_layout Plain Layout
1022 override Script #'script-priority = #-100
1025 \begin_layout Plain Layout
1032 \begin_layout Plain Layout
1043 \begin_layout Plain Layout
1048 \begin_layout Plain Layout
1053 \begin_layout Plain Layout
1058 \begin_layout Plain Layout
1063 \begin_layout Plain Layout
1070 \begin_layout Plain Layout
1077 \begin_layout Plain Layout
1082 \begin_layout Plain Layout
1087 \begin_layout Plain Layout
1092 \begin_layout Plain Layout
1097 \begin_layout Plain Layout
1102 \begin_layout Plain Layout
1107 \begin_layout Plain Layout
1114 \begin_layout Plain Layout
1123 \begin_layout Plain Layout
1130 \begin_layout Plain Layout
1134 override Fingering #'direction = #down
1137 \begin_layout Plain Layout
1141 set Staff.fingeringOrientations = #'(down)
1144 \begin_layout Plain Layout
1151 \begin_layout Plain Layout
1158 \begin_layout Plain Layout
1162 set doubleSlurs = ##t
1165 \begin_layout Plain Layout
1170 \begin_layout Plain Layout
1177 \begin_layout Plain Layout
1184 \begin_layout Plain Layout
1191 \begin_layout Plain Layout
1198 \begin_layout Plain Layout
1203 \begin_layout Plain Layout
1207 set doubleSlurs = ##f
1210 \begin_layout Plain Layout
1215 \begin_layout Plain Layout
1220 \begin_layout Plain Layout
1227 \begin_layout Plain Layout
1234 \begin_layout Plain Layout
1239 \begin_layout Plain Layout
1244 \begin_layout Plain Layout
1249 \begin_layout Plain Layout
1256 \begin_layout Plain Layout
1267 \begin_layout Plain Layout
1272 \begin_layout Plain Layout
1277 \begin_layout Plain Layout
1282 \begin_layout Plain Layout
1287 \begin_layout Plain Layout
1294 \begin_layout Plain Layout
1301 \begin_layout Plain Layout
1306 \begin_layout Plain Layout
1311 \begin_layout Plain Layout
1316 \begin_layout Plain Layout
1321 \begin_layout Plain Layout
1326 \begin_layout Plain Layout
1340 \begin_layout Standard
1343 \begin_inset Flex URL
1346 \begin_layout Plain Layout
1348 http://lsr.di.unimi.it/LSR/Item?id=627
1353 ; scheme code removed, centering applied through the paragraph settings]
1356 \begin_layout Subsection
1358 \begin_inset CommandInset label
1360 name "subsec:Tablatures-template"
1367 \begin_layout Standard
1368 \begin_inset Preview
1370 \begin_layout Standard
1371 \begin_inset Flex LilyPond
1374 \begin_layout Plain Layout
1381 \begin_layout Plain Layout
1387 \begin_layout Plain Layout
1392 \begin_layout Plain Layout
1399 \begin_layout Plain Layout
1404 \begin_layout Plain Layout
1409 \begin_layout Plain Layout
1416 \begin_layout Plain Layout
1423 \begin_layout Plain Layout
1427 new Staff = "guitar" <<
1430 \begin_layout Plain Layout
1434 context Voice = "upper guitar" {
1443 \begin_layout Plain Layout
1447 context Voice = "lower guitar" {
1456 \begin_layout Plain Layout
1461 \begin_layout Plain Layout
1465 new TabStaff = "tab" <<
1468 \begin_layout Plain Layout
1472 context TabVoice = "upper tab" {
1481 \begin_layout Plain Layout
1485 context TabVoice = "lower tab" {
1494 \begin_layout Plain Layout
1499 \begin_layout Plain Layout
1504 \begin_layout Plain Layout
1519 \begin_layout Standard
1522 \begin_inset Flex URL
1525 \begin_layout Plain Layout
1527 http://lsr.di.unimi.it/LSR/Item?id=634