]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/lilypond-book.itely
* Documentation/user/lilypond-book.itely: small cleanups
[lilypond.git] / Documentation / user / lilypond-book.itely
1 @c -*-texinfo-*-
2
3 @ignore
4
5 TODO: cleanup
6
7 ** AARGH.e We also have tutorial.itely: Integrating text and music.
8
9    Could also do with a cleanup.  Lost inspiration to fix this manual
10    where to describe what?
11
12 @end ignore
13
14 @c @node Merging text and music with lilypond-book
15 @c @chapter Merging text and music with lilypond-book
16
17 @c  fix this node name , this is too long.
18
19 @node lilypond-book: Integrating text and music
20 @chapter lilypond-book: Integrating text and music
21
22 If you want to add pictures of music to a document, you can simply do
23 it the way you would do with other types of pictures.  You write
24 LilyPond code, process it separately to embedded PostScript or
25 @code{png}, and include it as a picture into your La@TeX{} or
26 @code{html} source.
27
28 @command{lilypond-book} provides you with a way to automate this
29 process: this program extracts snippets of music from your document,
30 runs lilypond on them, and substitutes the resulting pictures back.
31 The line width and font size definitions for the music are adjusted so
32 they match the layout of your document.
33
34 It can work on La@TeX{}, @code{html} or texinfo documents.  A tutorial
35 on using lilypond-book is in @ref{integrating text and music}.
36
37
38 @cindex texinfo
39 @cindex latex
40 @cindex texinfo
41 @cindex @code{texi}
42 @cindex html
43 @cindex documents, adding music to
44
45
46 @node Integrating Texinfo and music
47 @section Integrating Texinfo and music
48
49 You specify the LilyPond code like this:
50 @example
51 @@lilypond[options, go, here]
52   YOUR LILYPOND CODE
53 @@end lilypond
54 @@lilypond[option, go, here]@{ YOUR LILYPOND CODE @}
55 @@lilypondfile[options, go,here]@{@var{filename}@}
56 @end example
57
58 We show two simple examples here. First a complete block:
59 @example
60 @@lilypond[26pt]
61 c' d' e' f' g'2 g'
62 @@end lilypond
63 @end example
64
65 produces this music:
66 @lilypond
67 c' d' e' f' g'2 g'
68 @end lilypond
69
70 Then the short version:
71 @example
72 @@lilypond[11pt]@{<c' e' g'>@}
73 @end example
74
75 and its music:
76
77 @lilypond[11pt]{<c' e' g'>}
78
79 @command{lilypond-book} knows the default margins, and a few paper
80 sizes. One of these commands should be in the beginning of the document:
81 @itemize @bullet
82 @item @code{@@afourpaper}
83 @item @code{@@afourlatex}
84 @item @code{@@afourwide}
85 @item @code{@@smallbook}
86 @end itemize
87 @code{@@pagesizes} are not yet supported.
88
89 When producing texinfo, lilypond-book also generates bitmaps of the
90 music, so you can make a HTML document with embedded music.
91
92 @node Integrating La@TeX{} and music
93 @section Integrating La@TeX{} and music
94
95 You specify the LilyPond code like this:
96 @example
97 \begin[option, go, here]@{lilypond@}
98  YOUR LILYPOND CODE
99 \end@{lilypond@}
100 @end example
101
102 @example
103 \lilypondfile[options, go,here]@{@var{filename}@}
104 @end example
105 or 
106 @example
107 \lilypond@{ YOUR LILYPOND CODE @}
108 @end example
109
110 We show some examples here.
111
112 @example
113 \begin[26pt]@{lilypond@}
114 c' d' e' f' g'2 g'2
115 \end@{lilypond@}
116 @end example
117
118 produces this music:
119
120 @lilypond[26pt]
121 c' d' e' f' g'2 g'2
122 @end lilypond
123
124 Then the short version:
125 @example
126 \lilypond[11pt]@{<c' e' g'>@}
127 @end example
128
129 and its music:
130
131 @lilypond[11pt]{<c' e' g'>}
132
133
134 You can use whatever commands you like in the document preamble,
135 that is the part of the document before @code{\begin@{document@}}.
136 @command{lilypond-book} will send it to La@TeX{} to find out how wide
137 the text is and adjust the linewidth variable in the paper definition of
138 you music according to that.
139
140 After @code{\begin@{document@}} you must be a little more careful
141 when you use commands that change the width of the text and how
142 many columns there are. @command{lilypond-book} know about the
143 @code{\onecolumn} and @code{\twocolumn} commands and the @code{multicols}
144 environment from the multicol package.
145
146 The music will be surrounded by @code{\preLilypondExample} and
147 @code{\postLilypondExample}. The variables are 
148 defined to nothing by default, and the user can redefine them
149 to whatever he wants.
150
151
152 @node Integrating HTML and music
153 @section Integrating HTML and music
154
155 You specify the LilyPond code like this:
156
157 @quotation
158 @example
159 <lilypond relative1 verbatim>
160   \key c \minor r8 c16 b c8 g as c16 b c8 d | g,4
161 </lilypond> 
162 @end example
163 @end quotation
164
165 produces
166
167 @quotation
168 @example
169 <lilypond relative1 verbatim>
170   \key c \minor r8 c16 b c8 g as c16 b c8 d | g,4
171 </lilypond> 
172 @end example
173 @lilypond[relative1]
174   \key c \minor r8 c16 b c8 g as c16 b c8 d | g,4
175 @end lilypond
176 @end quotation
177
178 Inline picture:
179
180 @quotation
181 @example
182 Some music in <lilypond a b c/> a line of text.
183 @end example
184 @end quotation
185
186 @node Music fragment options
187 @section Music fragment options
188
189 The commands for lilypond-book have room to specify options. These are
190 all of the options:
191
192 @table @code
193 @item eps
194 This will create the music as eps graphics and include it into the
195 document with the @code{\includegraphics} command. It works in
196 La@TeX{} only.
197
198 This enables you to place music examples in the running text (and not in
199 a separate paragraph). To avoid that La@TeX{} places the music on a line
200 of its own, there should be no empty lines between the normal text and
201 the LilyPond environment. For inline music, you probably also need a
202 smaller music font size (eg. 11 pt or 13 pt) 
203
204
205 @item verbatim
206     CONTENTS is copied into the source enclosed in a verbatim block,
207     followed by any text given with the @code{intertext} option, then
208     the actual music is displayed. This option does not work with
209     the short version of the LilyPond blocks:
210
211     @code{ @@lilypond@{ CONTENTS @} } and @code{ \lilypond@{ CONTENTS @} }
212
213 @item smallverbatim
214       like @code{verbatim}, but in a smaller font.
215
216 @item intertext="@var{text}"
217     Used in conjunction with @code{verbatim} option: this puts
218 @var{text} between the code and the music.
219 @item filename="@var{filename}"
220     Save the LilyPond code to @var{filename}. By default, a hash value
221 of the code is used.
222
223 @item @code{11pt}
224 @lilypond[11pt, eps]
225   \relative c'{
226     r16 [c d e][f d e c] [g'8 c][b-\prall c] |
227     [d16 g, a b][c a b g][d'8 g f-\prall g]
228   }
229 @end lilypond
230 @item @code{13pt}
231 @lilypond[13pt, eps]
232   \relative c'{
233     r16 [c d e][f d e c] [g'8 c][b-\prall c] |
234     [d16 g, a b][c a b g][d'8 g f-\prall g]
235   }
236 @end lilypond
237 @item @code{16pt}
238 @lilypond[16pt, eps]
239   \relative c'{
240     r16 [c d e][f d e c] [g'8 c][b-\prall c] |
241     [d16 g, a b][c a b g][d'8 g f-\prall g]
242   }
243 @end lilypond
244 @item @code{20pt}
245 @lilypond[20pt, eps]
246   \relative c'{
247     r16 [c d e][f d e c] [g'8 c][b-\prall c] |
248     [d16 g, a b][c a b g][d'8 g f-\prall g]
249   }
250 @end lilypond
251 @item @code{26pt}
252 @lilypond[26pt, eps]
253   \relative c'{
254     r16 [c d e][f d e c] [g'8 c][b-\prall c] |
255   }
256 @end lilypond
257
258 @item singleline
259   Produce a single naturally spaced, unjustified line. (i.e.: linewidth = -1).
260 @item multiline
261   The opposite of @code{singleline}: justify and break lines.
262 @item linewidth=@var{size}@var{unit}
263     Set linewidth to @var{size}, where @var{unit} = cm, mm, in or pt.
264 @item fragment
265 @item nofragment
266     Override @command{lilypond-book} auto detection of what type of code is in the
267     LilyPond block, voice contents or complete code.
268 @item indent=@var{size}@var{unit}
269     Set first line indent to @var{size}, where @var{unit} = cm, mm, in or pt.
270 @item noindent
271     Set first line indent to zero.
272 @item printfilename
273     Prints the file name before the music example. Useful in conjunction
274 with @code{\lilypondfile}.
275 @item relative, relative @var{N}
276     Use relative octave mode. By default, notes are specified relative 
277     central C. The optional integer argument specifies how many octaves 
278     higher (positive number) or lower (negative number) to place the 
279     starting note.
280 @end table
281
282 @node Invoking lilypond-book
283 @section Invoking lilypond-book
284
285 When you run @command{lilypond-book} it will generate lots of small
286 files that LilyPond will process. So to avoid all the garbage in
287 your source directory, you should either change to a temporary
288 directory, or use the @code{--outdir} command line options:
289
290 @code{cd out && lilypond-book ../yourfile.tex}
291
292 @code{lilypond-book --outdir=out yourfile.tex}
293
294
295 For latex input, the file to give to latex has extension @file{.latex}.
296 Texinfo input will be written to a file with extension @file{.texi}.
297
298 If you use @code{--outdir}, you should also @code{cd} to that directory
299 before running LaTeX or makeinfo. This may seem a little kludgey, but
300 both Latex and makeinfo expect picture files (the music) to be in the
301 current working directory. Moreover, if you do this, LaTeX will not
302 clutter you normal working directory  with output files.
303
304 @cindex titling and lilypond-book
305 @cindex lilypond-book and titling
306 @cindex \header in LaTeX documents
307
308 If you want to add titling from the @code{\header} section of the
309 files, you should add  the following to the top of your LaTeX
310 @example
311 \input titledefs.tex
312 \def\preLilypondExample@{\def\mustmakelilypondtitle@{@}@}
313 @end example
314
315 lilypond-book accepts the following command-line options: 
316 @table @code
317 @item @option{-f}, @option{--format=}
318     Specify the document type to process: @code{html}, @code{latex} or
319 @code{texi} (default).  @command{lilypond-book} usually figures this
320 out automatically.
321
322 @item --default-music-fontsize=@var{sz}pt
323     Set the fontsize to use for LilyPond if no fontsize is given
324     as option.
325 @item --force-music-fontsize=@var{sz}pt
326     Force all LilyPond to use this fontsize, overriding options
327     given to @code{\begin@{lilypond@}}
328 @item -I @var{DIR}, --include=@var{DIR}
329     Add @var{DIR} to the include path.
330 @item -M, --dependencies
331         Write dependencies to @file{filename.dep}
332 @item --dep-prefix=@code{PREF}
333         prepend @code{PREF} before each @code{-M} dependency
334 @item -n, --no-lily
335         don't run LilyPond, but do generate the @code{.ly} files
336 @item --no-music
337         strip all  LilyPond blocks from the file.
338 @item --no-pictures
339         don't generate pictures when processing Texinfo.
340 @item --read-lys
341         don't write ly files. This way you can do
342 @example
343  lilypond-book file.tely
344  convert-ly
345  lilypond-book --read-lys
346 @end example
347
348 @item --outname=@var{FILE}
349     The name of La@TeX{} file to output. If this option  is not given,
350     the output name is derived from the input name.
351 @item --outdir=@var{DIR}
352          place generated files in @var{DIR}.
353 @item --version
354         print version information
355 @item --help
356         Print a short help message
357 @end table
358
359
360 @section Bugs
361   
362 The La@TeX{} \includeonly@{...@} command is ignored.
363
364 The Texinfo command @code{pagesize} is on the TODO list for LilyPond
365 1.6, but changing the linewidth in other ways will not give you a
366 straight right margin.
367
368 Almost all La@TeX{} commands that change margins and line widths are
369 ignored.
370
371 There is no way to automatically apply convert-ly only to fragments
372 inside a lilypond-book file.
373
374 @file{lilypond-book} processes all music fragments in one big run. The
375 state of the GUILE interpreter is not reset between fragments; this
376 means that global GUILE definitions, eg. done with @code{#(define
377 .. )} and @code{#(set! .. )} can leak from one fragment into a next
378 fragment.