1

I'm currently facing a problem where the main file compiles everything after \end{document} for all subfiles in the project.

If I compile the individual documents one by one, the compilation stops after \end{document}, meaning the problem is only prevalent in the main document.

Any input would be greatly appericiated.

Other info: I'm using Overleaf.

SOLUTION: Insert \endinput after \end{document}

Thanks fort the contributions.

6
  • Thank you for your help, David. I've added two scripts. The first short one with the format of the subfiles. The second with the script from the main file. Thank you for your patience, it's my first post here. Please let me know if you'd like me to change the script. I don't think I did exactly what you instructed of me.
    – Sindre
    Nov 26 '20 at 17:02
  • 2
    no sorry that can not be used to test your issue. Firstly the second one has multiple \subfile references to files that we don't have (it should just reference the other file you posted, presumably) and neither file appears to have any text after \end{document} so this doesn't seem to be an example of the problem that you are asking about. Nov 26 '20 at 17:40
  • Please check in the log file, which version of the subfiles package you are using. For old versions (1.x), it is document behaviour (a 'feature') that stuff after \end{document} is processed. New versions (2.x) stop at \end{document} and ignore the rest of the file.
    – gernot
    Nov 26 '20 at 17:42
  • 1
    For long documents, it is often easier to use a list of \input statements as the main file and to comment/uncomment the \input statements as needed.
    – gernot
    Nov 26 '20 at 17:48
  • 1
    @gernot that will be it, overleaf has Package: subfiles 2020/02/14 v1.6 Multi-file projects (package) Sindre it is rather unusual to have text after end document, you could simply delete it, otherwise put \endinput before the text so it is not read. Nov 26 '20 at 18:00
2

For the record, a summary of the comments.

subfiles v1.x: When loading subfiles from another file or when loading the preamble of the main file from a subfile, the lines after \end{document} are added to the subfile or to the preamble of the main file (documented behaviour, a 'feature').

To avoid the processing of these lines, either remove them or add \endinput after \end{document}.

subfiles v2.x: By default, any lines after \end{document} are ignored. To restore the behaviour of v1.x, load the package with the option v1.

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.