LyXEmbedding of Lilypond File

Information and discussion about LyX, a WYSIWYM editor, available for Linux, Windows and Mac OS X systems.
Post Reply
Sash
Posts: 3
Joined: Thu Aug 01, 2013 3:33 pm

Embedding of Lilypond File

Post by Sash »

Hello! I'm trying to embed a LilyPond file in LyX, but when I try to export it to PDF or preview, I get a message.

Code: Select all

An error occurred while running:
lilypond -dbackend=eps -dsafe --pdf
Can somebody help me with this?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Sash
Posts: 3
Joined: Thu Aug 01, 2013 3:33 pm

Embedding of Lilypond File

Post by Sash »

Ok, solved that somehow, but now I have another problem. The LilyPond snippet takes up a whole page, only to be written on the bottom "Music engraving by LilyPond", like this.
lilypond-lyx.jpg
lilypond-lyx.jpg (10.21 KiB) Viewed 6959 times
When I use the LilyPond extension in Libre Office, it doesn't happen, so maybe it's something with the LyX settings?
Last edited by localghost on Fri Aug 02, 2013 8:38 am, edited 1 time in total.
scottkosty
Site Moderator
Posts: 542
Joined: Sat Sep 01, 2012 6:38 am

Embedding of Lilypond File

Post by scottkosty »

Hi Sash,

Please provide a minimal LyX example. Also with LyX questions it's useful if you give your LyX version number, operating system, and TeX distribution (e.g. TeX Live).
Sash
Posts: 3
Joined: Thu Aug 01, 2013 3:33 pm

Re: Embedding of Lilypond File

Post by Sash »

Sure. Here are two .lyx files with their corresponding .ly files that I tried to insert. In the second I tried to crop the .ly file with various settings but either the LilyPond didn't show at all on the pdf preview, or it was taking up a whole page. I guess I don't know how to use the crop with all the 4 parameters. But the strangest thing to me is that with the extension in LibreOffice I don't have such problems at all.

The version of Lyx: 2.0.6-1
TeX, Version 3.1415926 (TeX Live 2009/Debian)
OS: Ubuntu 12.04
Attachments
LyxFiles.zip
(2.09 KiB) Downloaded 376 times
scottkosty
Site Moderator
Posts: 542
Joined: Sat Sep 01, 2012 6:38 am

Embedding of Lilypond File

Post by scottkosty »

Disclaimer: I've never used LilyPond before.

Solution 1:
Inserting LilyPond files with the external material inset uses the following command:

Code: Select all

lilypond -dbackend=eps -dsafe --pdf YOURFILE.ly
If you run that manually, you will see that this produces full page EPS and PDF files. Further, these can't be cropped with, e.g. pdfcrop, because of the note (that you mentioned in your post also) at the bottom. To remove this note, take a look here (or just google the message followed by "remove"):
http://lilypond.1069038.n5.nabble.com/R ... 39566.html

You can modify the command run above by going to Tools > Preferences > File Handling > Converters

Solution 2:
In LyX, there is a LilyPond specific manual. It might be in the examples folder or in Help > Specific Manuals > LilyPond (I forget for 2.0.6-1). There you can see examples where the LilyPond code is put in directly to LyX. And as you can see in the output there are no full-page problems. The reason for this is that when you put the LilyPond code in directly, LyX passes all of the LaTeX code to LilyPond so that LilyPond knows to convert everything in-line (that is, understanding that there are things around it). It runs this command:

Code: Select all

lilypond-book --safe --pdf --latex-program=pdflatex --lily-output-dir=ly-pdf "lilypond.lytex"
Post Reply