Generalrelative image paths from \input{} file

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
chan102
Posts: 2
Joined: Tue Feb 09, 2010 8:43 pm

relative image paths from \input{} file

Post by chan102 »

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!

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

php1ic
Posts: 192
Joined: Wed Jan 28, 2009 8:17 pm

Re: relative image paths from \input{} file

Post by php1ic »

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
chan102
Posts: 2
Joined: Tue Feb 09, 2010 8:43 pm

Re: relative image paths from \input{} file

Post by chan102 »

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!
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

relative image paths from \input{} file

Post by localghost »

The \graphicspath command should be used with caution. See l2tabu for further information.


Best regards and welcome to the board
Thorsten
Post Reply