In a folder example/ there are subdirectories example/chapter1/, example/chapter2/ etc.

Some images occur in more than one chapter, hence I made a subdirectory example/images/ where I put the images, let's call it example/images/image.pdf.

In the base directory there is example/images.sty providing a command for including the image (and does some more stuff I stripped for this MWE):


Now some file in a subdirectory, let's say example/chapter1/main.tex, uses that command like this:


When compiling with pdflatex on the command line this works. But when using LyX this doesn't work: import example/chapter1/main.tex into LyX (so example/chapter1/main.lyx is created) and try creating pdflatex via LyX and it claims File image.pdf not found. (And when using \includegraphics directly in main.tex instead via images.sty it works, too.)

  • A comma should separate the graphics paths. \usepackage{../images} is not right. You should only use \usepackage{images} and ensure the relevant directory is searched by TeX.
    – cfr
    Dec 10 '14 at 23:33
  • I have never seen an example using a comma separating the \graphicspath; and a classic trap of \graphicspath is that it ignores everything outside the {}, hence it does not matter whether one uses a comma or not. If I use \usepackage{images} TeX doesn't find it because it is not a global package but one belonging to this single project. And \usepackage{../images} works, otherwise it would neither tell me that it could not find the file when trying to call pdflatex in LyX nor successfully compile when calling pdflatex manually.
    – user66554
    Dec 11 '14 at 6:11
  • For a MWE need only one of the paths in \graphicspath, anyway, so I changed that.
    – user66554
    Dec 11 '14 at 6:59

Problem was that as far as LyX is concerned .sty files are raw LaTeX, hence only the file gets copied to the temporary directory where LyX does the compilation but not the dependencies referenced in that file - these get resolved only for .lyx files.

I went with using an absolute path \graphicspath{{/home/username/latex/example/images/}}. That's going to give me trouble only when I move it to a new directory or computer - and then I would have only to change the directory reference.

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.