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"
35 \pdf_bookmarksnumbered false
36 \pdf_bookmarksopen false
37 \pdf_bookmarksopenlevel 1
52 \paperorientation portrait
65 \paragraph_separation indent
66 \paragraph_indentation default
67 \quotes_language english
70 \paperpagestyle default
71 \tracking_changes false
84 \begin_layout Abstract
85 This document explains and demonstrates the inclusion of musical snippets
86 in a LyX document, using the LilyPond syntax for music notation and the
87 LilyPond-book utility for processing.
94 \begin_layout Standard
95 LilyPond is an open-source project that renders possible the creation of
96 beautiful computer-generated musical scores.
97 The project consists of a text-based music notation language, and a program
98 to process this notation into musical scores.
101 \begin_layout Standard
102 While LilyPond itself supports the display of title, author information,
103 footnotes, endnotes, etc., its primary focus is on music typesetting.
104 For text typesetting, other programs are generally better suited.
105 LilyPond-book is an utility provided by the LilyPond project that helps
106 incorporate musical scores using the LilyPond notation into LaTeX documents,
110 \begin_layout Standard
111 This document describes the use of the Lilypond music notation within LyX
112 documents that use a LaTeX-based layout, thus combining the beauty and
113 quality of the typesetting achieved by both LaTeX and LilyPond.
114 While a basic understanding of the LilyPond syntax for music notation is
115 in order, knowledge of LaTeX is not necessary when using LyX.
118 \begin_layout Standard
120 \begin_inset CommandInset ref
122 reference "sec:Using-LilyPond-code"
126 explains the requirements, usage instructions, and shortcomings of LilyPond
127 music notation within LyX.
129 \begin_inset CommandInset ref
131 reference "sec:LilyPond-examples"
135 demonstrates the beauty and quality of the typesetting with a few examples.
138 \begin_layout Section
139 Using LilyPond code within LyX
140 \begin_inset CommandInset label
142 name "sec:Using-LilyPond-code"
149 \begin_layout Standard
150 Support for LilyPond music notation (LilyPond code) within LyX is enabled
151 by adding the LilyPond module to your document.
152 This is done from the menu
154 Document\SpecialChar \menuseparator
157 , then selecting LilyPond in the list of modules.
158 You can use any LaTeX-based LyX layout and use the regular preview and
159 export mechanism; LyX will take care of processing the mixed LaTeX/LilyPond
160 code through LilyPond-book for you.
161 LilyPond-book can also handle DocBook documents but LilyPond-DocBook support
162 in LyX is missing at the moment.
165 \begin_layout Subsection
169 \begin_layout Standard
170 LilyPond-book version 2.13 or newer.
174 \begin_layout Plain Layout
175 LilyPond-book supports LaTeX output since version 2.1.
176 However, some features used by LyX are available only in recent versions:
177 PDFLaTeX support (version 2.9), the
181 flag (version 2.11) and especially the
193 \begin_layout Subsection
197 \begin_layout Standard
198 The module provides a LilyPond inset which you insert from the menu
200 Insert\SpecialChar \menuseparator
208 This inset is for typing the LilyPond code which will be typeset into your
210 First, let us try a simple scale:
213 \begin_layout Standard
214 \begin_inset Flex LilyPond
217 \begin_layout Plain Layout
224 \begin_layout Plain Layout
229 \begin_layout Plain Layout
239 \begin_layout Standard
241 The previous LyX inset produces the following LaTeX-lookalike code:
244 \begin_layout LyX-Code
250 \begin_layout LyX-Code
256 \begin_layout LyX-Code
260 \begin_layout LyX-Code
264 \begin_layout LyX-Code
270 \begin_layout Standard
271 This code is not, in fact, processed by LaTeX, but is preprocessed by LilyPond-b
272 ook, which creates the graphics files and includes them in the LaTeX document
273 by replacing the above with a
277 includegraphics{\SpecialChar \ldots{}
283 \begin_layout Standard
284 Thus, the conversion path is as follow:
286 LyX\SpecialChar \menuseparator
287 LilyPond-book\SpecialChar \menuseparator
291 Every step of the tool chain obeys your spacing, so whether you put the
292 musical extract in line, or in its own paragraph, centered, left-aligned,
293 etc., what you see in the LyX window should be respected in the final format.
294 An example of in-line use may be to display a chord name, such as
295 \begin_inset Flex LilyPond
298 \begin_layout Plain Layout
313 , or perhaps a very short snippet.
316 \begin_layout Subsection
320 \begin_layout Standard
321 It is possible to have a direct feedback of what the music notation looks
322 like from within LyX.
323 To do this, wrap a LilyPond inset inside a Preview inset, which you find
326 Insert\SpecialChar \menuseparator
330 This only affects the display within LyX, not the output:
333 \begin_layout Standard
336 \begin_layout Standard
337 \begin_inset Flex LilyPond
340 \begin_layout Plain Layout
347 \begin_layout Plain Layout
352 \begin_layout Plain Layout
367 \begin_layout Standard
368 Unfortunately, you might find that the preview isn't exactly instantaneous.
369 You need to move the cursor out of the Preview inset to start compilation,
370 and processing time can take a few seconds.
371 Nevertheless, the direct feedback is often worthwhile during editing, and
372 renders the navigation through the document much easier.
375 \begin_layout Subsection
379 \begin_layout Standard
380 A few gotchas that have been experienced with the integration of LilyPond-book
381 and LyX are reported here.
384 \begin_layout Subsubsection
388 \begin_layout Standard
389 A LyX document using the LilyPond module cannot have child documents using
391 \begin_inset Quotes eld
395 \begin_inset Quotes erd
400 \begin_inset Quotes eld
404 \begin_inset Quotes erd
408 \begin_inset Quotes eld
412 \begin_inset Quotes erd
417 Insert\SpecialChar \menuseparator
418 File\SpecialChar \menuseparator
425 , you will get an error when producing output.
426 This is due to the way LilyPond-book automatically processes these input
428 Since there is currently no command-line option to turn off this behavior
429 of LilyPond-book, it is suggested to use the
430 \begin_inset Quotes eld
434 \begin_inset Quotes erd
440 \begin_layout Standard
441 Note that it is possible to insert child documents which make use of the
442 LilyPond module, using either the
443 \begin_inset Quotes eld
447 \begin_inset Quotes erd
451 \begin_inset Quotes eld
455 \begin_inset Quotes erd
458 method, in a master document which does not make use of the LilyPond module.
459 For this to work you might have to add the line
462 \begin_layout LyX-Code
468 \begin_layout Standard
469 to your master document's preamble under
471 Document\SpecialChar \menuseparator
477 \begin_layout Subsubsection
481 \begin_layout Standard
482 LilyPond-book searches for a
494 command when it decides if the code is only a fragment.
495 It is possible to include no LilyPond command at all, but in that case
496 {surrounding braces} are required.
497 Thus, in the following code,
500 \begin_layout LyX-Code
506 \begin_layout LyX-Code
512 \begin_layout LyX-Code
518 \begin_layout Standard
519 LilyPond-book gets confused:
522 \begin_layout LyX-Code
523 error: syntax error, unexpected NOTENAME_PITCH
526 \begin_layout LyX-Code
532 \begin_layout Standard
533 With surrounding braces, all is well:
536 \begin_layout Standard
539 \begin_layout Standard
540 \begin_inset Flex LilyPond
543 \begin_layout Plain Layout
545 {ais' f'' g' e''} % no
560 \begin_layout Subsubsection
564 \begin_layout Standard
565 Another gotcha is with subsequent lilypond snippets with
574 \begin_layout LyX-Code
580 \begin_layout LyX-Code
585 fret-diagram-terse #"x;3;2;o;1;o;" }
588 \begin_layout LyX-Code
594 \begin_layout LyX-Code
598 \begin_layout LyX-Code
604 \begin_layout LyX-Code
609 fret-diagram-terse #"x;x;o;2;3;2;" }
612 \begin_layout LyX-Code
618 \begin_layout Standard
619 For some reason LilyPond-book version 2.13 barks on this when run in safe
620 mode (which you always should use, unless you know what you are doing).
623 \begin_layout Section
625 \begin_inset CommandInset label
627 name "sec:LilyPond-examples"
634 \begin_layout Standard
636 \begin_inset CommandInset ref
638 reference "sub:Editorial-headword"
642 shows a complex example using many LilyPond constructs; some scheme code
643 has been removed from the original source of this snippet, to be able to
646 \begin_inset CommandInset ref
648 reference "sub:Tablatures-template"
652 shows another LilyPond output which should be interesting to guitarists.
655 \begin_layout Subsection
657 \begin_inset CommandInset label
659 name "sub:Editorial-headword"
666 \begin_layout Standard
667 NR 1.7 Editorial annotations Beethoven, Op.
669 3 Piano sonata 18, Movt II, Scherzo Measures 9--14.
672 \begin_layout Standard
677 \begin_layout Standard
678 \begin_inset Flex LilyPond
681 \begin_layout Plain Layout
688 \begin_layout Plain Layout
693 \begin_layout Plain Layout
698 \begin_layout Plain Layout
705 \begin_layout Plain Layout
712 \begin_layout Plain Layout
721 \begin_layout Plain Layout
728 \begin_layout Plain Layout
732 set Staff.fingeringOrientations = #'(up)
735 \begin_layout Plain Layout
739 set Score.currentBarNumber = #9
742 \begin_layout Plain Layout
749 \begin_layout Plain Layout
756 \begin_layout Plain Layout
761 \begin_layout Plain Layout
765 set doubleSlurs = ##t
768 \begin_layout Plain Layout
773 \begin_layout Plain Layout
780 \begin_layout Plain Layout
787 \begin_layout Plain Layout
796 \begin_layout Plain Layout
801 \begin_layout Plain Layout
808 \begin_layout Plain Layout
813 \begin_layout Plain Layout
818 \begin_layout Plain Layout
825 \begin_layout Plain Layout
832 \begin_layout Plain Layout
837 \begin_layout Plain Layout
842 \begin_layout Plain Layout
847 \begin_layout Plain Layout
853 override Script #'script-priority = #-100
856 \begin_layout Plain Layout
863 \begin_layout Plain Layout
874 \begin_layout Plain Layout
879 \begin_layout Plain Layout
884 \begin_layout Plain Layout
889 \begin_layout Plain Layout
894 \begin_layout Plain Layout
901 \begin_layout Plain Layout
908 \begin_layout Plain Layout
913 \begin_layout Plain Layout
918 \begin_layout Plain Layout
923 \begin_layout Plain Layout
928 \begin_layout Plain Layout
933 \begin_layout Plain Layout
938 \begin_layout Plain Layout
945 \begin_layout Plain Layout
954 \begin_layout Plain Layout
961 \begin_layout Plain Layout
965 override Fingering #'direction = #down
968 \begin_layout Plain Layout
972 set Staff.fingeringOrientations = #'(down)
975 \begin_layout Plain Layout
982 \begin_layout Plain Layout
989 \begin_layout Plain Layout
993 set doubleSlurs = ##t
996 \begin_layout Plain Layout
1001 \begin_layout Plain Layout
1008 \begin_layout Plain Layout
1015 \begin_layout Plain Layout
1022 \begin_layout Plain Layout
1029 \begin_layout Plain Layout
1034 \begin_layout Plain Layout
1038 set doubleSlurs = ##f
1041 \begin_layout Plain Layout
1046 \begin_layout Plain Layout
1051 \begin_layout Plain Layout
1058 \begin_layout Plain Layout
1065 \begin_layout Plain Layout
1070 \begin_layout Plain Layout
1075 \begin_layout Plain Layout
1080 \begin_layout Plain Layout
1087 \begin_layout Plain Layout
1098 \begin_layout Plain Layout
1103 \begin_layout Plain Layout
1108 \begin_layout Plain Layout
1113 \begin_layout Plain Layout
1118 \begin_layout Plain Layout
1125 \begin_layout Plain Layout
1132 \begin_layout Plain Layout
1137 \begin_layout Plain Layout
1142 \begin_layout Plain Layout
1147 \begin_layout Plain Layout
1152 \begin_layout Plain Layout
1157 \begin_layout Plain Layout
1171 \begin_layout Standard
1174 \begin_inset Flex URL
1177 \begin_layout Plain Layout
1179 http://lsr.dsi.unimi.it/LSR/Item?id=627
1184 ; scheme code removed, centering applied through the paragraph settings]
1187 \begin_layout Subsection
1189 \begin_inset CommandInset label
1191 name "sub:Tablatures-template"
1198 \begin_layout Standard
1199 \begin_inset Preview
1201 \begin_layout Standard
1202 \begin_inset Flex LilyPond
1205 \begin_layout Plain Layout
1212 \begin_layout Plain Layout
1218 \begin_layout Plain Layout
1223 \begin_layout Plain Layout
1230 \begin_layout Plain Layout
1235 \begin_layout Plain Layout
1240 \begin_layout Plain Layout
1247 \begin_layout Plain Layout
1254 \begin_layout Plain Layout
1258 new Staff = "guitar" <<
1261 \begin_layout Plain Layout
1265 context Voice = "upper guitar" {
1274 \begin_layout Plain Layout
1278 context Voice = "lower guitar" {
1287 \begin_layout Plain Layout
1292 \begin_layout Plain Layout
1296 new TabStaff = "tab" <<
1299 \begin_layout Plain Layout
1303 context TabVoice = "upper tab" {
1312 \begin_layout Plain Layout
1316 context TabVoice = "lower tab" {
1325 \begin_layout Plain Layout
1330 \begin_layout Plain Layout
1335 \begin_layout Plain Layout
1350 \begin_layout Standard
1353 \begin_inset Flex URL
1356 \begin_layout Plain Layout
1358 http://lsr.dsi.unimi.it/LSR/Item?id=634