[Tex/LaTex] How to work and compile efficiently in a multi-file project in Texworks

subfilestexworks

I use Texworks on a multi-file project linked to each other through a master file. It is quite tedious to modify a subfile, save, change window to master file and then compile.

Is it possible to configure the software to link the compile button to the master file so that I can compile directly from the sub-file window?

Best Answer

You can use magical comments just as !TeX root=mainfile.tex with relative path as first line of your subfile.

Let's say you have the following document tree:

thesis.tex
chapters/
- chapone.tex
- chaptwo.tex

Then your chapone.tex (which is \input or \included in thesis.tex) would start with:

%!TeX root=../thesis.tex
% your document here