TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to redefine \[ and \] so that they behave as \begin{gather*} and end{gather*}. I've been doing this using \DeclareRobustCommmand; however, when I try to compile the following minimal program:

\[ 2+2=4 \]

I get this error:

! LaTeX Error: \begin{gather*} on input line 9 ended by \end{document`.

This does not happen if I replace gather with equation. What is going on here?

share|improve this question
bad idea. single-line displays need different "surroundings", whether or not they have associated equation numbers. – barbara beeton Dec 7 '11 at 17:41
Do not call it a bad idea unconditionally. If you have many more multi-line displays than one-line displays, then you can use \[...\] as a shorthand for the former and use the lenghtier \begin{equation}...\end{eqaution} for the latter. – Federico Poloni Dec 8 '11 at 8:25
up vote 5 down vote accepted

You can't do like that, because TeX needs to see \end{gather*} in order to know where gather* ends. A low level command definition is needed


But I don't recommend this, as one line displayed equations need different vertical spacing around them, which \[...\] (or equation*) ensures.

share|improve this answer
More precisely, \begin{foo} needs to see \end{bar}, and will complain if the string foo is different from the string bar. So the problem is inherent to defining \[ to begin an environment using the \begin{...} syntax. If you want equivalent functionality to the gather* environment, you can do it, but you'll have to re-implement (i.e. duplicate) some of the functionality of environments in general as well. – Niel de Beaudrap Dec 7 '11 at 15:37
@NieldeBeaudrap: That's not quite true. You can, for example, redefine the {center} environment in exactly this way and it will work. The problem is actually that the way the amsmath environments are defined requires that the closing tag be visible at the top level. Presumably this is similar to the {verbatim} environment. – Ryan Reich Dec 7 '11 at 18:13

@Ryan Reich: Your view is the closest. Some changes can be made to the AMS codes to permit the type of abbreviation that the OP seeks. This comes up often. The logic of Michael Downes, the coder of much of the original AMS stuff, is obvious from this snippet:

   \push@begins#1\begin\end \expandafter\@gobble\begin@stack}

This stack will not stop building until the end of the current topmost environment is seen.

share|improve this answer

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.