Math & ScienceHelp with aligning equations!

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

Help with aligning equations!

Post by juliette »

I realize that I could do something like:

Code: Select all

\begin{equation}
\begin{align}
|\Psi_A|^2 &= P_A \\
|\Psi_A + \Psi_B|^2 &= P_A + P_B + I_{AB} \\
\end{align}
\end{equation}
to line up the equal signs. Now what if I wanted to make the first line equal A and the second line equal B, and I want the A= and B= to each be on the LEFT sides of their respective equations and lined up vertically as well.

Is there a way I can have BOTH the first AND the second equal signs line up??

When I try:

Code: Select all

\begin{equation}
\begin{align}
P_A &= |\Psi_A|^2 &= P_A \\
P_{AB} &= |\Psi_A + \Psi_B|^2 &= P_A + P_B + I_{AB} \\
\end{align}
\end{equation}

I get a disaster.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Help with aligning equations!

Post by gmedina »

Hi,

you could use the alignat environment provided by amsmath:

Code: Select all

\documentclass{report}
\usepackage{amsmath}

\begin{document}

\begin{alignat}{2}
  P_A &= |\Psi_A|^2 &&= P_A \\
  P_{AB} &= |\Psi_A + \Psi_B|^2 &&= P_A + P_B + I_{AB}
\end{alignat}

\end{document}
Basic information on typesetting math can be found in the amsmath's user guide and in the Mathmode document.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
Post Reply