[ << Running lilypond-book ] | [Top][Contents][Index] | [ External programs >> ] |
[ < Running lilypond-book ] | [ Up : Running lilypond-book ] | [ Integrating music and text > ] |
3.1 An example of a musicological document
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 or PDF 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
extracts the music fragments,
formats them, and puts 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.
Input
\documentclass[a4paper]{article} \begin{document} Documents for \verb+lilypond-book+ may freely mix music and text. For example, \begin{lilypond} \relative { c'2 e2 \tuplet 3/2 { f8 a b } a2 e4 } \end{lilypond} Options to control the appearance of the snippets can be added, too. For example, \begin{lilypond}[fragment,quote,staffsize=26,verbatim] c'4 f16 \end{lilypond} Larger music snippets can be put into separate files. For example, \lilypondfile[quote,noindent]{screech-and-boink.ly} (If needed, replace \verb+screech-and-boink.ly+ by any \verb+.ly+ file you put in the same directory as this file.) \end{document}
Processing
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.25.23
Reading 'lilybook.lytex'...
…lots of stuff deleted…
Writing 'out/lilybook.tex'...
> cd out
> pdflatex lilybook
This is pdfTeX, ...
(./lilybook.tex
…lots of stuff deleted…
Output written on lilypond.pdf, ...
> 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 to
create the files in a separate subdirectory dir.
Because this tutorial is written in Texinfo we cannot directly show the LaTeX output of the example. In the next section, however, you can see an approximation (structure-wise) of the result.
This finishes the tutorial section.
Output
Documents for lilypond-book
may freely mix music and text.
Using Texinfo syntax, this example
@lilypond \relative { c'2 e2 \tuplet 3/2 { f8 a b } a2 e4 } @end lilypond
produces
Options to control the appearance of snippets can be added, too. Using LaTeX syntax, this example
\begin{lilypond}[fragment, quote, staffsize=26] c'4 f16 \end{lilypond}
produces
Larger music snippets can be put into separate files. Using HTML syntax, this example
<lilypondfile quote noindent> snippets/screech-and-boink.ly </lilypondfile>
produces
If a tagline
is required, either default or custom, the
entire snippet must be enclosed in a \book { }
construct.
\book { \header { title = "A scale in LilyPond" } \relative { c' d e f g a b c } }
[ << Running lilypond-book ] | [Top][Contents][Index] | [ External programs >> ] |
[ < Running lilypond-book ] | [ Up : Running lilypond-book ] | [ Integrating music and text > ] |