|
|
GNU LilyPondWelcome to the home of the GNU Music Typesetter |
||||||||||
|
Node:Integrating text and music, Next:End of tutorial, Previous:Other ways to run LilyPond, Up:Tutorial Integrating text and musicSometimes, you might want to use music examples in a text that you are writing. For example, if you are writing 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 wordprocessor. However, there is a also an automated procedure: If you use 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, a number of 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} also shows the LilyPond code, \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 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 $ lilypond-book --outdir=out/ lilbook.tex lilypond-book (GNU LilyPond) 1.3.146 Reading `/home/hanwen/usr/src/lilypond-1.3.146/input/tutorial/lilbook.tex' Reading `/home/hanwen/usr/src/lilypond-1.3.146/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 more or less looks like this: In a lilypond-book document, you can freely mix music and text. For example:
If you have no In the example you see here, a number of things happened: a
c'4 f bes eshi 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 lilypond@packages.debian.org Copyright (c) 1997--2001 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.4.12 (stable-branch) by