1 #LyX 2.2 created this file. For more info see http://www.lyx.org/
5 \origin /systemlyxdir/examples/
7 \use_default_options true
11 \maintain_unincluded_children false
13 \language_package default
16 \font_roman "lmodern" "default"
17 \font_sans "lmss" "default"
18 \font_typewriter "lmtt" "default"
19 \font_math "auto" "auto"
20 \font_default_family default
21 \use_non_tex_fonts false
24 \font_sf_scale 100 100
25 \font_tt_scale 100 100
27 \default_output_format default
29 \bibtex_command default
30 \index_command default
31 \paperfontsize default
34 \pdf_title "LilyPond-book and LyX"
35 \pdf_author "The LyX Team"
37 \pdf_bookmarksnumbered true
38 \pdf_bookmarksopen true
39 \pdf_bookmarksopenlevel 1
44 \pdf_pdfusetitle false
45 \pdf_quoted_options "linkcolor=blue,urlcolor=blue,pdfstartview=XYZ"
48 \use_package amsmath 1
49 \use_package amssymb 1
52 \use_package mathdots 1
53 \use_package mathtools 0
55 \use_package stackrel 0
56 \use_package stmaryrd 0
57 \use_package undertilde 0
59 \cite_engine_type default
63 \paperorientation portrait
77 \paragraph_separation indent
78 \paragraph_indentation default
79 \quotes_language english
82 \paperpagestyle default
83 \tracking_changes false
93 LilyPond-book and \SpecialCharNoPassThru LyX
97 The \SpecialCharNoPassThru LyX
105 \begin_layout Abstract
106 This document explains and demonstrates the inclusion of musical snippets
107 in a \SpecialCharNoPassThru LyX
108 document, using the LilyPond syntax for music notation and the
109 LilyPond-book utility for processing.
112 \begin_layout Section
116 \begin_layout Standard
117 LilyPond is an open-source project that renders possible the creation of
118 beautiful computer-generated musical scores.
119 The project consists of a text-based music notation language, and a program
120 to process this notation into musical scores.
123 \begin_layout Standard
124 While LilyPond itself supports the display of title, author information,
125 footnotes, endnotes, etc., its primary focus is on music typesetting.
126 For text typesetting, other programs are generally better suited.
127 LilyPond-book is a utility provided by the LilyPond project that helps
128 incorporate musical scores using the LilyPond notation into \SpecialCharNoPassThru LaTeX
133 \begin_layout Standard
134 This document describes the use of the LilyPond music notation within \SpecialCharNoPassThru LyX
135 documents that use a \SpecialCharNoPassThru LaTeX
136 -based layout, thus combining the beauty and
137 quality of the typesetting achieved by both \SpecialCharNoPassThru LaTeX
139 While a basic understanding of the LilyPond syntax for music notation is
140 in order, knowledge of \SpecialCharNoPassThru LaTeX
141 is not necessary when using \SpecialCharNoPassThru LyX
145 \begin_layout Standard
147 \begin_inset CommandInset ref
149 reference "sec:Using-LilyPond-code"
153 explains the requirements, usage instructions, and shortcomings of LilyPond
154 music notation within \SpecialCharNoPassThru LyX
157 \begin_inset CommandInset ref
159 reference "sec:LilyPond-examples"
163 demonstrates the beauty and quality of the typesetting with a few examples.
166 \begin_layout Section
167 Using LilyPond code within \SpecialCharNoPassThru LyX
168 \begin_inset CommandInset label
170 name "sec:Using-LilyPond-code"
177 \begin_layout Standard
178 Support for LilyPond music notation (LilyPond code) within \SpecialCharNoPassThru LyX
180 by adding the LilyPond module to your document.
181 This is done from the menu
183 Document\SpecialChar menuseparator
186 , then selecting LilyPond in the list of modules.
187 You can use any \SpecialCharNoPassThru LaTeX
188 -based \SpecialCharNoPassThru LyX
189 layout and use the regular preview and
190 export mechanism; \SpecialCharNoPassThru LyX
191 will take care of processing the mixed \SpecialCharNoPassThru LaTeX
193 code through LilyPond-book for you.
194 LilyPond-book can also handle DocBook and HTML documents, but the integration
195 of these document types with LilyPond-book and \SpecialCharNoPassThru LyX
196 is missing at the moment.
199 \begin_layout Subsection
203 \begin_layout Standard
204 LilyPond-book version 2.13 or newer.
208 \begin_layout Plain Layout
209 LilyPond-book supports \SpecialCharNoPassThru LaTeX
210 output since version 2.1.
211 However, some features used by \SpecialCharNoPassThru LyX
212 are available only in recent versions:
213 PDF\SpecialCharNoPassThru LaTeX
214 support (version 2.9), the
219 flag (version 2.11) and especially the
232 \begin_layout Subsection
236 \begin_layout Standard
237 The module provides a LilyPond inset which you insert from the menu
239 Insert\SpecialChar menuseparator
247 This inset is for typing the LilyPond code which will be typeset into your
249 First, let us try a simple scale:
252 \begin_layout Standard
253 \begin_inset Flex LilyPond
256 \begin_layout Plain Layout
258 \begin_inset Argument 1
261 \begin_layout Plain Layout
270 \begin_layout Plain Layout
277 \begin_layout Plain Layout
282 \begin_layout Plain Layout
292 \begin_layout Standard
294 The previous \SpecialCharNoPassThru LyX
295 inset produces the following \SpecialCharNoPassThru LaTeX
299 \begin_layout LyX-Code
302 begin{lilypond}[staffsize=28]
305 \begin_layout LyX-Code
309 \begin_layout LyX-Code
315 \begin_layout LyX-Code
319 \begin_layout LyX-Code
323 \begin_layout LyX-Code
329 \begin_layout Standard
330 What appear first inside square brackets are options to pass to LilyPond-book.
331 This is inserted in \SpecialCharNoPassThru LyX
336 menu, in the same way that the LilyPond inset itself is inserted.
337 Here, we set the dimension of the staff to 28
338 \begin_inset space \thinspace{}
342 Other options can be added by separating them by a comma, for example:
345 [staffsize=28,verbatim]
348 A list of music fragment options is available in the LilyPond documentation.
349 This whole block can be omitted when the default settings are desired.
352 \begin_layout Standard
353 What follows after the options block is the textual representation in LilyPond
354 syntax of a musical fragment.
355 This code is not, in fact, processed by \SpecialCharNoPassThru LaTeX
356 , but is preprocessed by LilyPond-
357 book, which creates the graphics files and includes them in the \SpecialCharNoPassThru LaTeX
359 by replacing the above with a
363 includegraphics{\SpecialChar ldots
369 \begin_layout Standard
370 Thus, the conversion process is as follow:
372 \SpecialCharNoPassThru LyX
373 \SpecialChar menuseparator
374 LilyPond-book\SpecialChar menuseparator
375 \SpecialCharNoPassThru LaTeX
378 \SpecialCharNoPassThru LyX
379 creates a .lytex file, LilyPond-book creates a .tex files and the accompanyin
380 g image files, and \SpecialCharNoPassThru LaTeX
381 creates the final document.
382 Every step of the tool chain obeys your spacing, so whether you put the
383 musical extract inline, or in its own paragraph, centered, left-aligned,
384 etc., what you see in the \SpecialCharNoPassThru LyX
385 window should be respected in the final format.
386 An example of inline use may be to display a chord name, such as
387 \begin_inset Flex LilyPond
390 \begin_layout Plain Layout
392 \begin_inset Argument 1
395 \begin_layout Plain Layout
414 , or perhaps a very short snippet.
417 \begin_layout Subsection
421 \begin_layout Standard
422 It is possible to have a direct feedback of what the music notation looks
423 like from within \SpecialCharNoPassThru LyX
425 To do this, wrap a LilyPond inset inside a Preview inset, which you find
428 Insert\SpecialChar menuseparator
432 This only affects the display within \SpecialCharNoPassThru LyX
436 \begin_layout Standard
439 \begin_layout Standard
440 \begin_inset Flex LilyPond
443 \begin_layout Plain Layout
450 \begin_layout Plain Layout
455 \begin_layout Plain Layout
470 \begin_layout Standard
471 Unfortunately, you might find that the preview isn't exactly instantaneous.
472 You need to move the cursor out of the Preview inset to start compilation,
473 and processing time can take a few seconds.
474 Nevertheless, the direct feedback is often worthwhile during editing, and
475 renders the navigation through the document much easier.
478 \begin_layout Subsection
482 \begin_layout Standard
483 A few gotchas that have been experienced with the integration of LilyPond-book
484 and \SpecialCharNoPassThru LyX
488 \begin_layout Subsubsection
492 \begin_layout Standard
493 A \SpecialCharNoPassThru LyX
494 document using the LilyPond module cannot have child documents using
496 \begin_inset Quotes eld
500 \begin_inset Quotes erd
505 \begin_inset Quotes eld
509 \begin_inset Quotes erd
513 \begin_inset Quotes eld
517 \begin_inset Quotes erd
522 Insert\SpecialChar menuseparator
523 File\SpecialChar menuseparator
530 , you will get an error when producing output.
531 This is due to the way LilyPond-book automatically processes these input
533 Since there is currently no command-line option to turn off this behavior
534 of LilyPond-book, it is suggested to use the
535 \begin_inset Quotes eld
539 \begin_inset Quotes erd
545 \begin_layout Standard
546 Note that it is possible to insert child documents which make use of the
547 LilyPond module, using either the
548 \begin_inset Quotes eld
552 \begin_inset Quotes erd
556 \begin_inset Quotes eld
560 \begin_inset Quotes erd
563 method, in a master document which does not make use of the LilyPond module.
564 For this to work you might have to add the line
567 \begin_layout LyX-Code
573 \begin_layout Standard
574 to your master document's preamble under
576 Document\SpecialChar menuseparator
582 \begin_layout Subsubsection
586 \begin_layout Standard
587 LilyPond-book searches for a
599 command when it decides if the code is only a fragment.
600 It is possible to include no LilyPond command at all, but in that case
601 {surrounding braces} are required.
602 Thus, in the following code,
605 \begin_layout LyX-Code
611 \begin_layout LyX-Code
617 \begin_layout LyX-Code
623 \begin_layout Standard
624 LilyPond-book gets confused:
627 \begin_layout LyX-Code
628 error: syntax error, unexpected NOTENAME_PITCH
631 \begin_layout LyX-Code
637 \begin_layout Standard
638 With surrounding braces, all is well:
641 \begin_layout Standard
644 \begin_layout Standard
645 \begin_inset Flex LilyPond
648 \begin_layout Plain Layout
650 {ais' f'' g' e''} % no
665 \begin_layout Standard
666 Writing the notes directly within braces without using any LilyPond command
667 is convenient when writing short snippets.
668 Advanced users will probably want to enter their musical content using
669 LilyPond variables and commands, which is of course supported.
672 \begin_layout Subsubsection
676 \begin_layout Standard
677 Another gotcha is with subsequent LilyPond snippets with
686 \begin_layout LyX-Code
692 \begin_layout LyX-Code
697 fret-diagram-terse #"x;3;2;o;1;o;" }
700 \begin_layout LyX-Code
706 \begin_layout LyX-Code
710 \begin_layout LyX-Code
716 \begin_layout LyX-Code
721 fret-diagram-terse #"x;x;o;2;3;2;" }
724 \begin_layout LyX-Code
730 \begin_layout Standard
731 For some reason LilyPond-book version 2.13 barks on this when run in safe
732 mode (which you always should use, unless you know what you are doing).
733 This has been corrected as of version 2.15 (was LilyPond issue #1900).
736 \begin_layout Subsubsection
746 \begin_layout Standard
747 LilyPond-book supports including LilyPond code that resides in external
755 With this command, the LilyPond code is processed as if it was typed inside
756 the document and the output score follows the typesetting determined by
757 \SpecialCharNoPassThru LaTeX
758 with respect to line width, page breaks, and so on.
759 This is in contrast to the long-standing \SpecialCharNoPassThru LyX
760 feature to include LilyPond
761 scores as external material, which calls LilyPond on the external file
762 to produce a rigid figure, and includes this figure in the document, leaving
763 the typesetting decisions to LilyPond.
764 Unfortunately, support for the
770 command in \SpecialCharNoPassThru LyX
771 is not implemented yet, but it is possible to use it inside
772 a \SpecialCharNoPassThru TeX
773 -Code block, provided that one writes the complete, absolute path
777 \begin_layout Section
779 \begin_inset CommandInset label
781 name "sec:LilyPond-examples"
788 \begin_layout Standard
790 \begin_inset CommandInset ref
792 reference "subsec:Editorial-headword"
796 shows a complex score using many LilyPond constructs; some scheme code
797 has been removed from the original source of this snippet, to be able to
800 \begin_inset CommandInset ref
802 reference "subsec:Tablatures-template"
806 shows another LilyPond output which should be interesting to guitarists.
809 \begin_layout Subsection
811 \begin_inset CommandInset label
813 name "subsec:Editorial-headword"
820 \begin_layout Standard
821 NR 1.7 Editorial annotations Beethoven, Op.
823 3 Piano sonata 18, Movt II, Scherzo Measures 9\twohyphens
825 \begin_inset Separator parbreak
830 \begin_layout Standard
835 \begin_layout Standard
836 \begin_inset Flex LilyPond
839 \begin_layout Plain Layout
846 \begin_layout Plain Layout
851 \begin_layout Plain Layout
856 \begin_layout Plain Layout
863 \begin_layout Plain Layout
870 \begin_layout Plain Layout
879 \begin_layout Plain Layout
886 \begin_layout Plain Layout
890 set Staff.fingeringOrientations = #'(up)
893 \begin_layout Plain Layout
897 set Score.currentBarNumber = #9
900 \begin_layout Plain Layout
907 \begin_layout Plain Layout
914 \begin_layout Plain Layout
919 \begin_layout Plain Layout
923 set doubleSlurs = ##t
926 \begin_layout Plain Layout
931 \begin_layout Plain Layout
938 \begin_layout Plain Layout
945 \begin_layout Plain Layout
954 \begin_layout Plain Layout
959 \begin_layout Plain Layout
966 \begin_layout Plain Layout
971 \begin_layout Plain Layout
976 \begin_layout Plain Layout
983 \begin_layout Plain Layout
990 \begin_layout Plain Layout
995 \begin_layout Plain Layout
1000 \begin_layout Plain Layout
1005 \begin_layout Plain Layout
1011 override Script #'script-priority = #-100
1014 \begin_layout Plain Layout
1021 \begin_layout Plain Layout
1032 \begin_layout Plain Layout
1037 \begin_layout Plain Layout
1042 \begin_layout Plain Layout
1047 \begin_layout Plain Layout
1052 \begin_layout Plain Layout
1059 \begin_layout Plain Layout
1066 \begin_layout Plain Layout
1071 \begin_layout Plain Layout
1076 \begin_layout Plain Layout
1081 \begin_layout Plain Layout
1086 \begin_layout Plain Layout
1091 \begin_layout Plain Layout
1096 \begin_layout Plain Layout
1103 \begin_layout Plain Layout
1112 \begin_layout Plain Layout
1119 \begin_layout Plain Layout
1123 override Fingering #'direction = #down
1126 \begin_layout Plain Layout
1130 set Staff.fingeringOrientations = #'(down)
1133 \begin_layout Plain Layout
1140 \begin_layout Plain Layout
1147 \begin_layout Plain Layout
1151 set doubleSlurs = ##t
1154 \begin_layout Plain Layout
1159 \begin_layout Plain Layout
1166 \begin_layout Plain Layout
1173 \begin_layout Plain Layout
1180 \begin_layout Plain Layout
1187 \begin_layout Plain Layout
1192 \begin_layout Plain Layout
1196 set doubleSlurs = ##f
1199 \begin_layout Plain Layout
1204 \begin_layout Plain Layout
1209 \begin_layout Plain Layout
1216 \begin_layout Plain Layout
1223 \begin_layout Plain Layout
1228 \begin_layout Plain Layout
1233 \begin_layout Plain Layout
1238 \begin_layout Plain Layout
1245 \begin_layout Plain Layout
1256 \begin_layout Plain Layout
1261 \begin_layout Plain Layout
1266 \begin_layout Plain Layout
1271 \begin_layout Plain Layout
1276 \begin_layout Plain Layout
1283 \begin_layout Plain Layout
1290 \begin_layout Plain Layout
1295 \begin_layout Plain Layout
1300 \begin_layout Plain Layout
1305 \begin_layout Plain Layout
1310 \begin_layout Plain Layout
1315 \begin_layout Plain Layout
1329 \begin_layout Standard
1332 \begin_inset Flex URL
1335 \begin_layout Plain Layout
1337 http://lsr.di.unimi.it/LSR/Item?id=627
1342 ; scheme code removed, centering applied through the paragraph settings]
1345 \begin_layout Subsection
1347 \begin_inset CommandInset label
1349 name "subsec:Tablatures-template"
1356 \begin_layout Standard
1357 \begin_inset Preview
1359 \begin_layout Standard
1360 \begin_inset Flex LilyPond
1363 \begin_layout Plain Layout
1370 \begin_layout Plain Layout
1376 \begin_layout Plain Layout
1381 \begin_layout Plain Layout
1388 \begin_layout Plain Layout
1393 \begin_layout Plain Layout
1398 \begin_layout Plain Layout
1405 \begin_layout Plain Layout
1412 \begin_layout Plain Layout
1416 new Staff = "guitar" <<
1419 \begin_layout Plain Layout
1423 context Voice = "upper guitar" {
1432 \begin_layout Plain Layout
1436 context Voice = "lower guitar" {
1445 \begin_layout Plain Layout
1450 \begin_layout Plain Layout
1454 new TabStaff = "tab" <<
1457 \begin_layout Plain Layout
1461 context TabVoice = "upper tab" {
1470 \begin_layout Plain Layout
1474 context TabVoice = "lower tab" {
1483 \begin_layout Plain Layout
1488 \begin_layout Plain Layout
1493 \begin_layout Plain Layout
1508 \begin_layout Standard
1511 \begin_inset Flex URL
1514 \begin_layout Plain Layout
1516 http://lsr.di.unimi.it/LSR/Item?id=634