]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/latex-lilypond-example.latex
Docs: reorganize documentation directory structure
[lilypond.git] / Documentation / latex-lilypond-example.latex
1 \documentclass[a4paper, 12pt]{article}
2 % keep \documentclass on 1st line for lilypond-book auto-detection
3
4 %
5 % This is way too long and hairy --
6 %
7 %
8
9
10
11
12 %\def\preLilyPondExample{}
13 %\def\postLilyPondExample{}
14 %\usepackage{graphics}
15 %\usepackage{landscape}
16
17 \begin{document}
18 %uncomment this to try twocolumn mode
19 %\twocolumn
20
21
22 \section{LilyPond-book + LaTeX}
23
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.
26
27 A simple scale:
28
29 \begin{lilypond}
30 \score{
31   \relative c'{c d e f g a b c}
32 }
33 \end{lilypond}
34
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.
38
39 \begin[fragment]{lilypond}
40 c d e % \score
41 \end{lilypond}
42
43 There is also a shorthand version \verb|\lilypond[fragment]{c' e' g'}|:
44
45 \lilypond[fragment]{c' e' g'}
46
47 that is the same as writing
48 \begin{verbatim}
49 \begin[fragment]{lilypond}
50 c' e' g'
51 \end{lilypond}
52 \end{verbatim}
53
54 This C major
55 %%\begin[staffsize=11\pt,fragment]{lilypond}
56 \begin[11pt,fragment]{lilypond}
57 \context Voice <<c' e' g'>>
58 \end{lilypond}
59 and C minor
60 \lilypond[fragment,11pt]{\context Voice <<c' es' g'>>}  chords are floating inside the text.
61
62 \subsection{verb and verbatim}
63
64 As you see, the begin/end verbatim command inside
65 does not confuse lilypond-book:
66
67 \verb|\begin[fragment]{lilypond}c d e\end{lilypond}|
68
69 Neither does a verbatim inside verb:
70
71 \verb|\begin{verbatim}\begin[fragment]{lilypond}c d e\end{lilypond}\end{verbatim}|
72
73 or verb inside verbatim:
74
75 \begin{verbatim}
76 \verb|\begin[fragment]{lilypond}c d e\end{lilypond}|
77 \end{verbatim}
78
79 But this is just to stress \verb|lilypond-book|. What you need is:
80
81 \verb|\lilypond[fragment]{c' d' e'}|
82
83 and
84
85 \begin{verbatim}
86 \begin{lilypond}
87 c d e
88 \end{lilypond}
89 \end{verbatim}
90
91 \subsection{The 'verbatim' and 'intertext' option}
92 This shows the verbatim option:
93 \begin[fragment,verbatim, intertext="gives this music:"]{lilypond}
94 c' d' e'
95 \end{lilypond}
96
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'>>}
101
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 :-)
104
105 \subsection{To float or not to float}
106 This music
107 \begin[fragment]{lilypond}
108 c' e'
109 \end{lilypond}
110 should be floating inside the text by using the \verb|eps| options.
111
112 This music
113
114 \begin[fragment]{lilypond}
115 c' e'
116 \end{lilypond}
117
118 has also the \verb|eps| options, but is not floating because there
119 are an emptry 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.
123
124 \subsection{More examples}
125
126 Itemize environment:
127 \begin{itemize}
128 \item
129 \lilypond[11pt,fragment]{ c'} do
130 \item
131 \lilypond[11pt,fragment]{d'} re
132 \item
133 \lilypond[11pt,fragment]{e'} mi
134 \item
135 \lilypond[11pt,fragment]{f'} fa
136 \item
137 \lilypond[11pt,fragment]{g'} sol
138 \end{itemize}
139
140 Tables\footnote{ and footnote:
141 \lilypond[11pt,fragment]{c' e' g'} }:
142 \marginpar{ Yes, even as marginpar
143 \lilypond[11pt,fragment]{c' d' e'} }
144
145 \begin{tabular}{|l|l|r|}
146 \hline
147 \em Notes & \em Name \\
148 \hline
149 \lilypond[11pt,fragment,filename="cdur"]{\context Voice <<c' e' g'>>} & major \\
150 \lilypond[11pt,fragment]{\context Voice <<c' es' g'>>} & minor \\
151 \lilypond[11pt,fragment]{\context Voice <<c' es' ges'>>} & diminished \\
152 \lilypond[11pt,fragment]{\context Voice <<c' e' gis'>>} & augmented \\
153 \hline
154 \end{tabular}
155
156 \pagebreak
157
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
161
162 \begin{lilypond}
163 \score{ \relative c'{ c d e f g a b c} }
164 \end{lilypond}
165
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
169
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
174 \begin{lilypond}
175 \score{ \relative c'{ c d e f g a b c} }
176 \end{lilypond}
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
179
180 %% need to use an -I ../../../input/test to find the file
181 %% \lilypondfile{tie.ly}
182
183 \end{document}