I am using overleaf and I have a main document and several subfiles. Is there a way of always having the main file compile even if I have selected and I am editing subfiles? Cheers in advance, Blake
Asked
Active
Viewed 1,093 times
1 Answers
5
(Tom from Overleaf Support here.)
To me it seems that always wanting to compile the main file quite defies the purpose of using subfiles, but if you wish, you can do that by replacing
\documentclass[...]{subfiles}
with
\csname documentclass\endcsname[...]{subfiles}
in the sub-file.
This dirty hack will trick our compiler into not seeing the \documentclass command and thus compiling the main file instead.
yo'
- 51,322
-
That works wonders cheers. I was just using subfiles to split the document up. Cheers for the help. – Blake Rowan Oct 31 '22 at 14:04
-
@BlakeRowan Cool -- great to hear it works. Note that then a simple
\inputwould do the trick just the same, without the overhead of the non-trivialitiessubfilesis doing. – yo' Oct 31 '22 at 14:10
\inputand\includeinstead of usingsubfiles, that way there would be no\documentclassin your sub-files. – user202729 Oct 31 '22 at 13:21\documentclass(whitespace ignored) within the first 30kB of the file contents, so something else must have been happening for that user. See https://github.com/overleaf/overleaf/blob/4688cb7b5485cdb58e4fa0da23d671a1828bdc69/services/web/app/src/Features/Documents/DocumentHelper.js#L38 and https://github.com/overleaf/overleaf/blob/dc2097e6845e5d86050498f6be1153140a731608/services/web/app/src/Features/Project/ProjectRootDocManager.js#L29 – yo' Oct 31 '22 at 14:09