I have a file, which is meant to be used as a fragment file inside a larger document:
\include{boilerplate} content \include{boilerplate} The goal is to make a fragment file compilable. So inside boilerplate.tex, I have:
\ifx\maindocument\undefined \documentclass{article} \def\maindocument{} \begin{document} fragment is now standalone \else fragment is finished \end{document} \fi When I compile the fragment, I get:
(\end occurred when \ifx on line 1 was incomplete) The "cause" of this is that inside my \ifx, I end the document and so the \ifx never finishes. However, everything seems to compile properly. How can I keep this general format, but make the error message go away? I tried putting an \expandafter{\end{document}} but that didn't help.
After incorporating the suggestions about \enddocument (or another macro), I was able to remove the error. However, a few remain:
(\end occurred when \iftrue on line 3 was incomplete) (\end occurred when \ifnum on line 3 was incomplete) Here is my boilerplate.tex now:
\def\prestuff{% \documentclass{article} \def\maindocument{} \begin{document} fragment is now standalone } \def\poststuff{% fragment is finished \end{document} } \ifx\maindocument\undefined \expandafter\prestuff \else \expandafter\poststuff \fi So what about these errors?
\includeand prefer\input. The errors are indeed caused by\include.