Next: , Previous: Integrating Texinfo and music, Up: lilypond-book manual



6.2 Integrating LaTeX and music

For LaTeX, music is entered using

     \begin[options,go,here]{lilypond}
       YOUR LILYPOND CODE
     \end{lilypond}
     \lilypondfile[options,go,here]{filename}

or

     \lilypond{ YOUR LILYPOND CODE }

Running lilypond-book yields a file that can be processed with LaTeX.

We show some examples here:

     \begin[staffsize=26]{lilypond}
       c' d' e' f' g'2 g'2
     \end{lilypond}

produces

[image of music]

Then the short version:

     \lilypond[staffsize=11]{<c' e' g'>}

produces

[image of music]

The linewidth of the music will be adjust by examining the commands in the document preamble, the part of the document before \begin{document}: lilypond-book sends these to LaTeX to find out how wide the text is. The line width variable for the music fragments are adjusted to the text width.

After \begin{document}, the column changing commands \onecolumn, \twocolumn commands are also interpreted.

The titling from the \header section of the fragments can be imported by adding the following to the top of the LaTeX file:

     \input titledefs.tex
     \def\preLilyPondExample{\def\mustmakelilypondtitle{}}

The music will be surrounded by \preLilyPondExample and \postLilyPondExample, which are defined to be empty by default.

For printing the LaTeX document, you will need to use dvips. For producing PostScript with scalable fonts, add the following options to the dvips command line:

      -Ppdf -u +lilypond.map

PDF can then be produced with ps2pdf.

LilyPond does not use the LaTeX font handling scheme for lyrics and text markups, so if you use characters in your lilypond-book documents that are not included in the standard US-ASCII character set, include \usepackage[latin1]{inputenc} in the file header but do not include \usepackage[[T1]{fontenc}. Character sets other than latin1 are not supported directly but may be handled by explicitly specifying the font-name property in LilyPond and using the corresponding LaTeX packages. Please consult the mailing list for more details.

Read comments on this page, or add one.

This page is for LilyPond-2.2.6 (stable-branch).

Report errors to <bug-lilypond@gnu.org>.