\PassOptionsToPackage{unicode=true}{hyperref} % options for packages loaded elsewhere
\PassOptionsToPackage{hyphens}{url}
%
\documentclass[]{article}
\usepackage{lmodern}
\usepackage{amssymb,amsmath}
\usepackage{ifxetex,ifluatex}
\usepackage{fixltx2e} % provides \textsubscript
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
  \usepackage[T1]{fontenc}
  \usepackage[utf8]{inputenc}
  \usepackage{textcomp} % provides euro and other symbols
\else % if luatex or xelatex
  \usepackage{unicode-math}
  \defaultfontfeatures{Ligatures=TeX,Scale=MatchLowercase}
\fi
% use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
% use microtype if available
\IfFileExists{microtype.sty}{%
\usepackage[]{microtype}
\UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
}{}
\IfFileExists{parskip.sty}{%
\usepackage{parskip}
}{% else
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}
}
\usepackage{hyperref}
\hypersetup{
            pdfborder={0 0 0},
            breaklinks=true}
\urlstyle{same}  % don't use monospace font for urls
\setlength{\emergencystretch}{3em}  % prevent overfull lines
\providecommand{\tightlist}{%
  \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
\setcounter{secnumdepth}{0}
% Redefines (sub)paragraphs to behave more like sections
\ifx\paragraph\undefined\else
\let\oldparagraph\paragraph
\renewcommand{\paragraph}[1]{\oldparagraph{#1}\mbox{}}
\fi
\ifx\subparagraph\undefined\else
\let\oldsubparagraph\subparagraph
\renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}}
\fi

% set default figure placement to htbp
\makeatletter
\def\fps@figure{htbp}
\makeatother


\date{}

\begin{document}

\hypertarget{lyluatex}{%
\section{Lyluatex}\label{lyluatex}}

\hypertarget{usage}{%
\subsection{Usage}\label{usage}}

In the preable of your document, include the package \texttt{lyluatex}:

\begin{verbatim}
\usepackage{lyluatex}
\end{verbatim}

The \texttt{program} option permits the definition of an alternative
path to \texttt{lilypond}, for example:

\begin{verbatim}
\usepackage[program=/opt/lilypond-dev/lilypond]{lyluatex}
\end{verbatim}

Thereafter, you can include a lilypond file with the command:

\begin{verbatim}
\includely[staffsize=17]{PATH/TO/THE/FILE}
\end{verbatim}

The argument \texttt{staffsize}, which is optional, changes the size of
the score. You can change the size for all the subsequent scores in a
document by placing the following command before your first include
statement to be so affected:

\begin{verbatim}
\def\staffsize{24}
\end{verbatim}

Next, you simply need to compile the document normally with the command
\texttt{lualatex\ -shell-escape}~:

\begin{verbatim}
lualatex -shell-escape DOCUMENT.TEX
\end{verbatim}

Another ``more secure'' option is to add \texttt{lilypond} to default
allowed commands~:

\begin{verbatim}
shell_escape_commands=$(kpsewhich -expand-var '$shell_escape_commands'),lilypond lualatex DOCUMENT.TEX
\end{verbatim}

On systems with low RAM, when working on big documents, you could
encounter \emph{buffer overflows} in \texttt{lilypond} calls. In that
case, first compile with option \texttt{-draftmode}, then compile again
without this option.

You can also input music directly into your docoment with the
\texttt{ly} environment. This is only recommended for relatively short
snippets. For example:

\begin{verbatim}
\begin{ly}
\relative c' { c d e f g a b c }
\end{ly}
\end{verbatim}

Finally, for truly short snippets, there is also the
\texttt{\textbackslash{}lily} command. Example:

\begin{verbatim}
\lily[staffsize=12]{c' d' g'}
\end{verbatim}

\textbf{Nota bene:} The \texttt{\textbackslash{}lily} command \emph{does
not} support blocks of LilyPond code with explicit
\texttt{\textbackslash{}score} blocks. Such code must be included with
the \texttt{ly} environment or as a separate file.

\hypertarget{migration-from-lilypond-book}{%
\subsection{\texorpdfstring{Migration from
\texttt{lilypond-book}}{Migration from lilypond-book}}\label{migration-from-lilypond-book}}

In order to facilitate the migration from \texttt{lilypond-book},
\texttt{lyluatex} defines the command
\texttt{\textbackslash{}lilypondfile} with the same arguments as
\texttt{\textbackslash{}includely}. There is also the environment
\texttt{lilypond} which is the same as \texttt{ly}, and the command
\texttt{\textbackslash{}lilypond} should work as with
\texttt{lilypond-book}.

In this manner, documents typeset with \texttt{lilypond-book} can be
adapted to use \texttt{lyluatex} without much difficulty. Just keep in
mind that apart from the \texttt{staffsize} parameter, the optional
parameters that \texttt{lilypond-book} supports are not supported by
\texttt{lyluatex} (at least for now).

\end{document}
