Math & ScienceCentering equations in equation arrays ?

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
juliette
Posts: 75
Joined: Thu Nov 20, 2008 10:15 pm

Centering equations in equation arrays ?

Post by juliette »

I have the following code:

Code: Select all

\begin{eqnarray}
|\Psi(x)|^2 = \xi \quad , \quad P(x) = |\Psi(x)|^{2+\epsilon} = \xi^{1+\frac{\epsilon}{2}} = \xi + b_1 \, (\frac{\epsilon}{2}) ~ + ~ b_2 \, (\frac{\epsilon}{2})^2 ~ + \cdots \quad \textrm{where,}  \\
b_n \equiv \frac{1}{n!}\frac{d^n \xi^{(1+\frac{\epsilon}{2})}}{d \epsilon}\left.{\!\!\frac{}{}}\right|_{\epsilon=0} 
\end{eqnarray} 
except the second line is not centered. I tried \begin{center} \end{center} , I've tried \centering , and I've tried the "aligned" environment. But nothing that gives me what I want. Does anyone know how to do this ?? I'm using revTex4 as my document type, maybe that is what is causing it?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX books
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Centering equations in equation arrays ?

Post by localghost »

At first you should read something about why not use the eqnarray environment [1]. With this information and the help of the amsmath user guide you will understand the modifications of your sample code.

Code: Select all

\begin{alignat}{2}
  &\hphantom{=}\;\; |\Psi(x)|^2 &&= \xi \quad , \\
 \quad P(x) &= |\Psi(x)|^{2+\epsilon} &&= \xi^{1+\frac{\epsilon}{2}} = \xi+b_1\,\left(\frac{\epsilon}{2}\right)+b_2 \,\left(\frac{\epsilon}{2}\right)^2+\cdots\quad\textrm{where,}  \\
  b_n &\equiv \frac{1}{n!}\frac{d^n \xi^{(1+\frac{\epsilon}{2})}}{d \epsilon}\Big|_{\epsilon=0}
\end{alignat}
You didn't use the alignment character ("&") to align your equations. This character is also used in the eqnarray environment. Nevertheless the alignat environment in this case is the better solution. More useful information about typesetting mathematical expressions can be found in the "Math mode" document.

[1] The PracTeX Journal - Lars Madsen: Avoid eqnarray!


Best regards
Thorsten¹
juliette
Posts: 75
Joined: Thu Nov 20, 2008 10:15 pm

Re: Centering equations in equation arrays ?

Post by juliette »

Thanks a lot! What you gave me was not exactly what I wanted, but I read the link you sent me with the amsmath documentation, and I found that the "gather" environment does JUST what I needed! Thanks again.
ankhi
Posts: 32
Joined: Sun Aug 26, 2012 6:07 pm

Centering equations in equation arrays ?

Post by ankhi »

Sorry for bumping but I have the exact same question.

The attached template will not let me use the amsmath package. So I have to use {eqnarray} environment for multi-line equations. Any idea how to center the whole thing without amsmath? In the template you will find one {eqnarray} environment.
Attachments
AGUtmpl.tex
(16.55 KiB) Downloaded 662 times
Last edited by localghost on Tue Feb 26, 2013 6:27 pm, edited 1 time in total.
User avatar
svend_tveskaeg
Posts: 478
Joined: Sun Jul 12, 2009 5:31 am

Centering equations in equation arrays ?

Post by svend_tveskaeg »

Read Lars Madsen's PracTeX (or TUGboat) article. Then you know why you shouldn't use the {eqnarray} environment at all.
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)
ankhi
Posts: 32
Joined: Sun Aug 26, 2012 6:07 pm

Centering equations in equation arrays ?

Post by ankhi »

svend_tveskaeg wrote:Read Lars Madsen's PracTeX (or TUGboat) article. Then you know why you shouldn't use the {eqnarray} environment at all.
I know why I shouldnt but the people at AGU still dont!!! they have specified this template not me!!! I just got to follow it.... :(
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Centering equations in equation arrays ?

Post by localghost »

ankhi wrote:I know why I shouldnt but the people at AGU still dont!!! they have specified this template not me!!! I just got to follow it.... :(
Since the people at AGU seemingly force you to use this template, they are in charge of providing an appropriate solution. Only my opinion.


Thorsten
ankhi
Posts: 32
Joined: Sun Aug 26, 2012 6:07 pm

Centering equations in equation arrays ?

Post by ankhi »

localghost wrote:
ankhi wrote:I know why I shouldnt but the people at AGU still dont!!! they have specified this template not me!!! I just got to follow it.... :(
Since the people at AGU seemingly force you to use this template, they are in charge of providing an appropriate solution. Only my opinion.


Thorsten
Image
:(
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Centering equations in equation arrays ?

Post by localghost »

My advice was meant to be serious. No reason for silly replies. Contact the maintainer of the template as well as of the used class. It is their job to correct that and to provide a template that uses modern LaTeX.
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Centering equations in equation arrays ?

Post by cgnieder »

localghost wrote:It is their job to correct that and to provide a template that uses modern LaTeX.
While I agree in general I think we should also try to deal with such problems.

AGU are not the only ones to demand older (La)TeX. Springer is also known to demand {eqnarray}, for example. Other journals demand that you don't use e-TeX, let alone biblatex. I remember having read comments from Barbara Beaton (responsible for AMS typesetting and the ams classes and packages) explaining why it is not a simple task for them to switch to a modern system (but couldn't find it any more, unfortunately :( ). So all in all it repeatedly is a problem for users having to deal with such demands.

Thus my question/request to ankhi: the »AGUTeX« class is no standard class so it is not available to us. Maybe you can attach it to forum in your next post?

Regards
site moderator & package author
Post Reply