What is wrong with defining \bal as \begin{align}?
The ‘problem’ is known and documented. I don't believe it's a problem at all, actually, for I can't see how
\bal
a&=b\\
c&<d
\eal
is clearer input than
\begin{align}
a&=b\\
c&<d
\end{align}
To the contrary, I firmly believe that the latter syntax is much better than the former, because it clearly marks the document. Good editors provide fast shortcuts for inputting the latter syntax with as few keystrokes as possible.
Let's see why your definition doesn't work. The align
environment must absorb all of its contents before starting to typeset it, since it needs to do two passes over the material: the first pass is for measuring it, the second one for doing the real typesetting. This is the key for proper placement of the material and of the equation numbers.
With \newcommand{\bal}{\begingroup\align\@ifstar{\nonumber}{}}
you start align
, but LaTeX will never see the end of it, because it doesn't expand tokens while absorbing the material, so \eal
will be absorbed and not recognized as the end of align
.
You could define
\makeatletter
\newcommand{\bal}{\@ifstar{\@bals}{\@bal}}
\def\@bals#1\eal{\begin{align*}#1\end{align*}}
\def\@bal#1\eal{\begin{align}#1\end{align}}
\makeatletter
so that the required tokens are found, but it's clumsy and, as I said, it doesn't provide no benefit whatsoever, while obfuscating the code.
The issue doesn't show with equation
, because this environment doesn't do complex tasks for measuring its contents. But the same arguments apply: there's no gain in inputting
\beq
a=b
\eeq
instead of
\begin{equation}
a=b
\end{equation}
and nobody will ever be able to convince me of the contrary.
Similarly, one can't define a new environment based on align
by
\newenvironment{myalign}
{<something>\begin{align}}
{\end{align}}
where <something>
is any code one wants to be executed for modifying align
's behavior. The problem is exactly the same; but this will work:
\newenvironment{myalign}
{<something>\align}
{\endalign}
because \align
captures the current environment's name and will use \end{myalign}
as the end mark for the material to be gathered.A
This issue is dicussed in section 6 of the file technote.pdf
among the files distributed with amsmath.sty
. (on my system texdoc technote.pdf
will open this file in a pdf viewer.)
I copy here the end of this section, but you should read it in full.
Some workarounds:
\def\bal#1\eal{\begin{align}#1\end{align}}
Define
\newcommand{\env}[2]{\begin{#1}#2\end{#1}}
and then use\env{align}{...}