Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!ames!orion.arc.nasa.gov!ogawa From: ogawa@orion.arc.nasa.gov (Arthur Ogawa) Newsgroups: comp.text.tex Subject: Re: Problem with LaTeX eqnarray... Message-ID: <1991Feb5.081221.8606@news.arc.nasa.gov> Date: 5 Feb 91 08:12:21 GMT References: Sender: usenet@news.arc.nasa.gov (USENET Administration) Organization: /usr/local/lib/rn/organization Lines: 52 In article sullivan@msor.exeter.ac.uk (Rob Sullivan) writes: >I would be most grateful if someone could point out what is wrong with >the following LaTeX file. It appears to produce a TeX 'weird' error. > >\documentstyle{article} >\begin{document} >text text text text >\begin{eqnarray} >[a,b]&=&0 \\ >[a,b]&=&0 >\end{eqnarray} >text text text >\end{document} Be careful: the \\ command at the end of each line in the eqnarray will be looking for an optional argument of the form []. It's also looking for a preceding *. Rewrite your eqnarray's content: \begin{eqnarray} [a,b]&=&0 \\\relax [a,b]&=&0 \end{eqnarray} Note that the \relax command is probably only one of many ways to overcome this problem, but it's the one I favor. >What should I do if I want aligned commutator brackets. The right bracket will be aligned as is. If you want the left brackets to align, too, you could do \begin{equation}% \everymath{\displaystyle}% \begin{tabular}{l@{}r@{}l} $[{aaa\over b},$&$b]$&${}=0$ \\\relax $[a,$&$bbbb]$&${}=0$ \end{tabular} \end{equation} Explanation: We use an equation environment so we can continue to have numbered equations. Inside of the environment is a tabular environment, whose features are used to accomplish the alignment (otherwise unavailable in eqnarray). The first column is left justified (thus aligning the left bracket) the second column is aligned on the right for the sake of the right bracket. In order to continue to set the material in math mode, each cell is surrounded with $s (you could use \(\) equally well). And, in order to simulate display math, each cell is set in \displaystyle. I know the above solution is not characterized by pretty markup, and that you've lost the ability to apply an equation number to each line. The alternative is to change the definition of the eqnarray environment. I could post this, if there is interest.