1 \documentclass[a4paper, 12pt]{article}
2 % keep \documentclass on 1st line for lilypond-book auto-detection
5 % This is way too long and hairy --
12 %\def\preLilyPondExample{}
13 %\def\postLilyPondExample{}
14 %\usepackage{graphics}
15 %\usepackage{landscape}
18 %uncomment this to try twocolumn mode
22 \section{LilyPond-book + LaTeX}
24 This is an examplefile for mixing LilyPond and Latex. It is also
25 used to test lilypond-book. View the source to see how it is done.
31 \relative c'{c d e f g a b c}
35 LilyPond-book search for the \verb|\score| command when it decides
36 if the code is only a fragment. Thus, in the following code, you have
37 to use \verb|fragment| option, because the comment confuses lilypond-book.
39 \begin{lilypond}[fragment]
43 There is also a shorthand version \verb|\lilypond[fragment]{c' e' g'}|:
45 \lilypond[fragment]{c' e' g'}
47 that is the same as writing
49 \begin{lilypond}[fragment]
55 %%\begin{lilypond}[staffsize=11,fragment]
56 \begin{lilypond}[staffsize=11,fragment]
57 \context Voice <<c' e' g'>>
60 \lilypond[fragment,staffsize=11]{\context Voice <<c' es' g'>>} chords are floating inside the text.
62 \subsection{verb and verbatim}
64 As you see, the begin/end verbatim command inside
65 does not confuse lilypond-book:
67 \verb|\begin{lilypond}[fragment]c d e\end{lilypond}|
69 Neither does a verbatim inside verb:
71 \verb|\begin{verbatim}\begin{lilypond}[fragment]c d e\end{lilypond}\end{verbatim}|
73 or verb inside verbatim:
76 \verb|\begin{lilypond}[fragment]c d e\end{lilypond}|
79 But this is just to stress \verb|lilypond-book|. What you need is:
81 \verb|\lilypond[fragment]{c' d' e'}|
91 \subsection{The 'verbatim' and 'intertext' option}
92 This shows the verbatim option:
93 \begin{lilypond}[fragment,verbatim, intertext="gives this music:"]
97 \subsection{LaTeX comments}
98 This is a line with lilypond code
99 after the comment char % \lilypond{\context Voice <<c' e' g'>>}
100 % \lilypond{\context Voice <<c' e' g'>>}
102 If you do not see any music from the heading 'LaTeX comments' and until
103 this line, then lilypond-book is handling latex comments pretty well :-)
105 \subsection{To float or not to float}
107 \begin{lilypond}[fragment]
110 should be floating inside the text by using the \verb|eps| options.
114 \begin{lilypond}[fragment]
118 has also the \verb|eps| options, but is not floating because there
119 are an empty line before and after the lilypond block. That is
120 correct behaviour because it follows La\TeX{} convention that an
121 empty line signals a new paragraph. The \verb|eps| option
122 is not necessary when you want the music in a paragraph on its own.
124 \subsection{More examples}
129 \lilypond[staffsize=11,fragment]{ c'} do
131 \lilypond[staffsize=11,fragment]{d'} re
133 \lilypond[staffsize=11,fragment]{e'} mi
135 \lilypond[staffsize=11,fragment]{f'} fa
137 \lilypond[staffsize=11,fragment]{g'} sol
140 Tables\footnote{ and footnote:
141 \lilypond[staffsize=11,fragment]{c' e' g'} }:
142 \marginpar{ Yes, even as marginpar
143 \lilypond[staffsize=11,fragment]{c' d' e'} }
145 \begin{tabular}{|l|l|r|}
147 \em Notes & \em Name \\
149 \lilypond[staffsize=11,fragment,filename="cdur"]{\context Voice <<c' e' g'>>} & major \\
150 \lilypond[staffsize=11,fragment]{\context Voice <<c' es' g'>>} & minor \\
151 \lilypond[staffsize=11,fragment]{\context Voice <<c' es' ges'>>} & diminished \\
152 \lilypond[staffsize=11,fragment]{\context Voice <<c' e' gis'>>} & augmented \\
158 Testing of spacing. The next music is surrounded by an empty line.
159 text text text text text text text text text text text text
160 text text text text text text text text text text text text
163 \score{ \relative c'{ c d e f g a b c} }
166 text text text text text text text text text text text text
167 text text text text text text text text text text text text
168 text text text text text text text text text text text text
170 Next has no empty lines.
171 text text text text text text text text text text text text
172 text text text text text text text text text text text text
173 text text text text text text text text text text text text
175 \score{ \relative c'{ c d e f g a b c} }
177 text text text text text text text text text text text text
178 text text text text text text text text text text text text
180 %% need to use an -I ../../../input/test to find the file
181 %% \lilypondfile{tie.ly}