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