2

I am writing a paper on Overleaf (free version) that is starting to be a little long, so to optimize the compilation time I decided to put each section in a separate .tex file, and use the command \include in the main file (I am not using them nested, I am not using subfiles, I didn't use other commands like import, input...).

After compiling once successfully, I then use the command \includeonly to re-compile only the section I am working on, so that it takes much less time for the file to compile when I need to work on one specific part.

The problem I encounter is that, after a while (possibly after closing the browser tab or refreshing the page, I am not sure), Overleaf seems to 'forget' that I compiled the project with all the sections included. After looking at the raw output, it seems that it deletes the .aux files automatically, which are necessary for the intended use of the command \includeonly... So when compiling using \includeonly after some time, I get a bunch of errors, among which something like "Counldn't find [...].aux ...", and to make everything work again, I have to recompile the whole file once removing the command \includeonly, and then compile again restoring the same line.

So, since this is all a little annoying, I was wondering if there is a way to tell Overleaf not to delete the .aux files corresponding to the \included files when closing the browser or refreshing the page. If not, I would be happy to know if there is a way to obtain a similar result which works on Overleaf.


Update:

I wrote to the support of Overleaf concerning the above and they replied. I thought the message could be useful for others.

Hi,

Thanks for getting in touch about this - apologies for the delayed response.

You are right that the cached files are cleared after a period of time - the exact timing of this can vary, since it is based on the allocation of compile server resources (there isn't an exact time at which they expire, there are some events which cause the cache to be cleared, and some resource allocation rules that also affect this).

So when revisiting the project after some time away, or after clearing the cache, you'll need to do at least one compile with all the .tex files included, so that their corresponding .aux files can be regenerated. If the whole project is too large to compile in one go, you could do this first compile in draft mode to skip image inclusion. (This is what takes the most time in most compiles.)

Once the .aux files have been regenerated, then you can use \includeonly again if you'd like. (To check if the .aux files have been generated, you can check the "other logs and files" list that can be accessed at the very bottom of the logs view. https://www.overleaf.com/learn/how-to/View_generated_files).

Currently there is not an option for forcing the generated files to be persisted. Sorry for the limitation. I've also passed your feedback to them that, particularly for certain types of projects, that the aux files be retained longer than they currently are.

Best,

7
  • 2
    This seems specific to Overleaf, so you may need to contact their support. Or they may stop by here in the near future.
    – Teepeemm
    Jan 4 at 20:46
  • If you are doing documents large enough to use \inculdeonly, perhaps it is time to load a LaTeX compiler on your computer. Jan 5 at 2:42
  • @JohnKormylo I already have it. The one I mentioned is a shared project. Jan 5 at 3:26
  • Overleaf is a cloud platform, so most likely whenever a different cloud node compiles your project it does not "inherit" intermediate files from the previous one.
    – amonakov
    Jan 5 at 7:17
  • 2
    If you use \IfFileExists{chapter2.aux}{\includeonly{chapter1,chapter2}}{} (testing for any of the chapter aux files, then if they get dropped all that happens is the next run does a full run and takes a bit longer, you don't need to edit anything and after that it will pick up the includeonly again. Jan 5 at 10:40

1 Answer 1

5

If you use

\IfFileExists{chapter2.aux}{\includeonly{chapter1,chapter2}}{}

(testing for any of the chapter aux files), then if they get dropped all that happens is the next run does a full run and takes a bit longer, you don't need to edit anything and after that it will pick up the \includeonly again.

3
  • Thank you so much for your hint! I have just tried to use the command on Overleaf and it seems to be working better than what I thought, meaning that when I manually erase the cached files, the PDF output of the next compilation only includes the selected chapters, with the correct numbering, and I get no errors... Like it's compiling twice. I have no idea why it does that, but for now the command is working well. Many thanks! Jan 5 at 16:59
  • 1
    @LorenzoPompili overleaf is using latexmk which always runs latex multiple times to resolve references Jan 5 at 18:13
  • I see, that is helpful to know. Thank you! Jan 5 at 21:26

You must log in to answer this question.

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