To my knowledge, LilyPond is by far the best tex-lookalike music typesetting software. Other tex-based alternatives like musixtex or abc just don't look professional. I would like a workflow where I can write a TeX (probably LaTeX) document which includes lilypond notated musical examples in an analogous way to a mathematician including mathematical equations. Treating musical extracts as figures separated from the document is like telling a mathematician to treat equations as graphics and harks back to the dark ages.

My original question: I am aware of lyluatex from the tex-first approach and lilypond-book from the lilypond-first approach. As of 2023, I find LyLuaTeX has an incompatibility with MiKTeX. After trying texlive instead, I have got it working**, but it is annoyingly clunky having two distributions. Moreover I am slightly suspicious about its robustness due to the number of bugs I encountered trying to make it work (perhaps it will prove me wrong however). Hence my question:

  • Are there alternatives apart from LyLuaTeX which would provide such integration?

(This has been asked before, but it is 2022 now so things may have changed)

Update: After becoming more sophisticated in TeX I completely agree with David Carslisle's comment that TeX live is no problem at all. I was too hasty in dismissing it. Second, see the LyLuaTeX author's answer below, which claims that the MiKTeX compatibility has been fixed. So LyLuaTeX probably is the best TeX-first approach. I have also found lilypond-book to work relatively well. However, if any new solutions arise please post them here!

** I got a rawget error - a certain function expects a table as argument. By removing line 814 on lyluatex.lua entirely one bypasses this and then lyluatexseems to work. This seems to be some kind of clash between MiKTeX and LyLuaTeX, both of which are currently installed on my system.

  • 1
    with no example shown it is a bit hard to comment, as far as I know luatex and lilypond should work with miktex, but I've always used texlive personally. As for "installing packages on the fly compared with TeX Live." That may have been an issue in previous times but most texlive users install the full set to start with so on-the-fly install just never comes up. It's not that big, I have several texlives installed, Commented Jul 15, 2022 at 21:56
  • Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer.
    – Community Bot
    Commented Jul 15, 2022 at 22:33
  • No idea? If it seems like a bug in the package then report a bug on the appropriate place and wait/hope they will fix it..
    – user202729
    Commented Jul 16, 2022 at 0:39
  • Side note, if you did some research and come across related questions on the site, do link to them for searchability.
    – user202729
    Commented Jul 16, 2022 at 0:40
  • Try the abc package... Commented Jul 16, 2022 at 9:37

3 Answers 3


For a small number of music symbols you could use my musicography LaTeX package; for a wider range, if you don't need pdflatex, there is lilyglyphs.

If you have full music examples, I would treat Lilypond like any other graphics program that will produce images for inclusion in LaTeX. Make all your examples in Lilypond (or Dorico or Finale) and export them to a directory of PDFs or image files, then just \includegraphics to bring the images. You can use the pdfcrop tool to trim the margins around the images you want to include.

Especially if you are new to Lilypond, the "integrated solutions" (lyluatex, lilypond-book) are likely to cause more headaches than you need.

So for example, you have a musical example to be included in a document.

music example source file: music-examples/example1.ly

\version "2.22"
\header { tagline = ##f }
{ c'4 d'4 e'2 }

document: document.tex

\NewDocumentCommand{\includeMusic}{ m }{\includegraphics{build/img/#1}}
Here is some music:

Now you need a Makefile to first create and crop the graphics and then run LaTeX including the graphics.


dirs    = aux build build/img
tex_in  = $(wildcard *.tex)
pdf_out = $(addprefix build/,$(tex_in:%.tex=%.pdf))

ly_in   = $(wildcard music-examples/*.ly)
ly_img  = $(addprefix aux/,$(notdir $(ly_in:%.ly=%.pdf)))
img_out = $(addprefix build/img/,$(notdir $(ly_img)))

.PHONY : all clean

all : $(pdf_out) $(img_out)

build/%.pdf : aux/%.pdf
        cp $< $@

aux/%.pdf : %.tex $(img_out) | $(dirs)
        latexmk -outdir=aux -pdf $<

build/img/%.pdf : aux/%.pdf
        pdfcrop $< $@

aux/%.pdf : music-examples/%.ly | $(dirs)
        lilypond --output=aux/ $<

$(dirs) :
        mkdir -p $(dirs)

clean :
        rm -rf $(dirs)

If you need to configure the Lilypond output to fit better in your LaTeX document (e.g., setting an optimal text width, indent and margins, using the same font) you can put that in a Lilypond file (e.g., example.ly) and the add \include "example.ly" to all your Lilypond example files.

To compile your document, just type make. The output will be in the build directory.

  • 1
    While I like this solution (+1), I'm not sure it is actually easier than for example lilypond-book - maybe it would be advisable (for future visitors) to try the integrated solutions first, and use this answer only when those solutions indeed cause problems.
    – Marijn
    Commented Nov 4, 2022 at 14:19
  • @Marijn I hope someone will post a lyluatex answer. When I established this workflow it was not quite ready for prime time but I think it is fully functional now. This make system is more similar to what lilypond-book does but is in my opinion easier to deal with once it's set up. I think it is easier to configure the two programs (LaTeX & Lilypond) separately; sometimes an integrated solution just adds a third thing to configure. This is a one-tool-per-job approach as opposed to an all-in-one method. Commented Nov 4, 2022 at 19:29
  • I strongly disagree with this approach (i.e. separating music excerpts from the flow of text. that is, processing them separately as graphics and including them as figures). This might be feasible if you are a professional typographer who has been given a finalised document, or if the user has only a few musical extracts. But in my case - and I imagine this is commonplace - the music is really just part of the flow of the document - it makes as much sense to separate it from the workflow as it does separating mathematical equations from a mathematics/physics paper by treating them as graphics. Commented Apr 15 at 8:22

Main author of lyluatex here. As of 2023, the compatibility problem between lyluatex and MiKTeX should be fixed with LilyPond <= 2.22. There is a known bug for latest LilyPond, which is waiting for pull requests if anyone wants to look at it (quite complicated for me, as I don’t own a Windows machine).

Feel free to fill an issue in case of problems, as I don’t follow tex.stackexchange.


Have alook here Are there similar documents in English about "How to integrate music examples with open source tools in scientific documents"?.

The document cited is written in German, which may be unfortunate. However, the author scanned, tried and evaluated all music-related packages for LaTeX available in 2020. See e.g. his "flowchart" on p. 91, which gives a good impression what's feasable.

For the authors purpose, to assist musicology, he clearly favours the Lilipond flow.

If you are only after typesetting, I found musixtex not that hard to understand and to apply. I run it all the time via pdflatex (MikTeX).

For further examples you may want to check https://tex.stackexchange.com/search?q=musixtex, or a recent power-use of musixtex https://tex.stackexchange.com/search?q=user%3A285170

  • Thanks. I am also coming round to the lilypond-book workflow. It is a shame that the tex-first options are so limited though. Lyluatex also works for me as of 2024, but the required --shell-escape is a little annoying to me. I think any musical typesetting has to be through lilypond. It is the only tex-lookalike I know to generate professional looking sheet music. Musixtex just looks too childish. Commented Apr 15 at 8:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .