3.7 lilypond-book templates

These templates are for use with lilypond-book. If you’re not familiar with this program, please refer to Running lilypond-book.

LaTeX

You can include LilyPond fragments in a LaTeX document.

\documentclass{article}

% here you can insert packages all LaTeX flavours understand
\usepackage[ngerman,finnish,english]{babel}
\usepackage{graphicx}
\usepackage{libertinus}

\usepackage{iftex}
\ifxetex
  % stuff specific to XeTeX
  \usepackage{xltxtra}
\else
  % this can be empty if you are not going to use pdfTeX
  \usepackage[T1]{fontenc}
\fi


\begin{document}

\title{A short document with LilyPond and \LaTeX}
\maketitle

Normal \textbf{font} commands inside the \emph{text} work,
because they are \textsf{supported by all \LaTeX{} flavours}.
If you want to use specific commands like \verb+\XeTeX+, you
should include them again in a \verb+\ifxetex+ block.
You can use this to print the \ifxetex \XeTeX{} \else XeTeX \fi
command, which is not known to pdfTeX by default.

In normal text you can easily use LilyPond commands, like this:

\smallskip
\begin[staffsize=12]{lilypond}
{ a2^"foo" b_"bar" c'8 c' c' c' }

\paper {
  property-defaults.fonts.serif = "Libertinus Serif"
}
\end{lilypond}
\smallskip

\noindent
Note that the fonts used in snippets have to be set from inside
the snippets, as demonstrated.

\selectlanguage{ngerman}
Da die Standard-Eingabekodierung von \LaTeX{} UTF-8 ist,
funktionieren Umlaute u.\,ä. ohne \LaTeX-Akzentbefehle (ßäöü),
wenn sie von der Schriftart unterstützt werden.

\end{document}

Texinfo

You can include LilyPond fragments in Texinfo; in fact, this entire manual is written in Texinfo.

\input texinfo 
@ifnottex
@node Top
@top
@end ifnottex

Texinfo text

@lilypond
\relative {
  a4 b c d
}
@end lilypond

More Texinfo text, and options in brackets.

@lilypond[verbatim,fragment,ragged-right]
d4 c b a
@end lilypond

@bye

HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<body>

<p>
Documents for lilypond-book may freely mix music and text.  For
example,
<lilypond>
\relative {
  a'4 b c d
}
</lilypond>
</p>

<p>
Another bit of lilypond, this time with options:

<lilypond fragment quote staffsize=26 verbatim>
a4 b c d
</lilypond>
</p>

</body>
</html>

LilyPond Application Usage v2.25.21 (development-branch).