# How to input file with relative paths within

In most of my work, I use a specific .tex ("main".tex) file with a preamble and \begin- and \end{document}. In the document I use \input{...} to another .tex file, with no preamble. Let's say "main".tex is located in H:.

My problem is, that when I use a music notation system called "Lilypond", it generates a .tex file with relative paths to pictures. Let's say it's called "lilypond".tex and is located in H:/lilypond/.

When "lilypond".tex is included in my "main".tex file, I get an error because the pictures cannot be located: The compiler searches in H:, because the paths in "lilypond".tex are relative.

How can I avoid this problem, without having to manually edit my "main".tex according to every specific file I might include?

I use Emacs, and have thought of making a macro to run through the "lilypond".tex-file and edit paths, but it might be a little inconvenient.

• just make sure H:lilypond is in your TEXINPUTS path and it should just work., – David Carlisle Jun 18 '15 at 18:52
• Hi! I hadn't thought about that, but I imagine, that I would have to add individual paths to all my lilypond-files, since the pictures is in a folder with each lilypond-file? If H:/lilypond/mozart/mozart.tex and H:/lilypond/beethoven/beethoven.tex both should be able to be compiled, I guess I would have to add both "H:/lilypond/mozart" and "H:/lilypond/beethoven" to TEXTINPUTS? – simon Jun 18 '15 at 19:03
• No, the relative paths should work should work and in anycase you can add h:/lilypond// where the // denotes all directories below there – David Carlisle Jun 18 '15 at 19:05
• I have made TEXINPUTS as an enviromental variable for my user in Windows 7. I have added a path to the folder, where my lilypond-files are in, but not specified sub-folders (like so, H:\lilypond//). I am still getting the error. – simon Jun 18 '15 at 19:17
• \input etc. uses Unix files notation. Use / instead of \. – John Kormylo Jun 19 '15 at 0:50

\graphicspath{{H:/lilypond/}}

• @simon why don't you use this command in the input'd files, then? untested, but i think it'd work. – Sean Allred Jul 18 '15 at 21:36