2 @node Invoking LilyPond
3 @chapter Invoking LilyPond
5 This chapter details the technicalities of running LilyPond.
14 * Invoking lilypond-latex::
17 @node Invoking lilypond
18 @section Invoking lilypond
19 @cindex Invoking LilyPond
20 @cindex command line options
21 @cindex options, command line
25 The @code{lilypond} may be called as follows from the command line.
28 lilypond [@var{option}]@dots{} @var{file}@dots{}
32 When invoked with a filename that has no extension, the @file{.ly}
33 extension is tried first. To read input from stdin, use a
34 dash @code{-} for @var{file}.
36 When @file{filename.ly} is processed it will produce
37 @file{filename.tex} as output (or @file{filename.ps} for PostScript
38 output). If @file{filename.ly} contains more than one @code{\score}
39 block, then the rest of the scores will be output in numbered files,
40 starting with @file{filename-1.tex}. Several files can be specified;
41 they will each be processed independently. @footnote{The status of
42 GUILE is not reset across invocations, so be careful not to change any
43 system defaults from within Scheme.}
46 @section Command line options
48 The following options are supported:
52 @item -e,--evaluate=@var{expr}
53 Evaluate the Scheme @var{expr} before parsing any @file{.ly} files.
54 Multiple @code{-e} options may be given, they will be evaluated
55 sequentially. The function @code{ly:set-option} allows for access to
56 some internal variables. Use @code{-e '(ly:option-usage)'} for more
59 @item -f,--format=@var{format}
62 A comma separated list of back-end output formats to use. Choices are
63 @code{tex} (for @TeX{} output, to be processed with La@TeX{}, and
64 @code{ps} for PostScript.
66 Other output options are intended for developers.
69 @cindex output format, setting
70 @cindex PostScript output
74 Show a summary of usage.
75 @item --include, -I=@var{directory}
76 Add @var{directory} to the search path for input files.
77 @cindex file searching
79 @item -i,--init=@var{file}
80 Set init file to @var{file} (default: @file{init.ly}).
81 @item -o,--output=@var{FILE}
82 Set the default output file to @var{FILE}.
86 Generate DVI files. In this case, the @TeX{} backend should be
87 specified, i.e. @code{-f tex}.
89 Generate pictures of each page, in PNG format. This implies @code{--ps}.
91 Generate PDF. This implies @code{--ps}.
93 Generate an output file containing the titles and the first system
97 Do not trust the @code{.ly} input.
99 When LilyPond formatting available through a web server, the
100 @code{--safe} @b{MUST} be passed. This will prevent code like
105 c4^#(ly:export (ly:gulp-file "/etc/passwd"))
109 The @code{--safe} option works by evaluating in-line Scheme
110 expressions in a special safe module. This safe module is derived from
111 GUILE @file{safe-r5rs} module, but adds a number of functions of the
112 LilyPond API. These functions are listed in @file{safe-lily.scm}.
114 In addition, @code{--safe} disallows @code{\include} directives and
115 disables the use of backslashes in @TeX{} strings.
117 In @code{--safe} mode, it is not possible to import LilyPond variables
121 Show version information.
123 Be verbose: show full paths of all files read, and give timing
127 Show the warranty with which GNU LilyPond comes. (It comes with
128 @strong{NO WARRANTY}!)
131 @section Environment variables
134 For processing both the @TeX{} and the PostScript output, the
135 appropriate environment variables must be set. The following scripts
139 @item @file{buildscripts/out/lilypond-profile}
141 @item @file{buildscripts/out/lilypond-login} (for C-shells)
144 They should normally be sourced as part of the login process. If these
145 scripts are not run from the system wide login process, then you must
148 @cindex installing LilyPond
150 If you use sh, bash, or a similar shell, then add the following to
151 your @file{.profile}:
153 . @var{/the/path/to/}lilypond-profile
156 If you use csh, tcsh or a similar shell, then add the following to
157 your @file{~/.login}:
159 source @var{/the/path/to/}lilypond-login
162 Of course, in both cases, you should substitute the proper location of
165 These scripts set the following variables:
168 To make sure that @TeX{} and lilypond find data files (among
169 others @file{.tex}, @file{.mf} and @file{.tfm}),
170 you have to set @code{TEXMF} to point to the lilypond data
171 file tree. A typical setting would be
173 @{/usr/share/lilypond/1.6.0,@{!!/usr/share/texmf@}@}
178 For processing PostScript output (obtained with
179 @code{-f ps}) with Ghostscript you have to set @code{GS_LIB} to
180 point to the directory containing library PS files.
183 For processing PostScript output (obtained with
184 @code{-f ps}) with Ghostscript you have to set @code{GS_FONTPATH} to
185 point to the directory containing PFA files.
187 When you print direct PS output, remember to send the PFA files to the
197 @cindex printing postscript
199 The binary itself recognizes the following environment variables:
202 This specifies a directory where locale messages and
203 data files will be looked up by default. The directory should contain
204 subdirectories called @file{ly/}, @file{ps/}, @file{tex/}, etc.
207 This selects the language for the warning messages.
211 @cindex LILYPONDPREFIX
214 @section Error messages
216 @cindex error messages
217 Different error messages can appear while compiling a file:
223 Something looks suspect. If you are requesting something out of the
224 ordinary then you will understand the message, and can ignore it.
225 However, warnings usually indicate that something is wrong with the
229 Something is definitely wrong. The current processing step (parsing,
230 interpreting, or formatting) will be finished, but the next step will
236 Something is definitely wrong, and LilyPond cannot continue. This
237 happens rarely. The most usual cause is misinstalled fonts.
239 @cindex trace, Scheme
243 Errors that occur while executing Scheme code are caught by the Scheme
244 interpreter. If running with the verbose option (@code{-V} or
245 @code{--verbose}) then a call trace is printed of the offending
248 @cindex Programming error
249 @item Programming error
250 There was some internal inconsistency. These error messages are
251 intended to help the programmers and debuggers. Usually, they can be
252 ignored. Sometimes, they come in such big quantities that they obscure
253 other output. In this case, file a bug-report.
255 @item Aborted (core dumped)
256 This signals a serious programming error that caused the program to
257 crash. Such errors are considered critical. If you stumble on one,
263 @cindex errors, message format
264 If warnings and errors can
265 be linked to some part of the input file, then error messages have the
269 @var{filename}:@var{lineno}:@var{columnno}: @var{message}
270 @var{offending input line}
273 A line-break is inserted in offending line to indicate the column
274 where the error was found. For example,
277 test.ly:2:19: error: not a duration: 5:
284 @section Reporting bugs
287 @cindex reporting bugs
289 If you have input that results in a crash or an erroneous output, then
290 that is a bug. We try respond to bug-reports promptly, and fix them as
291 soon as possible. For this, we need to reproduce and isolate the
292 problem. Help us by sending a defective input file, so we can
293 reproduce the problem. Make it small, so we can easily debug the
294 problem. Don't forget to tell which version you use, and on which
295 platform you run it. Send the report to
296 @email{bug-lilypond@@gnu.org}.
299 @section Editor support
304 @cindex modes, editor
305 @cindex syntax coloring
306 @cindex coloring, syntax
308 There is support from different editors for LilyPond.
312 Emacs has a @file{lilypond-mode}, which provides keyword
313 autocompletion, indentation, LilyPond specific parenthesis matching
314 and syntax coloring, handy compile short-cuts and reading LilyPond
315 manuals using Info. If lilypond-mode is not installed on your
316 platform, then refer to the installation instructions for more
321 For @uref{http://www.vim.org,VIM}, a vimrc is supplied, along with
322 syntax coloring tools. For more information, refer to the
324 @uref{../../../topdocs/out-www/INSTALL.html,installation instructions}.
327 installation instructions.
331 For both editors, there is also a facility to jump in the input file
332 to the source of errors in the graphical output. See @ref{Point and
337 There exists a plugin for @uref{http://www.jedit.org/,jEdit}. Refer to
338 the @uref{http://lily4jedit.sourceforge.net,plugin website} for more
343 @node Point and click
344 @section Point and click
345 @cindex point and click
347 @cindex source specials
348 @cindex specials, source
350 Point and click lets you find notes in the input by clicking on them in
351 the Xdvi window. This makes it easier to find input that causes some
352 error in the sheet music.
354 To use it, you need the following software:
356 @item a dvi viewer that supports src specials:
358 @item Xdvi, version 22.36 or newer. Available from
359 @uref{ftp://ftp.math.berkeley.edu/pub/Software/TeX/xdvi.tar.gz,ftp.math.berkeley.edu}.
361 Most @TeX{} distributions ship with xdvik, which is always a few
362 versions behind the official Xdvi. To find out which Xdvi you are
363 running, try @code{xdvi -version} or @code{xdvi.bin -version}.
364 @item KDVI. A dvi viewer for KDE. You need KDVI from KDE 3.0 or
365 newer. Enable option @emph{Inverse search} in the menu @emph{Settings}.
367 Apparently, KDVI does not process PostScript specials correctly. Beams
368 and slurs will not be visible in KDVI.
377 @item an editor with a client/server interface (or a lightweight GUI
383 @item Emacs. Emacs is an extensible text-editor. It is available from
384 @uref{http://www.gnu.org/software/emacs/}. You need version 21 to use
387 @c move this elsewhere?
392 @cindex lilypond-mode for Emacs
393 @cindex syntax coloring
395 @item XEmacs. XEmacs is very similar to Emacs.
399 @item NEdit. NEdit runs under Windows, and Unix.
400 It is available from @uref{http://www.nedit.org}.
404 @item GVim. GVim is a GUI variant of VIM, the popular VI
405 clone. It is available from @uref{http://www.vim.org}.
414 Xdvi must be configured to find the @TeX{} fonts and music
415 fonts. Refer to the Xdvi documentation for more information.
417 To use point-and-click, add one of these lines to the top of your .ly
420 #(ly:set-point-and-click 'line)
422 @cindex line-location
424 When viewing, Control-Mousebutton 1 will take you to the originating
425 spot in the @file{.ly} file. Control-Mousebutton 2 will show all
428 If you correct large files with point-and-click, be sure to start
429 correcting at the end of the file. When you start at the top, and
430 insert one line, all following locations will be off by a line.
433 For using point-and-click with Emacs, add the following
434 In your Emacs startup file (usually @file{~/.emacs}):
439 Make sure that the environment variable @var{XEDITOR} is set to
441 emacsclient --no-wait +%l %f
443 @cindex @var{XEDITOR}
444 If you use XEmacs instead of Emacs, you use @code{(gnuserve-start)} in
445 your @file{.emacs}, and set @code{XEDITOR} to @code{gnuclient -q +%l %f}.
447 For using Vim, set @code{XEDITOR} to @code{gvim --remote +%l %f}, or
448 use this argument with Xdvi's @code{-editor} option.
451 For using NEdit, set @code{XEDITOR} to @code{nc -noask +%l %f}, or
452 use this argument with Xdvi's @code{-editor} option.
454 If can also make your editor jump to the exact location of the note
455 you clicked. This is only supported on Emacs and VIM. Users of Emacs version
456 20 must apply the patch @file{emacsclient.patch}. Users of version 21
457 must apply @file{server.el.patch} (version 21.2 and earlier). At the
458 top of the @code{ly} file, replace the @code{set-point-and-click} line
459 with the following line:
461 #(ly:set-point-and-click 'line-column)
463 @cindex line-column-location
464 and set @code{XEDITOR} to @code{emacsclient --no-wait +%l:%c %f}. Vim
465 users can set @var{XEDITOR} to @code{gvim --remote +:%l:norm%c| %f}.
469 @node Invoking lilypond-latex
470 @section Invoking lilypond-latex
472 Before LilyPond 3.0, the @code{lilypond} program only generated music
473 notation. Titles and page layout was done in a separate wrapper
474 program. For compatibility with older files, this wrapper program has
475 been retained as @code{lilypond-latex}. It uses the LilyPond program
476 and La@TeX{} to create a nicely titled piece of sheet music. Use of
477 this program is only necessary if the input file contains special
478 La@TeX{} options or formatting codes in markup texts.
480 The @code{lilypond-latex} wrapper is invoked from the command-line as
483 @code{lilypond-latex} [@var{option}]@dots{} @var{file}@dots{}
486 To have @code{lilypond-latex} read from stdin, use a dash @code{-} for
487 @var{file}. The program supports the following options.
489 @cindex stdin, reading
493 Keep the temporary directory with all output
494 files. The temporary directory is created in the current directory as @code{@code{lilypond}.dir}.
497 @item -I,--include=@var{dir}
498 Add @var{dir} to LilyPond's include path.
499 @item -o,--output=@var{file}
500 Generate output to @var{file}. The extension of @var{file} is ignored.
502 Also generate pictures of each page, in PNG format.
504 Also generate a picture of the first system of the score.
513 @item -s,--set=@var{key}=@var{val}
514 Add @var{key}= @var{val} to the settings, overriding those specified
515 in the files. Possible keys: @code{language}, @code{latexheaders},
516 @code{latexpackages}, @code{latexoptions}, @code{papersize},
517 @code{linewidth}, @code{orientation},
520 Show version information.
522 Be verbose. This prints out commands as they are executed, and more
523 information about the formatting process is printed.
525 Print even more information. This is useful when generating bug reports.
527 Show the warranty with which GNU LilyPond comes. (It comes with
528 @strong{NO WARRANTY}!)
533 @subsection Additional parameters
535 The @code{lilypond} program responds to several parameters specified
536 in a @code{\paper} section of the input file. They can be overridden
537 by supplying a @code{--set} command line option.
541 Specify La@TeX{} language: the @code{babel} package will be
542 included. Default: unset.
544 Read from the @code{\header} block.
547 Specify additional La@TeX{} headers file.
548 Normally read from the @code{\header} block. Default value: empty.
551 Specify additional La@TeX{} packages file. This works cumulative,
552 so you can add multiple packages using multiple @code{-s=latexpackages} options.
553 Normally read from the @code{\header} block. Default value:
557 Specify additional options for the La@TeX{}
558 @code{\documentclass}. You can put any valid value here. This was
559 designed to allow @code{lilypond} to produce output for double-sided
560 paper, with balanced margins and page numbers on alternating sides. To
561 achieve this specify @code{twoside}.
564 Set orientation. Choices are @code{portrait} or @code{landscape}. Is
565 read from the @code{\paper} block, if set.
568 The vertical extension of the music on the page. It is normally
569 calculated automatically, based on the paper size.
572 The music line width. It is normally read from the @code{\paper}
576 The paper size (as a name, e.g. @code{a4}). It is normally read from
577 the @code{\paper} block.
580 The font encoding, should be set identical to the @code{font-encoding}
581 property in the score.