# %!TEX root = to parent directory

Currently, I am writing a large report. In my previous ones, I always had the chapters and the main file (`thesis.tex`) in the same directory as the individual chapters. This time, however, I created a subfolder called "chapters" and put the chapter `.tex` files in there. But obviously, the command

``````%!TEX root = thesis.tex"`
``````

which I previously put at the beginning of each `chapter.tex`, does not work anymore. Since I work on the report from different locations, I can not define an absolute path but need to define a relative one. I tried `%!TEX root = ../thesis.tex` and `/%!TEX root = thesis.tex`, both of which do not work.

I found threads and solutions for `\input` and other commands, none of which solve by problem, though. If anyone was able to shed some light here, I'd be very thankful!

-
Welcome to TeX.SX. Note that you don't have to sign with your name since it automatically appears in the lower right corner of your post. –  Claudio Fiandrino Dec 6 '13 at 9:50

Try `%!TEX root = ../thesis.tex`

-
Thanks, that's actually what I tried to do. Unfortunately, that does not work... –  ribrob710 Dec 6 '13 at 12:55
Try again with a minimal example and directory structure. This should definitely work. –  Ingmar Dec 6 '13 at 13:17
I get the error message "the file {parent directory}/chapters/../thesis.tex could not be read". –  ribrob710 Dec 6 '13 at 15:15
The path in the error message is correct, though? Have you checked permissions? –  Ingmar Dec 6 '13 at 16:46
Permission is not a problem, the thing is that tex interprets ../ as a folder called .. As a result it does not try to access the parent directory but the subfolder .. in the chapters folder. –  ribrob710 Dec 8 '13 at 11:16

Not sure if you still need help and maybe my solution is not what you need, but here it goes: The structure in my project basically looks like

``````/.../MScThesis/chapters/partI
``````

The `main.tex` (in your case `thesis.tex`) file is in the `MScThesis` folder and the written stuff itself is in a sub-sub-folder.

I use

``````% !TEX root =  ../../main.tex
``````

and that works fine. Basically varying the amount of "../" until you reach the right folder above. So in case you have more than just one subfolder, this should do the trick. I have no idea what your chapter-folder looks like so maybe this is a useless answer, but well :)

-
Welcome to TeX.SX! –  egreg Jan 24 '14 at 16:50