So let’s say that I have a document:

% Preamble
% Preamble

Some questions:

  1. Let’s suppose that the file is not compiled yet, and I compile say, FileA. Will the title ever appear, or will I have to run the main file to get the title to appear?
  2. From what I see, subfiles are compiled independently from the rest of the subfiles i.e. compiling only that section, while compiling the main file is the same as if I use \input or just having the entire TeX code from the subfiles in there. Is there a way to compile some subfiles simultaneously while leaving the other subfiles untouched (as in, the results from the subfiles do not change instead of not appearing in the pdf)?
  3. If I compile a subfile, and the results of multiple subfiles are on the same page as that subfile, will the results from the succeeding subfiles be “overwritten” by those due to compiling that subfile?
  4. I just compiled a subfile, for some reason the compilation time is the same as compiling the main file. Is this supposed to happen?
  5. Edit to 4: I just closed the main file and ran the subfile, it turns out that the result is compiling the entire file instead of just the subfile, which seems contradictory to the subfiles being “compilable on their own.” Can someone elaborate?

I use TeXStudio by the way.

1 Answer 1


Too long for the comments.

Re question 1: The title appears in the document that contains the \maketitle command. If it is in the main file and you compile some subfile, then the title will not appear, because the subfile takes only the preamble from the main file and ignores the rest.

Re question 2: This question is not specific to subfiles, and the answer is basically 'no'. As far as I know, none of the TeX processors performs caching and typesets only those parts that have changed. Some packages provide the possibility to cache the result of intensive computations for the next run (like externalization in pgfplots). On a larger scale, you can use tools for building a project, like make, ant and many more, to compile only parts of a project that have changed. But for TeX files, it will still call a tex processor that typesets the whole file.

Re question 3: I think this is a misconception of what TeX and the subfiles package does. When typesetting the main document, it will load the tex sources of the subfiles, ignoring any pdf. So typesetting any of the subfiles will generate new pdfs for the subfiles, but leave the pdf of the main file untouched. TeXStudio may disguise the fact that you are editing actually tex files which are typeset on the fly to pdf to be viewed.

Re question 4: When typesetting a subfile the processing time is definitely shorter than when typesetting the main file. However, in most situations you will not notice it, because starting the program and opening the files takes much more time than typesetting some text. You will see real time savings only when the main file is huge and/or some parts contain computing-intensive graphcis.

Re question 5: This is probably a TeXStudio and/or usage issue. TeXStudio probably always typesets the file set as the 'current' one, and it probably was not aware that you wanted it to typeset only the subfile.

General recommendation: Start out with a single tex file. If it becomes too large, structure it using \input or \include. Only if you really need to be able to typeset part of the document independently, start experimenting with packages like subfiles.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .