There exist several questions along the same line as mine here, but none of them have been answered:
How do I compile standalone files in TeXStudio?
Texstudio and subfiles package
Problems when compiling subfiles (with the subfiles package)
How do I get only my subfile to compile in TeXstudio once it has detected what the root file is. Currently, it will always compile the root file, instead of just the subfile, which takes away the actual function of the subfiles package! Annoying!
Best Answer
You can use a magic comment called
%!TeX root
at the beginning of yoursubfile.tex
to override the default root detection by TXS. This way, when you are insubfile.tex
and press compile, TXS will treatsubfile.tex
as root and compile that instead ofmain.tex
, as required.As an example, it might look something like:
subfile.tex
This was also covered in the TXS user manual.