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