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?


3 Answers 3


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.

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

  • How do I do this in Plain TeX? Commented Jul 29, 2015 at 0:05
  • @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. Commented Jul 29, 2015 at 4:41
  • Is there an easier way that doesn't involve a hack like this? Commented Oct 22, 2015 at 19:04
  • @tommy.carstensen: Not sure how to help you. Perhaps if I knew what part of this you consider a hack, it might be easier to help. I think you should post a new question and detail what you want to accomplish and the problems with the approaches outlined here. Commented Oct 22, 2015 at 22:15
  • @PeterGrill Thanks! I did here: tex.stackexchange.com/questions/274457/… It is suggested to be a duplicate of tex.stackexchange.com/questions/128067/… Commented Oct 23, 2015 at 0:05

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?.


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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .