I am writing my thesis using a college provided template which uses subfiles. I have was stuck for a few hours on an issue wherein some comments are being interpreted by the compiler when the subfiles package is used and a subfile is compiled.
For example, this is my main file named Main.tex:
\documentclass{article}
\usepackage{subfiles}
\begin{document}
%\end{document}
\subfile{Hello}
\end{document}
My subfile named Hello.tex contains:
\documentclass[Main.tex]{subfiles}
\begin{document}
Hello world!
\end{document}
When the compile the main file (Main.tex), there is no problem. But when I try to compile the Hello.tex file, the compilation fails with the error:
! LaTeX Error: Missing \begin{document}.
When I remove the \end{document} comment in the main file, things are fine once again. Weirdly, there is no problem with other comments in the same place. Only an \end{document} comment seems to be interpreted.
Anyone know why this is happening?