2

I'm struggling to get the workflow outlined in Integrating LaTeX and Lilypond to Embed Music in Text Documents to work, specifically the custom TexStudio (I'm using v. 2.12.16) build command

"C:/Program Files (x86)/LilyPond/usr/bin/lilypond-book.py" -- pdf %.lytex | txs:///pdflatex | txs:///view-pdf-internal

While its equivalent works using a command line, on TexStudio it gives the error

Error: Could not start the command: "C:/Program Files (x86)/LilyPond/usr/bin/lilypond-book.py" -- pdf "example".lytex

and outputs a generic (lorem ipsum) PDF. I have my Windows (10; 1809) PATH set to C:/Program Files (x86)/LilyPond/usr/bin. Any suggestions?

siracusa
  • 13,411
Steven Jan
  • 81
  • 3

2 Answers2

4

There are multiple issues at stake here. Some of which I note you seem to have allowed for. I will * the ones which differ from yours

*) Avoid calling your test file example.lytex On my system other TeX system files were called instead ! (note the "example".lytex ideally should be "example.lytex")

TeXstudio is not very helpful in showing why an external command may not work. Please ensure if possible to include more verbose .log file output.

Issues I had that may reflect your steps.

The linked guide does not reflect a true installation of the current windows download (lilypond-2.18.2-1.mingw.exe) which should install to the legacy folder "C:\Program Files (x86)". You appear to have allowed for that).

Note the guide will say "C:\Program Files\Lilypond\usr\bin" which was in both our cases "C:\Program Files (x86)\Lilypond\usr\bin".

*) Essential tests now, are at command prompt> where $path:lilypond should confirm that lilypond.exe is in the correct bin directory. Also need to confirm python is the default py handler. At command line prompt both where /r c:\ python & where $path:python should reply with identical locations. If you get more or less than one from each request there may be conflicts that would confuse lilypond/TeXstudio (If all is well then reboot and retest, they must stick from boot to boot.)

Windows (especially more recent versions) can be tricky to run files by extension first time so calling a file run-me.py needs a py file handler set by default and often the extension must be part of the command. Thus at this stage I need...

"C:\Program Files (x86)\Lilypond\usr\bin\lilypond-book.py" which the configuration guide says needs the options --pdf %.lytex instantly followed by pdfLaTeX. (This appears to be your current setting).

Again I found my usage was not automatic and needed two full external runs prior to the pdfLaTeX run. For that reason I would run lilypond-book.py twice then pdfLaTeX.

*) In summary I find it is best to have one simple user entry to run twice manually (later it could be melded into a more complex combination) and I finally settled on

cmd /c "C:/Program Files (x86)/Lilypond/usr/bin/lilypond-book.py" --pdf  "?am.lytex"

*) Coupled with that command TXS will then need to find other lilypond support files, you have already added the bin folder (in our case "C:/Program Files (x86)/Lilypond/usr/bin/) to the system path settings.However For double surety you can add it into TeXstudio commands ($PATH)

enter image description here

  • Thanks very much for this. The cmd /c "C:/Program Files (x86)/Lilypond/usr/bin/lilypond-book.py" --pdf "?am.lytex" suggestion works, but the output example.pdf (appearing in the same directory as example.lytex) is still a lorem ipsum. The desired pdf, correctly processed, is buried within a sub folder and has a name (not example.pdf) which makes it inaccessible to an intended later stage of processing (i.e., pickup, via standalone, to a chapter file within which example.pdf constitutes an embedded music example. Is there a way I can make the correct pdf appear in the correct directory? – Steven Jan Jul 09 '19 at 10:33
1

For reference, here is an alternative way with lyluatex.

jperon
  • 109
  • 1
  • 7