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