[Tex/LaTex] File path problems using subfiles package

foldersstandalonesubfiles

I am following this tutorial (section subfiles) on how to use the package subfiles for a large latex document. I am using this package because I want to be able to compile each chapter separately. I keep my chapters in ./tex/ but main.tex is located in the root directory.

When I compile main.tex, I get no error but when I try to compile a chapter I get an error because the file ./mystyle.sty can't be found. If I go to main.tex and change the line \usepackage{./mystyle} to \usepackage{../mystyle}, I can compile the chapters now but I can't compile main.tex. I could solve this by providing the full path of to mystyle.sty but then it won't work with other computers. I would rather not the standalone package because I would like to use the command \chapter.

I have read the six year old post about the same issue but I was wondering if in the meantime subfiles package was modified to solve this or if there is a way to use \chapter in the standalone package.

Best Answer

In my opinion the clean way of solving this would be to properly install mystyle.sty in your texmf folder.

If you do not want to do this, you could add the parent folder to your input path, see Can a default path be set globally for \input{...} akin to \graphicspath{...}? how to do this and then use \usepackage{mystyle}.