[Tex/LaTex] Which is the preferred command for equations in LaTeX

best practicesequations

While browsing some of the older questions I learned that I should not use $$. I also learned that I blamed LaTeX for obscure error messages that can be prevented by using \( and \). I started to further review my LaTeX files (old habits die hard) and now I have the following question:

Even if not using $$, there are many possible ways to get equations separated from the text. Which one should I use and why? \begin{equation}, \[, \begin{eqnarray} or some other?

I want to make the question more precise and ask for

  • a. a one line equation with no label/number,
  • b. a one line equation with a label/number,
  • c. a multi line equation with no label/number,
  • d. a multi line equation with one label/number and
  • e. a multi line equation with one number/label for each line.

Could you please point out if a package is needed as well, but I would prefer to learn the 'pure' LaTeX macros/ environments, first.

Best Answer

The built-in environments are displaymath for a single unnumbered equation, equation for a single numbered equation, and eqnarray and eqnarray* for multiple aligned equations with and without numbering, respectively. \[ and \] are equivalent to \begin{displaymath} and end{displaymath}.

It is widely accepted that eqnarray and eqnarray* should not be used, because the spacing they create is inconsistent with all of the other environments (see Avoid eqnarray for details).

To generate aligned equations, one could use the array environment inside an equation or displaymath environment, but most people load the amsmath package, which provides many flexible environments for displayed equations. Note that amsmath creates an equation* environment for single unnumbered equations, which is syntactically more consistent than displaymath.

Related Question