LilyPond & LaTeX

How to include Music Examples in a LaTeX Document

First you need to check, whether you have in your Shell the command: lilypond-book:

which lilypond-book
/bin/lilypond-book

If you don't get this answer, you have to refer to the page http://lilypond.org/macos-x.html

Now you need to put an other extension to your latex file: .lytex
And this file is from now on, the main file. With the command lilypond-book the file.tex is created. But you have to write all changes into the .lytex file! If not all changes you made will be lost, with the next lilypond-book command.

LaTeX-File with Lilypond Music included: lily_latex.lytex

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.
\documentclass[twoside,a4paper,headsepline=yes,draft=true]{scrreprt}
\usepackage{geometry}
\geometry{a4paper}
\usepackage{graphicx}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}

\begin{document}


\titlehead{Piano-Lehrer.de\\
Berlin - Munich\\
Headquarters:\\
...\\
...}

\subject{How to teach Piano - Just an other Didactic}
\title{Didactic of Piano Teaching}
\author{Marek Stepanek\\
marek@piano-lehrer.de}


\date{\today}

\maketitle
\tableofcontents
\listoffigures

\section{Pleasure of Music}
No music without pleasure. Music is not a Hochleistungssport!
\subsection{Examples of Musical Patterns}

One of the most known patterns are scales:

\begin{lilypond}
\relative c' {
c4 d e f | g4 a b c ||
}

\end{lilypond}

The pupil should learn from this picture: one note of a scale after the other looks always on and the next in between.

The next pattern are Dreiklänge:

\begin{lilypond}
\relative c' {
c4 e g4 c ||
}

\end{lilypond}

\end{document}

You compile this example file with following commands:

Commands in tcsh (Shell - Terminal)
1.
2.
3.
4.
cd ~/Documents/programming/latex/music_latex/
lilypond-book lily_latex.lytex
pdflatex lily_latex.tex
open lily_latex.pdf

While compiling this examples are created many files, which are not easy to understand, what they are for: