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 \SpecialCharNoPassThru LyX
98 The \SpecialCharNoPassThru LyX
106 \begin_layout Abstract
107 This document explains and demonstrates the inclusion of musical snippets
108 in a \SpecialCharNoPassThru LyX
109 document, using the LilyPond syntax for music notation and the
110 LilyPond-book utility for processing.
113 \begin_layout Section
117 \begin_layout Standard
118 LilyPond is an open-source project that renders possible the creation of
119 beautiful computer-generated musical scores.
120 The project consists of a text-based music notation language, and a program
121 to process this notation into musical scores.
124 \begin_layout Standard
125 While LilyPond itself supports the display of title, author information,
126 footnotes, endnotes, etc., its primary focus is on music typesetting.
127 For text typesetting, other programs are generally better suited.
128 LilyPond-book is a utility provided by the LilyPond project that helps
129 incorporate musical scores using the LilyPond notation into \SpecialCharNoPassThru LaTeX
134 \begin_layout Standard
135 This document describes the use of the LilyPond music notation within \SpecialCharNoPassThru LyX
136 documents that use a \SpecialCharNoPassThru LaTeX
137 -based layout, thus combining the beauty and
138 quality of the typesetting achieved by both \SpecialCharNoPassThru LaTeX
140 While a basic understanding of the LilyPond syntax for music notation is
141 in order, knowledge of \SpecialCharNoPassThru LaTeX
142 is not necessary when using \SpecialCharNoPassThru LyX
146 \begin_layout Standard
148 \begin_inset CommandInset ref
150 reference "sec:Using-LilyPond-code"
154 explains the requirements, usage instructions, and shortcomings of LilyPond
155 music notation within \SpecialCharNoPassThru LyX
158 \begin_inset CommandInset ref
160 reference "sec:LilyPond-examples"
164 demonstrates the beauty and quality of the typesetting with a few examples.
167 \begin_layout Section
168 Using LilyPond code within \SpecialCharNoPassThru LyX
169 \begin_inset CommandInset label
171 name "sec:Using-LilyPond-code"
178 \begin_layout Standard
179 Support for LilyPond music notation (LilyPond code) within \SpecialCharNoPassThru LyX
181 by adding the LilyPond module to your document.
182 This is done from the menu
184 Document\SpecialChar menuseparator
187 , then selecting LilyPond in the list of modules.
188 You can use any \SpecialCharNoPassThru LaTeX
189 -based \SpecialCharNoPassThru LyX
190 layout and use the regular preview and
191 export mechanism; \SpecialCharNoPassThru LyX
192 will take care of processing the mixed \SpecialCharNoPassThru LaTeX
194 code through LilyPond-book for you.
195 LilyPond-book can also handle DocBook and HTML documents, but the integration
196 of these document types with LilyPond-book and \SpecialCharNoPassThru LyX
197 is missing at the moment.
200 \begin_layout Subsection
204 \begin_layout Standard
205 LilyPond-book version 2.13 or newer.
209 \begin_layout Plain Layout
210 LilyPond-book supports \SpecialCharNoPassThru LaTeX
211 output since version 2.1.
212 However, some features used by \SpecialCharNoPassThru LyX
213 are available only in recent versions:
214 PDF\SpecialCharNoPassThru LaTeX
215 support (version 2.9), the
220 flag (version 2.11) and especially the
233 \begin_layout Subsection
237 \begin_layout Standard
238 The module provides a LilyPond inset which you insert from the menu
240 Insert\SpecialChar menuseparator
248 This inset is for typing the LilyPond code which will be typeset into your
250 First, let us try a simple scale:
253 \begin_layout Standard
254 \begin_inset Flex LilyPond
257 \begin_layout Plain Layout
259 \begin_inset Argument 1
262 \begin_layout Plain Layout
271 \begin_layout Plain Layout
278 \begin_layout Plain Layout
283 \begin_layout Plain Layout
293 \begin_layout Standard
295 The previous \SpecialCharNoPassThru LyX
296 inset produces the following \SpecialCharNoPassThru LaTeX
300 \begin_layout LyX-Code
303 begin{lilypond}[staffsize=28]
306 \begin_layout LyX-Code
310 \begin_layout LyX-Code
316 \begin_layout LyX-Code
320 \begin_layout LyX-Code
324 \begin_layout LyX-Code
330 \begin_layout Standard
331 What appear first inside square brackets are options to pass to LilyPond-book.
332 This is inserted in \SpecialCharNoPassThru LyX
337 menu, in the same way that the LilyPond inset itself is inserted.
338 Here, we set the dimension of the staff to 28
339 \begin_inset space \thinspace{}
343 Other options can be added by separating them by a comma, for example:
346 [staffsize=28,verbatim]
349 A list of music fragment options is available in the LilyPond documentation.
350 This whole block can be omitted when the default settings are desired.
353 \begin_layout Standard
354 What follows after the options block is the textual representation in LilyPond
355 syntax of a musical fragment.
356 This code is not, in fact, processed by \SpecialCharNoPassThru LaTeX
357 , but is preprocessed by LilyPond-
358 book, which creates the graphics files and includes them in the \SpecialCharNoPassThru LaTeX
360 by replacing the above with a
364 includegraphics{\SpecialChar ldots
370 \begin_layout Standard
371 Thus, the conversion process is as follow:
373 \SpecialCharNoPassThru LyX
374 \SpecialChar menuseparator
375 LilyPond-book\SpecialChar menuseparator
376 \SpecialCharNoPassThru LaTeX
379 \SpecialCharNoPassThru LyX
380 creates a .lytex file, LilyPond-book creates a .tex files and the accompanyin
381 g image files, and \SpecialCharNoPassThru LaTeX
382 creates the final document.
383 Every step of the tool chain obeys your spacing, so whether you put the
384 musical extract inline, or in its own paragraph, centered, left-aligned,
385 etc., what you see in the \SpecialCharNoPassThru LyX
386 window should be respected in the final format.
387 An example of inline use may be to display a chord name, such as
388 \begin_inset Flex LilyPond
391 \begin_layout Plain Layout
393 \begin_inset Argument 1
396 \begin_layout Plain Layout
415 , or perhaps a very short snippet.
418 \begin_layout Subsection
422 \begin_layout Standard
423 It is possible to have a direct feedback of what the music notation looks
424 like from within \SpecialCharNoPassThru LyX
426 To do this, wrap a LilyPond inset inside a Preview inset, which you find
429 Insert\SpecialChar menuseparator
433 This only affects the display within \SpecialCharNoPassThru LyX
437 \begin_layout Standard
440 \begin_layout Standard
441 \begin_inset Flex LilyPond
444 \begin_layout Plain Layout
451 \begin_layout Plain Layout
456 \begin_layout Plain Layout
471 \begin_layout Standard
472 Unfortunately, you might find that the preview isn't exactly instantaneous.
473 You need to move the cursor out of the Preview inset to start compilation,
474 and processing time can take a few seconds.
475 Nevertheless, the direct feedback is often worthwhile during editing, and
476 renders the navigation through the document much easier.
479 \begin_layout Subsection
483 \begin_layout Standard
484 A few gotchas that have been experienced with the integration of LilyPond-book
485 and \SpecialCharNoPassThru LyX
489 \begin_layout Subsubsection
493 \begin_layout Standard
494 A \SpecialCharNoPassThru LyX
495 document using the LilyPond module cannot have child documents using
497 \begin_inset Quotes eld
501 \begin_inset Quotes erd
506 \begin_inset Quotes eld
510 \begin_inset Quotes erd
514 \begin_inset Quotes eld
518 \begin_inset Quotes erd
523 Insert\SpecialChar menuseparator
524 File\SpecialChar menuseparator
531 , you will get an error when producing output.
532 This is due to the way LilyPond-book automatically processes these input
534 Since there is currently no command-line option to turn off this behavior
535 of LilyPond-book, it is suggested to use the
536 \begin_inset Quotes eld
540 \begin_inset Quotes erd
546 \begin_layout Standard
547 Note that it is possible to insert child documents which make use of the
548 LilyPond module, using either the
549 \begin_inset Quotes eld
553 \begin_inset Quotes erd
557 \begin_inset Quotes eld
561 \begin_inset Quotes erd
564 method, in a master document which does not make use of the LilyPond module.
565 For this to work you might have to add the line
568 \begin_layout LyX-Code
574 \begin_layout Standard
575 to your master document's preamble under
577 Document\SpecialChar menuseparator
583 \begin_layout Subsubsection
587 \begin_layout Standard
588 LilyPond-book searches for a
600 command when it decides if the code is only a fragment.
601 It is possible to include no LilyPond command at all, but in that case
602 {surrounding braces} are required.
603 Thus, in the following code,
606 \begin_layout LyX-Code
612 \begin_layout LyX-Code
618 \begin_layout LyX-Code
624 \begin_layout Standard
625 LilyPond-book gets confused:
628 \begin_layout LyX-Code
629 error: syntax error, unexpected NOTENAME_PITCH
632 \begin_layout LyX-Code
638 \begin_layout Standard
639 With surrounding braces, all is well:
642 \begin_layout Standard
645 \begin_layout Standard
646 \begin_inset Flex LilyPond
649 \begin_layout Plain Layout
651 {ais' f'' g' e''} % no
666 \begin_layout Standard
667 Writing the notes directly within braces without using any LilyPond command
668 is convenient when writing short snippets.
669 Advanced users will probably want to enter their musical content using
670 LilyPond variables and commands, which is of course supported.
673 \begin_layout Subsubsection
677 \begin_layout Standard
678 Another gotcha is with subsequent LilyPond snippets with
687 \begin_layout LyX-Code
693 \begin_layout LyX-Code
698 fret-diagram-terse #"x;3;2;o;1;o;" }
701 \begin_layout LyX-Code
707 \begin_layout LyX-Code
711 \begin_layout LyX-Code
717 \begin_layout LyX-Code
722 fret-diagram-terse #"x;x;o;2;3;2;" }
725 \begin_layout LyX-Code
731 \begin_layout Standard
732 For some reason LilyPond-book version 2.13 barks on this when run in safe
733 mode (which you always should use, unless you know what you are doing).
734 This has been corrected as of version 2.15 (was LilyPond issue #1900).
737 \begin_layout Subsubsection
747 \begin_layout Standard
748 LilyPond-book supports including LilyPond code that resides in external
756 With this command, the LilyPond code is processed as if it was typed inside
757 the document and the output score follows the typesetting determined by
758 \SpecialCharNoPassThru LaTeX
759 with respect to line width, page breaks, and so on.
760 This is in contrast to the long-standing \SpecialCharNoPassThru LyX
761 feature to include LilyPond
762 scores as external material, which calls LilyPond on the external file
763 to produce a rigid figure, and includes this figure in the document, leaving
764 the typesetting decisions to LilyPond.
765 Unfortunately, support for the
771 command in \SpecialCharNoPassThru LyX
772 is not implemented yet, but it is possible to use it inside
773 a \SpecialCharNoPassThru TeX
774 -Code block, provided that one writes the complete, absolute path
778 \begin_layout Section
780 \begin_inset CommandInset label
782 name "sec:LilyPond-examples"
789 \begin_layout Standard
791 \begin_inset CommandInset ref
793 reference "subsec:Editorial-headword"
797 shows a complex score using many LilyPond constructs; some scheme code
798 has been removed from the original source of this snippet, to be able to
801 \begin_inset CommandInset ref
803 reference "subsec:Tablatures-template"
807 shows another LilyPond output which should be interesting to guitarists.
810 \begin_layout Subsection
812 \begin_inset CommandInset label
814 name "subsec:Editorial-headword"
821 \begin_layout Standard
822 NR 1.7 Editorial annotations Beethoven, Op.
824 3 Piano sonata 18, Movt II, Scherzo Measures 9\twohyphens
826 \begin_inset Separator parbreak
831 \begin_layout Standard
836 \begin_layout Standard
837 \begin_inset Flex LilyPond
840 \begin_layout Plain Layout
847 \begin_layout Plain Layout
852 \begin_layout Plain Layout
857 \begin_layout Plain Layout
864 \begin_layout Plain Layout
871 \begin_layout Plain Layout
880 \begin_layout Plain Layout
887 \begin_layout Plain Layout
891 set Staff.fingeringOrientations = #'(up)
894 \begin_layout Plain Layout
898 set Score.currentBarNumber = #9
901 \begin_layout Plain Layout
908 \begin_layout Plain Layout
915 \begin_layout Plain Layout
920 \begin_layout Plain Layout
924 set doubleSlurs = ##t
927 \begin_layout Plain Layout
932 \begin_layout Plain Layout
939 \begin_layout Plain Layout
946 \begin_layout Plain Layout
955 \begin_layout Plain Layout
960 \begin_layout Plain Layout
967 \begin_layout Plain Layout
972 \begin_layout Plain Layout
977 \begin_layout Plain Layout
984 \begin_layout Plain Layout
991 \begin_layout Plain Layout
996 \begin_layout Plain Layout
1001 \begin_layout Plain Layout
1006 \begin_layout Plain Layout
1012 override Script #'script-priority = #-100
1015 \begin_layout Plain Layout
1022 \begin_layout Plain Layout
1033 \begin_layout Plain Layout
1038 \begin_layout Plain Layout
1043 \begin_layout Plain Layout
1048 \begin_layout Plain Layout
1053 \begin_layout Plain Layout
1060 \begin_layout Plain Layout
1067 \begin_layout Plain Layout
1072 \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
1104 \begin_layout Plain Layout
1113 \begin_layout Plain Layout
1120 \begin_layout Plain Layout
1124 override Fingering #'direction = #down
1127 \begin_layout Plain Layout
1131 set Staff.fingeringOrientations = #'(down)
1134 \begin_layout Plain Layout
1141 \begin_layout Plain Layout
1148 \begin_layout Plain Layout
1152 set doubleSlurs = ##t
1155 \begin_layout Plain Layout
1160 \begin_layout Plain Layout
1167 \begin_layout Plain Layout
1174 \begin_layout Plain Layout
1181 \begin_layout Plain Layout
1188 \begin_layout Plain Layout
1193 \begin_layout Plain Layout
1197 set doubleSlurs = ##f
1200 \begin_layout Plain Layout
1205 \begin_layout Plain Layout
1210 \begin_layout Plain Layout
1217 \begin_layout Plain Layout
1224 \begin_layout Plain Layout
1229 \begin_layout Plain Layout
1234 \begin_layout Plain Layout
1239 \begin_layout Plain Layout
1246 \begin_layout Plain Layout
1257 \begin_layout Plain Layout
1262 \begin_layout Plain Layout
1267 \begin_layout Plain Layout
1272 \begin_layout Plain Layout
1277 \begin_layout Plain Layout
1284 \begin_layout Plain Layout
1291 \begin_layout Plain Layout
1296 \begin_layout Plain Layout
1301 \begin_layout Plain Layout
1306 \begin_layout Plain Layout
1311 \begin_layout Plain Layout
1316 \begin_layout Plain Layout
1330 \begin_layout Standard
1333 \begin_inset Flex URL
1336 \begin_layout Plain Layout
1338 http://lsr.di.unimi.it/LSR/Item?id=627
1343 ; scheme code removed, centering applied through the paragraph settings]
1346 \begin_layout Subsection
1348 \begin_inset CommandInset label
1350 name "subsec:Tablatures-template"
1357 \begin_layout Standard
1358 \begin_inset Preview
1360 \begin_layout Standard
1361 \begin_inset Flex LilyPond
1364 \begin_layout Plain Layout
1371 \begin_layout Plain Layout
1377 \begin_layout Plain Layout
1382 \begin_layout Plain Layout
1389 \begin_layout Plain Layout
1394 \begin_layout Plain Layout
1399 \begin_layout Plain Layout
1406 \begin_layout Plain Layout
1413 \begin_layout Plain Layout
1417 new Staff = "guitar" <<
1420 \begin_layout Plain Layout
1424 context Voice = "upper guitar" {
1433 \begin_layout Plain Layout
1437 context Voice = "lower guitar" {
1446 \begin_layout Plain Layout
1451 \begin_layout Plain Layout
1455 new TabStaff = "tab" <<
1458 \begin_layout Plain Layout
1462 context TabVoice = "upper tab" {
1471 \begin_layout Plain Layout
1475 context TabVoice = "lower tab" {
1484 \begin_layout Plain Layout
1489 \begin_layout Plain Layout
1494 \begin_layout Plain Layout
1509 \begin_layout Standard
1512 \begin_inset Flex URL
1515 \begin_layout Plain Layout
1517 http://lsr.di.unimi.it/LSR/Item?id=634