Is it possible to interrupt a LaTeX environment, say OuterEnv, by another environment, say InnerEnv, the later closing the first in the environment startup code, doing 'whatever' and then resuming the outer one in the end code, proceeding as if nothing has been done before?
This is not a question about resuming enumerate etc. lists.
I know there might be issues with environment arguments and especially with the environment startup code, let alone the grouping feature of environments.
I fear the answer is no :-(
Here is a non-working MWE. LaTeX complains about the InnerEnv ending the OuterEnv (of course ;-))
\documentclass{article}
\usepackage{xcolor}
\usepackage{blindtext}
\newenvironment{OuterEnv}{%
\parindent0pt
Foo
\textcolor{red}{\blindtext}%
}{%
Bar\vskip2\baselineskip% Just for debugging
}
\newenvironment{InnerEnv}{%
\end{OuterEnv} % Fails
Closing Outer...
\textcolor{blue}{\blindtext}%
}{%
Resuming Outer\vskip3\baselineskip
\begin{OuterEnv} %Fails too
}
\begin{document}
\begin{OuterEnv}
\begin{InnerEnv}
\end{InnerEnv}
\end{OuterEnv}
\end{document}
I dot not stick on \newenvironment. \NewDocumentEnvironment for xparse will do too, of course!
\global, but just "one level up". I don't think this is possible, but I am looking forward to the answers of egreg, David, Bruno et al. – Daniel Apr 08 '15 at 11:34\aftergroup? I think our Gurus will have answers (either good or bad ;-)) – Apr 08 '15 at 11:36