Next: Integrating music and text, Up: LilyPond-book
Some texts contain music examples. These texts are musicological treatises, songbooks, or manuals like this. Such texts can be made by hand, simply by importing a PostScript figure into the word processor. However, there is an automated procedure to reduce the amount of work involved in HTML, LaTeX, Texinfo and DocBook documents.
A script called lilypond-book
will extract the music fragments,
format them, and put back the resulting notation. Here we show a small
example for use with LaTeX. The example also contains explanatory
text, so we will not comment on it further.
\documentclass[a4paper]{article} \begin{document} Documents for \verb+lilypond-book+ may freely mix music and text. For example, \begin{lilypond} \relative c' { c2 g'2 \times 2/3 { f8 e d } c'2 g4 } \end{lilypond} Options are put in brackets. \begin[fragment,quote,staffsize=26,verbatim]{lilypond} c'4 f16 \end{lilypond} Larger examples can be put into a separate file, and introduced with \verb+\lilypondfile+. \lilypondfile[quote,noindent]{screech-boink.ly} (If needed, replace screech-boink.ly by any .ly file you put in the same directory as this file.) \end{document}
Save the code above to a file called lilybook.lytex, then in a terminal run
lilypond-book --output=out --pdf lilybook.lytex
lilypond-book (GNU LilyPond) 2.11.58
Reading lilybook.lytex...
..lots of stuff deleted..
Compiling lilybook.tex...
cd out
pdflatex lilybook
..lots of stuff deleted..
xpdf lilybook
(replace xpdf by your favorite PDF viewer)
Running lilypond-book and latex creates a lot of
temporary files, which would clutter up the working directory. To
remedy this, use the --output=
dir option. It will create
the files in a separate subdirectory dir.
Finally the result of the LaTeX example shown above.1 This finishes the tutorial section.
Documents for lilypond-book may freely mix music and text. For example,
Options are put in brackets.
c'4 f16
Larger examples can be put into a separate file, and introduced with
\lilypondfile
.
[1] This tutorial is processed with Texinfo, so the example gives slightly different results in layout.
Cette page documente LilyPond-2.11.58 (branche de développement).
Rapportez toute anomalie en français à lilypond-user-fr@gnu.org ou en anglais à http://post.gmane.org/post.php?group=gmane.comp.gnu.lilypond.bugs
Vos suggestions à propos de la documentation sont les bienvenues.