]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/invoking.itexi
Lily was here -> Engraved by LilyPond also in the reference manual.
[lilypond.git] / Documentation / user / invoking.itexi
1 @c -*-texinfo-*-
2 @node Invoking LilyPond
3 @chapter Invoking LilyPond
4
5 This chapter details the technicalities of running LilyPond.
6
7  
8 @menu
9 * Invoking lilypond::           Titling LilyPond scores.
10 * Invoking the lilypond binary::  
11 * Error messages::              
12 * Reporting bugs::              
13 * Editor support::              
14 * Point and click::             
15 @end menu
16
17 @node Invoking lilypond
18 @section Invoking lilypond
19
20 Nicely titled output is created through a separate program:
21 @file{@code{lilypond}} is a script that uses the LilyPond formatting
22 engine (which is in a separate program) and La@TeX{} to create a
23 nicely titled piece of sheet music, in PDF (Portable Document Format)
24 format.
25
26 @example
27         @code{lilypond} [@var{option}]@dots{} @var{file}@dots{}
28 @end example
29
30 To have @code{lilypond} read from stdin, use a dash @code{-} for @var{file}.
31
32 The @code{lilypond} program supports the following options:
33
34 @table @code
35 @item -k,--keep
36     Keep the temporary directory with all output
37 files. The temporary directory is created in the current directory as @code{@code{lilypond}.dir}.
38 @item -d,--dependencies
39     Write @code{Makefile} dependencies for every input file.
40 @item -h,--help
41     Print usage help.
42 @item -I,--include=@var{dir}
43     Add @var{dir} to LilyPond's include path.
44 @item -m,--no-paper
45     Produce MIDI output only.
46 @item --no-lily
47     Do not run @file{lilypond-bin}. Useful for debugging @code{lilypond}.
48 @item -o,--output=@var{file}
49     Generate output to @var{file}.  The extension of @var{file} is ignored.
50 @item --no-pdf
51     Do not generate  (PDF) or PS.
52
53 @cindex PDF
54 @cindex Scalable fonts
55     
56 @c why is this comment here? --hwn
57
58         If you use lilypond-book or your own wrapper files, do not use
59 @code{\usepackage[[T1]@{fontenc@}} in the file header but do not forget
60 @code{\usepackage[latin1]@{inputenc@}} if you use any other
61 non-anglosaxian characters.
62
63 @item --png
64     Also generate pictures of each page, in PNG format. 
65 @item --psgz
66     Gzip the postscript file.
67 @item --html
68     Make a .HTML file with links to all output files.
69 @item --preview
70     Also generate a picture of the first system of the score.
71
72 @cindex preview
73 @cindex picture
74 @cindex bitmap
75 @cindex pixmap
76 @cindex thumbnail
77 @cindex screenshot
78     
79 @item -s,--set=@var{key}=@var{val}
80     Add @var{key}= @var{val} to the settings, overriding those specified
81 in the files. Possible keys: @code{language}, @code{latexheaders},
82 @code{latexpackages}, @code{latexoptions}, @code{papersize},
83 @code{pagenumber}, @code{linewidth}, @code{orientation},
84 @code{textheight}.
85 @item -v,--version
86 Show version information.
87 @item -V,--verbose
88 Be verbose. This prints out commands as they are executed, and more
89 information about the formatting process is printed.
90 @item --debug
91 Print even more information. This is useful when generating bugreports.
92 @item -w,--warranty
93 Show the warranty with which GNU LilyPond comes. (It comes with 
94 @strong{NO WARRANTY}!)
95 @end table
96
97 @subsection Titling layout
98
99 @code{lilypond} extracts the following header fields from the LY files
100 to generate titling; an example demonstrating all these fields is in
101 @inputfileref{input/test,lilypond-testpage.ly}:
102
103 @table @code
104 @item title
105     The title of the music. Centered on top of the first page.
106 @item subtitle
107     Subtitle, centered below the title.
108 @item poet
109     Name of the poet, left flushed below the subtitle.
110 @item composer
111     Name of the composer, right flushed below the subtitle.
112 @item meter
113     Meter string, left flushed below the poet.
114 @item opus
115     Name of the opus, right flushed below the composer.
116 @item arranger
117     Name of the arranger, right flushed below the opus.
118 @item instrument
119     Name of the instrument, centered below the arranger.
120 @item dedication            
121     To whom the piece is dedicated.
122 @item piece
123     Name of the piece, left flushed below the instrument.
124 @item head
125     A text to print in the header of all pages. It is not called
126 @code{header}, because @code{\header} is a reserved word in LilyPond.
127 @item copyright
128     A text to print in the footer of the first page. Default is to 
129     print the standard footer also on the first page. Note that if the
130     score is only page, the first page is also the last page and in this
131     case, the tagline is printed instead of the copyright.
132 @item footer
133     A text to print in the footer of all but the last page.
134 @item tagline
135     Line to print at the bottom of last page. The default text is ``Engraved by LilyPond @var{version-number}''.
136 @end table
137
138
139 @cindex header
140 @cindex footer
141 @cindex page layout
142 @cindex titles
143
144
145
146 @subsection Additional parameters
147
148 The @code{lilypond} program responds to several parameters specified
149 in a @code{\paper} section of the input file. They can be overridden
150 by supplying a @code{--set} command line option.
151
152 @table @code
153 @item language
154     Specify La@TeX{} language: the @code{babel} package will be
155 included.  Default: unset.
156
157         Read from the @code{\header} block.
158
159 @item latexheaders
160     Specify additional La@TeX{} headers file.
161
162         Normally read from the @code{\header} block. Default value: empty.
163
164 @item latexpackages
165     Specify additional La@TeX{} packages file. This works cumulative,
166 so you can add multiple packages using multiple @code{-s=latexpackages} options.
167        Normally read from the @code{\header} block. Default value:
168 @code{geometry}.
169
170 @item latexoptions
171     Specify additional options for the La@TeX{}
172 @code{\documentclass}. You can put any valid value here. This was
173 designed to allow @code{lilypond} to produce output for double-sided
174 paper, with balanced margins and pagenumbers on alternating sides. To
175 achieve this specify @code{twoside}.
176
177 @item orientation
178     Set orientation. Choices are @code{portrait} or @code{landscape}. Is
179 read from the @code{\paper} block, if set.
180         
181 @item textheight
182     The vertical extension of the music on the page. It is normally 
183     calculated automatically, based on the paper size.
184
185 @item linewidth
186         The music line width. It is normally read from the @code{\paper}
187 block.
188
189 @item papersize
190    The paper size (as a name, e.g. @code{a4}). It is normally read from
191 the @code{\paper} block.
192
193 @item pagenumber
194    If set to @code{no}, no page numbers will be printed.  If set to a
195 positive integer, start with this value as the first page number.
196
197   
198   @item fontenc
199      The font encoding, should be set identical to the @code{font-encoding}
200      property in the score.
201 @end table
202
203
204
205 @node Invoking the lilypond binary
206 @section Invoking the lilypond binary
207 @cindex Invoking LilyPond
208 @cindex command line options
209 @cindex options, command line
210 @cindex switches
211
212
213 The LilyPond system consists of two parts: a binary executable, which
214 is responsible for the formatting functionality, and support scripts,
215 which post-process the resulting output. Normally, the support scripts
216 are called, which in turn invoke the @code{lilypond-bin}
217 binary. However, @code{lilypond-bin} may be called directly as
218 follows.
219
220 @example
221         lilypond-bin [@var{option}]@dots{} @var{file}@dots{}
222 @end example
223
224
225 When invoked with a filename that has no extension, the @file{.ly}
226 extension is tried first.  To read input from  stdin, use a
227 dash @code{-} for @var{file}.
228
229 When @file{filename.ly} is processed it will produce
230 @file{filename.tex} as output (or @file{filename.ps} for PostScript
231 output).  If @file{filename.ly} contains more than one @code{\score}
232 block, then the rest of the scores will be output in numbered files,
233 starting with @file{filename-1.tex}.  Several files can be specified;
234 they will each be processed independently.  @footnote{The status of
235   GUILE is not reset across invocations, so be careful not to change any
236   system defaults from within Scheme.}
237
238
239 @section Command line options
240
241 The following options are supported:
242
243 @table @code
244
245 @item -e,--evaluate=@var{expr}
246 Evaluate the Scheme @var{expr} before parsing any @file{.ly} files.
247 Multiple @code{-e} options may be given, they will be evaluated
248 sequentially.  The function @code{ly:set-option} allows for access to
249 some internal variables.  Use @code{-e '(ly:option-usage')} for more
250 information.
251
252 @item -f,--format=@var{format}
253 @c
254 @c
255 Output format for sheet music. Choices are @code{tex} (for @TeX{}
256 output, to be processed with plain @TeX{}, or through @code{lilypond}),
257 @code{pdftex} for PDF@TeX{} input, @code{ps} (for PostScript),
258 @code{scm} (for a Scheme dump), @code{sk} (for Sketch) and @code{as}
259 (for ASCII-art).
260
261 @strong{This option is only for developers}. Only the @TeX{} output of
262 these is usable for real work.
263
264
265 @cindex output format, setting
266 @cindex Sketch output
267 @cindex ASCII-art output
268 @cindex PDFTeX output
269 @cindex PostScript output
270 @cindex Scheme dump
271
272 @item -h,--help
273 Show a summary of usage.
274 @item --include, -I=@var{directory}
275 Add @var{directory} to the search path for input files.
276 @cindex file searching
277 @cindex search path
278 @item -i,--init=@var{file}
279 Set init file to @var{file} (default: @file{init.ly}).
280 @item -m,--no-paper
281 @cindex MIDI
282 Disable @TeX{} output. If you have a @code{\midi} definition MIDI output
283 will be generated.
284 @item -M,--dependencies
285 Output rules to be included in Makefile.
286 @item -o,--output=@var{FILE}
287 Set the default output file to @var{FILE}.
288
289 @ignore
290 @item -s,--safe
291 Disallow untrusted @code{\include} directives, in-line
292 Scheme evaluation, backslashes in @TeX{}, code.
293
294 @strong{WARNING}: the @code{--safe} option has not been reviewed for a
295 long time. Do not rely on it for automatic invocation (e.g. over the
296 web). Volunteers are welcome to do a new audit.
297 @end ignore
298
299 @item -v,--version
300 Show version information.
301 @item -V,--verbose
302 Be verbose: show full paths of all  files read, and give timing
303 information.
304
305 @item -w,--warranty
306 Show the warranty with which GNU LilyPond comes. (It comes with 
307 @strong{NO WARRANTY}!)
308 @end table
309
310 @section Environment variables
311
312
313 For processing both the @TeX{} and the PostScript output, the
314 appropriate environment variables must be set.  The following scripts
315 do this:
316
317 @itemize @bullet
318 @item @file{buildscripts/out/lilypond-profile}
319 (for SH shells)
320 @item  @file{buildscripts/out/lilypond-login} (for C-shells)
321 @end itemize
322
323 They should normally be sourced as part of the login process. If these
324 scripts are not run from the system wide login process, then you must
325 run it yourself.
326
327 @cindex installing LilyPond
328
329 If you use sh, bash, or a similar shell, then add the following to
330 your @file{.profile}:
331 @example
332         . @var{/the/path/to/}lilypond-profile
333 @end example
334
335 If you use csh, tcsh or a similar shell, then add the following to
336 your @file{~/.login}:
337 @example
338         source @var{/the/path/to/}lilypond-login
339 @end example
340
341 Of course, in both cases, you should substitute the proper location of
342 either script.
343
344 These scripts set the following variables:
345 @table @code
346 @item TEXMF
347  To make sure that @TeX{} and lilypond find data files (among
348 others @file{.tex}, @file{.mf} and @file{.tfm}),
349 you have to set @code{TEXMF} to point to the lilypond data
350 file tree. A typical setting would be
351 @example
352 @{/usr/share/lilypond/1.6.0,@{!!/usr/share/texmf@}@}
353 @end example
354
355
356 @item GS_LIB
357 For processing PostScript output (obtained with
358 @code{-f ps}) with Ghostscript you have to set @code{GS_LIB} to
359 point to the directory containing library PS files.
360
361 @item GS_FONTPATH
362 For processing PostScript output (obtained with
363 @code{-f ps}) with Ghostscript you have to set @code{GS_FONTPATH} to
364 point to the directory containing  PFA files.
365
366 When you print direct PS output, remember to send the PFA files to the
367 printer as well.
368 @end table
369
370
371 @cindex ghostscript
372 @cindex PostScript
373 @cindex GS_FONTPATH
374 @cindex GS_LIB
375 @cindex TEXMF
376 @cindex printing postscript
377
378 The  binary itself recognizes the following environment variables:
379 @table @code
380 @item LILYPONDPREFIX
381 This specifies a directory where locale messages and
382 data files will be looked up by default. The directory should contain
383 subdirectories called @file{ly/}, @file{ps/}, @file{tex/}, etc.
384
385 @item LANG
386 This selects the language for the warning messages.
387 @end table
388
389 @cindex LANG
390 @cindex LILYPONDPREFIX
391
392 @node Error messages
393 @section Error messages
394
395 @cindex error messages
396 Different error messages can appear while compiling a file:
397
398 @table @emph
399 @cindex warning
400
401 @item Warning
402   Something looks suspect. If you are requesting something out of the
403 ordinary then you will understand the message, and can ignore it.
404 However, warnings usually indicate that something is wrong with the
405 input file.
406
407 @item Error
408 Something is definitely wrong.  The current processing step (parsing,
409 interpreting, or formatting) will be finished, but the next step will
410 be skipped.
411
412 @cindex error
413 @cindex fatal error
414 @item Fatal error
415 Something is definitely wrong, and LilyPond cannot continue. This
416 happens rarely. The most usual cause is misinstalled fonts.
417
418 @cindex call trace
419 @cindex Scheme error
420 @item Scheme error
421 Errors that occur while executing Scheme code are caught by the Scheme
422 interpreter. If running with the verbose option (@code{-V} or
423 @code{--verbose}) then a call trace is printed of the offending
424 function call.
425
426 @cindex Programming error
427 @item Programming error
428 There was some internal inconsistency. These error messages are
429 intended to help the programmers and debuggers. Usually, they can be
430 ignored. Sometimes, they come in such big quantities that they obscure
431 other output. In this case, a bug-report should be filed.
432
433 @end table
434
435 @cindex errors, message format
436 If warnings and errors can
437 be linked to some part of the input file, then error messages have the
438 following form
439
440 @example
441   @var{filename}:@var{lineno}:@var{columnno}: @var{message}
442   @var{offending input line}
443 @end example 
444
445 A line-break is inserted in offending line to indicate the column
446 where the error was found. For example, 
447
448 @example
449 test.ly:2:19: error: not a duration: 5:
450   \notes @{ c'4 e'5 
451                    g' @}
452 @end example
453
454
455 @node Reporting bugs
456 @section Reporting bugs
457
458 @cindex bugs
459 @cindex reporting bugs
460
461 If you have input that results in a crash or an erroneous output, then
462 that is a bug. We try respond to bug-reports promptly, and fix them as
463 soon as possible. For this, we need to reproduce and isolate the
464 problem. Help us by sending a defective input file, so we can
465 reproduce the problem. Make it small, so we can easily debug the
466 problem. Don't forget to tell which version you use, and on which
467 platform you run it.  Send the report to
468 @email{bug-lilypond@@gnu.org}.
469
470 @node Editor support
471 @section Editor support
472
473 @cindex editors
474 @cindex vim
475 @cindex emacs
476 @cindex modes, editor 
477 @cindex syntax coloring
478 @cindex coloring, syntax
479
480 There is support from different editors  for LilyPond.
481
482 Emacs has a @file{lilypond-mode}, which provides keyword
483 autocompletion, indentation, LilyPond specific parenthesis matching
484 and syntax coloring, handy compile short-cuts and reading LilyPond
485 manuals using Info.  If lilypond-mode is not installed on your
486 platform, then refer to the installation instructions for more
487 information.
488
489 For @uref{http://www.vim.org,VIM}, a vimrc is supplied, along with
490 syntax coloring tools. For more information, refer to the
491 @ifhtml
492 @uref{../../../topdocs/out-www/INSTALL.html,installation instructions}.
493 @end ifhtml
494
495 @ifnothtml
496 installation instructions.
497 @end ifnothtml
498
499 For both editors, there is also a facility to jump in the input file
500 to the source of errors in the graphical output. See @ref{Point and
501 click}.
502
503 There exists a plugin for @uref{http://www.jedit.org/,jEdit}. Refer to
504 the @uref{http://lily4jedit.sourceforget.net,plugin website} for more
505 information.
506
507
508 @node Point and click
509 @section Point and click
510 @cindex poind and click
511
512 Point and click lets you find notes in the input by clicking on them in
513 the Xdvi window. This makes it easier to find input that causes some
514 error in the sheet music.
515
516 To use it, you need the following software:
517 @itemize @bullet
518 @item a dvi viewer that supports src specials:
519 @itemize @bullet
520 @item Xdvi, version 22.36 or newer.  Available from
521 @uref{ftp://ftp.math.berkeley.edu/pub/Software/TeX/xdvi.tar.gz,ftp.math.berkeley.edu}.
522
523    Most @TeX{} distributions ship with xdvik, which is always a few
524 versions behind the official Xdvi. To find out which Xdvi you are
525 running, try @code{xdvi -version} or @code{xdvi.bin -version}.
526 @item KDVI.  A dvi viewer for KDE.  You need KDVI from KDE 3.0 or
527 newer.  Enable option @emph{Inverse search} in the menu @emph{Settings}.
528
529 Apparently, KDVI does not process PostScript specials correctly. Beams
530 and slurs will not be visible in KDVI.
531
532 @cindex Xdvi
533 @cindex KDVI
534 @cindex KDE
535
536
537
538 @end itemize
539 @item an editor with a client/server interface (or a lightweight GUI
540 editor):
541
542 @cindex editor
543
544 @itemize @bullet
545 @item Emacs. Emacs is an extensible text-editor.  It is available from
546 @uref{http://www.gnu.org/software/emacs/}.  You need version 21 to use
547 column location.
548
549 @c move this elsewhere?
550
551
552 @cindex Emacs
553 @cindex Emacs mode
554 @cindex lilypond-mode for Emacs
555 @cindex syntax coloring
556
557 @item XEmacs. XEmacs is very similar to Emacs.
558
559 @cindex XEmacs
560
561 @item NEdit.  NEdit runs under Windows, and Unix.
562   It is available from @uref{http://www.nedit.org}.
563
564 @cindex NEdit
565
566 @item GVim.  GVim is a GUI variant of VIM, the popular VI
567 clone.  It is available from @uref{http://www.vim.org}.
568
569 @cindex GVim
570 @cindex Vim
571
572 @end itemize
573 @end itemize
574
575
576 Xdvi must be configured to find the @TeX{} fonts and music
577 fonts. Refer to the Xdvi documentation for more information.
578
579 To use point-and-click, add one of these lines to the top of your .ly
580 file:
581 @example
582 #(ly:set-point-and-click 'line)
583 @end example
584 @cindex line-location
585
586 When viewing, Control-Mousebutton 1 will take you to the originating
587 spot in the @file{.ly} file.  Control-Mousebutton 2 will show all
588 clickable boxes.
589
590 If you correct large files with point-and-click, be sure to start
591 correcting at the end of the file. When you start at the top, and
592 insert one line, all following locations will be off by a line.
593
594 @cindex Emacs
595 For using point-and-click with Emacs,  add the following
596 In your Emacs startup file (usually @file{~/.emacs}):
597 @example
598 (server-start)
599 @end example
600
601 Make sure that the environment variable @var{XEDITOR} is set to
602 @example
603 emacsclient --no-wait +%l %f
604 @end example
605 @cindex @var{XEDITOR}
606 If you use XEmacs instead of Emacs, you use @code{(gnuserve-start)} in
607 your @file{.emacs}, and set @code{XEDITOR} to @code{gnuclient -q +%l %f}.
608
609 For using Vim, set @code{XEDITOR} to @code{gvim --remote +%l %f}, or
610 use this argument with Xdvi's @code{-editor} option.
611
612 @cindex NEdit
613 For using NEdit, set @code{XEDITOR} to @code{nc -noask +%l %f}, or
614 use this argument with Xdvi's @code{-editor} option.
615
616 If can also make your editor jump to the exact location of the note
617 you clicked. This is only supported on Emacs and VIM. Users of Emacs version
618 20 must apply the patch @file{emacsclient.patch}. Users of version 21
619 must apply @file{server.el.patch} (version 21.2 and earlier).  At the
620 top of the @code{ly} file, replace the @code{set-point-and-click} line
621 with the following line:
622 @example
623 #(ly:set-point-and-click 'line-column)
624 @end example
625 @cindex line-colomn-location
626 and set @code{XEDITOR} to @code{emacsclient --no-wait +%l:%c %f}.  Vim
627 users can set @var{XEDITOR} to @code{gvim --remote +:%l:norm%c| %f}.
628
629
630
631 @refbugs
632
633 When you convert the @TeX{} file to PostScript using @code{dvips}, it
634 will complain about not finding @code{src:X:Y} files. These complaints
635 are harmless, and can be ignored.
636
637
638