1 #LyX 2.3 created this file. For more info see http://www.lyx.org/
5 \save_transient_properties true
6 \origin /systemlyxdir/examples/Modules/
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
81 \paragraph_separation indent
82 \paragraph_indentation default
84 \math_numbering_side default
89 \paperpagestyle default
90 \tracking_changes false
100 LilyPond-book and \SpecialChar LyX
109 \begin_layout Abstract
110 This document explains and demonstrates the inclusion of musical snippets
111 in a \SpecialChar LyX
112 document, using the LilyPond syntax for music notation and the LilyPond-b
113 ook utility for processing.
116 \begin_layout Section
120 \begin_layout Standard
121 LilyPond is an open-source project that renders possible the creation of
122 beautiful computer-generated musical scores.
123 The project consists of a text-based music notation language, and a program
124 to process this notation into musical scores.
127 \begin_layout Standard
128 While LilyPond itself supports the display of title, author information,
129 footnotes, endnotes, etc., its primary focus is on music typesetting.
130 For text typesetting, other programs are generally better suited.
131 LilyPond-book is a utility provided by the LilyPond project that helps
132 incorporate musical scores using the LilyPond notation into \SpecialChar LaTeX
137 \begin_layout Standard
138 This document describes the use of the LilyPond music notation within \SpecialChar LyX
140 that use a \SpecialChar LaTeX
141 -based layout, thus combining the beauty and quality of the
142 typesetting achieved by both \SpecialChar LaTeX
144 While a basic understanding of the LilyPond syntax for music notation is
145 in order, knowledge of \SpecialChar LaTeX
146 is not necessary when using \SpecialChar LyX
150 \begin_layout Standard
152 \begin_inset CommandInset ref
154 reference "sec:Using-LilyPond-code"
158 explains the requirements, usage instructions, and shortcomings of LilyPond
159 music notation within \SpecialChar LyX
162 \begin_inset CommandInset ref
164 reference "sec:LilyPond-examples"
168 demonstrates the beauty and quality of the typesetting with a few examples.
171 \begin_layout Section
172 Using LilyPond code within \SpecialChar LyX
174 \begin_inset CommandInset label
176 name "sec:Using-LilyPond-code"
183 \begin_layout Standard
184 Support for LilyPond music notation (LilyPond code) within \SpecialChar LyX
186 adding the LilyPond module to your document.
187 This is done from the menu
189 Document\SpecialChar menuseparator
192 , then selecting LilyPond in the list of modules.
193 You can use any \SpecialChar LaTeX
194 -based \SpecialChar LyX
195 layout and use the regular preview and export mechanism
197 will take care of processing the mixed \SpecialChar LaTeX
198 /LilyPond code through LilyPond-book
200 LilyPond-book can also handle DocBook and HTML documents, but the integration
201 of these document types with LilyPond-book and \SpecialChar LyX
202 is missing at the moment.
205 \begin_layout Subsection
209 \begin_layout Standard
210 LilyPond-book version 2.13 or newer.
214 \begin_layout Plain Layout
215 LilyPond-book supports \SpecialChar LaTeX
216 output since version 2.1.
217 However, some features used by \SpecialChar LyX
218 are available only in recent versions:
219 PDF\SpecialChar LaTeX
220 support (version 2.9), the
224 flag (version 2.11) and especially the
236 \begin_layout Subsection
240 \begin_layout Standard
241 The module provides a LilyPond inset which you insert from the menu
243 Insert\SpecialChar menuseparator
251 This inset is for typing the LilyPond code which will be typeset into your
253 First, let us try a simple scale:
256 \begin_layout Standard
257 \begin_inset Flex LilyPond
260 \begin_layout Plain Layout
262 \begin_inset Argument 1
265 \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
421 , or perhaps a very short snippet.
424 \begin_layout Subsection
428 \begin_layout Standard
429 It is possible to have a direct feedback of what the music notation looks
430 like from within \SpecialChar LyX
432 To do this, wrap a LilyPond inset inside a Preview inset, which you find
435 Insert\SpecialChar menuseparator
439 This only affects the display within \SpecialChar LyX
443 \begin_layout Standard
446 \begin_layout Standard
447 \begin_inset Flex LilyPond
450 \begin_layout Plain Layout
457 \begin_layout Plain Layout
462 \begin_layout Plain Layout
477 \begin_layout Standard
478 Unfortunately, you might find that the preview isn't exactly instantaneous.
479 You need to move the cursor out of the Preview inset to start compilation,
480 and processing time can take a few seconds.
481 Nevertheless, the direct feedback is often worthwhile during editing, and
482 renders the navigation through the document much easier.
485 \begin_layout Subsection
489 \begin_layout Standard
490 A few gotchas that have been experienced with the integration of LilyPond-book
495 \begin_layout Subsubsection
499 \begin_layout Standard
501 document using the LilyPond module cannot have child documents using
503 \begin_inset Quotes eld
507 \begin_inset Quotes erd
512 \begin_inset Quotes eld
516 \begin_inset Quotes erd
520 \begin_inset Quotes eld
524 \begin_inset Quotes erd
529 Insert\SpecialChar menuseparator
530 File\SpecialChar menuseparator
537 , you will get an error when producing output.
538 This is due to the way LilyPond-book automatically processes these input
540 Since there is currently no command-line option to turn off this behavior
541 of LilyPond-book, it is suggested to use the
542 \begin_inset Quotes eld
546 \begin_inset Quotes erd
552 \begin_layout Standard
553 Note that it is possible to insert child documents which make use of the
554 LilyPond module, using either the
555 \begin_inset Quotes eld
559 \begin_inset Quotes erd
563 \begin_inset Quotes eld
567 \begin_inset Quotes erd
570 method, in a master document which does not make use of the LilyPond module.
571 For this to work you might have to add the line
574 \begin_layout LyX-Code
580 \begin_layout Standard
581 to your master document's preamble under
583 Document\SpecialChar menuseparator
589 \begin_layout Subsubsection
593 \begin_layout Standard
594 LilyPond-book searches for a
606 command when it decides if the code is only a fragment.
607 It is possible to include no LilyPond command at all, but in that case
608 {surrounding braces} are required.
609 Thus, in the following code,
612 \begin_layout LyX-Code
618 \begin_layout LyX-Code
624 \begin_layout LyX-Code
630 \begin_layout Standard
631 LilyPond-book gets confused:
634 \begin_layout LyX-Code
635 error: syntax error, unexpected NOTENAME_PITCH
638 \begin_layout LyX-Code
644 \begin_layout Standard
645 With surrounding braces, all is well:
648 \begin_layout Standard
651 \begin_layout Standard
652 \begin_inset Flex LilyPond
655 \begin_layout Plain Layout
657 {ais' f'' g' e''} % no
672 \begin_layout Standard
673 Writing the notes directly within braces without using any LilyPond command
674 is convenient when writing short snippets.
675 Advanced users will probably want to enter their musical content using
676 LilyPond variables and commands, which is of course supported.
679 \begin_layout Subsubsection
683 \begin_layout Standard
684 Another gotcha is with subsequent LilyPond snippets with
693 \begin_layout LyX-Code
699 \begin_layout LyX-Code
704 fret-diagram-terse #"x;3;2;o;1;o;" }
707 \begin_layout LyX-Code
713 \begin_layout LyX-Code
717 \begin_layout LyX-Code
723 \begin_layout LyX-Code
728 fret-diagram-terse #"x;x;o;2;3;2;" }
731 \begin_layout LyX-Code
737 \begin_layout Standard
738 For some reason LilyPond-book version 2.13 barks on this when run in safe
739 mode (which you always should use, unless you know what you are doing).
740 This has been corrected as of version 2.15 (was LilyPond issue #1900).
743 \begin_layout Subsubsection
753 \begin_layout Standard
754 LilyPond-book supports including LilyPond code that resides in external
762 With this command, the LilyPond code is processed as if it was typed inside
763 the document and the output score follows the typesetting determined by
765 with respect to line width, page breaks, and so on.
766 This is in contrast to the long-standing \SpecialChar LyX
767 feature to include LilyPond scores
768 as external material, which calls LilyPond on the external file to produce
769 a rigid figure, and includes this figure in the document, leaving the typesetti
770 ng decisions to LilyPond.
771 Unfortunately, support for the
777 command in \SpecialChar LyX
778 is not implemented yet, but it is possible to use it inside
780 -Code block, provided that one writes the complete, absolute path to
784 \begin_layout Section
786 \begin_inset CommandInset label
788 name "sec:LilyPond-examples"
795 \begin_layout Standard
797 \begin_inset CommandInset ref
799 reference "subsec:Editorial-headword"
803 shows a complex score using many LilyPond constructs; some scheme code
804 has been removed from the original source of this snippet, to be able to
807 \begin_inset CommandInset ref
809 reference "subsec:Tablatures-template"
813 shows another LilyPond output which should be interesting to guitarists.
816 \begin_layout Subsection
818 \begin_inset CommandInset label
820 name "subsec:Editorial-headword"
827 \begin_layout Standard
828 NR 1.7 Editorial annotations Beethoven, Op.
830 3 Piano sonata 18, Movt II, Scherzo Measures 9–14.
833 \begin_layout Standard
838 \begin_layout Standard
839 \begin_inset Flex LilyPond
842 \begin_layout Plain Layout
849 \begin_layout Plain Layout
854 \begin_layout Plain Layout
859 \begin_layout Plain Layout
866 \begin_layout Plain Layout
873 \begin_layout Plain Layout
882 \begin_layout Plain Layout
889 \begin_layout Plain Layout
893 set Staff.fingeringOrientations = #'(up)
896 \begin_layout Plain Layout
900 set Score.currentBarNumber = #9
903 \begin_layout Plain Layout
910 \begin_layout Plain Layout
917 \begin_layout Plain Layout
922 \begin_layout Plain Layout
926 set doubleSlurs = ##t
929 \begin_layout Plain Layout
934 \begin_layout Plain Layout
941 \begin_layout Plain Layout
948 \begin_layout Plain Layout
957 \begin_layout Plain Layout
962 \begin_layout Plain Layout
969 \begin_layout Plain Layout
974 \begin_layout Plain Layout
979 \begin_layout Plain Layout
986 \begin_layout Plain Layout
993 \begin_layout Plain Layout
998 \begin_layout Plain Layout
1003 \begin_layout Plain Layout
1008 \begin_layout Plain Layout
1014 override Script #'script-priority = #-100
1017 \begin_layout Plain Layout
1024 \begin_layout Plain Layout
1035 \begin_layout Plain Layout
1040 \begin_layout Plain Layout
1045 \begin_layout Plain Layout
1050 \begin_layout Plain Layout
1055 \begin_layout Plain Layout
1062 \begin_layout Plain Layout
1069 \begin_layout Plain Layout
1074 \begin_layout Plain Layout
1079 \begin_layout Plain Layout
1084 \begin_layout Plain Layout
1089 \begin_layout Plain Layout
1094 \begin_layout Plain Layout
1099 \begin_layout Plain Layout
1106 \begin_layout Plain Layout
1115 \begin_layout Plain Layout
1122 \begin_layout Plain Layout
1126 override Fingering #'direction = #down
1129 \begin_layout Plain Layout
1133 set Staff.fingeringOrientations = #'(down)
1136 \begin_layout Plain Layout
1143 \begin_layout Plain Layout
1150 \begin_layout Plain Layout
1154 set doubleSlurs = ##t
1157 \begin_layout Plain Layout
1162 \begin_layout Plain Layout
1169 \begin_layout Plain Layout
1176 \begin_layout Plain Layout
1183 \begin_layout Plain Layout
1190 \begin_layout Plain Layout
1195 \begin_layout Plain Layout
1199 set doubleSlurs = ##f
1202 \begin_layout Plain Layout
1207 \begin_layout Plain Layout
1212 \begin_layout Plain Layout
1219 \begin_layout Plain Layout
1226 \begin_layout Plain Layout
1231 \begin_layout Plain Layout
1236 \begin_layout Plain Layout
1241 \begin_layout Plain Layout
1248 \begin_layout Plain Layout
1259 \begin_layout Plain Layout
1264 \begin_layout Plain Layout
1269 \begin_layout Plain Layout
1274 \begin_layout Plain Layout
1279 \begin_layout Plain Layout
1286 \begin_layout Plain Layout
1293 \begin_layout Plain Layout
1298 \begin_layout Plain Layout
1303 \begin_layout Plain Layout
1308 \begin_layout Plain Layout
1313 \begin_layout Plain Layout
1318 \begin_layout Plain Layout
1332 \begin_layout Standard
1335 \begin_inset Flex URL
1338 \begin_layout Plain Layout
1340 http://lsr.di.unimi.it/LSR/Item?id=627
1345 ; scheme code removed, centering applied through the paragraph settings]
1348 \begin_layout Subsection
1350 \begin_inset CommandInset label
1352 name "subsec:Tablatures-template"
1359 \begin_layout Standard
1360 \begin_inset Preview
1362 \begin_layout Standard
1363 \begin_inset Flex LilyPond
1366 \begin_layout Plain Layout
1373 \begin_layout Plain Layout
1379 \begin_layout Plain Layout
1384 \begin_layout Plain Layout
1391 \begin_layout Plain Layout
1396 \begin_layout Plain Layout
1401 \begin_layout Plain Layout
1408 \begin_layout Plain Layout
1415 \begin_layout Plain Layout
1419 new Staff = "guitar" <<
1422 \begin_layout Plain Layout
1426 context Voice = "upper guitar" {
1435 \begin_layout Plain Layout
1439 context Voice = "lower guitar" {
1448 \begin_layout Plain Layout
1453 \begin_layout Plain Layout
1457 new TabStaff = "tab" <<
1460 \begin_layout Plain Layout
1464 context TabVoice = "upper tab" {
1473 \begin_layout Plain Layout
1477 context TabVoice = "lower tab" {
1486 \begin_layout Plain Layout
1491 \begin_layout Plain Layout
1496 \begin_layout Plain Layout
1511 \begin_layout Standard
1514 \begin_inset Flex URL
1517 \begin_layout Plain Layout
1519 http://lsr.di.unimi.it/LSR/Item?id=634