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 "Julien Rioux"
36 \pdf_bookmarksnumbered false
37 \pdf_bookmarksopen false
38 \pdf_bookmarksopenlevel 1
53 \paperorientation portrait
66 \paragraph_separation skip
68 \quotes_language english
71 \paperpagestyle default
72 \tracking_changes false
85 \begin_layout Abstract
86 This is an example file demonstrating the inclusion of musical snippets
87 in a LyX document, using the LilyPond music notation and the LilyPond-book
88 utility for processing.
92 Using LilyPond code within LyX
95 \begin_layout Standard
96 Support for LilyPond constructs (LilyPond code) within LyX is enabled by
97 adding the LilyPond module to your document.
98 This is done from the menu Document \SpecialChar \menuseparator
99 Settings..., then selecting LilyPond
100 in the list of modules.
101 You can use any LaTeX-based LyX layout and use the regular preview and
102 export mechanism; LyX will take care of processing the LaTeX code through
103 LilyPond-book for you.
104 LilyPond-book can also handle DocBook documents but LilyPond-DocBook support
105 in LyX is missing at the moment.
108 \begin_layout Subsection
112 \begin_layout Itemize
113 LilyPond-book version 2.13
116 \begin_layout Paragraph
120 \begin_layout Standard
121 LilyPond-book supports LaTeX output since version 2.1.
122 However, some features used by LyX are available only in recent versions:
123 PDFLaTeX support (version 2.9), the
127 flag (version 2.11) and especially the
134 \begin_layout Subsection
138 \begin_layout Standard
139 The module provides a LilyPond inset which you insert from the menu Insert
140 \SpecialChar \menuseparator
142 This inset is for typing the LilyPond code which will be typeset into your
144 First, let's try a simple scale:
147 \begin_layout Standard
148 \begin_inset Flex LilyPond
151 \begin_layout Plain Layout
158 \begin_layout Plain Layout
163 \begin_layout Plain Layout
173 \begin_layout Standard
174 The previous LyX inset produces the following LaTeX-lookalike code:
177 \begin_layout LyX-Code
183 \begin_layout LyX-Code
189 \begin_layout LyX-Code
193 \begin_layout LyX-Code
197 \begin_layout LyX-Code
203 \begin_layout Standard
204 This code is not, in fact, processed by LaTeX, but is preprocessed by LilyPond-b
205 ook, which creates the graphics files and include them in the LaTeX document
206 by replacing the above with
210 includegraphics{\SpecialChar \ldots{}
216 \begin_layout Standard
217 Thus, the conversion path is as follow: LyX\SpecialChar \menuseparator
218 LilyPond-book\SpecialChar \menuseparator
220 Every step of the tool chain obeys your spacing, so whether you put the
221 musical extract in line, or in its own paragraph, centered, left-aligned,
222 etc., what you see in the LyX window should be respected in the final format.
223 An example of in-line use may be to display a chord name, such as
224 \begin_inset Flex LilyPond
227 \begin_layout Plain Layout
242 , or perhaps a very short snippet.
245 \begin_layout Subsection
249 \begin_layout Standard
250 It is possible to have a direct feedback of what the music notation looks
251 like from within LyX.
252 To do this, wrap a LilyPond inset inside a Preview inset, which you find
253 from the menu Insert \SpecialChar \menuseparator
255 This only affects the display within LyX, not the output:
258 \begin_layout Standard
261 \begin_layout Standard
262 \begin_inset Flex LilyPond
265 \begin_layout Plain Layout
272 \begin_layout Plain Layout
277 \begin_layout Plain Layout
292 \begin_layout Standard
293 Unfortunately, you might find that the preview isn't exactly instantaneous.
294 You need to move the cursor out of the Preview inset to start compilation,
295 and processing time can take a few seconds.
298 \begin_layout Subsection
302 \begin_layout Subsubsection
306 \begin_layout Standard
307 A LyX document using the LilyPond module cannot have child documents using
309 \begin_inset Quotes eld
313 \begin_inset Quotes erd
318 \begin_inset Quotes eld
322 \begin_inset Quotes erd
326 \begin_inset Quotes eld
330 \begin_inset Quotes erd
333 under Insert\SpecialChar \menuseparator
334 File\SpecialChar \menuseparator
335 Child Document, you will get an error when producing output.
336 This is due to the way LilyPond-book automatically processes these input
338 Since there is currently no command-line option to turn off this behavior
339 of LilyPond-book, it is suggested to use the
340 \begin_inset Quotes eld
344 \begin_inset Quotes erd
350 \begin_layout Standard
351 Note that it is possible to insert child documents which make use of the
352 LilyPond module, using either the
353 \begin_inset Quotes eld
357 \begin_inset Quotes erd
361 \begin_inset Quotes eld
365 \begin_inset Quotes erd
368 method, in a master document which does not make use of the LilyPond module.
369 For this to work you might have to add the line
372 \begin_layout LyX-Code
378 \begin_layout Standard
379 to your master document's preamble under Document\SpecialChar \menuseparator
383 \begin_layout Subsubsection
387 \begin_layout Standard
388 LilyPond-book searches for a
400 command when it decides if the code is only a fragment.
401 It is possible to include no LilyPond command at all, but in that case
402 {surrounding braces} are required.
403 Thus, in the following code,
406 \begin_layout LyX-Code
412 \begin_layout LyX-Code
418 \begin_layout LyX-Code
424 \begin_layout Standard
425 LilyPond-book gets confused:
428 \begin_layout LyX-Code
429 error: syntax error, unexpected NOTENAME_PITCH
432 \begin_layout LyX-Code
438 \begin_layout Standard
439 With surrounding braces, all is well:
442 \begin_layout Standard
445 \begin_layout Standard
446 \begin_inset Flex LilyPond
449 \begin_layout Plain Layout
451 {ais' f'' g' e''} % no
466 \begin_layout Subsubsection
470 \begin_layout Standard
471 Another gotcha is with subsequent lilypond snippets with
480 \begin_layout LyX-Code
486 \begin_layout LyX-Code
491 fret-diagram-terse #"x;3;2;o;1;o;" }
494 \begin_layout LyX-Code
500 \begin_layout LyX-Code
504 \begin_layout LyX-Code
510 \begin_layout LyX-Code
515 fret-diagram-terse #"x;x;o;2;3;2;" }
518 \begin_layout LyX-Code
524 \begin_layout Standard
525 For some reason LilyPond-book version 2.13 barks on this when run in safe
526 mode (which you always should use, unless you know what you are doing).
529 \begin_layout Section
533 \begin_layout Standard
535 \begin_inset CommandInset ref
537 reference "sub:Editorial-headword"
541 shows a complex example using many LilyPond constructs; some scheme code
542 has been removed from the original source of this snippet, to be able to
545 \begin_inset CommandInset ref
547 reference "sub:Tablatures-template"
551 shows another LilyPond output which should be interesting to guitarists.
554 \begin_layout Subsection
556 \begin_inset CommandInset label
558 name "sub:Editorial-headword"
565 \begin_layout Standard
566 NR 1.7 Editorial annotations Beethoven, Op.
568 3 Piano sonata 18, Movt II, Scherzo Measures 9--14.
571 \begin_layout Standard
576 \begin_layout Standard
577 \begin_inset Flex LilyPond
580 \begin_layout Plain Layout
587 \begin_layout Plain Layout
592 \begin_layout Plain Layout
597 \begin_layout Plain Layout
604 \begin_layout Plain Layout
611 \begin_layout Plain Layout
620 \begin_layout Plain Layout
627 \begin_layout Plain Layout
631 set Staff.fingeringOrientations = #'(up)
634 \begin_layout Plain Layout
638 set Score.currentBarNumber = #9
641 \begin_layout Plain Layout
648 \begin_layout Plain Layout
655 \begin_layout Plain Layout
660 \begin_layout Plain Layout
664 set doubleSlurs = ##t
667 \begin_layout Plain Layout
672 \begin_layout Plain Layout
679 \begin_layout Plain Layout
686 \begin_layout Plain Layout
695 \begin_layout Plain Layout
700 \begin_layout Plain Layout
707 \begin_layout Plain Layout
712 \begin_layout Plain Layout
717 \begin_layout Plain Layout
724 \begin_layout Plain Layout
731 \begin_layout Plain Layout
736 \begin_layout Plain Layout
741 \begin_layout Plain Layout
746 \begin_layout Plain Layout
752 override Script #'script-priority = #-100
755 \begin_layout Plain Layout
762 \begin_layout Plain Layout
773 \begin_layout Plain Layout
778 \begin_layout Plain Layout
783 \begin_layout Plain Layout
788 \begin_layout Plain Layout
793 \begin_layout Plain Layout
800 \begin_layout Plain Layout
807 \begin_layout Plain Layout
812 \begin_layout Plain Layout
817 \begin_layout Plain Layout
822 \begin_layout Plain Layout
827 \begin_layout Plain Layout
832 \begin_layout Plain Layout
837 \begin_layout Plain Layout
844 \begin_layout Plain Layout
853 \begin_layout Plain Layout
860 \begin_layout Plain Layout
864 override Fingering #'direction = #down
867 \begin_layout Plain Layout
871 set Staff.fingeringOrientations = #'(down)
874 \begin_layout Plain Layout
881 \begin_layout Plain Layout
888 \begin_layout Plain Layout
892 set doubleSlurs = ##t
895 \begin_layout Plain Layout
900 \begin_layout Plain Layout
907 \begin_layout Plain Layout
914 \begin_layout Plain Layout
921 \begin_layout Plain Layout
928 \begin_layout Plain Layout
933 \begin_layout Plain Layout
937 set doubleSlurs = ##f
940 \begin_layout Plain Layout
945 \begin_layout Plain Layout
950 \begin_layout Plain Layout
957 \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
997 \begin_layout Plain Layout
1002 \begin_layout Plain Layout
1007 \begin_layout Plain Layout
1012 \begin_layout Plain Layout
1017 \begin_layout Plain Layout
1024 \begin_layout Plain Layout
1031 \begin_layout Plain Layout
1036 \begin_layout Plain Layout
1041 \begin_layout Plain Layout
1046 \begin_layout Plain Layout
1051 \begin_layout Plain Layout
1056 \begin_layout Plain Layout
1070 \begin_layout Standard
1072 \begin_inset Flex URL
1075 \begin_layout Plain Layout
1077 http://lsr.dsi.unimi.it/LSR/Item?id=627
1082 ; scheme code removed, centering applied through the paragraph settings]
1085 \begin_layout Subsection
1087 \begin_inset CommandInset label
1089 name "sub:Tablatures-template"
1096 \begin_layout Standard
1097 \begin_inset Preview
1099 \begin_layout Standard
1100 \begin_inset Flex LilyPond
1103 \begin_layout Plain Layout
1110 \begin_layout Plain Layout
1116 \begin_layout Plain Layout
1121 \begin_layout Plain Layout
1128 \begin_layout Plain Layout
1133 \begin_layout Plain Layout
1138 \begin_layout Plain Layout
1145 \begin_layout Plain Layout
1152 \begin_layout Plain Layout
1156 new Staff = "guitar" <<
1159 \begin_layout Plain Layout
1163 context Voice = "upper guitar" {
1172 \begin_layout Plain Layout
1176 context Voice = "lower guitar" {
1185 \begin_layout Plain Layout
1190 \begin_layout Plain Layout
1194 new TabStaff = "tab" <<
1197 \begin_layout Plain Layout
1201 context TabVoice = "upper tab" {
1210 \begin_layout Plain Layout
1214 context TabVoice = "lower tab" {
1223 \begin_layout Plain Layout
1228 \begin_layout Plain Layout
1233 \begin_layout Plain Layout
1248 \begin_layout Standard
1250 \begin_inset Flex URL
1253 \begin_layout Plain Layout
1255 http://lsr.dsi.unimi.it/LSR/Item?id=634