Say I have an environment env which is used like this:
\begin{env}
*Text*
\end{env}
Is it possible to "use" *Text* in the definition of the environment (top or bottom part) - similar as a parameter #1 is used within a command. I am aware that an environment is a completely different construct and actually consists of two commands which enclose *Text*. But I imagine a really cool hack which initiates scanning the text in the first command, and stores it to be used in the second. Is this at all possible?


environpackage does this. – Manuel Jul 21 '15 at 16:20\newenvironment{env}[1]{}{}will allow you to invoke it as\begin{env}{*Text*} ... \end{env}. Do you mean to use the complete text of the environment, or only the leading text? – Steven B. Segletes Jul 21 '15 at 16:27filecontentsdef. See package documentation and my other answer https://tex.stackexchange.com/a/622425/250119 for details and other options. – user202729 Jan 22 '22 at 05:03