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