When using the lilypond environment in LaTeX, you have to first run lilypond-book on yourdocument.lytex. This generates yourdocument.tex which you then run the rest of your build commands on (pdflatex, bibtex etc.). However, this means that you must do all your editing on the yourdocument.lytex file, which causes synctex not to work in tex studio. That is, ctrl-clicking a word in the embedded pdf viewer takes you not to the corresponding source code in the .lytex file but to the code in the .tex file instead, whereas ctrl clicking a word in the .lytex file open in the editor does nothing at all.

The main reasons I use texstudio rather than batchfiles + a text editor is that setting up synchronization between external viewers and notepad++ proved quite difficult, and most tex editors display the document structure, which I rely upon quite heavily to navigate documents. If there were a solution that provided said functionality I appreciate in sophisticated tex editors while using a program like notepad++, I'd be open to that too.

The way lilypond-book adds the music to the texdocument is by converting the code in the lilypond environment into a cropped pdf file, then replacing the lilypond environment in the .lytex file with \includegraphics{croppedpdf.pdf} (+ some alignment code) then saving the whole file as a .tex which can then be parsed by pdflatex. If there were some way to tell lilypond to generate this cropped file (without running lilypond book), this would provide a third possible solution as I could manually include the graphics using \includegraphics.

  • Please provide a minimum working example (MWE) as that will help you attract helpful answers. meta.tex.stackexchange.com/questions/228/…
    – A Feldman
    Mar 27, 2016 at 12:51
  • In my experience lilypond-book works even if your main file isn't a lytex file, but a regluar .tex file. Maybe I just haven't discovered the real feature that the ly prefix triggers, but I think it's really just an organizational/visualization recommendation...
    – EngBIRD
    Mar 29, 2016 at 20:08

1 Answer 1


This section of the documentation (http://lilypond.org/doc/v2.18/Documentation/usage/lilypond-output-in-other-programs) tells you about how to create cropped output in pdf, eps or png using lilypond.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.