1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
|
\documentclass[a4paper, 12pt]{article}
% keep \documentclass on 1st line for lilypond-book auto-detection
%
% This is way too long and hairy --
%
%
%\def\preLilyPondExample{}
%\def\postLilyPondExample{}
%\usepackage{graphics}
%\usepackage{landscape}
\begin{document}
%uncomment this to try twocolumn mode
%\twocolumn
\section{LilyPond-book + LaTeX}
This is an examplefile for mixing LilyPond and Latex. It is also
used to test lilypond-book. View the source to see how it is done.
A simple scale:
\begin{lilypond}
\score{
\relative c'{c d e f g a b c}
}
\end{lilypond}
LilyPond-book search for the \verb|\score| command when it decides
if the code is only a fragment. Thus, in the following code, you have
to use \verb|fragment| option, because the comment confuses lilypond-book.
\begin{lilypond}[fragment]
c d e % \score
\end{lilypond}
There is also a shorthand version \verb|\lilypond[fragment]{c' e' g'}|:
\lilypond[fragment]{c' e' g'}
that is the same as writing
\begin{verbatim}
\begin{lilypond}[fragment]
c' e' g'
\end{lilypond}
\end{verbatim}
This C major
%%\begin{lilypond}[staffsize=11\pt,fragment]
\begin{lilypond}[11pt,fragment]
\context Voice <<c' e' g'>>
\end{lilypond}
and C minor
\lilypond[fragment,11pt]{\context Voice <<c' es' g'>>} chords are floating inside the text.
\subsection{verb and verbatim}
As you see, the begin/end verbatim command inside
does not confuse lilypond-book:
\verb|\begin{lilypond}[fragment]c d e\end{lilypond}|
Neither does a verbatim inside verb:
\verb|\begin{verbatim}\begin{lilypond}[fragment]c d e\end{lilypond}\end{verbatim}|
or verb inside verbatim:
\begin{verbatim}
\verb|\begin{lilypond}[fragment]c d e\end{lilypond}|
\end{verbatim}
But this is just to stress \verb|lilypond-book|. What you need is:
\verb|\lilypond[fragment]{c' d' e'}|
and
\begin{verbatim}
\begin{lilypond}
c d e
\end{lilypond}
\end{verbatim}
\subsection{The 'verbatim' and 'intertext' option}
This shows the verbatim option:
\begin{lilypond}[fragment,verbatim, intertext="gives this music:"]
c' d' e'
\end{lilypond}
\subsection{LaTeX comments}
This is a line with lilypond code
after the comment char % \lilypond{\context Voice <<c' e' g'>>}
% \lilypond{\context Voice <<c' e' g'>>}
If you do not see any music from the heading 'LaTeX comments' and until
this line, then lilypond-book is handling latex comments pretty well :-)
\subsection{To float or not to float}
This music
\begin{lilypond}[fragment]
c' e'
\end{lilypond}
should be floating inside the text by using the \verb|eps| options.
This music
\begin{lilypond}[fragment]
c' e'
\end{lilypond}
has also the \verb|eps| options, but is not floating because there
are an empty line before and after the lilypond block. That is
correct behaviour because it follows La\TeX{} convention that an
empty line signals a new paragraph. The \verb|eps| option
is not necessary when you want the music in a paragraph on its own.
\subsection{More examples}
Itemize environment:
\begin{itemize}
\item
\lilypond[11pt,fragment]{ c'} do
\item
\lilypond[11pt,fragment]{d'} re
\item
\lilypond[11pt,fragment]{e'} mi
\item
\lilypond[11pt,fragment]{f'} fa
\item
\lilypond[11pt,fragment]{g'} sol
\end{itemize}
Tables\footnote{ and footnote:
\lilypond[11pt,fragment]{c' e' g'} }:
\marginpar{ Yes, even as marginpar
\lilypond[11pt,fragment]{c' d' e'} }
\begin{tabular}{|l|l|r|}
\hline
\em Notes & \em Name \\
\hline
\lilypond[11pt,fragment,filename="cdur"]{\context Voice <<c' e' g'>>} & major \\
\lilypond[11pt,fragment]{\context Voice <<c' es' g'>>} & minor \\
\lilypond[11pt,fragment]{\context Voice <<c' es' ges'>>} & diminished \\
\lilypond[11pt,fragment]{\context Voice <<c' e' gis'>>} & augmented \\
\hline
\end{tabular}
\pagebreak
Testing of spacing. The next music is surrounded by an empty line.
text text text text text text text text text text text text
text text text text text text text text text text text text
\begin{lilypond}
\score{ \relative c'{ c d e f g a b c} }
\end{lilypond}
text text text text text text text text text text text text
text text text text text text text text text text text text
text text text text text text text text text text text text
Next has no empty lines.
text text text text text text text text text text text text
text text text text text text text text text text text text
text text text text text text text text text text text text
\begin{lilypond}
\score{ \relative c'{ c d e f g a b c} }
\end{lilypond}
text text text text text text text text text text text text
text text text text text text text text text text text text
%% need to use an -I ../../../input/test to find the file
%% \lilypondfile{tie.ly}
\end{document}
|