# What are the differences between , , align, equation and displaymath? I once learnt, that it is uncool to use , but why is that? Why does \[ not act as a abbreviation to \begin{align}? I noticed, that there is a difference, since one cannot use & and \\ inside a block started with \[. - ## 3 Answers As I understand your question, you'd like to know what the differences are between constructing display-math expressions using the following five methods: 1.  ...  2. \[ ...  3. \begin{displaymath} ... \end{displaymath} 4. ... 5. \begin{gather*} ... \end{gather*}. Actually, you asked about the align environment, but I think that for the sake of providing a straightforward comparison among the display-math methods, it's better to focus on the gather* environment, which centers its contents and doesn't generate an equation number. Compared with the gather and gather* environments, the significant added capability of the align and align* environments is their ability to vertically align equations along certain elements, such as on equal signs. The first method is the "Plain TeX" method for generating displayed equations. ("Plain TeX" refers to a set of macros, written by Knuth, designed to make the so-called "TeX primitives" usable for ordinary typesetting purposes. A full explanation of what the  specifiers do is provided on p. 287 of the TeXBook.) However, using the $$ method is nowadays heavily deprecated. See, for instance, the question "Why is $...$ preferable to$$?", and the associated answers, for an examination of why one should not employ $$ ... $$ directly when using the LaTeX format (or one its successors, such as pdfLaTeX, XeLaTeX, etc).

The second method, $ and $, is Leslie Lamport's re-implementation of the Plain-TeX $$ ... $$ method. The LaTeX code that defines the $ and $ commands is contained in the file latex.ltx:

\def${% \relax\ifmmode \@badmath \else \ifvmode \nointerlineskip \makebox[.6\linewidth]{}% \fi %% BRACE MATCH HACK \fi } \def${%
\relax\ifmmode
\ifinner
\else
$$%%$$ BRACE MATCH HACK
\fi
\else
\fi
\ignorespaces
}


Basically, the $ and $ commands act as carefully designed wrappers around the $$ opening and closing commands. Error messages will be generated if a $ statement is encountered while TeX is already in math mode or if a $ statement is encountered while not in ("normal" or "outer") math mode. In addition, the command $ begins by checking if TeX is in so-called "vertical mode" (this happens to be the case, most commonly, at the start of a paragraph); if that's the case, it avoids inserting any additional vertical space by issuing the command \nointerlineskip. The LaTeX code for the third method is simply: \def\displaymath{\[} \def\enddisplaymath{$\@ignoretrue}  i.e., it is (essentially) equivalent to the second method, while arguably being easier to read and debug. By easier to debug, I mean that these commands are not as easy to overlook as the $ and $ commands are. Note that these first three methods do not generate an equation number associated with the material set in display-math (usually an equation). As implemented in LaTeX -- but without loading the amsmath package -- the code for the fourth method ( ... ) is: \@definecounter{equation} \def\equation{$$\refstepcounter{equation}}
\def\endequation{\eqno \hbox{\@eqnnum}$$\@ignoretrue} \def\@eqnnum{{\normalfont \normalcolor (\theequation)}}  This method thus also provides a "wrapper" around the (internally generated) $$ pair of commands, while adding a right-aligned equation number that's surrounded by parentheses. The (\eqno macro is a TeX macro, described on pp. 186-7 and elsewhere in the TeXBook, that inserts an equation number given by \@eqnum.)

Finally, about the \begin{gather*} ... \end{gather*} method that's made available by loading the amsmath package. Before examining the details of this method, it's important to mention that the amsmath package provides the commands \mathdisplay and \endmathdisplay, which serve as (even more elaborate) "wrappers" around -- you guessed it -- the plain-TeX $$ constructs. The amsmath package provides a redefinition of the equation environment and a new environment for unnumbered equations called equation*: \renewenvironment{equation}{% \incr@eqnum \mathdisplay@push \st@rredfalse \global\@eqnswtrue \mathdisplay{equation}% }{% \endmathdisplay{equation}% \mathdisplay@pop \ignorespacesafterend } \newenvironment{equation*}{% \mathdisplay@push \st@rredtrue \global\@eqnswfalse \mathdisplay{equation*}% }{% \endmathdisplay{equation*}% \mathdisplay@pop \ignorespacesafterend }  As you can see, the equation and equation* environments eventually call the \mathdisplay and \endmathdisplay commands, which, in turn, call the TeX $$ macros. Incidentally, amsmath also redefines the LaTeX commands $ and $ as follows:

\DeclareRobustCommand{$}{\begin{equation*}} \DeclareRobustCommand{$}{\end{equation*}}


(Observe that because displaymath is defined in terms of the $ and $ commands, its appearance too may change when used in combination with the amsmath package.)

On, then, to the code for the gather* environment:

\newenvironment{gather*}{%
\start@gather\st@rredtrue
}{%
\endgather
}


where the \start@gather command is defined as

\def\start@gather#1{%
\RIfM@
\nomath@env
\DN@{\@namedef{end\@currenvir}{}\@gobble}%
\else
$$% #1% \ifst@rred \else \global\@eqnswtrue \fi \let\next@\gather@ \fi \collect@body\next@ }  The command \endgather, which is defined implicitly, executes the following instructions: \math@cr \black@\totwidth@ \egroup$$\ignorespacesafterend


The main thing to take away from examining these lines of code -- without going into too many of the details, many of which relate to the fact that the align, align*, gather, gather*, etc environments can typeset multiple, consecutive lines of displayed-math material -- is that the gather* environment too (eventually) calls the $$ TeX macro, while taking care of quite a few housekeeping and error-avoidance steps along the way. In sum, one thing that should be amply clear from all this is that using the $$ constructs directly is unnecessary and even reckless, as doing so risks causing all kinds of messy screw-ups. The alternative methods 2 through 5 take care to avoid these problems and should therefore always be preferred to using the $$ pair of commands. - This is a great answer. Thank you! – niklasfi Jan 9 '12 at 18:39 Your link seems to be broken. – celtschk Jan 9 '12 at 20:07 @celtschk: Thanks for pointing out the problem; I've fixed the link. – Mico Jan 9 '12 at 20:12 $$ is not supported in LaTeX at all, it is primitive TeX syntax that just happens to sort of almost work most of the time. The standard LaTeX classes for example all have a fleqn option to align rather than center . Even with no options, the behaviour of  and  are different at the start of a paragraph, where \[ does \nointerlineskip \makebox[.6\linewidth]{}%  before doing  -  thanks for editing, was just looking up the quote syntax, and by the time I came back you'd fixed it:-) – David Carlisle Jan 9 '12 at 10:21 Welcome back to TeX.SX! – egreg Jan 9 '12 at 15:10 Also align does not behave the same way as \[... regards to spacing before. $...$ and the equation environment can adjust the spacing above the equation if there is enough room, align cannot (because of the manner in which it is constructed)

-
 An example of this spacing difference can be found at align vs equation. – Peter Grill Jan 9 '12 at 20:20