2

I have been told that there was a way to use text within eqnarray; however, I have not been able to find or create any workable code. Any help is appreciated.

Torbjørn T.
  • 206,688

1 Answers1

3
\documentclass{report}
\usepackage{amsmath}

\begin{document}

\begin{eqnarray}
\text{left} &=& \text{right}
\end{eqnarray}
\begin{align}
\text{left} &=  \text{right}
\end{align}
\end{document}

enter image description here

edit: (by bbeeton, without consulting Sigur)

Consider the following slightly extended example:

\documentclass{report}
\usepackage{amsmath}

\begin{document}
\begin{eqnarray*}
\text{left} &=& \text{middle} = \text{right}
\end{eqnarray*}
\begin{align*}
\text{left} &= \text{middle} = \text{right}
\end{align*}
\end{document}

output of example code

(There isn't any facility for adding extra alignment points in eqnarray; they are changed to "new line" breaks, after being reported as an error.)

Now is it obvious what the (or at least one) problem is with eqnarray?

Sigur
  • 37,330
  • I prefer the top version (which is eqnarray). Why should I not use it? – Mathematician Jun 17 '14 at 19:43
  • @Mathematician, see the Ian comment above. He linked a pdf file. See it and also the section 2.2 therein. – Sigur Jun 17 '14 at 19:44
  • @Mathematician: Look at the spacing of \text{left}=\text{right} and compare it to the spacing of \begin{eqnarray} \text{left} &=& \text{right} \end{eqnarray} - they're inconsistent. – Werner Jun 17 '14 at 19:44
  • @Sigur So, based on Section 2.2, using eqnarray* is good since that does not label the equation. – Mathematician Jun 17 '14 at 19:48
  • @Werner I am sorry, but I do not understand what you are talking about. The spacing looks fine to me. – Mathematician Jun 17 '14 at 19:49
  • @Mathematician, OK. But and if you really need to number it? Also, see 2.3. – Sigur Jun 17 '14 at 19:49
  • 1
    @Mathematician: Yes, the spacing looks fine to you in the separate environments and that's good. In a similar light, the discussion in What is the Necessity of $…$ Around Numbers? would probably seem superfluous to you... and that's fine as well. It's just that a majority of LaTeX users have conformed to not using eqnarray for reasons already mentioned. Just like I enjoy cream in my coffee doesn't mean that everyone has to follow what I do, so be happy with your choice and accept that (most) others have a different opinion. – Werner Jun 17 '14 at 19:53
  • 1
    @Mathematician Apart of the spacing, if your equation is long, eqnarray type the number of the equation over the equation, while align type the equation number below the equation. – Dox Jun 17 '14 at 19:56
  • @Werner You say that the majority of LaTeX users have conformed to not using eqnarray but no one has said explicitly WHY align is better. I am just trying to figure out why. I am not trying to give people a hard time. I just want to know whether the preference of align over eqnarray is merely opinion or whether there is an actual reason. – Mathematician Jun 17 '14 at 20:02
  • Also, if eqnarray is so bad, why has it not been eliminated? – Mathematician Jun 17 '14 at 20:04
  • @Mathematician, if this would the case, we would have to change all our old files. – Sigur Jun 17 '14 at 20:05
  • 3
    @Mathematician: I think most of that is covered in eqnarray vs align (and the links provided there). Many things remain in (La)TeX for legacy reasons, otherwise there would be no compatibility with a new/updated release (...things would break). – Werner Jun 17 '14 at 20:06