Hello,
I have one main file, which references several other .tex files using the \input{directory1/file1.tex} command. However within file1.tex there are \includegraphics{picture1} commands, where picture1 exists inside directory1 with the tex file. However, when running the main file, I get errors that picture1 is not found, because LaTex is looking in top-most directory (the folder with the main program, not directory1.
Both file1 and picture1 are automatically generated, and refreshed often, so it would be best to not have to move picture1 out of the inclosing folder by hand. Thank you for any advice you have on straightening this out!
General ⇒ relative image paths from \input{} file
NEW: TikZ book now 40% off at Amazon.com for a short time.

Re: relative image paths from \input{} file
Latex will always look in the same directory as the 'main' file for any files called via \input{} or \includegraphics{}, unless a relative path is given, or a graphicpath{} is defined.
If the files are automatically generated, can you not generate/create them with names that take the directory structure into account. ie.
directoryx/filex.tex
directoryx/picturex
rather than
filex.tex
picturex
If the files are automatically generated, can you not generate/create them with names that take the directory structure into account. ie.
directoryx/filex.tex
directoryx/picturex
rather than
filex.tex
picturex
Re: relative image paths from \input{} file
Thank you for your reply; I had missed the part of the documentation about the \graphicspath{} command, but that it is completely sufficient for my needs. Cheers!
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
relative image paths from \input{} file
The \graphicspath command should be used with caution. See l2tabu for further information.
Best regards and welcome to the board
Thorsten
Best regards and welcome to the board
Thorsten
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10