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:

\include{chap1/ch1}

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

\include{introduction}

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:

\include{chap1/introduction}

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
6  
    
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
1  
I'm not sure but maybe the import package is what you need. –  Martin Scharrer Aug 12 '11 at 19:10

2 Answers 2

up vote 8 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

\newcommand*{\MyPath}{../thesis}%
\input{\MyPath/chap1/ch1.tex}

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

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

Your Answer

 
discard

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.