\documentclass{scrartcl}
% keep \documentclass on 1st line for lilypond-book auto-detection

%
% This is way too long and hairy --
%
%


\usepackage[latin1]{inputenc}

%\def\preLilyPondExample{}
%\def\postLilyPondExample{}
%\usepackage{graphics}
%\usepackage{landscape}

\usepackage{graphics}
\begin{document}
%uncomment this to try twocolumn mode
%\twocolumn


\section{LilyPond-book + LaTeX}

This is an examplefile for mixing LilyPond and Latex. It is also
used to test lilypond-book. View the source to see how it is done.

A simple scale:

{%
\parindent 0pt
\ifx\preLilyPondExample \undefined
\else
  \expandafter\preLilyPondExample
\fi
\def\lilypondbook{}%
\input 89/lily-54f49c62-systems.tex
\ifx\postLilyPondExample \undefined
\else
  \expandafter\postLilyPondExample
\fi
}

LilyPond-book searches for the \verb|\score| command when it decides
if the code is only a fragment. Thus, in the following code, you have
to use \verb|fragment| option, because the comment confuses lilypond-book.

{%
\parindent 0pt
\ifx\preLilyPondExample \undefined
\else
  \expandafter\preLilyPondExample
\fi
\def\lilypondbook{}%
\input 5b/lily-b9f2d3b1-systems.tex
\ifx\postLilyPondExample \undefined
\else
  \expandafter\postLilyPondExample
\fi
}

There is also a shorthand version: \begin{verbatim}\lilypond[fragment]{c' e' g'}\end{verbatim}
%\verb|\lilypond[fragment]{c' e' g'}|   doesn't work!!!

{%
\parindent 0pt
\ifx\preLilyPondExample \undefined
\else
  \expandafter\preLilyPondExample
\fi
\def\lilypondbook{}%
\input c0/lily-921c3552-systems.tex
\ifx\postLilyPondExample \undefined
\else
  \expandafter\postLilyPondExample
\fi
}

that is the same as writing
\begin{verbatim}
\begin[fragment]{lilypond}
c' e' g'
\end{lilypond}
\end{verbatim}

This C major
%%\begin[staffsize=11\pt,fragment]{lilypond}
{%
\parindent 0pt
\ifx\preLilyPondExample \undefined
\else
  \expandafter\preLilyPondExample
\fi
\def\lilypondbook{}%
\input 84/lily-ad5965b2-systems.tex
\ifx\postLilyPondExample \undefined
\else
  \expandafter\postLilyPondExample
\fi
}
and C minor
{%
\parindent 0pt
\ifx\preLilyPondExample \undefined
\else
  \expandafter\preLilyPondExample
\fi
\def\lilypondbook{}%
\input 39/lily-21112fa6-systems.tex
\ifx\postLilyPondExample \undefined
\else
  \expandafter\postLilyPondExample
\fi
}  chords are floating inside the text.


\subsection{The 'verbatim' and 'intertext' option}
This shows the verbatim option:
\noindent
\begin{verbatim}
c' d' e'
\end{verbatim}
{%
\parindent 0pt
\ifx\preLilyPondExample \undefined
\else
  \expandafter\preLilyPondExample
\fi
\def\lilypondbook{}%
\input ae/lily-f8959a36-systems.tex
\ifx\postLilyPondExample \undefined
\else
  \expandafter\postLilyPondExample
\fi
}

NB: 'intertext' doesn't work.

\subsection{LaTeX comments}
This is a line with lilypond code
after the comment char % \lilypond{\context Voice <<c' e' g'>>}
% \lilypond{\context Voice <<c' e' g'>>}

If you do not see any music from the heading 'LaTeX comments' and until
this line, then lilypond-book is handling latex comments pretty well :-)

\subsection{To float or not to float}
This music
{%
\parindent 0pt
\ifx\preLilyPondExample \undefined
\else
  \expandafter\preLilyPondExample
\fi
\def\lilypondbook{}%
\input f7/lily-793d87f9-systems.tex
\ifx\postLilyPondExample \undefined
\else
  \expandafter\postLilyPondExample
\fi
}
should be floating inside the text by using the \verb|eps| options.

This music

{%
\parindent 0pt
\ifx\preLilyPondExample \undefined
\else
  \expandafter\preLilyPondExample
\fi
\def\lilypondbook{}%
\input f7/lily-793d87f9-systems.tex
\ifx\postLilyPondExample \undefined
\else
  \expandafter\postLilyPondExample
\fi
}

has also the \verb|eps| options, but is not floating because there
are empty lines before and after the lilypond block. That is
correct behaviour because it follows La\TeX{} convention that an
empty line signals a new paragraph. The \verb|eps| option
is not necessary when you want the music in a paragraph on its own.

\subsection{More examples}

Itemize environment:
\begin{itemize}
\item
{%
\parindent 0pt
\ifx\preLilyPondExample \undefined
\else
  \expandafter\preLilyPondExample
\fi
\def\lilypondbook{}%
\input 01/lily-6e6560a4-systems.tex
\ifx\postLilyPondExample \undefined
\else
  \expandafter\postLilyPondExample
\fi
} do
\item
{%
\parindent 0pt
\ifx\preLilyPondExample \undefined
\else
  \expandafter\preLilyPondExample
\fi
\def\lilypondbook{}%
\input 04/lily-1dd90433-systems.tex
\ifx\postLilyPondExample \undefined
\else
  \expandafter\postLilyPondExample
\fi
} re
\item
{%
\parindent 0pt
\ifx\preLilyPondExample \undefined
\else
  \expandafter\preLilyPondExample
\fi
\def\lilypondbook{}%
\input 5e/lily-5121f9fd-systems.tex
\ifx\postLilyPondExample \undefined
\else
  \expandafter\postLilyPondExample
\fi
} mi
\item
{%
\parindent 0pt
\ifx\preLilyPondExample \undefined
\else
  \expandafter\preLilyPondExample
\fi
\def\lilypondbook{}%
\input 88/lily-7f4f7bc1-systems.tex
\ifx\postLilyPondExample \undefined
\else
  \expandafter\postLilyPondExample
\fi
} fa
\item
{%
\parindent 0pt
\ifx\preLilyPondExample \undefined
\else
  \expandafter\preLilyPondExample
\fi
\def\lilypondbook{}%
\input 04/lily-f2755d38-systems.tex
\ifx\postLilyPondExample \undefined
\else
  \expandafter\postLilyPondExample
\fi
} sol
\end{itemize}

Tables\footnote{and footnotes:
{%
\parindent 0pt
\ifx\preLilyPondExample \undefined
\else
  \expandafter\preLilyPondExample
\fi
\def\lilypondbook{}%
\input 9a/lily-eb81608e-systems.tex
\ifx\postLilyPondExample \undefined
\else
  \expandafter\postLilyPondExample
\fi
}}:
\marginpar{Yes, even as marginpar
{%
\parindent 0pt
\ifx\preLilyPondExample \undefined
\else
  \expandafter\preLilyPondExample
\fi
\def\lilypondbook{}%
\input a1/lily-3c544d89-systems.tex
\ifx\postLilyPondExample \undefined
\else
  \expandafter\postLilyPondExample
\fi
}}

\begin{tabular}{|l|l|r|}
\hline
\em Notes & \em Name \\
\hline
{%
\parindent 0pt
\ifx\preLilyPondExample \undefined
\else
  \expandafter\preLilyPondExample
\fi
\def\lilypondbook{}%
\input 94/lily-ba262154-systems.tex
\ifx\postLilyPondExample \undefined
\else
  \expandafter\postLilyPondExample
\fi
} & major \\
{%
\parindent 0pt
\ifx\preLilyPondExample \undefined
\else
  \expandafter\preLilyPondExample
\fi
\def\lilypondbook{}%
\input 39/lily-21112fa6-systems.tex
\ifx\postLilyPondExample \undefined
\else
  \expandafter\postLilyPondExample
\fi
} & minor \\
{%
\parindent 0pt
\ifx\preLilyPondExample \undefined
\else
  \expandafter\preLilyPondExample
\fi
\def\lilypondbook{}%
\input 66/lily-bc284324-systems.tex
\ifx\postLilyPondExample \undefined
\else
  \expandafter\postLilyPondExample
\fi
} & diminished \\
{%
\parindent 0pt
\ifx\preLilyPondExample \undefined
\else
  \expandafter\preLilyPondExample
\fi
\def\lilypondbook{}%
\input 3f/lily-be5f3e37-systems.tex
\ifx\postLilyPondExample \undefined
\else
  \expandafter\postLilyPondExample
\fi
} & augmented \\
\hline
\end{tabular}

\pagebreak

Testing of spacing. The next music is surrounded by an empty line.
text text text text text text text text text text text text
text text text text text text text text text text text text

{%
\parindent 0pt
\ifx\preLilyPondExample \undefined
\else
  \expandafter\preLilyPondExample
\fi
\def\lilypondbook{}%
\input 9f/lily-73eea72c-systems.tex
\ifx\postLilyPondExample \undefined
\else
  \expandafter\postLilyPondExample
\fi
}

text text text text text text text text text text text text
text text text text text text text text text text text text
text text text text text text text text text text text text

Next has no empty lines.
text text text text text text text text text text text text
text text text text text text text text text text text text
text text text text text text text text text text text text
{%
\parindent 0pt
\ifx\preLilyPondExample \undefined
\else
  \expandafter\preLilyPondExample
\fi
\def\lilypondbook{}%
\input 9f/lily-73eea72c-systems.tex
\ifx\postLilyPondExample \undefined
\else
  \expandafter\postLilyPondExample
\fi
}
text text text text text text text text text text text text
text text text text text text text text text text text text

%% need to use an -I ../../../input/test to find the file
%% \lilypondfile{tie.ly}

\end{document}

