Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have a top-level latex file: /thesis.tex

And subfolders with chapters: /chap1/ch1.tex

In thesis.tex I use \include commands like so:


And in ch1.tex I have more includes for the sections of the chapter:


The ch1.tex file and all its included sections use relative paths as above (this was a standalone document that is now a chapter of the larger thesis.tex doc). I realize I have to fix all the paths in the include statements for ch1.tex and its sections to respect the main document directory as the root:


Is there another way? Do I have to go through and change all the include and figure references in this way, or is there a way I can tell all such links to use relative paths within ch1?

share|improve this question
You have chap1 in one place, but then mention ch1 in another. Also, a leading slash denotes an absolete path. Is your thesis.tex really in /? :-) –  Andrey Vihrov Aug 12 '11 at 17:04
I'm not sure but maybe the import package is what you need. –  Martin Scharrer Aug 12 '11 at 19:10

3 Answers 3

up vote 9 down vote accepted

It is best to use relative paths, that way if you move the entire directory tree things will still work. So use


So assuming that you have your files as:

<some path>/thesis/thesis.tex
<some path>/thesis/chap1/ch1.tex
<some path>/thesis/chap2/ch2.tex

all the files are input relative to where they are with respect to the thesis directory.

Am pretty sure that you'll need to update all you \input statements, but this way it is flexible in case you decide to change the top level directory, or move it somewhere.

share|improve this answer
How do I do this in Plain TeX? –  Wk_of_Angmar yesterday
@Wk_of_Angmar: I don't use Plain TeX but I think using \def\MyPath{../thesis} and the Plain TeX equivalent of \input. Perhaps you could post a new question if that does not work. –  Peter Grill yesterday

Adding this as a separate answer as I am not recommend using this method as it likely more work than it is worth, and that is to modify the input macro to do a search for a file over a list of directories and include that. This would have the advantage that you would not need to change each of the individual files, and allow you to move files around and still have them work.

If you decide to pursue this approach this question on How to iterate through the name of files in a folder might be helpful.

share|improve this answer

I know the question is pretty old but since this post was the first on tex.sx I found this might be of help.

As proposed by Martin, a solution to the problem could be to use the import package as explained in How to use the import package?.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.