Math & Scienceequation alignment

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
teddy0625
Posts: 9
Joined: Sat Mar 28, 2009 10:34 am

equation alignment

Post by teddy0625 »

Code: Select all

\begin{align}
\mathbf{u}=(u(x,y,t),v(x,y,t))
\end{align}
then general form of Euler equation can be defined as 
\begin{align*}
\rho\bigg(\frac{\partial}{\partial t}+\mathbf{u} \cdot \nabla\bigg)\mathbf{u}+\nabla p=0, \\
\nabla\cdot\mathbf{u}=0.
\end{align*}
Hi
I want to align all my equations right in the middle as in standard textbooks. All of the equations are always automatically left aligned and I do not know how to change that. And what is the difference between \begin{align} and \begin{eqnarray}?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
localghost
Site Moderator
Posts: 9201
Joined: Fri Feb 02, 2007 12:06 pm

equation alignment

Post by localghost »

teddy0625 wrote:[...] I want to align all my equations right in the middle as in standard textbooks. All of the equations are always automatically left aligned and I do not know how to change that. [...]
Check the option list for the document class or the amsmath package for the fleqn option and remove it. Posting almost the same request two times is not necessary [1]. An answer has already been given there.
teddy0625 wrote:[...] And what is the difference between \begin{align} and \begin{eqnarray}?
Differences and very good reasons against the eqnarray environment are given in a paper [2]. There you will find all necessary information.

You should use the align environment in the right way.

Code: Select all

\begin{align}
  \mathbf{u}&=(u(x,y,t),v(x,y,t))
\end{align}
then general form of Euler equation can be defined as
\begin{align*}
  \rho\bigg(\frac{\partial}{\partial t}+\mathbf{u} \cdot \nabla\bigg \mathbf{u}+\nabla p&=0, \\
  \nabla\cdot\mathbf{u}&=0.
\end{align*}
Note the position of the ampersand ("&") as alignment character.

[1] View topic: equations alignment
[2] PracTeX Journal - Lars Madsen: Avoid eqnarray!


Best regards
Thorsten¹
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes[/size]

¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1
User avatar
Juanjo
Posts: 657
Joined: Sat Jan 27, 2007 12:46 am

equation alignment

Post by Juanjo »

For formulas extending along only one line, don't use align but equation (or equation* if unnumbered):

Code: Select all

\begin{equation}
   \mathbf{u}=(u(x,y,t),v(x,y,t))
\end{equation}
The CTAN lion is an artwork by Duane Bibby. Courtesy of www.ctan.org.
Post Reply