I have a tex file which \includegraphics an image in the same directory. If the file is run with texstudio the image is included.

If the same file is run in a process started from a program, the file is not found. It is found if the address is a full path, but not found with a relative path (relative to the tex file, like \includegraphics{DSC08138.JPG}. What can cause this?

lualatex is called with the arguments -interaction=nonstopmode --output-directory=dir1 filename.tex where dir1 is the directory in which the filename.tex and the image is stored.

The relevant part of the code is:

putIOwords ["writePDF2text 1 infn", showT infn]
let dir1 = getParentDir fnres :: FilePath
let out1 = "--output-directory=" <> (dir1)
putIOwords ["writePDF2text 2 out1", showT out1]
callIO $ Sys.callProcess
    [out1, "-interaction=nonstopmode", toFilePath infn]

Your program should be started from the directory where the filename.tex resides, or should perform cd (change directory) to that directory (variable dir1) before running lualatex (luatex has no "--input-directory" switch).

Sorry I don't recognize the code sample (Basic-ish?), so I can't show the exact fix at this time.

If it is "DOS" style batch scripting, then the cd command is what you want.

  • 1
    Thank you for the hint. I was under the assumption that the tex file is interpreted in the directory it is in, but - as you point out - it uses the current working directory. I have changed the (Haskell) code and it does indeed solve the problem.
    – user855443
    Jun 27 '20 at 13:25

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.