I want use \def to simplify the \begin{array}. Here is the code
\def\ba#1{\begin{array}#1}
\def\ea{\end{array}}
$$ \ba{ccc} a11 & a12 & a13\\ a21 & a22 & a23 \ea $$
I got error. I try to use:
\renewcommand {\begin{array}} {\ba}
\renewcommand {\end{array}} {\ea}
and this:
\newcommand(\ba)[]{\begin{array}}
\newcommand(\ea)[]{\end{array}}
get error too. So which command I should use?
It is different with programming language I think. Here I want just text substitute \ba instead \begin{array}. It don't need evaluate in macro define.
Update: So I using the same tips to continue simpling:
\bea
y &=& x^4 + 4 \nonumber \\
&=& (x^2+2)^2 -4x^2 \nonumber \\
&\le&(x^2+2)^2
\eea
It work fine. while combine them all:
\newcommand{\sev}[1]{\left| {#1} \right|}
\def\ba#1{\begin{array}{#1}}
\def\ea{\end{array}}
\def\bea{\begin{eqnarray}}
\def\eea{\end{eqnarray}}
Q: $$D=\sev{\ba{cccccc}
s_0&s_1&s_2&\cdots&s_{n-1}&1\\
s_1&s_2&s_3&\cdots&s_n&x\\
s_2&s_3&s_4&\cdots&s_{n+1}&x^2\\
\vdots&\vdots&\vdots&\ddots&\vdots\\
s_n&s_{n+1}&s_{n+2}&\cdots&s_{2n-1}&x^n \ea}$$
and $s_k=x_1^k+x_2^k+\cdots+x_n^k$.
A: $$ \bea D &=& \sev{\ba{ccccc}
1&1&\cdots&1&1\\
x_1&x_2&\cdots&x_n&x\\
\vdots&\vdots&\ddots&\vdots&\vdots\\
x_1^{n-1}&x_2^{n-1}&\cdots&x_n^{n-1}&x^{n-1}\\
x_1^n&x_2^n&\cdots&x_n^n&x^n \ea} \eea $$
The Q is right, But the A is wrong and tell "Missing \endgroup"
\sev,\ba, '\bea' work fine alone. But combine them together got error. – jiamo Nov 26 '15 at 09:31eqnarray! You actually shouldn't do this at all. I have never understood why people consider the 20 extra strokes for environments a problem. It takes hours to think out the contents, and then a couple seconds is a problem? And if it is, you should really rather get a TeX editor capable of good auto-complete. Last but not least, note that you hide the document's structure in the code. As a copy editor, I can tell you that dealing with a code like that is then really painful. – yo' Nov 26 '15 at 09:36eqnarrayafter an opening$$directive. Remove the$$directives in the "A" portion of the code and it will compile fine. – Mico Nov 26 '15 at 09:47eqnarrayenvironment?! This environment is severely deprecated -- there is simply no excuse for using it these days. See the posting eqnarray vs align for more information on this subject. – Mico Nov 26 '15 at 09:52$$in a LaTeX document; use\[and\]instead. No exceptions. By all means, do learn how to use thealignenvironment. – Mico Nov 26 '15 at 09:53$$, and using\def\bea{\begin{align}}it can work like\def\bea{\begin{eqnarray}}– jiamo Nov 26 '15 at 10:14\beawill work, but\def\eea{\end{align}} will not. See the posting [What is wrong with defining \bal as \begin{align}?](http://tex.stackexchange.com/q/100138/5001), and especially egreg's answer, for information on why\eea`, as defined by you in the preceding comment, will not work. – Mico Nov 26 '15 at 10:26