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
25 \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
93 \tracking_changes false
94 \postpone_fragile_content false
104 LilyPond-book and \SpecialChar LyX
113 \begin_layout Abstract
114 This document explains and demonstrates the inclusion of musical snippets
115 in a \SpecialChar LyX
116 document, using the LilyPond syntax for music notation and the LilyPond-b
117 ook utility for processing.
120 \begin_layout Section
124 \begin_layout Standard
125 LilyPond is an open-source project that renders possible the creation of
126 beautiful computer-generated musical scores.
127 The project consists of a text-based music notation language, and a program
128 to process this notation into musical scores.
131 \begin_layout Standard
132 While LilyPond itself supports the display of title, author information,
133 footnotes, endnotes, etc., its primary focus is on music typesetting.
134 For text typesetting, other programs are generally better suited.
135 LilyPond-book is a utility provided by the LilyPond project that helps
136 incorporate musical scores using the LilyPond notation into \SpecialChar LaTeX
141 \begin_layout Standard
142 This document describes the use of the LilyPond music notation within \SpecialChar LyX
144 that use a \SpecialChar LaTeX
145 -based layout, thus combining the beauty and quality of the
146 typesetting achieved by both \SpecialChar LaTeX
148 While a basic understanding of the LilyPond syntax for music notation is
149 in order, knowledge of \SpecialChar LaTeX
150 is not necessary when using \SpecialChar LyX
154 \begin_layout Standard
156 \begin_inset CommandInset ref
158 reference "sec:Using-LilyPond-code"
162 explains the requirements, usage instructions, and shortcomings of LilyPond
163 music notation within \SpecialChar LyX
166 \begin_inset CommandInset ref
168 reference "sec:LilyPond-examples"
172 demonstrates the beauty and quality of the typesetting with a few examples.
175 \begin_layout Section
176 Using LilyPond code within \SpecialChar LyX
178 \begin_inset CommandInset label
180 name "sec:Using-LilyPond-code"
187 \begin_layout Standard
188 Support for LilyPond music notation (LilyPond code) within \SpecialChar LyX
190 adding the LilyPond module to your document.
191 This is done from the menu
193 Document\SpecialChar menuseparator
196 , then selecting LilyPond in the list of modules.
197 You can use any \SpecialChar LaTeX
198 -based \SpecialChar LyX
199 layout and use the regular preview and export mechanism
201 will take care of processing the mixed \SpecialChar LaTeX
202 /LilyPond code through LilyPond-book
204 LilyPond-book can also handle DocBook and HTML documents, but the integration
205 of these document types with LilyPond-book and \SpecialChar LyX
206 is missing at the moment.
209 \begin_layout Subsection
213 \begin_layout Standard
214 LilyPond-book version 2.13 or newer.
218 \begin_layout Plain Layout
219 LilyPond-book supports \SpecialChar LaTeX
220 output since version 2.1.
221 However, some features used by \SpecialChar LyX
222 are available only in recent versions:
223 PDF\SpecialChar LaTeX
224 support (version 2.9), the
228 flag (version 2.11) and especially the
240 \begin_layout Subsection
244 \begin_layout Standard
245 The module provides a LilyPond inset which you insert from the menu
247 Insert\SpecialChar menuseparator
255 This inset is for typing the LilyPond code which will be typeset into your
257 First, let us try a simple scale:
260 \begin_layout Standard
261 \begin_inset Flex LilyPond
264 \begin_layout Plain Layout
266 \begin_inset Argument 1
269 \begin_layout Plain Layout
279 \begin_layout Plain Layout
286 \begin_layout Plain Layout
291 \begin_layout Plain Layout
301 \begin_layout Standard
303 The previous \SpecialChar LyX
304 inset produces the following \SpecialChar LaTeX
308 \begin_layout LyX-Code
311 begin{lilypond}[staffsize=28]
314 \begin_layout LyX-Code
318 \begin_layout LyX-Code
324 \begin_layout LyX-Code
328 \begin_layout LyX-Code
332 \begin_layout LyX-Code
338 \begin_layout Standard
339 What appear first inside square brackets are options to pass to LilyPond-book.
340 This is inserted in \SpecialChar LyX
345 menu, in the same way that the LilyPond inset itself is inserted.
346 Here, we set the dimension of the staff to 28
347 \begin_inset space \thinspace{}
351 Other options can be added by separating them by a comma, for example:
354 [staffsize=28,verbatim]
357 A list of music fragment options is available in the LilyPond documentation.
358 This whole block can be omitted when the default settings are desired.
361 \begin_layout Standard
362 What follows after the options block is the textual representation in LilyPond
363 syntax of a musical fragment.
364 This code is not, in fact, processed by \SpecialChar LaTeX
365 , but is preprocessed by LilyPond-book,
366 which creates the graphics files and includes them in the \SpecialChar LaTeX
368 replacing the above with a
372 includegraphics{\SpecialChar ldots
378 \begin_layout Standard
379 Thus, the conversion process is as follow:
382 \SpecialChar menuseparator
383 LilyPond-book\SpecialChar menuseparator
389 creates a .lytex file, LilyPond-book creates a .tex files and the accompanying
390 image files, and \SpecialChar LaTeX
391 creates the final document.
392 Every step of the tool chain obeys your spacing, so whether you put the
393 musical extract inline, or in its own paragraph, centered, left-aligned,
394 etc., what you see in the \SpecialChar LyX
395 window should be respected in the final format.
396 An example of inline use may be to display a chord name, such as
397 \begin_inset Flex LilyPond
400 \begin_layout Plain Layout
402 \begin_inset Argument 1
405 \begin_layout Plain Layout
425 , or perhaps a very short snippet.
428 \begin_layout Subsection
432 \begin_layout Standard
433 It is possible to have a direct feedback of what the music notation looks
434 like from within \SpecialChar LyX
436 To do this, wrap a LilyPond inset inside a Preview inset, which you find
439 Insert\SpecialChar menuseparator
443 This only affects the display within \SpecialChar LyX
447 \begin_layout Standard
450 \begin_layout Standard
451 \begin_inset Flex LilyPond
454 \begin_layout Plain Layout
461 \begin_layout Plain Layout
466 \begin_layout Plain Layout
481 \begin_layout Standard
482 Unfortunately, you might find that the preview isn't exactly instantaneous.
483 You need to move the cursor out of the Preview inset to start compilation,
484 and processing time can take a few seconds.
485 Nevertheless, the direct feedback is often worthwhile during editing, and
486 renders the navigation through the document much easier.
489 \begin_layout Subsection
493 \begin_layout Standard
494 A few gotchas that have been experienced with the integration of LilyPond-book
499 \begin_layout Subsubsection
503 \begin_layout Standard
505 document using the LilyPond module cannot have child documents using
507 \begin_inset Quotes eld
511 \begin_inset Quotes erd
516 \begin_inset Quotes eld
520 \begin_inset Quotes erd
524 \begin_inset Quotes eld
528 \begin_inset Quotes erd
533 Insert\SpecialChar menuseparator
534 File\SpecialChar menuseparator
541 , you will get an error when producing output.
542 This is due to the way LilyPond-book automatically processes these input
544 Since there is currently no command-line option to turn off this behavior
545 of LilyPond-book, it is suggested to use the
546 \begin_inset Quotes eld
550 \begin_inset Quotes erd
556 \begin_layout Standard
557 Note that it is possible to insert child documents which make use of the
558 LilyPond module, using either the
559 \begin_inset Quotes eld
563 \begin_inset Quotes erd
567 \begin_inset Quotes eld
571 \begin_inset Quotes erd
574 method, in a master document which does not make use of the LilyPond module.
575 For this to work you might have to add the line
578 \begin_layout LyX-Code
584 \begin_layout Standard
585 to your master document's preamble under
587 Document\SpecialChar menuseparator
593 \begin_layout Subsubsection
597 \begin_layout Standard
598 LilyPond-book searches for a
610 command when it decides if the code is only a fragment.
611 It is possible to include no LilyPond command at all, but in that case
612 {surrounding braces} are required.
613 Thus, in the following code,
616 \begin_layout LyX-Code
622 \begin_layout LyX-Code
628 \begin_layout LyX-Code
634 \begin_layout Standard
635 LilyPond-book gets confused:
638 \begin_layout LyX-Code
639 error: syntax error, unexpected NOTENAME_PITCH
642 \begin_layout LyX-Code
648 \begin_layout Standard
649 With surrounding braces, all is well:
652 \begin_layout Standard
655 \begin_layout Standard
656 \begin_inset Flex LilyPond
659 \begin_layout Plain Layout
661 {ais' f'' g' e''} % no
676 \begin_layout Standard
677 Writing the notes directly within braces without using any LilyPond command
678 is convenient when writing short snippets.
679 Advanced users will probably want to enter their musical content using
680 LilyPond variables and commands, which is of course supported.
683 \begin_layout Subsubsection
687 \begin_layout Standard
688 Another gotcha is with subsequent LilyPond snippets with
697 \begin_layout LyX-Code
703 \begin_layout LyX-Code
708 fret-diagram-terse #"x;3;2;o;1;o;" }
711 \begin_layout LyX-Code
717 \begin_layout LyX-Code
721 \begin_layout LyX-Code
727 \begin_layout LyX-Code
732 fret-diagram-terse #"x;x;o;2;3;2;" }
735 \begin_layout LyX-Code
741 \begin_layout Standard
742 For some reason LilyPond-book version 2.13 barks on this when run in safe
743 mode (which you always should use, unless you know what you are doing).
744 This has been corrected as of version 2.15 (was LilyPond issue #1900).
747 \begin_layout Subsubsection
757 \begin_layout Standard
758 LilyPond-book supports including LilyPond code that resides in external
766 With this command, the LilyPond code is processed as if it was typed inside
767 the document and the output score follows the typesetting determined by
769 with respect to line width, page breaks, and so on.
770 This is in contrast to the long-standing \SpecialChar LyX
771 feature to include LilyPond scores
772 as external material, which calls LilyPond on the external file to produce
773 a rigid figure, and includes this figure in the document, leaving the typesetti
774 ng decisions to LilyPond.
775 Unfortunately, support for the
781 command in \SpecialChar LyX
782 is not implemented yet, but it is possible to use it inside
784 -Code block, provided that one writes the complete, absolute path to
788 \begin_layout Section
790 \begin_inset CommandInset label
792 name "sec:LilyPond-examples"
799 \begin_layout Standard
801 \begin_inset CommandInset ref
803 reference "subsec:Editorial-headword"
807 shows a complex score using many LilyPond constructs; some scheme code
808 has been removed from the original source of this snippet, to be able to
811 \begin_inset CommandInset ref
813 reference "subsec:Tablatures-template"
817 shows another LilyPond output which should be interesting to guitarists.
820 \begin_layout Subsection
822 \begin_inset CommandInset label
824 name "subsec:Editorial-headword"
831 \begin_layout Standard
832 NR 1.7 Editorial annotations Beethoven, Op.
834 3 Piano sonata 18, Movt II, Scherzo Measures 9–14.
837 \begin_layout Standard
842 \begin_layout Standard
843 \begin_inset Flex LilyPond
846 \begin_layout Plain Layout
853 \begin_layout Plain Layout
858 \begin_layout Plain Layout
863 \begin_layout Plain Layout
870 \begin_layout Plain Layout
877 \begin_layout Plain Layout
886 \begin_layout Plain Layout
893 \begin_layout Plain Layout
897 set Staff.fingeringOrientations = #'(up)
900 \begin_layout Plain Layout
904 set Score.currentBarNumber = #9
907 \begin_layout Plain Layout
914 \begin_layout Plain Layout
921 \begin_layout Plain Layout
926 \begin_layout Plain Layout
930 set doubleSlurs = ##t
933 \begin_layout Plain Layout
938 \begin_layout Plain Layout
945 \begin_layout Plain Layout
952 \begin_layout Plain Layout
961 \begin_layout Plain Layout
966 \begin_layout Plain Layout
973 \begin_layout Plain Layout
978 \begin_layout Plain Layout
983 \begin_layout Plain Layout
990 \begin_layout Plain Layout
997 \begin_layout Plain Layout
1002 \begin_layout Plain Layout
1007 \begin_layout Plain Layout
1012 \begin_layout Plain Layout
1018 override Script #'script-priority = #-100
1021 \begin_layout Plain Layout
1028 \begin_layout Plain Layout
1039 \begin_layout Plain Layout
1044 \begin_layout Plain Layout
1049 \begin_layout Plain Layout
1054 \begin_layout Plain Layout
1059 \begin_layout Plain Layout
1066 \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
1103 \begin_layout Plain Layout
1110 \begin_layout Plain Layout
1119 \begin_layout Plain Layout
1126 \begin_layout Plain Layout
1130 override Fingering #'direction = #down
1133 \begin_layout Plain Layout
1137 set Staff.fingeringOrientations = #'(down)
1140 \begin_layout Plain Layout
1147 \begin_layout Plain Layout
1154 \begin_layout Plain Layout
1158 set doubleSlurs = ##t
1161 \begin_layout Plain Layout
1166 \begin_layout Plain Layout
1173 \begin_layout Plain Layout
1180 \begin_layout Plain Layout
1187 \begin_layout Plain Layout
1194 \begin_layout Plain Layout
1199 \begin_layout Plain Layout
1203 set doubleSlurs = ##f
1206 \begin_layout Plain Layout
1211 \begin_layout Plain Layout
1216 \begin_layout Plain Layout
1223 \begin_layout Plain Layout
1230 \begin_layout Plain Layout
1235 \begin_layout Plain Layout
1240 \begin_layout Plain Layout
1245 \begin_layout Plain Layout
1252 \begin_layout Plain Layout
1263 \begin_layout Plain Layout
1268 \begin_layout Plain Layout
1273 \begin_layout Plain Layout
1278 \begin_layout Plain Layout
1283 \begin_layout Plain Layout
1290 \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
1322 \begin_layout Plain Layout
1336 \begin_layout Standard
1339 \begin_inset Flex URL
1342 \begin_layout Plain Layout
1344 http://lsr.di.unimi.it/LSR/Item?id=627
1349 ; scheme code removed, centering applied through the paragraph settings]
1352 \begin_layout Subsection
1354 \begin_inset CommandInset label
1356 name "subsec:Tablatures-template"
1363 \begin_layout Standard
1364 \begin_inset Preview
1366 \begin_layout Standard
1367 \begin_inset Flex LilyPond
1370 \begin_layout Plain Layout
1377 \begin_layout Plain Layout
1383 \begin_layout Plain Layout
1388 \begin_layout Plain Layout
1395 \begin_layout Plain Layout
1400 \begin_layout Plain Layout
1405 \begin_layout Plain Layout
1412 \begin_layout Plain Layout
1419 \begin_layout Plain Layout
1423 new Staff = "guitar" <<
1426 \begin_layout Plain Layout
1430 context Voice = "upper guitar" {
1439 \begin_layout Plain Layout
1443 context Voice = "lower guitar" {
1452 \begin_layout Plain Layout
1457 \begin_layout Plain Layout
1461 new TabStaff = "tab" <<
1464 \begin_layout Plain Layout
1468 context TabVoice = "upper tab" {
1477 \begin_layout Plain Layout
1481 context TabVoice = "lower tab" {
1490 \begin_layout Plain Layout
1495 \begin_layout Plain Layout
1500 \begin_layout Plain Layout
1515 \begin_layout Standard
1518 \begin_inset Flex URL
1521 \begin_layout Plain Layout
1523 http://lsr.di.unimi.it/LSR/Item?id=634