jperon / lyluatex

Alternative à lilypond-book pour lualatex
MIT License
58 stars 11 forks source link

REQ: Lilypond working directory #6

Closed PunctatorFortunatus closed 9 years ago

PunctatorFortunatus commented 9 years ago

Is there a way to set a working directory for lilypond? I'm using a complex structure for my project, and when I compile my files only with lilypond, all \included files are found correctly; but when compiling with LuaLaTeX they are no longer found. This is because the relative path changes from one file to the other, so it would be nice to add some working directory parameter to lyluatex, so lilypond can find her files without having to symlink them.

rpspringuel commented 9 years ago

You might try adding #(ly:set-option 'relative-includes #t) to the head of your Lilypond files. This option will make it so that any include statements in the file are taken to be relative to the file's location, rather than the working directory from which lilypond was invoked.

PunctatorFortunatus commented 9 years ago

No, I'm trying this right now and the path is always relative to the .tex file. The file structure I'm working with is as follows:

project/main.tex project/main.sty project/lilypond/music.ly project/style/style.ly project/tex/music.tex

So in project/main.tex, there is a \input{tex/music.tex} and the \includely{lilypond/music.ly} command is in project/tex/music.tex file. In music.ly is a \include "../style/style.ly" wich works when processing the file solely with lilypond, but when I compile main.tex, the file stile.ly is not found. However, if I change the line to \include "style/style.ly" in music.ly, then I can compile main.tex without problem.

In the process, I stumbled across the bug in the other thread, I'll explain it there.

jperon commented 9 years ago

Could you please send me an archive with an elementary project like this ? I'll have a look at this problem tomorrow.

PunctatorFortunatus commented 9 years ago

Here you can see an example. In master.pdf you can see the incorrect output, and in music/music_example.pdf the expected output. If you add #(ly:set-option 'relative-includes #t) to music_example.ly the output remains the same.

jperon commented 9 years ago

I think I've seen the problem : as lyluatex outputs temporary results to tmp_ly/TREE, this adds one level to the hierarchy of folders. As a result, ../style/style.ly is equivalent to project/tmp_ly/style/style.ly.

I've corrected that in last commit, may you try it please ?

PunctatorFortunatus commented 9 years ago

It seems to work correctly now, thank you very much. I've only tried in the example, I'll test in my project by sunday.

jperon commented 9 years ago

I'll leave this open for now, as I think the fix is really a workaround, that doesn't cover all possible cases.

jperon commented 9 years ago

The last commit should really solve the problem : the folder of the lilypond score is now included in search path at compile time. Let me know wether you encounter bugs ; if not, I'll close this issue.

PunctatorFortunatus commented 9 years ago

I've tested it on my project today without any problem. Thank you so much for this. Regards.