2 @node Invoking LilyPond
3 @chapter Invoking LilyPond
5 This chapter details the technicalities of running LilyPond.
9 * Invoking lilypond:: Titling LilyPond scores.
10 * Invoking the lilypond binary::
17 @node Invoking lilypond
18 @section Invoking lilypond
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)
27 @code{lilypond} [@var{option}]@dots{} @var{file}@dots{}
30 To have @code{lilypond} read from stdin, use a dash @code{-} for
31 @var{file}. The program supports the following options.
35 Keep the temporary directory with all output
36 files. The temporary directory is created in the current directory as @code{@code{lilypond}.dir}.
39 @item -I,--include=@var{dir}
40 Add @var{dir} to LilyPond's include path.
42 Produce MIDI output only.
44 Do not run @file{lilypond-bin}. Useful for debugging @code{lilypond}.
45 @item -o,--output=@var{file}
46 Generate output to @var{file}. The extension of @var{file} is ignored.
48 Do not generate (PDF) or PS.
51 @cindex Scalable fonts
54 Also generate pictures of each page, in PNG format.
56 Gzip the postscript file.
58 Make a .HTML file with links to all output files.
60 Also generate a picture of the first system of the score.
69 @item -s,--set=@var{key}=@var{val}
70 Add @var{key}= @var{val} to the settings, overriding those specified
71 in the files. Possible keys: @code{language}, @code{latexheaders},
72 @code{latexpackages}, @code{latexoptions}, @code{papersize},
73 @code{pagenumber}, @code{linewidth}, @code{orientation},
76 Show version information.
78 Be verbose. This prints out commands as they are executed, and more
79 information about the formatting process is printed.
81 Print even more information. This is useful when generating bug reports.
83 Show the warranty with which GNU LilyPond comes. (It comes with
84 @strong{NO WARRANTY}!)
87 @subsection Titling layout
89 @code{lilypond} extracts the following header fields from the LY files
90 to generate titling; an example demonstrating all these fields is in
91 @inputfileref{input/test,lilypond-testpage.ly}:
95 The title of the music. Centered on top of the first page.
97 Subtitle, centered below the title.
99 Name of the poet, left flushed below the subtitle.
101 Name of the composer, right flushed below the subtitle.
103 Meter string, left flushed below the poet.
105 Name of the opus, right flushed below the composer.
107 Name of the arranger, right flushed below the opus.
109 Name of the instrument, centered below the arranger.
111 To whom the piece is dedicated.
113 Name of the piece, left flushed below the instrument.
115 A text to print in the header of all pages. It is not called
116 @code{header}, because @code{\header} is a reserved word in LilyPond.
118 A text to print in the footer of the first page. Default is to
119 print the standard footer also on the first page. Note that if the
120 score consists of only a single page, the first page is also the
121 last page, and in this case, the tagline is printed instead of the
124 A text to print in the footer of all but the last page.
126 Line to print at the bottom of last page. The default text is ``Engraved
127 by LilyPond @var{version-number}''.
138 @subsection Additional parameters
140 The @code{lilypond} program responds to several parameters specified
141 in a @code{\paper} section of the input file. They can be overridden
142 by supplying a @code{--set} command line option.
146 Specify La@TeX{} language: the @code{babel} package will be
147 included. Default: unset.
149 Read from the @code{\header} block.
152 Specify additional La@TeX{} headers file.
154 Normally read from the @code{\header} block. Default value: empty.
157 Specify additional La@TeX{} packages file. This works cumulative,
158 so you can add multiple packages using multiple @code{-s=latexpackages} options.
159 Normally read from the @code{\header} block. Default value:
163 Specify additional options for the La@TeX{}
164 @code{\documentclass}. You can put any valid value here. This was
165 designed to allow @code{lilypond} to produce output for double-sided
166 paper, with balanced margins and page numbers on alternating sides. To
167 achieve this specify @code{twoside}.
170 Set orientation. Choices are @code{portrait} or @code{landscape}. Is
171 read from the @code{\paper} block, if set.
174 The vertical extension of the music on the page. It is normally
175 calculated automatically, based on the paper size.
178 The music line width. It is normally read from the @code{\paper}
182 The paper size (as a name, e.g. @code{a4}). It is normally read from
183 the @code{\paper} block.
186 If set to @code{no}, no page numbers will be printed. If set to a
187 positive integer, start with this value as the first page number.
191 The font encoding, should be set identical to the @code{font-encoding}
192 property in the score.
197 @node Invoking the lilypond binary
198 @section Invoking the lilypond binary
199 @cindex Invoking LilyPond
200 @cindex command line options
201 @cindex options, command line
205 The formatting system consists of two parts: a binary executable
206 (@file{lilypond-bin}), which is responsible for the formatting
207 functionality, and support scripts, which post-process the resulting
208 output. Normally, the support scripts are called, which in turn invoke
209 the @code{lilypond-bin} binary. However, @code{lilypond-bin} may be
210 called directly as follows.
213 lilypond-bin [@var{option}]@dots{} @var{file}@dots{}
217 When invoked with a filename that has no extension, the @file{.ly}
218 extension is tried first. To read input from stdin, use a
219 dash @code{-} for @var{file}.
221 When @file{filename.ly} is processed it will produce
222 @file{filename.tex} as output (or @file{filename.ps} for PostScript
223 output). If @file{filename.ly} contains more than one @code{\score}
224 block, then the rest of the scores will be output in numbered files,
225 starting with @file{filename-1.tex}. Several files can be specified;
226 they will each be processed independently. @footnote{The status of
227 GUILE is not reset across invocations, so be careful not to change any
228 system defaults from within Scheme.}
230 We strongly advise against making LilyPond formatting available
231 through a web server. That is, processing input from untrusted users,
232 and returning the resulting PDF file. LilyPond is a big and complex
233 program. It was not written with security in mind. Making it available
234 to the outside world is a huge risk; consider the security
240 c4^#(ly:export (ly:gulp-file "/etc/passwd"))
245 @section Command line options
247 The following options are supported:
251 @item -e,--evaluate=@var{expr}
252 Evaluate the Scheme @var{expr} before parsing any @file{.ly} files.
253 Multiple @code{-e} options may be given, they will be evaluated
254 sequentially. The function @code{ly:set-option} allows for access to
255 some internal variables. Use @code{-e '(ly:option-usage)'} for more
258 @item -f,--format=@var{format}
261 Output format for sheet music. Choices are @code{tex} (for @TeX{}
262 output, to be processed with La@TeX{}, or through @code{lilypond}),
263 @code{pdftex} for PDF@TeX{} input, @code{ps} (for PostScript),
264 @code{scm} (for a Scheme dump), @code{sk} (for Sketch).
266 @strong{This option is only for developers}. Only the @TeX{} output of
267 these is usable for real work.
270 @cindex output format, setting
271 @cindex Sketch output
272 @cindex PDFTeX output
273 @cindex PostScript output
277 Show a summary of usage.
278 @item --include, -I=@var{directory}
279 Add @var{directory} to the search path for input files.
280 @cindex file searching
282 @item -i,--init=@var{file}
283 Set init file to @var{file} (default: @file{init.ly}).
286 Disable @TeX{} output. If you have a @code{\midi} definition MIDI output
288 @item -o,--output=@var{FILE}
289 Set the default output file to @var{FILE}.
292 Disallow untrusted @code{\include} directives, limit available in-line
293 Scheme function, disable backslashes in @TeX{}, code.
296 Show version information.
298 Be verbose: show full paths of all files read, and give timing
302 Show the warranty with which GNU LilyPond comes. (It comes with
303 @strong{NO WARRANTY}!)
306 @section Environment variables
309 For processing both the @TeX{} and the PostScript output, the
310 appropriate environment variables must be set. The following scripts
314 @item @file{buildscripts/out/lilypond-profile}
316 @item @file{buildscripts/out/lilypond-login} (for C-shells)
319 They should normally be sourced as part of the login process. If these
320 scripts are not run from the system wide login process, then you must
323 @cindex installing LilyPond
325 If you use sh, bash, or a similar shell, then add the following to
326 your @file{.profile}:
328 . @var{/the/path/to/}lilypond-profile
331 If you use csh, tcsh or a similar shell, then add the following to
332 your @file{~/.login}:
334 source @var{/the/path/to/}lilypond-login
337 Of course, in both cases, you should substitute the proper location of
340 These scripts set the following variables:
343 To make sure that @TeX{} and lilypond find data files (among
344 others @file{.tex}, @file{.mf} and @file{.tfm}),
345 you have to set @code{TEXMF} to point to the lilypond data
346 file tree. A typical setting would be
348 @{/usr/share/lilypond/1.6.0,@{!!/usr/share/texmf@}@}
353 For processing PostScript output (obtained with
354 @code{-f ps}) with Ghostscript you have to set @code{GS_LIB} to
355 point to the directory containing library PS files.
358 For processing PostScript output (obtained with
359 @code{-f ps}) with Ghostscript you have to set @code{GS_FONTPATH} to
360 point to the directory containing PFA files.
362 When you print direct PS output, remember to send the PFA files to the
372 @cindex printing postscript
374 The binary itself recognizes the following environment variables:
377 This specifies a directory where locale messages and
378 data files will be looked up by default. The directory should contain
379 subdirectories called @file{ly/}, @file{ps/}, @file{tex/}, etc.
382 This selects the language for the warning messages.
386 @cindex LILYPONDPREFIX
389 @section Error messages
391 @cindex error messages
392 Different error messages can appear while compiling a file:
398 Something looks suspect. If you are requesting something out of the
399 ordinary then you will understand the message, and can ignore it.
400 However, warnings usually indicate that something is wrong with the
404 Something is definitely wrong. The current processing step (parsing,
405 interpreting, or formatting) will be finished, but the next step will
411 Something is definitely wrong, and LilyPond cannot continue. This
412 happens rarely. The most usual cause is misinstalled fonts.
414 @cindex trace, Scheme
418 Errors that occur while executing Scheme code are caught by the Scheme
419 interpreter. If running with the verbose option (@code{-V} or
420 @code{--verbose}) then a call trace is printed of the offending
423 @cindex Programming error
424 @item Programming error
425 There was some internal inconsistency. These error messages are
426 intended to help the programmers and debuggers. Usually, they can be
427 ignored. Sometimes, they come in such big quantities that they obscure
428 other output. In this case, file a bug-report.
432 @cindex errors, message format
433 If warnings and errors can
434 be linked to some part of the input file, then error messages have the
438 @var{filename}:@var{lineno}:@var{columnno}: @var{message}
439 @var{offending input line}
442 A line-break is inserted in offending line to indicate the column
443 where the error was found. For example,
446 test.ly:2:19: error: not a duration: 5:
453 @section Reporting bugs
456 @cindex reporting bugs
458 If you have input that results in a crash or an erroneous output, then
459 that is a bug. We try respond to bug-reports promptly, and fix them as
460 soon as possible. For this, we need to reproduce and isolate the
461 problem. Help us by sending a defective input file, so we can
462 reproduce the problem. Make it small, so we can easily debug the
463 problem. Don't forget to tell which version you use, and on which
464 platform you run it. Send the report to
465 @email{bug-lilypond@@gnu.org}.
468 @section Editor support
473 @cindex modes, editor
474 @cindex syntax coloring
475 @cindex coloring, syntax
477 There is support from different editors for LilyPond.
481 Emacs has a @file{lilypond-mode}, which provides keyword
482 autocompletion, indentation, LilyPond specific parenthesis matching
483 and syntax coloring, handy compile short-cuts and reading LilyPond
484 manuals using Info. If lilypond-mode is not installed on your
485 platform, then refer to the installation instructions for more
490 For @uref{http://www.vim.org,VIM}, a vimrc is supplied, along with
491 syntax coloring tools. For more information, refer to the
493 @uref{../../../topdocs/out-www/INSTALL.html,installation instructions}.
496 installation instructions.
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
506 There exists a plugin for @uref{http://www.jedit.org/,jEdit}. Refer to
507 the @uref{http://lily4jedit.sourceforge.net,plugin website} for more
512 @node Point and click
513 @section Point and click
514 @cindex point and click
516 @cindex source specials
517 @cindex specials, source
519 Point and click lets you find notes in the input by clicking on them in
520 the Xdvi window. This makes it easier to find input that causes some
521 error in the sheet music.
523 To use it, you need the following software:
525 @item a dvi viewer that supports src specials:
527 @item Xdvi, version 22.36 or newer. Available from
528 @uref{ftp://ftp.math.berkeley.edu/pub/Software/TeX/xdvi.tar.gz,ftp.math.berkeley.edu}.
530 Most @TeX{} distributions ship with xdvik, which is always a few
531 versions behind the official Xdvi. To find out which Xdvi you are
532 running, try @code{xdvi -version} or @code{xdvi.bin -version}.
533 @item KDVI. A dvi viewer for KDE. You need KDVI from KDE 3.0 or
534 newer. Enable option @emph{Inverse search} in the menu @emph{Settings}.
536 Apparently, KDVI does not process PostScript specials correctly. Beams
537 and slurs will not be visible in KDVI.
546 @item an editor with a client/server interface (or a lightweight GUI
552 @item Emacs. Emacs is an extensible text-editor. It is available from
553 @uref{http://www.gnu.org/software/emacs/}. You need version 21 to use
556 @c move this elsewhere?
561 @cindex lilypond-mode for Emacs
562 @cindex syntax coloring
564 @item XEmacs. XEmacs is very similar to Emacs.
568 @item NEdit. NEdit runs under Windows, and Unix.
569 It is available from @uref{http://www.nedit.org}.
573 @item GVim. GVim is a GUI variant of VIM, the popular VI
574 clone. It is available from @uref{http://www.vim.org}.
583 Xdvi must be configured to find the @TeX{} fonts and music
584 fonts. Refer to the Xdvi documentation for more information.
586 To use point-and-click, add one of these lines to the top of your .ly
589 #(ly:set-point-and-click 'line)
591 @cindex line-location
593 When viewing, Control-Mousebutton 1 will take you to the originating
594 spot in the @file{.ly} file. Control-Mousebutton 2 will show all
597 If you correct large files with point-and-click, be sure to start
598 correcting at the end of the file. When you start at the top, and
599 insert one line, all following locations will be off by a line.
602 For using point-and-click with Emacs, add the following
603 In your Emacs startup file (usually @file{~/.emacs}):
608 Make sure that the environment variable @var{XEDITOR} is set to
610 emacsclient --no-wait +%l %f
612 @cindex @var{XEDITOR}
613 If you use XEmacs instead of Emacs, you use @code{(gnuserve-start)} in
614 your @file{.emacs}, and set @code{XEDITOR} to @code{gnuclient -q +%l %f}.
616 For using Vim, set @code{XEDITOR} to @code{gvim --remote +%l %f}, or
617 use this argument with Xdvi's @code{-editor} option.
620 For using NEdit, set @code{XEDITOR} to @code{nc -noask +%l %f}, or
621 use this argument with Xdvi's @code{-editor} option.
623 If can also make your editor jump to the exact location of the note
624 you clicked. This is only supported on Emacs and VIM. Users of Emacs version
625 20 must apply the patch @file{emacsclient.patch}. Users of version 21
626 must apply @file{server.el.patch} (version 21.2 and earlier). At the
627 top of the @code{ly} file, replace the @code{set-point-and-click} line
628 with the following line:
630 #(ly:set-point-and-click 'line-column)
632 @cindex line-column-location
633 and set @code{XEDITOR} to @code{emacsclient --no-wait +%l:%c %f}. Vim
634 users can set @var{XEDITOR} to @code{gvim --remote +:%l:norm%c| %f}.