I am using overleaf to write my thesis, there is a main.tex files that includes (with the command include) files that are in the same directory.

When I am working on one of this sub-files, using CTRL+S does not compile the whole project, but only the current file, so I cannot see the result directly and I have to click 1st on the main.tex file and compile it.

So, my question is, is it possible to compile the main file from any other file ? Or to compile all at once ?


  • 1
    Welcome to TeX.SE. Have you tried contacting the Overleaf helpdesk with your question that's highly specific to the Overleaf platform? I hear their LaTeX support staff is top-notch.
    – Mico
    May 28 '21 at 18:24
  • Thank you, I tested tex.se but it's a dead link... May 28 '21 at 18:33
  • 2
    @RandomFellow TeX.SE is an abbreviation of this site; I don't think Mico intended for you to think that is a link. You can reach Overleaf support at support@overleaf.com May 28 '21 at 18:39
  • 1
    using subfiles isn't often much of a help and I don't see it helps at all on overleaf: it is simpler to just have normal \input. Either way you can make every compliation use the top level file by supplying a suitable latexmkrc file to your project May 28 '21 at 23:05
  • @DavidCarlisle I think you are right, I sent the support a request, because I could not find how to do this May 29 '21 at 12:48

You can use a latexmkrc file that runs latex on the main file whatever arguments it is given.

This seems to work in a copy of the overleaf example subfiles project

$pdflatex='pdflatex %O main ';

this shows a compilation started in the Introduction subfile but showing the full document

enter image description here

Currently you can view the project at


but I don't promise to keep that link forever.

  • cool! let me try :) May 29 '21 at 15:21
  • It's working! Life saving, thanks! May 29 '21 at 15:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.