Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm trying to define two commands \bal and \eal instead of inserting \begin{align} and \end{align} in my document, but in the code below, I'll get some errors. What is wrong with it?

share|improve this question
You cannot, align literally looks for \end{align}. In general it is a bad idea to write using shortcuts like these as it makes the code much harder to read. –  daleif Feb 27 '13 at 10:55
It has no sense to use align for a one line display; use equation, instead. Those shorthands may seem useful, but they aren't: they make the LaTeX document less readable and searchable. Good editors provide keyboard shortcuts that make easy inputting those environments. –  egreg Feb 27 '13 at 11:33
Related questions (possible duplicates?): tex.stackexchange.com/q/3169/86, tex.stackexchange.com/q/65581/86 –  Loop Space Feb 27 '13 at 12:48
@egreg my code above is just a MWE. My problem is that why this definition works for, say, equation environment, but doesn't work for align environment. –  Vahid Damanafshan Feb 27 '13 at 13:33
They are different beasts –  daleif Feb 27 '13 at 13:58
show 1 more comment

2 Answers

up vote 10 down vote accepted

The ‘problem’ is known and documented. I don't believe it's a problem at all, actually, for I can't see how


is clearer input than


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


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


instead of


and nobody will ever be able to convince me of the contrary.

Similarly, one can't define a new environment based on align by


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:


because \align captures the current environment's name and will use \end{myalign} as the end mark for the material to be gathered.A

share|improve this answer
add comment

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:

  1. \def\bal#1\eal{\begin{align}#1\end{align}}

  2. Define \newcommand{\env}[2]{\begin{#1}#2\end{#1}} and then use \env{align}{...}

share|improve this answer
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.