1 #LyX 2.2 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 \default_output_format default
30 \bibtex_command default
31 \index_command default
32 \paperfontsize default
35 \pdf_title "LilyPond-book and LyX"
36 \pdf_author "The LyX Team"
38 \pdf_bookmarksnumbered true
39 \pdf_bookmarksopen true
40 \pdf_bookmarksopenlevel 1
45 \pdf_pdfusetitle false
46 \pdf_quoted_options "linkcolor=blue,urlcolor=blue,pdfstartview=XYZ"
49 \use_package amsmath 1
50 \use_package amssymb 1
53 \use_package mathdots 1
54 \use_package mathtools 0
56 \use_package stackrel 0
57 \use_package stmaryrd 0
58 \use_package undertilde 0
60 \cite_engine_type default
64 \paperorientation portrait
78 \paragraph_separation indent
79 \paragraph_indentation default
80 \quotes_language english
83 \paperpagestyle default
84 \tracking_changes false
94 LilyPond-book and \SpecialChar LyX
107 \begin_layout Abstract
108 This document explains and demonstrates the inclusion of musical snippets
109 in a \SpecialChar LyX
110 document, using the LilyPond syntax for music notation and the LilyPond-b
111 ook utility for processing.
114 \begin_layout Section
118 \begin_layout Standard
119 LilyPond is an open-source project that renders possible the creation of
120 beautiful computer-generated musical scores.
121 The project consists of a text-based music notation language, and a program
122 to process this notation into musical scores.
125 \begin_layout Standard
126 While LilyPond itself supports the display of title, author information,
127 footnotes, endnotes, etc., its primary focus is on music typesetting.
128 For text typesetting, other programs are generally better suited.
129 LilyPond-book is a utility provided by the LilyPond project that helps
130 incorporate musical scores using the LilyPond notation into \SpecialChar LaTeX
135 \begin_layout Standard
136 This document describes the use of the LilyPond music notation within \SpecialChar LyX
138 that use a \SpecialChar LaTeX
139 -based layout, thus combining the beauty and quality of the
140 typesetting achieved by both \SpecialChar LaTeX
142 While a basic understanding of the LilyPond syntax for music notation is
143 in order, knowledge of \SpecialChar LaTeX
144 is not necessary when using \SpecialChar LyX
148 \begin_layout Standard
150 \begin_inset CommandInset ref
152 reference "sec:Using-LilyPond-code"
156 explains the requirements, usage instructions, and shortcomings of LilyPond
157 music notation within \SpecialChar LyX
160 \begin_inset CommandInset ref
162 reference "sec:LilyPond-examples"
166 demonstrates the beauty and quality of the typesetting with a few examples.
169 \begin_layout Section
170 Using LilyPond code within \SpecialChar LyX
172 \begin_inset CommandInset label
174 name "sec:Using-LilyPond-code"
181 \begin_layout Standard
182 Support for LilyPond music notation (LilyPond code) within \SpecialChar LyX
184 adding the LilyPond module to your document.
185 This is done from the menu
187 Document\SpecialChar menuseparator
190 , then selecting LilyPond in the list of modules.
191 You can use any \SpecialChar LaTeX
192 -based \SpecialChar LyX
193 layout and use the regular preview and export mechanism
195 will take care of processing the mixed \SpecialChar LaTeX
196 /LilyPond code through LilyPond-book
198 LilyPond-book can also handle DocBook and HTML documents, but the integration
199 of these document types with LilyPond-book and \SpecialChar LyX
200 is missing at the moment.
203 \begin_layout Subsection
207 \begin_layout Standard
208 LilyPond-book version 2.13 or newer.
212 \begin_layout Plain Layout
213 LilyPond-book supports \SpecialChar LaTeX
214 output since version 2.1.
215 However, some features used by \SpecialChar LyX
216 are available only in recent versions:
217 PDF\SpecialChar LaTeX
218 support (version 2.9), the
222 flag (version 2.11) and especially the
234 \begin_layout Subsection
238 \begin_layout Standard
239 The module provides a LilyPond inset which you insert from the menu
241 Insert\SpecialChar menuseparator
249 This inset is for typing the LilyPond code which will be typeset into your
251 First, let us try a simple scale:
254 \begin_layout Standard
255 \begin_inset Flex LilyPond
258 \begin_layout Plain Layout
260 \begin_inset Argument 1
263 \begin_layout Plain Layout
272 \begin_layout Plain Layout
279 \begin_layout Plain Layout
284 \begin_layout Plain Layout
294 \begin_layout Standard
296 The previous \SpecialChar LyX
297 inset produces the following \SpecialChar LaTeX
301 \begin_layout LyX-Code
304 begin{lilypond}[staffsize=28]
307 \begin_layout LyX-Code
311 \begin_layout LyX-Code
317 \begin_layout LyX-Code
321 \begin_layout LyX-Code
325 \begin_layout LyX-Code
331 \begin_layout Standard
332 What appear first inside square brackets are options to pass to LilyPond-book.
333 This is inserted in \SpecialChar LyX
338 menu, in the same way that the LilyPond inset itself is inserted.
339 Here, we set the dimension of the staff to 28
340 \begin_inset space \thinspace{}
344 Other options can be added by separating them by a comma, for example:
347 [staffsize=28,verbatim]
350 A list of music fragment options is available in the LilyPond documentation.
351 This whole block can be omitted when the default settings are desired.
354 \begin_layout Standard
355 What follows after the options block is the textual representation in LilyPond
356 syntax of a musical fragment.
357 This code is not, in fact, processed by \SpecialChar LaTeX
358 , but is preprocessed by LilyPond-book,
359 which creates the graphics files and includes them in the \SpecialChar LaTeX
361 replacing the above with a
365 includegraphics{\SpecialChar ldots
371 \begin_layout Standard
372 Thus, the conversion process is as follow:
375 \SpecialChar menuseparator
376 LilyPond-book\SpecialChar menuseparator
382 creates a .lytex file, LilyPond-book creates a .tex files and the accompanying
383 image files, and \SpecialChar LaTeX
384 creates the final document.
385 Every step of the tool chain obeys your spacing, so whether you put the
386 musical extract inline, or in its own paragraph, centered, left-aligned,
387 etc., what you see in the \SpecialChar LyX
388 window should be respected in the final format.
389 An example of inline use may be to display a chord name, such as
390 \begin_inset Flex LilyPond
393 \begin_layout Plain Layout
395 \begin_inset Argument 1
398 \begin_layout Plain Layout
417 , or perhaps a very short snippet.
420 \begin_layout Subsection
424 \begin_layout Standard
425 It is possible to have a direct feedback of what the music notation looks
426 like from within \SpecialChar LyX
428 To do this, wrap a LilyPond inset inside a Preview inset, which you find
431 Insert\SpecialChar menuseparator
435 This only affects the display within \SpecialChar LyX
439 \begin_layout Standard
442 \begin_layout Standard
443 \begin_inset Flex LilyPond
446 \begin_layout Plain Layout
453 \begin_layout Plain Layout
458 \begin_layout Plain Layout
473 \begin_layout Standard
474 Unfortunately, you might find that the preview isn't exactly instantaneous.
475 You need to move the cursor out of the Preview inset to start compilation,
476 and processing time can take a few seconds.
477 Nevertheless, the direct feedback is often worthwhile during editing, and
478 renders the navigation through the document much easier.
481 \begin_layout Subsection
485 \begin_layout Standard
486 A few gotchas that have been experienced with the integration of LilyPond-book
491 \begin_layout Subsubsection
495 \begin_layout Standard
497 document using the LilyPond module cannot have child documents using
499 \begin_inset Quotes eld
503 \begin_inset Quotes erd
508 \begin_inset Quotes eld
512 \begin_inset Quotes erd
516 \begin_inset Quotes eld
520 \begin_inset Quotes erd
525 Insert\SpecialChar menuseparator
526 File\SpecialChar menuseparator
533 , you will get an error when producing output.
534 This is due to the way LilyPond-book automatically processes these input
536 Since there is currently no command-line option to turn off this behavior
537 of LilyPond-book, it is suggested to use the
538 \begin_inset Quotes eld
542 \begin_inset Quotes erd
548 \begin_layout Standard
549 Note that it is possible to insert child documents which make use of the
550 LilyPond module, using either the
551 \begin_inset Quotes eld
555 \begin_inset Quotes erd
559 \begin_inset Quotes eld
563 \begin_inset Quotes erd
566 method, in a master document which does not make use of the LilyPond module.
567 For this to work you might have to add the line
570 \begin_layout LyX-Code
576 \begin_layout Standard
577 to your master document's preamble under
579 Document\SpecialChar menuseparator
585 \begin_layout Subsubsection
589 \begin_layout Standard
590 LilyPond-book searches for a
602 command when it decides if the code is only a fragment.
603 It is possible to include no LilyPond command at all, but in that case
604 {surrounding braces} are required.
605 Thus, in the following code,
608 \begin_layout LyX-Code
614 \begin_layout LyX-Code
620 \begin_layout LyX-Code
626 \begin_layout Standard
627 LilyPond-book gets confused:
630 \begin_layout LyX-Code
631 error: syntax error, unexpected NOTENAME_PITCH
634 \begin_layout LyX-Code
640 \begin_layout Standard
641 With surrounding braces, all is well:
644 \begin_layout Standard
647 \begin_layout Standard
648 \begin_inset Flex LilyPond
651 \begin_layout Plain Layout
653 {ais' f'' g' e''} % no
668 \begin_layout Standard
669 Writing the notes directly within braces without using any LilyPond command
670 is convenient when writing short snippets.
671 Advanced users will probably want to enter their musical content using
672 LilyPond variables and commands, which is of course supported.
675 \begin_layout Subsubsection
679 \begin_layout Standard
680 Another gotcha is with subsequent LilyPond snippets with
689 \begin_layout LyX-Code
695 \begin_layout LyX-Code
700 fret-diagram-terse #"x;3;2;o;1;o;" }
703 \begin_layout LyX-Code
709 \begin_layout LyX-Code
713 \begin_layout LyX-Code
719 \begin_layout LyX-Code
724 fret-diagram-terse #"x;x;o;2;3;2;" }
727 \begin_layout LyX-Code
733 \begin_layout Standard
734 For some reason LilyPond-book version 2.13 barks on this when run in safe
735 mode (which you always should use, unless you know what you are doing).
736 This has been corrected as of version 2.15 (was LilyPond issue #1900).
739 \begin_layout Subsubsection
749 \begin_layout Standard
750 LilyPond-book supports including LilyPond code that resides in external
758 With this command, the LilyPond code is processed as if it was typed inside
759 the document and the output score follows the typesetting determined by
761 with respect to line width, page breaks, and so on.
762 This is in contrast to the long-standing \SpecialChar LyX
763 feature to include LilyPond scores
764 as external material, which calls LilyPond on the external file to produce
765 a rigid figure, and includes this figure in the document, leaving the typesetti
766 ng decisions to LilyPond.
767 Unfortunately, support for the
773 command in \SpecialChar LyX
774 is not implemented yet, but it is possible to use it inside
776 -Code block, provided that one writes the complete, absolute path to
780 \begin_layout Section
782 \begin_inset CommandInset label
784 name "sec:LilyPond-examples"
791 \begin_layout Standard
793 \begin_inset CommandInset ref
795 reference "subsec:Editorial-headword"
799 shows a complex score using many LilyPond constructs; some scheme code
800 has been removed from the original source of this snippet, to be able to
803 \begin_inset CommandInset ref
805 reference "subsec:Tablatures-template"
809 shows another LilyPond output which should be interesting to guitarists.
812 \begin_layout Subsection
814 \begin_inset CommandInset label
816 name "subsec:Editorial-headword"
823 \begin_layout Standard
824 NR 1.7 Editorial annotations Beethoven, Op.
826 3 Piano sonata 18, Movt II, Scherzo Measures 9–14.
827 \begin_inset Separator parbreak
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