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