lilypond-1.3.141
[lilypond.git] / Documentation / user / latex-lilypond-example.latex
blob155795a5266ef4602c77e1a32d61213e6383a673
2 % This is way too long and hairy
8 \documentclass[a4paper, 12pt]{article}
10 %\def\preLilypondExample{}
11 %\def\postLilypondExample{}
12 %\usepackage{graphics}
13 %\usepackage{landscape}
15 \begin{document}
16 %uncomment this to try twocolumn mode
17 %\twocolumn
20 \section{Lilypond-book + LaTeX}
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.
25 A simple scale:
27 \begin{lilypond}
28 \score{
29  \notes\relative c'{c d e f g a b c}
31 \end{lilypond}
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.
37 \begin[fragment]{lilypond}
38 c d e % \score
39 \end{lilypond}
41 There is also a shorthand version \verb|\lilypond{c' e' g'}|:
43 \lilypond{c' e' g'}
45 that is the same as writing
46 \begin{verbatim}
47 \begin[eps]{lilypond}
48 c' e' g'
49 \end{lilypond}
50 \end{verbatim}
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.
58 \subsection{verb and verbatim}
60 As you see, the begin/end verbatim command inside 
61 does not confuse lilypond-book:
63 \verb|\begin{lilypond}c d e\end{lilypond}|
65 Neither does a verbatim inside verb:
67 \verb|\begin{verbatim}\begin{lilypond}c d e\end{lilypond}\end{verbatim}|
69 or verb inside verbatim:
71 \begin{verbatim}
72 \verb|\begin{lilypond}c d e\end{lilypond}|
73 \end{verbatim}
75 But this is just to stress \verb|lilypond-book|. What you need is:
77 \verb|\lilypond{c' d' e'}|
79 and
81 \begin{verbatim}
82 \begin{lilypond}
83 c d e
84 \end{lilypond}
85 \end{verbatim}
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}
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'>}
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 :-)
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.
107 This music
109 \begin[eps]{lilypond}
110 c' e'
111 \end{lilypond}
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.
119 \subsection{More examples}
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}
130 Tables\footnote{ and footnote: \lilypond[eps,11pt]{c' e' g'} }:
131 \marginpar{ Yes, even as marginpar
132 \lilypond[eps,11pt]{c' d' e'} }
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}
145 \pagebreak
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 
151 \begin{lilypond}
152 \score{ \notes\relative c'{ c d e f g a b c} }
153 \end{lilypond}
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 
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 
169 %% need to use an -I ../../../input/test to find the file
170 %% \lilypondfile{tie.ly}
172 \end{document}