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!


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


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 :)


Although this is an old question, it seems still actual. I stepped over the same problem and


did not do it for me. Since I am using Windows, I tried a backslash instead:


and guess what - that did it. Hope that helps you Windows users out there ;-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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