gsalzer / subfiles

class and package for multi-file projects in LaTeX
LaTeX Project Public License v1.3c
25 stars 1 forks source link

subfiles reads past \end{document} #2

Closed alan-isaac closed 4 years ago

alan-isaac commented 4 years ago

In version 1.5, compiling the main document will include subfile content that follows the end{document} in the subfile.

gsalzer commented 4 years ago

This is something subfiles always did, nothing has changed. When the subfile is included, only the three commands \documentclass[...]{...}, \begin{document} and \end{document} are redefined to do nothing, everything else is typeset, including the stuff after \end{document}. See also section 3.4 of the documentation.

Is there a use case where the stuff after \end{document} should be skipped (given that one can just end the file after \end{document}? Right now some people use this behavior for adding stuff that is only visible when typesetting the main file. If there is the need for a different behavior of subfiles, one might add an option ...

alan-isaac commented 4 years ago

The behavior is implicit in the docs.

If LATEX is run on the main file, the subfile is loaded like with an\inputcommand, except that the three lines\documentclass[..]{subfiles},\begin{document}, and\end{document}are ignored.

Nevertheless, I did not expect it, and ended up with undesired material in the main file. So I suggest being even more explicit, adding after the above sentence:

(This means that content following the \end{document} of a subfile will be included when the main document is compiled.

gsalzer commented 4 years ago

Thanks for the input. I hope that the documentation of the next release will be clearer in this respect.

gsalzer commented 3 years ago

The default behaviour of subfiles 2.0 now is to ignore any stuff after \end{document}. To obtain the old behaviour, one has to use the option v1 when loading the package.