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