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