So I am thinking of creating a macro that takes any latex code as an argument. For example,
\newcommand\purp[1]{\color{purple} #1}
I hoped that this macro would make any latex code inside of \purp to be colored as purple. I realized, however, is that if I pass some environment (\begin.. \end) to the argument, some weird latex error occurs. For example.
\purp{
\begin{verbatim}
asdfadf
asdf
asdf
\end{verbatim}
}
breaks the verbatim output and generates bunch of latex errors. Is there any safe way to make a function that takes arbitrary latex code as an argument?
Edit
Besides a verbatim, I also observed that following produces very weird error.
\purp{
\[
x= \begin{cases*}
y & if x_1 \text{ is } 1\\
z & if x_2 \text{ is } 2
\end{cases*}
\]
}
This gives a weird error Missing $ is inserted. Any idea why?


