I am used to using \newenvironment to wrap an environment:
\newenvironment{wrappedequation}
{Look out for the equation!
\begin{equation}}
{\end{equation}
Phew, it's over.}
This works fine. However, it doesn't seem to work with align or align*:
\documentclass{amsart}
\newenvironment{wrappedalign}
{Look out for the aligned equation!
\begin{align}}
{\undefinedcommand
\end{align}
Phew, it's over.}
\begin{document}
\begin{wrappedalign}\end{wrappedalign}
\end{document}
produces
! LaTeX Error: \begin{align} on input line 9 ended by \end{wrappedalign}.
This error must be produced somehow very early in the expansion process (maybe in the argument-grabbing process?), because it doesn't mention the \undefinedcommand that I snuck in there.
EDIT: Darn it, I knew that this looked familiar. Is it the same as some \newcommand instructions not working ? Is there any (good) way to wrap align environments?
\alignand\endaligninstead of\begin{align}and\end{align}, respectively) should work for your case too. – Paul Gessler Jun 06 '15 at 22:09align*(without numbering). The solution given in the linked question does not apply foralign*. Using\align*and\endalign*does not do the intended. After lots of digging, I found out (from here) that I could use\csname align*\endcsnameand\csname endalign*\endcsnameto achieve what I wanted. Also, it is important to have no space before\endcsname. – frabala Feb 03 '21 at 12:42