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
17 \font_typewriter 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 "Your Name"
36 \pdf_bookmarksnumbered true
37 \pdf_bookmarksopen true
38 \pdf_bookmarksopenlevel 1
43 \pdf_pdfusetitle false
53 \paperorientation portrait
66 \paragraph_separation indent
67 \paragraph_indentation default
68 \quotes_language english
71 \paperpagestyle default
72 \tracking_changes false
87 \begin_inset Note Note
90 \begin_layout Plain Layout
91 author of this example file: Julien Rioux
99 \begin_layout Abstract
100 This document explains and demonstrates the inclusion of musical snippets
101 in a LyX document, using the LilyPond syntax for music notation and the
102 LilyPond-book utility for processing.
105 \begin_layout Section
109 \begin_layout Standard
110 LilyPond is an open-source project that renders possible the creation of
111 beautiful computer-generated musical scores.
112 The project consists of a text-based music notation language, and a program
113 to process this notation into musical scores.
116 \begin_layout Standard
117 While LilyPond itself supports the display of title, author information,
118 footnotes, endnotes, etc., its primary focus is on music typesetting.
119 For text typesetting, other programs are generally better suited.
120 LilyPond-book is an utility provided by the LilyPond project that helps
121 incorporate musical scores using the LilyPond notation into LaTeX documents,
125 \begin_layout Standard
126 This document describes the use of the Lilypond music notation within LyX
127 documents that use a LaTeX-based layout, thus combining the beauty and
128 quality of the typesetting achieved by both LaTeX and LilyPond.
129 While a basic understanding of the LilyPond syntax for music notation is
130 in order, knowledge of LaTeX is not necessary when using LyX.
133 \begin_layout Standard
135 \begin_inset CommandInset ref
137 reference "sec:Using-LilyPond-code"
141 explains the requirements, usage instructions, and shortcomings of LilyPond
142 music notation within LyX.
144 \begin_inset CommandInset ref
146 reference "sec:LilyPond-examples"
150 demonstrates the beauty and quality of the typesetting with a few examples.
153 \begin_layout Section
154 Using LilyPond code within LyX
155 \begin_inset CommandInset label
157 name "sec:Using-LilyPond-code"
164 \begin_layout Standard
165 Support for LilyPond music notation (LilyPond code) within LyX is enabled
166 by adding the LilyPond module to your document.
167 This is done from the menu
169 Document\SpecialChar \menuseparator
172 , then selecting LilyPond in the list of modules.
173 You can use any LaTeX-based LyX layout and use the regular preview and
174 export mechanism; LyX will take care of processing the mixed LaTeX/LilyPond
175 code through LilyPond-book for you.
176 LilyPond-book can also handle DocBook documents but LilyPond-DocBook support
177 in LyX is missing at the moment.
180 \begin_layout Subsection
184 \begin_layout Standard
185 LilyPond-book version 2.13 or newer.
189 \begin_layout Plain Layout
190 LilyPond-book supports LaTeX output since version 2.1.
191 However, some features used by LyX are available only in recent versions:
192 PDFLaTeX support (version 2.9), the
196 flag (version 2.11) and especially the
208 \begin_layout Subsection
212 \begin_layout Standard
213 The module provides a LilyPond inset which you insert from the menu
215 Insert\SpecialChar \menuseparator
223 This inset is for typing the LilyPond code which will be typeset into your
225 First, let us try a simple scale:
228 \begin_layout Standard
229 \begin_inset Flex LilyPond
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
271 \begin_layout LyX-Code
275 \begin_layout LyX-Code
279 \begin_layout LyX-Code
285 \begin_layout Standard
286 This code is not, in fact, processed by LaTeX, but is preprocessed by LilyPond-b
287 ook, which creates the graphics files and includes them in the LaTeX document
288 by replacing the above with a
292 includegraphics{\SpecialChar \ldots{}
298 \begin_layout Standard
299 Thus, the conversion path is as follow:
301 LyX\SpecialChar \menuseparator
302 LilyPond-book\SpecialChar \menuseparator
306 Every step of the tool chain obeys your spacing, so whether you put the
307 musical extract in line, or in its own paragraph, centered, left-aligned,
308 etc., what you see in the LyX window should be respected in the final format.
309 An example of in-line use may be to display a chord name, such as
310 \begin_inset Flex LilyPond
313 \begin_layout Plain Layout
328 , or perhaps a very short snippet.
331 \begin_layout Subsection
335 \begin_layout Standard
336 It is possible to have a direct feedback of what the music notation looks
337 like from within LyX.
338 To do this, wrap a LilyPond inset inside a Preview inset, which you find
341 Insert\SpecialChar \menuseparator
345 This only affects the display within LyX, not the output:
348 \begin_layout Standard
351 \begin_layout Standard
352 \begin_inset Flex LilyPond
355 \begin_layout Plain Layout
362 \begin_layout Plain Layout
367 \begin_layout Plain Layout
382 \begin_layout Standard
383 Unfortunately, you might find that the preview isn't exactly instantaneous.
384 You need to move the cursor out of the Preview inset to start compilation,
385 and processing time can take a few seconds.
386 Nevertheless, the direct feedback is often worthwhile during editing, and
387 renders the navigation through the document much easier.
390 \begin_layout Subsection
394 \begin_layout Standard
395 A few gotchas that have been experienced with the integration of LilyPond-book
396 and LyX are reported here.
399 \begin_layout Subsubsection
403 \begin_layout Standard
404 A LyX document using the LilyPond module cannot have child documents using
406 \begin_inset Quotes eld
410 \begin_inset Quotes erd
415 \begin_inset Quotes eld
419 \begin_inset Quotes erd
423 \begin_inset Quotes eld
427 \begin_inset Quotes erd
432 Insert\SpecialChar \menuseparator
433 File\SpecialChar \menuseparator
440 , you will get an error when producing output.
441 This is due to the way LilyPond-book automatically processes these input
443 Since there is currently no command-line option to turn off this behavior
444 of LilyPond-book, it is suggested to use the
445 \begin_inset Quotes eld
449 \begin_inset Quotes erd
455 \begin_layout Standard
456 Note that it is possible to insert child documents which make use of the
457 LilyPond module, using either the
458 \begin_inset Quotes eld
462 \begin_inset Quotes erd
466 \begin_inset Quotes eld
470 \begin_inset Quotes erd
473 method, in a master document which does not make use of the LilyPond module.
474 For this to work you might have to add the line
477 \begin_layout LyX-Code
483 \begin_layout Standard
484 to your master document's preamble under
486 Document\SpecialChar \menuseparator
492 \begin_layout Subsubsection
496 \begin_layout Standard
497 LilyPond-book searches for a
509 command when it decides if the code is only a fragment.
510 It is possible to include no LilyPond command at all, but in that case
511 {surrounding braces} are required.
512 Thus, in the following code,
515 \begin_layout LyX-Code
521 \begin_layout LyX-Code
527 \begin_layout LyX-Code
533 \begin_layout Standard
534 LilyPond-book gets confused:
537 \begin_layout LyX-Code
538 error: syntax error, unexpected NOTENAME_PITCH
541 \begin_layout LyX-Code
547 \begin_layout Standard
548 With surrounding braces, all is well:
551 \begin_layout Standard
554 \begin_layout Standard
555 \begin_inset Flex LilyPond
558 \begin_layout Plain Layout
560 {ais' f'' g' e''} % no
575 \begin_layout Subsubsection
579 \begin_layout Standard
580 Another gotcha is with subsequent lilypond snippets with
589 \begin_layout LyX-Code
595 \begin_layout LyX-Code
600 fret-diagram-terse #"x;3;2;o;1;o;" }
603 \begin_layout LyX-Code
609 \begin_layout LyX-Code
613 \begin_layout LyX-Code
619 \begin_layout LyX-Code
624 fret-diagram-terse #"x;x;o;2;3;2;" }
627 \begin_layout LyX-Code
633 \begin_layout Standard
634 For some reason LilyPond-book version 2.13 barks on this when run in safe
635 mode (which you always should use, unless you know what you are doing).
638 \begin_layout Section
640 \begin_inset CommandInset label
642 name "sec:LilyPond-examples"
649 \begin_layout Standard
651 \begin_inset CommandInset ref
653 reference "sub:Editorial-headword"
657 shows a complex example using many LilyPond constructs; some scheme code
658 has been removed from the original source of this snippet, to be able to
661 \begin_inset CommandInset ref
663 reference "sub:Tablatures-template"
667 shows another LilyPond output which should be interesting to guitarists.
670 \begin_layout Subsection
672 \begin_inset CommandInset label
674 name "sub:Editorial-headword"
681 \begin_layout Standard
682 NR 1.7 Editorial annotations Beethoven, Op.
684 3 Piano sonata 18, Movt II, Scherzo Measures 9--14.
687 \begin_layout Standard
692 \begin_layout Standard
693 \begin_inset Flex LilyPond
696 \begin_layout Plain Layout
703 \begin_layout Plain Layout
708 \begin_layout Plain Layout
713 \begin_layout Plain Layout
720 \begin_layout Plain Layout
727 \begin_layout Plain Layout
736 \begin_layout Plain Layout
743 \begin_layout Plain Layout
747 set Staff.fingeringOrientations = #'(up)
750 \begin_layout Plain Layout
754 set Score.currentBarNumber = #9
757 \begin_layout Plain Layout
764 \begin_layout Plain Layout
771 \begin_layout Plain Layout
776 \begin_layout Plain Layout
780 set doubleSlurs = ##t
783 \begin_layout Plain Layout
788 \begin_layout Plain Layout
795 \begin_layout Plain Layout
802 \begin_layout Plain Layout
811 \begin_layout Plain Layout
816 \begin_layout Plain Layout
823 \begin_layout Plain Layout
828 \begin_layout Plain Layout
833 \begin_layout Plain Layout
840 \begin_layout Plain Layout
847 \begin_layout Plain Layout
852 \begin_layout Plain Layout
857 \begin_layout Plain Layout
862 \begin_layout Plain Layout
868 override Script #'script-priority = #-100
871 \begin_layout Plain Layout
878 \begin_layout Plain Layout
889 \begin_layout Plain Layout
894 \begin_layout Plain Layout
899 \begin_layout Plain Layout
904 \begin_layout Plain Layout
909 \begin_layout Plain Layout
916 \begin_layout Plain Layout
923 \begin_layout Plain Layout
928 \begin_layout Plain Layout
933 \begin_layout Plain Layout
938 \begin_layout Plain Layout
943 \begin_layout Plain Layout
948 \begin_layout Plain Layout
953 \begin_layout Plain Layout
960 \begin_layout Plain Layout
969 \begin_layout Plain Layout
976 \begin_layout Plain Layout
980 override Fingering #'direction = #down
983 \begin_layout Plain Layout
987 set Staff.fingeringOrientations = #'(down)
990 \begin_layout Plain Layout
997 \begin_layout Plain Layout
1004 \begin_layout Plain Layout
1008 set doubleSlurs = ##t
1011 \begin_layout Plain Layout
1016 \begin_layout Plain Layout
1023 \begin_layout Plain Layout
1030 \begin_layout Plain Layout
1037 \begin_layout Plain Layout
1044 \begin_layout Plain Layout
1049 \begin_layout Plain Layout
1053 set doubleSlurs = ##f
1056 \begin_layout Plain Layout
1061 \begin_layout Plain Layout
1066 \begin_layout Plain Layout
1073 \begin_layout Plain Layout
1080 \begin_layout Plain Layout
1085 \begin_layout Plain Layout
1090 \begin_layout Plain Layout
1095 \begin_layout Plain Layout
1102 \begin_layout Plain Layout
1113 \begin_layout Plain Layout
1118 \begin_layout Plain Layout
1123 \begin_layout Plain Layout
1128 \begin_layout Plain Layout
1133 \begin_layout Plain Layout
1140 \begin_layout Plain Layout
1147 \begin_layout Plain Layout
1152 \begin_layout Plain Layout
1157 \begin_layout Plain Layout
1162 \begin_layout Plain Layout
1167 \begin_layout Plain Layout
1172 \begin_layout Plain Layout
1186 \begin_layout Standard
1189 \begin_inset Flex URL
1192 \begin_layout Plain Layout
1194 http://lsr.dsi.unimi.it/LSR/Item?id=627
1199 ; scheme code removed, centering applied through the paragraph settings]
1202 \begin_layout Subsection
1204 \begin_inset CommandInset label
1206 name "sub:Tablatures-template"
1213 \begin_layout Standard
1214 \begin_inset Preview
1216 \begin_layout Standard
1217 \begin_inset Flex LilyPond
1220 \begin_layout Plain Layout
1227 \begin_layout Plain Layout
1233 \begin_layout Plain Layout
1238 \begin_layout Plain Layout
1245 \begin_layout Plain Layout
1250 \begin_layout Plain Layout
1255 \begin_layout Plain Layout
1262 \begin_layout Plain Layout
1269 \begin_layout Plain Layout
1273 new Staff = "guitar" <<
1276 \begin_layout Plain Layout
1280 context Voice = "upper guitar" {
1289 \begin_layout Plain Layout
1293 context Voice = "lower guitar" {
1302 \begin_layout Plain Layout
1307 \begin_layout Plain Layout
1311 new TabStaff = "tab" <<
1314 \begin_layout Plain Layout
1318 context TabVoice = "upper tab" {
1327 \begin_layout Plain Layout
1331 context TabVoice = "lower tab" {
1340 \begin_layout Plain Layout
1345 \begin_layout Plain Layout
1350 \begin_layout Plain Layout
1365 \begin_layout Standard
1368 \begin_inset Flex URL
1371 \begin_layout Plain Layout
1373 http://lsr.dsi.unimi.it/LSR/Item?id=634