# Lilypond with LaTeX

Can someone ELI5 the process? I've tried reading the guide from

http://lilypond.org/doc/v2.18/Documentation/usage/an-example-of-a-musicological-document

but it doesn't seem to work. I am on Windows 10, and I have Lilypond 2.18.2 installed. That's everything I've done so far.

Here's what I've tried.

In a text editor, I copy and pasted the code

\documentclass[a4paper]{article}

\begin{document}

Documents for \verb+lilypond-book+ may freely mix music and text.
For example,

\begin{lilypond}
\relative c' {
c2 e2 \tuplet 3/2 { f8 a b } a2 e4
}
\end{lilypond}

Options are put in brackets.

\begin{lilypond}[fragment,quote,staffsize=26,verbatim]
c'4 f16
\end{lilypond}

Larger examples can be put into a separate file, and introduced with
\verb+\lilypondfile+.

\end{document}


Then I saved the file as lilybook.lytex

Then I pressed Start, and type in DOS. Something called a command prompt shows up, and I click it. Then I type in after C:\Users\[name]>, starting with a space,

lilypond-book --output=out --pdf lilybook.lytex


Then, it shows

'lilypond-book' is not recognized as an internal or external command, operable program or batch file.


So clearly there's something I did wrong or am missing. I am very confused, and I would like to finish a paper. Please help. Thank you.

• This might be better suited for TeX.SE. – Richard Nov 27 '18 at 13:25
• @Richard I disagree. Lots of people use LaTeX on Windows, but most of them will never have used Lilypond. – leftaroundabout Nov 27 '18 at 15:07
• @leftaroundabout Fair enough. I just know there are several questions on TeX.SE regarding lilypond-book that have been addressed. – Richard Nov 27 '18 at 15:22

The installation instructions will have told you how to set the system PATH to include the LilyPond executables. Have you done this?

After that has been done, obviously you also need the latex.exe of a TeX distribution in your system PATH. The usual way for that is to install TeXlive these days.

Then you want to use the Windows command line, not DOS (Windows is 32bit or more, DOS is 16bit).

• No, I use Frescobaldi (an outside program) to operate lilypond. How would I go about doing whatever that is? I use MikTeX distribution, so I don't know about latex.exe either. How do I get to the windows command line? – Ilyankor Nov 27 '18 at 23:41
• @Ilyankor I haven't used Windows in a while, but I would try it in the PowerShell console. You may also want to search if Frescobaldi doesn't have support for Lilypond books. — Generally speaking though, I would recommend you do this kind of stuff on a Linux-based OS, not on Windows. You can easily install one in a virtual machine, without needing to compromise your Windows installation. – leftaroundabout Nov 28 '18 at 10:47
• @Ilyankor Read "Running on the command-line" on the right side of the page http://lilypond.org/windows.html. – TiagoPC Dec 6 '18 at 15:27

To mix LaTeX and Lilypond is a - let's say - long work to do. I suggest, to do it the same way I do it. I first create snippets (what lilypond2latex also does) and insert them manually.

\version "2.18.2"

systemhoehe = 10

\paper{
annotate-spacing = ##f
indent=0\mm
short-indent = 0\mm
paper-width = 150\mm
paper-height = 50\pt
oddFooterMarkup=##f
evenFooterMarkup=##f
bookTitleMarkup = ##f
scoreTitleMarkup = ##f
print-page-number = ##f

left-margin = 0
right-margin = 0
top-margin = -5\pt
bottom-margin = 0
top-system-spacing.basic-distance = 15\pt
markup-system-spacing.basic-distance = 0\pt
top-markup-spacing.basic-distance = 0\pt
system-system-spacing.basic-distance = 200\pt

}

\score{
\layout {
\context {
\Score
\remove "Bar_number_engraver"
\override SpacingSpanner.base-shortest-duration = #(ly:make-moment 1/20)
}
}

\new Staff <<
\new Voice{
\relative c'{ \key d \major \partial 4 a4 d2 e4( g) fis fis8 e d4 e
}

}>>
}


This will create snippets which you can insert with

\includegraphics[width = \linewidth, page = 1]{./someDir/song.pdf}


You can check out my package in alpha version github. I created it for covering that problem (mixing LaTeX and lilypond) and for reusing songs.

• Wow, this looks great! Can you include a PDF of the compiled Demoprojekt in the repo for us to check out? – Richard Dec 30 '18 at 14:14
• @Richard Yes. I just didn't do it, because I'm trained to save space. Just did it. Should appear in a few minutes. – MaestroGlanz Dec 30 '18 at 14:20

This code is not for windows, but rather a Mac- or Linux-based system. You will either have to get a Mac/Linux/GNU system, or install a virtual machine to use the code and program.

The giveaway is the Processing code, the second line has “GNU”, which is a different type of Unix/Linux.

Additionally, this question would better be suited in StackOverflow.SE or TeX.SE.

• GNU does in this case not refer to any operating system (what's usually called “Linux” is indeed a GNU OS, but Mac OSX is not), but simply to the fact that Lilypond itself is a GNU project. And GNU programs can normally be run just fine on Windows, though I haven't used Lilypond on Windows myself. – leftaroundabout Nov 27 '18 at 15:05
• @leftaroundabout Thank you! From a quick google search, I assumed, because of all the text saying “GNU NOT LINUX”, they were separate programs. – icedtea Nov 28 '18 at 1:19
• @icedtea yeah, it's a bit weird – GNU was originally supposed to be just an OS, however the project only developed lots of great helper programs but never really got the OS kernel working. This gap was then filled by Linus Thorvalds, separately. In the end ever more programs were added to GNU, and it came to be that we have “Linux operating systems” supported by a “GNU ecosystem”. – leftaroundabout Nov 28 '18 at 10:34
• @leftaroundabout So basically, Linux just filled the OS kernel gap, and everything else is GNU? – icedtea Nov 28 '18 at 13:52
• That's at least how the FSF / GNU people like to phrase it. And it's pretty accurate as far as early Linux OSs are concerned. However, most modern Linux distributions contain lots of free software that's neither part of GNU nor of Linux. – leftaroundabout Nov 28 '18 at 13:59

Guessing that the installation was incomplete somehow... Replacing folder with wherever lily pond was installed:

c:\folder\lilypond-book --output=out --pdf lilybook.lytex

The path may end up on your system for example C:\Program Files (x86)\LillyPond\usr\bin\lillypond-book or C:\Program Files (x86)\LillyPond\usr\bin\lillypond-book.exe

I would process the lilypond seperately, it will create a pdf file. I would convert the pdf into a graphic (cut and paste the music into ms paint or gimp (even better!)), then insert the graphic into LaTeX.