I have a document of the form
\begin{document}
some text
\begin{myenv}
....
\end{myenv}
some other stuff
\end\document
I would like to set a boolean \newif\if@test in the header to control the output, such that if I set \@testtrue, the document would end just after \end{myenv} and not display some other stuff. My attempt is to put
\if@test \enddocument
at the end of the declaration of myenv. But this does not work, LaTeX complains that begin{myenv} is ended by \enddocument ...
How could I do that?

\end{document}in a macro – Martin Scharrer Jan 18 '12 at 19:38