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