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
89 \begin_layout Abstract
90 This is an example file demonstrating the inclusion of musical snippets
91 in a LyX document, using the LilyPond music notation and the LilyPond-book
92 utility for processing.
96 Using LilyPond code within LyX
99 \begin_layout Standard
100 Support for LilyPond constructs (LilyPond code) within LyX is enabled by
101 adding the LilyPond module to your document.
102 This is done from the menu
104 Document\SpecialChar \menuseparator
107 , then selecting LilyPond in the list of modules.
108 You can use any LaTeX-based LyX layout and use the regular preview and
109 export mechanism; LyX will take care of processing the LaTeX code through
110 LilyPond-book for you.
111 LilyPond-book can also handle DocBook documents but LilyPond-DocBook support
112 in LyX is missing at the moment.
115 \begin_layout Subsection
119 \begin_layout Standard
120 LilyPond-book version 2.13 or newer
124 \begin_layout Plain Layout
125 LilyPond-book supports LaTeX output since version 2.1.
126 However, some features used by LyX are available only in recent versions:
127 PDFLaTeX support (version 2.9), the
131 flag (version 2.11) and especially the
143 \begin_layout Subsection
147 \begin_layout Standard
148 The module provides a LilyPond inset which you insert from the menu
150 Insert\SpecialChar \menuseparator
158 This inset is for typing the LilyPond code which will be typeset into your
160 First, let us try a simple scale:
163 \begin_layout Standard
164 \begin_inset Flex LilyPond
167 \begin_layout Plain Layout
174 \begin_layout Plain Layout
179 \begin_layout Plain Layout
189 \begin_layout Standard
190 The previous LyX inset produces the following LaTeX-lookalike code:
193 \begin_layout LyX-Code
199 \begin_layout LyX-Code
205 \begin_layout LyX-Code
209 \begin_layout LyX-Code
213 \begin_layout LyX-Code
219 \begin_layout Standard
220 This code is not, in fact, processed by LaTeX, but is preprocessed by LilyPond-b
221 ook, which creates the graphics files and include them in the LaTeX document
222 by replacing the above with
226 includegraphics{\SpecialChar \ldots{}
232 \begin_layout Standard
233 Thus, the conversion path is as follow:
235 LyX\SpecialChar \menuseparator
236 LilyPond-book\SpecialChar \menuseparator
240 Every step of the tool chain obeys your spacing, so whether you put the
241 musical extract in line, or in its own paragraph, centered, left-aligned,
242 etc., what you see in the LyX window should be respected in the final format.
243 An example of in-line use may be to display a chord name, such as
244 \begin_inset Flex LilyPond
247 \begin_layout Plain Layout
262 , or perhaps a very short snippet.
265 \begin_layout Subsection
269 \begin_layout Standard
270 It is possible to have a direct feedback of what the music notation looks
271 like from within LyX.
272 To do this, wrap a LilyPond inset inside a Preview inset, which you find
275 Insert\SpecialChar \menuseparator
279 This only affects the display within LyX, not the output:
282 \begin_layout Standard
285 \begin_layout Standard
286 \begin_inset Flex LilyPond
289 \begin_layout Plain Layout
296 \begin_layout Plain Layout
301 \begin_layout Plain Layout
316 \begin_layout Standard
317 Unfortunately, you might find that the preview isn't exactly instantaneous.
318 You need to move the cursor out of the Preview inset to start compilation,
319 and processing time can take a few seconds.
322 \begin_layout Subsection
326 \begin_layout Subsubsection
330 \begin_layout Standard
331 A LyX document using the LilyPond module cannot have child documents using
333 \begin_inset Quotes eld
337 \begin_inset Quotes erd
342 \begin_inset Quotes eld
346 \begin_inset Quotes erd
350 \begin_inset Quotes eld
354 \begin_inset Quotes erd
359 Insert\SpecialChar \menuseparator
360 File\SpecialChar \menuseparator
367 , you will get an error when producing output.
368 This is due to the way LilyPond-book automatically processes these input
370 Since there is currently no command-line option to turn off this behavior
371 of LilyPond-book, it is suggested to use the
372 \begin_inset Quotes eld
376 \begin_inset Quotes erd
382 \begin_layout Standard
383 Note that it is possible to insert child documents which make use of the
384 LilyPond module, using either the
385 \begin_inset Quotes eld
389 \begin_inset Quotes erd
393 \begin_inset Quotes eld
397 \begin_inset Quotes erd
400 method, in a master document which does not make use of the LilyPond module.
401 For this to work you might have to add the line
404 \begin_layout LyX-Code
410 \begin_layout Standard
411 to your master document's preamble under
413 Document\SpecialChar \menuseparator
419 \begin_layout Subsubsection
423 \begin_layout Standard
424 LilyPond-book searches for a
436 command when it decides if the code is only a fragment.
437 It is possible to include no LilyPond command at all, but in that case
438 {surrounding braces} are required.
439 Thus, in the following code,
442 \begin_layout LyX-Code
448 \begin_layout LyX-Code
454 \begin_layout LyX-Code
460 \begin_layout Standard
461 LilyPond-book gets confused:
464 \begin_layout LyX-Code
465 error: syntax error, unexpected NOTENAME_PITCH
468 \begin_layout LyX-Code
474 \begin_layout Standard
475 With surrounding braces, all is well:
478 \begin_layout Standard
481 \begin_layout Standard
482 \begin_inset Flex LilyPond
485 \begin_layout Plain Layout
487 {ais' f'' g' e''} % no
502 \begin_layout Subsubsection
506 \begin_layout Standard
507 Another gotcha is with subsequent lilypond snippets with
516 \begin_layout LyX-Code
522 \begin_layout LyX-Code
527 fret-diagram-terse #"x;3;2;o;1;o;" }
530 \begin_layout LyX-Code
536 \begin_layout LyX-Code
540 \begin_layout LyX-Code
546 \begin_layout LyX-Code
551 fret-diagram-terse #"x;x;o;2;3;2;" }
554 \begin_layout LyX-Code
560 \begin_layout Standard
561 For some reason LilyPond-book version 2.13 barks on this when run in safe
562 mode (which you always should use, unless you know what you are doing).
565 \begin_layout Section
569 \begin_layout Standard
571 \begin_inset CommandInset ref
573 reference "sub:Editorial-headword"
577 shows a complex example using many LilyPond constructs; some scheme code
578 has been removed from the original source of this snippet, to be able to
581 \begin_inset CommandInset ref
583 reference "sub:Tablatures-template"
587 shows another LilyPond output which should be interesting to guitarists.
590 \begin_layout Subsection
592 \begin_inset CommandInset label
594 name "sub:Editorial-headword"
601 \begin_layout Standard
602 NR 1.7 Editorial annotations Beethoven, Op.
604 3 Piano sonata 18, Movt II, Scherzo Measures 9--14.
607 \begin_layout Standard
612 \begin_layout Standard
613 \begin_inset Flex LilyPond
616 \begin_layout Plain Layout
623 \begin_layout Plain Layout
628 \begin_layout Plain Layout
633 \begin_layout Plain Layout
640 \begin_layout Plain Layout
647 \begin_layout Plain Layout
656 \begin_layout Plain Layout
663 \begin_layout Plain Layout
667 set Staff.fingeringOrientations = #'(up)
670 \begin_layout Plain Layout
674 set Score.currentBarNumber = #9
677 \begin_layout Plain Layout
684 \begin_layout Plain Layout
691 \begin_layout Plain Layout
696 \begin_layout Plain Layout
700 set doubleSlurs = ##t
703 \begin_layout Plain Layout
708 \begin_layout Plain Layout
715 \begin_layout Plain Layout
722 \begin_layout Plain Layout
731 \begin_layout Plain Layout
736 \begin_layout Plain Layout
743 \begin_layout Plain Layout
748 \begin_layout Plain Layout
753 \begin_layout Plain Layout
760 \begin_layout Plain Layout
767 \begin_layout Plain Layout
772 \begin_layout Plain Layout
777 \begin_layout Plain Layout
782 \begin_layout Plain Layout
788 override Script #'script-priority = #-100
791 \begin_layout Plain Layout
798 \begin_layout Plain Layout
809 \begin_layout Plain Layout
814 \begin_layout Plain Layout
819 \begin_layout Plain Layout
824 \begin_layout Plain Layout
829 \begin_layout Plain Layout
836 \begin_layout Plain Layout
843 \begin_layout Plain Layout
848 \begin_layout Plain Layout
853 \begin_layout Plain Layout
858 \begin_layout Plain Layout
863 \begin_layout Plain Layout
868 \begin_layout Plain Layout
873 \begin_layout Plain Layout
880 \begin_layout Plain Layout
889 \begin_layout Plain Layout
896 \begin_layout Plain Layout
900 override Fingering #'direction = #down
903 \begin_layout Plain Layout
907 set Staff.fingeringOrientations = #'(down)
910 \begin_layout Plain Layout
917 \begin_layout Plain Layout
924 \begin_layout Plain Layout
928 set doubleSlurs = ##t
931 \begin_layout Plain Layout
936 \begin_layout Plain Layout
943 \begin_layout Plain Layout
950 \begin_layout Plain Layout
957 \begin_layout Plain Layout
964 \begin_layout Plain Layout
969 \begin_layout Plain Layout
973 set doubleSlurs = ##f
976 \begin_layout Plain Layout
981 \begin_layout Plain Layout
986 \begin_layout Plain Layout
993 \begin_layout Plain Layout
1000 \begin_layout Plain Layout
1005 \begin_layout Plain Layout
1010 \begin_layout Plain Layout
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
1106 \begin_layout Standard
1108 \begin_inset Flex URL
1111 \begin_layout Plain Layout
1113 http://lsr.dsi.unimi.it/LSR/Item?id=627
1118 ; scheme code removed, centering applied through the paragraph settings]
1121 \begin_layout Subsection
1123 \begin_inset CommandInset label
1125 name "sub:Tablatures-template"
1132 \begin_layout Standard
1133 \begin_inset Preview
1135 \begin_layout Standard
1136 \begin_inset Flex LilyPond
1139 \begin_layout Plain Layout
1146 \begin_layout Plain Layout
1152 \begin_layout Plain Layout
1157 \begin_layout Plain Layout
1164 \begin_layout Plain Layout
1169 \begin_layout Plain Layout
1174 \begin_layout Plain Layout
1181 \begin_layout Plain Layout
1188 \begin_layout Plain Layout
1192 new Staff = "guitar" <<
1195 \begin_layout Plain Layout
1199 context Voice = "upper guitar" {
1208 \begin_layout Plain Layout
1212 context Voice = "lower guitar" {
1221 \begin_layout Plain Layout
1226 \begin_layout Plain Layout
1230 new TabStaff = "tab" <<
1233 \begin_layout Plain Layout
1237 context TabVoice = "upper tab" {
1246 \begin_layout Plain Layout
1250 context TabVoice = "lower tab" {
1259 \begin_layout Plain Layout
1264 \begin_layout Plain Layout
1269 \begin_layout Plain Layout
1284 \begin_layout Standard
1286 \begin_inset Flex URL
1289 \begin_layout Plain Layout
1291 http://lsr.dsi.unimi.it/LSR/Item?id=634