TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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!

share|improve this question
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

share|improve this answer
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 :)

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.