1 #LyX 2.0 created this file. For more info see http://www.lyx.org/
6 \use_default_options true
10 \maintain_unincluded_children false
12 \language_package default
18 \font_default_family default
19 \use_non_tex_fonts false
26 \default_output_format default
28 \bibtex_command default
29 \index_command default
30 \paperfontsize default
33 \pdf_title "LilyPond-book and LyX"
34 \pdf_author "The LyX Team"
36 \pdf_bookmarksnumbered true
37 \pdf_bookmarksopen true
38 \pdf_bookmarksopenlevel 1
43 \pdf_pdfusetitle false
44 \pdf_quoted_options "linkcolor=blue,urlcolor=blue,pdfstartview=XYZ"
54 \paperorientation portrait
67 \paragraph_separation indent
68 \paragraph_indentation default
69 \quotes_language english
72 \paperpagestyle default
73 \tracking_changes false
94 \begin_layout Abstract
95 This document explains and demonstrates the inclusion of musical snippets
96 in a LyX document, using the LilyPond syntax for music notation and the
97 LilyPond-book utility for processing.
100 \begin_layout Section
104 \begin_layout Standard
105 LilyPond is an open-source project that renders possible the creation of
106 beautiful computer-generated musical scores.
107 The project consists of a text-based music notation language, and a program
108 to process this notation into musical scores.
111 \begin_layout Standard
112 While LilyPond itself supports the display of title, author information,
113 footnotes, endnotes, etc., its primary focus is on music typesetting.
114 For text typesetting, other programs are generally better suited.
115 LilyPond-book is an utility provided by the LilyPond project that helps
116 incorporate musical scores using the LilyPond notation into LaTeX documents,
120 \begin_layout Standard
121 This document describes the use of the LilyPond music notation within LyX
122 documents that use a LaTeX-based layout, thus combining the beauty and
123 quality of the typesetting achieved by both LaTeX and LilyPond.
124 While a basic understanding of the LilyPond syntax for music notation is
125 in order, knowledge of LaTeX is not necessary when using LyX.
128 \begin_layout Standard
130 \begin_inset CommandInset ref
132 reference "sec:Using-LilyPond-code"
136 explains the requirements, usage instructions, and shortcomings of LilyPond
137 music notation within LyX.
139 \begin_inset CommandInset ref
141 reference "sec:LilyPond-examples"
145 demonstrates the beauty and quality of the typesetting with a few examples.
148 \begin_layout Section
149 Using LilyPond code within LyX
150 \begin_inset CommandInset label
152 name "sec:Using-LilyPond-code"
159 \begin_layout Standard
160 Support for LilyPond music notation (LilyPond code) within LyX is enabled
161 by adding the LilyPond module to your document.
162 This is done from the menu
164 Document\SpecialChar \menuseparator
167 , then selecting LilyPond in the list of modules.
168 You can use any LaTeX-based LyX layout and use the regular preview and
169 export mechanism; LyX will take care of processing the mixed LaTeX/LilyPond
170 code through LilyPond-book for you.
171 LilyPond-book can also handle DocBook and HTML documents, but the integration
172 of these document types with LilyPond-book and LyX is missing at the moment.
175 \begin_layout Subsection
179 \begin_layout Standard
180 LilyPond-book version 2.13 or newer.
184 \begin_layout Plain Layout
185 LilyPond-book supports LaTeX output since version 2.1.
186 However, some features used by LyX are available only in recent versions:
187 PDFLaTeX support (version 2.9), the
191 flag (version 2.11) and especially the
203 \begin_layout Subsection
207 \begin_layout Standard
208 The module provides a LilyPond inset which you insert from the menu
210 Insert\SpecialChar \menuseparator
218 This inset is for typing the LilyPond code which will be typeset into your
220 First, let us try a simple scale:
223 \begin_layout Standard
224 \begin_inset Flex LilyPond
227 \begin_layout Plain Layout
232 \begin_layout Plain Layout
239 \begin_layout Plain Layout
244 \begin_layout Plain Layout
254 \begin_layout Standard
256 The previous LyX inset produces the following LaTeX-lookalike code:
259 \begin_layout LyX-Code
265 \begin_layout LyX-Code
269 \begin_layout LyX-Code
275 \begin_layout LyX-Code
279 \begin_layout LyX-Code
283 \begin_layout LyX-Code
289 \begin_layout Standard
290 What appear first inside square brackets are options to pass to LilyPond-book.
291 Here, we set the dimension of the staff to 28
292 \begin_inset space \thinspace{}
296 Other options can be added by separating them by a comma, for example:
299 [staffsize=28,verbatim]
302 A list of music fragment options is available in the LilyPond documentation.
303 This whole block can be omitted when the default settings are desired.
306 \begin_layout Standard
307 What follows after the options block is the textual representation in LilyPond
308 syntax of a musical fragment.
309 This code is not, in fact, processed by LaTeX, but is preprocessed by LilyPond-
310 book, which creates the graphics files and includes them in the LaTeX document
311 by replacing the above with a
315 includegraphics{\SpecialChar \ldots{}
321 \begin_layout Standard
322 Thus, the conversion process is as follow:
324 LyX\SpecialChar \menuseparator
325 LilyPond-book\SpecialChar \menuseparator
329 LyX creates a .lytex file, LilyPond-book creates a .tex files and the accompanyin
330 g image files, and LaTeX creates the final document.
331 Every step of the tool chain obeys your spacing, so whether you put the
332 musical extract inline, or in its own paragraph, centered, left-aligned,
333 etc., what you see in the LyX window should be respected in the final format.
334 An example of inline use may be to display a chord name, such as
335 \begin_inset Flex LilyPond
338 \begin_layout Plain Layout
353 , or perhaps a very short snippet.
356 \begin_layout Subsection
360 \begin_layout Standard
361 It is possible to have a direct feedback of what the music notation looks
362 like from within LyX.
363 To do this, wrap a LilyPond inset inside a Preview inset, which you find
366 Insert\SpecialChar \menuseparator
370 This only affects the display within LyX, not the output:
373 \begin_layout Standard
376 \begin_layout Standard
377 \begin_inset Flex LilyPond
380 \begin_layout Plain Layout
387 \begin_layout Plain Layout
392 \begin_layout Plain Layout
407 \begin_layout Standard
408 Unfortunately, you might find that the preview isn't exactly instantaneous.
409 You need to move the cursor out of the Preview inset to start compilation,
410 and processing time can take a few seconds.
411 Nevertheless, the direct feedback is often worthwhile during editing, and
412 renders the navigation through the document much easier.
415 \begin_layout Subsection
419 \begin_layout Standard
420 A few gotchas that have been experienced with the integration of LilyPond-book
421 and LyX are reported here.
424 \begin_layout Subsubsection
428 \begin_layout Standard
429 A LyX document using the LilyPond module cannot have child documents using
431 \begin_inset Quotes eld
435 \begin_inset Quotes erd
440 \begin_inset Quotes eld
444 \begin_inset Quotes erd
448 \begin_inset Quotes eld
452 \begin_inset Quotes erd
457 Insert\SpecialChar \menuseparator
458 File\SpecialChar \menuseparator
465 , you will get an error when producing output.
466 This is due to the way LilyPond-book automatically processes these input
468 Since there is currently no command-line option to turn off this behavior
469 of LilyPond-book, it is suggested to use the
470 \begin_inset Quotes eld
474 \begin_inset Quotes erd
480 \begin_layout Standard
481 Note that it is possible to insert child documents which make use of the
482 LilyPond module, using either the
483 \begin_inset Quotes eld
487 \begin_inset Quotes erd
491 \begin_inset Quotes eld
495 \begin_inset Quotes erd
498 method, in a master document which does not make use of the LilyPond module.
499 For this to work you might have to add the line
502 \begin_layout LyX-Code
508 \begin_layout Standard
509 to your master document's preamble under
511 Document\SpecialChar \menuseparator
517 \begin_layout Subsubsection
521 \begin_layout Standard
522 LilyPond-book searches for a
534 command when it decides if the code is only a fragment.
535 It is possible to include no LilyPond command at all, but in that case
536 {surrounding braces} are required.
537 Thus, in the following code,
540 \begin_layout LyX-Code
546 \begin_layout LyX-Code
552 \begin_layout LyX-Code
558 \begin_layout Standard
559 LilyPond-book gets confused:
562 \begin_layout LyX-Code
563 error: syntax error, unexpected NOTENAME_PITCH
566 \begin_layout LyX-Code
572 \begin_layout Standard
573 With surrounding braces, all is well:
576 \begin_layout Standard
579 \begin_layout Standard
580 \begin_inset Flex LilyPond
583 \begin_layout Plain Layout
585 {ais' f'' g' e''} % no
600 \begin_layout Standard
601 Writing the notes directly within braces without using any LilyPond command
602 is convenient when writing short snippets.
603 Advanced users will probably want to enter their musical content using
604 LilyPond variables and commands, which is of course supported.
607 \begin_layout Subsubsection
611 \begin_layout Standard
612 Another gotcha is with subsequent LilyPond snippets with
621 \begin_layout LyX-Code
627 \begin_layout LyX-Code
632 fret-diagram-terse #"x;3;2;o;1;o;" }
635 \begin_layout LyX-Code
641 \begin_layout LyX-Code
645 \begin_layout LyX-Code
651 \begin_layout LyX-Code
656 fret-diagram-terse #"x;x;o;2;3;2;" }
659 \begin_layout LyX-Code
665 \begin_layout Standard
666 For some reason LilyPond-book version 2.13 barks on this when run in safe
667 mode (which you always should use, unless you know what you are doing).
668 This has been corrected as of version 2.15 (was LilyPond issue #1900).
671 \begin_layout Subsubsection
681 \begin_layout Standard
682 LilyPond-book supports including LilyPond code that resides in external
690 With this command, the LilyPond code is processed as if it was typed inside
691 the document and the output score follows the typesetting determined by
692 LaTeX with respect to line width, page breaks, and so on.
693 This is in contrast to the long-standing LyX feature to include LilyPond
694 scores as external material, which calls LilyPond on the external file
695 to produce a rigid figure, and includes this figure in the document, leaving
696 the typesetting decisions to LilyPond.
697 Unfortunately, support for the
703 command in LyX is not implemented yet, but it is possible to use it inside
704 a TeX-Code block, provided that one writes the complete, absolute path
708 \begin_layout Section
710 \begin_inset CommandInset label
712 name "sec:LilyPond-examples"
719 \begin_layout Standard
721 \begin_inset CommandInset ref
723 reference "sub:Editorial-headword"
727 shows a complex score using many LilyPond constructs; some scheme code
728 has been removed from the original source of this snippet, to be able to
731 \begin_inset CommandInset ref
733 reference "sub:Tablatures-template"
737 shows another LilyPond output which should be interesting to guitarists.
740 \begin_layout Subsection
742 \begin_inset CommandInset label
744 name "sub:Editorial-headword"
751 \begin_layout Standard
752 NR 1.7 Editorial annotations Beethoven, Op.
754 3 Piano sonata 18, Movt II, Scherzo Measures 9--14.
757 \begin_layout Standard
762 \begin_layout Standard
763 \begin_inset Flex LilyPond
766 \begin_layout Plain Layout
773 \begin_layout Plain Layout
778 \begin_layout Plain Layout
783 \begin_layout Plain Layout
790 \begin_layout Plain Layout
797 \begin_layout Plain Layout
806 \begin_layout Plain Layout
813 \begin_layout Plain Layout
817 set Staff.fingeringOrientations = #'(up)
820 \begin_layout Plain Layout
824 set Score.currentBarNumber = #9
827 \begin_layout Plain Layout
834 \begin_layout Plain Layout
841 \begin_layout Plain Layout
846 \begin_layout Plain Layout
850 set doubleSlurs = ##t
853 \begin_layout Plain Layout
858 \begin_layout Plain Layout
865 \begin_layout Plain Layout
872 \begin_layout Plain Layout
881 \begin_layout Plain Layout
886 \begin_layout Plain Layout
893 \begin_layout Plain Layout
898 \begin_layout Plain Layout
903 \begin_layout Plain Layout
910 \begin_layout Plain Layout
917 \begin_layout Plain Layout
922 \begin_layout Plain Layout
927 \begin_layout Plain Layout
932 \begin_layout Plain Layout
938 override Script #'script-priority = #-100
941 \begin_layout Plain Layout
948 \begin_layout Plain Layout
959 \begin_layout Plain Layout
964 \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
1013 \begin_layout Plain Layout
1018 \begin_layout Plain Layout
1023 \begin_layout Plain Layout
1030 \begin_layout Plain Layout
1039 \begin_layout Plain Layout
1046 \begin_layout Plain Layout
1050 override Fingering #'direction = #down
1053 \begin_layout Plain Layout
1057 set Staff.fingeringOrientations = #'(down)
1060 \begin_layout Plain Layout
1067 \begin_layout Plain Layout
1074 \begin_layout Plain Layout
1078 set doubleSlurs = ##t
1081 \begin_layout Plain Layout
1086 \begin_layout Plain Layout
1093 \begin_layout Plain Layout
1100 \begin_layout Plain Layout
1107 \begin_layout Plain Layout
1114 \begin_layout Plain Layout
1119 \begin_layout Plain Layout
1123 set doubleSlurs = ##f
1126 \begin_layout Plain Layout
1131 \begin_layout Plain Layout
1136 \begin_layout Plain Layout
1143 \begin_layout Plain Layout
1150 \begin_layout Plain Layout
1155 \begin_layout Plain Layout
1160 \begin_layout Plain Layout
1165 \begin_layout Plain Layout
1172 \begin_layout Plain Layout
1183 \begin_layout Plain Layout
1188 \begin_layout Plain Layout
1193 \begin_layout Plain Layout
1198 \begin_layout Plain Layout
1203 \begin_layout Plain Layout
1210 \begin_layout Plain Layout
1217 \begin_layout Plain Layout
1222 \begin_layout Plain Layout
1227 \begin_layout Plain Layout
1232 \begin_layout Plain Layout
1237 \begin_layout Plain Layout
1242 \begin_layout Plain Layout
1256 \begin_layout Standard
1259 \begin_inset Flex URL
1262 \begin_layout Plain Layout
1264 http://lsr.dsi.unimi.it/LSR/Item?id=627
1269 ; scheme code removed, centering applied through the paragraph settings]
1272 \begin_layout Subsection
1274 \begin_inset CommandInset label
1276 name "sub:Tablatures-template"
1283 \begin_layout Standard
1284 \begin_inset Preview
1286 \begin_layout Standard
1287 \begin_inset Flex LilyPond
1290 \begin_layout Plain Layout
1297 \begin_layout Plain Layout
1303 \begin_layout Plain Layout
1308 \begin_layout Plain Layout
1315 \begin_layout Plain Layout
1320 \begin_layout Plain Layout
1325 \begin_layout Plain Layout
1332 \begin_layout Plain Layout
1339 \begin_layout Plain Layout
1343 new Staff = "guitar" <<
1346 \begin_layout Plain Layout
1350 context Voice = "upper guitar" {
1359 \begin_layout Plain Layout
1363 context Voice = "lower guitar" {
1372 \begin_layout Plain Layout
1377 \begin_layout Plain Layout
1381 new TabStaff = "tab" <<
1384 \begin_layout Plain Layout
1388 context TabVoice = "upper tab" {
1397 \begin_layout Plain Layout
1401 context TabVoice = "lower tab" {
1410 \begin_layout Plain Layout
1415 \begin_layout Plain Layout
1420 \begin_layout Plain Layout
1435 \begin_layout Standard
1438 \begin_inset Flex URL
1441 \begin_layout Plain Layout
1443 http://lsr.dsi.unimi.it/LSR/Item?id=634