Nested Environ's give "! Argument of ... has an extra }" error
Environment split
inside meqmultinum
provides an alignment. That means that the contents of the environment is processed cell by cell:
Cell 1: a
Cell 2: =\begin{marray}{l l}{1.2} \alpha
The rest & \beta \\ \gamma & \kappa \end{marray}
does not belong to cell 2.
Thus the code of \begin{marray}
complains, because it cannot find \end
of \end{marray}
.
This can be fixed by adding curly braces around \begin{marray}...\end{marray}
:
\begin{meqmultinum}{test}
a&={\begin{marray}{l l}{1.2}
\alpha & \beta\\
\gamma & \kappa
\end{marray}}\\
...
\end{meqmultinum}
Why does it work with array
instead of marray
? Environment array
does not need to see at the beginning \end{array}
, instead it sets up a tabular and the contents of array
with its &
is processed in this inner tabular.
Other definition of marray
Another way to fix this issue is given by David Carlisle in his comment. There is no need for the special environment processing of package environ
for array
:
\newenvironment*{marray}[2]{%
\renewcommand*{\arraystretch}{#2}%
\begin{array}{#1}%
}{%
\end{array}%
}
There is no need to use \NewEnviron
for these environments; in this case split
can give problems, but aligned
can be used instead.
\documentclass{article}
\usepackage{amsmath}
\newenvironment{meqmultinum}[1]
{\equation\label{eq:#1}\aligned}
{\endaligned\endequation}
\newenvironment{marray}[2]
{\renewcommand*{\arraystretch}{#2}\array{#1}}
{\endarray}
\begin{document}
\begin{meqmultinum}{test}
a&=\begin{marray}{l l}{1.2}
\alpha & \beta\\
\gamma & \kappa
\end{marray}\\
b&=\begin{array}{l l}
\alpha & \beta\\
\gamma & \kappa
\end{array}
\end{meqmultinum}
\end{document}