![]() |
GNU LilyPond-- -- |
||||||||||
|
Integrating text and musicSometimes you might want to use music examples in a text that you are writing (for example a musicological treatise, a songbook, or (like us) the LilyPond manual). You can make such texts by hand, simply by importing a PostScript figure into your word processor. However, there is an automated procedure to reduce the amount of work. If you use HTML, LaTeX, or texinfo, you can mix text and LilyPond
code. A script called \documentclass[a4paper]{article} \begin{document} In a lilypond-book document, you can freely mix music and text. For example: \begin{lilypond} \score { \notes \relative c' { c2 g'2 \times 2/3 { f8 e d } c'2 g4 } } \end{lilypond} Notice that the music line length matches the margin settings of the document. If you have no \verb+\score+ block in the fragment, \texttt{lilypond-book} will supply one: \begin{lilypond} c'4 \end{lilypond} In the example you see here, two things happened: a \verb+\score+ block was added, and the line width was set to natural length. You can specify many more options using \LaTeX style options in brackets: \begin[verbatim,11pt,singleline, fragment,relative,intertext="hi there!"]{lilypond} c'4 f bes es \end{lilypond} \texttt{verbatim} prints the LilyPond code in addition to the graphical score, \texttt{11pt} selects the default music size, \texttt{fragment} adds a score block, \texttt{relative} uses relative mode for the fragment, and \texttt{intertext} specifies what to print between the \texttt{verbatim} code and the music. If you want to include large examples into the text, it may be more convenient to put the example in a separate file: \lilypondfile[printfilename]{sammartini.ly} The \texttt{printfilename} option adds the file name to the output. \end{document} Under Unix, you can view the results as follows. $ cd input/tutorial $ mkdir -p out/ $ lilypond-book --outdir=out/ lilbook.tex lilypond-book (GNU LilyPond) 1.6.1 Reading `input/tutorial/lilbook.tex' Reading `input/tutorial/sammartini.ly' lots of stuff deleted Writing `out/lilbook.latex' $ cd out $ latex lilbook.latex lots of stuff deleted $ xdvi lilbook Notice the The result looks more or less like this: In a lilypond-book document, you can freely mix music and text. For example: Notice that the music line length matches the margin settings of the document. If you have no In the example you see here, a number of things happened: a
c'4 f bes es hi there!
If you include large examples into the text, it may be more convenient
to put the example in a separate file:
The |
||||||||||
Go back to index of LilyPond.
Please send GNU LilyPond questions and comments to lilypond-user@gnu.org. Please send comments on these web pages to (address unknown) Copyright (c) 1997--2002 Han-Wen Nienhuys and Jan Nieuwenhuizen. Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved. |
This page was built from LilyPond-1.7.14 (development-branch) by