7

I want to align this equation. I tried

\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{fourier}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\begin{document}
If $U$, $V$, $W$, $u$, $v$, $v$, $w$ are lengths of edges of the tetrahedron (first three form a triangle; $u$  opposite to $U$ and so on), 
\[\text{volume} = \frac{\sqrt {\,( - a + b + c + d)\,(a - b + c + d)\,(a + b - c + d)\,(a + b + c - d)}}{192\,u\,v\,w}\]
where
\begin{align*}
a  &= \sqrt{xYZ}, & b  = \sqrt{yZX},\\
c  &= \sqrt{zXY}, &d  = \sqrt{xyz},\\
X  &= (w - U + v)\cdot(U + v + w),   &x  = (U - v + w)\cdot(v - w + U),\\
Y &= (u - V + w)\cdot(V + w + u),  &y  = (V - w + u)\cdot(w - u + V),\\
Z  &= (v - W + u)\cdot(W + u + v), &z = (W - u + v)\cdot(u - v + W).
\end{align*}
\end{document}

enter image description here

I feel it is not good. How can I repair it?

  • You should use &= also in the equations on the right side – egreg Feb 22 '14 at 16:13
6

You should use &= also in the equations on the right side. If you feel that the spacing between the two blocks is too wide, use alignat*, where the spacing is explicitly marked. Below I have tried both.

\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{fourier}
\usepackage{amsmath}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\begin{document}

If $U$, $V$, $W$, $u$, $v$, $v$, $w$ are the edge lengths of the tetrahedron 
(first three form a triangle; $u$ opposite to $U$ and so on),
\[
\text{volume} = 
  \frac{\sqrt {\,(-a+b+c+d)\,(a-b+c+d)\,(a+b-c+d)\,(a+b+c-d)}}
       {192uvw}
\]
where
\begin{align*}
a &= \sqrt{xYZ},                  & b &= \sqrt{yZX},\\
c &= \sqrt{zXY},                  & d &= \sqrt{xyz},\\
X &= (w - U + v)\cdot(U + v + w), & x &= (U - v + w)\cdot(v - w + U),\\
Y &= (u - V + w)\cdot(V + w + u), & y &= (V - w + u)\cdot(w - u + V),\\
Z &= (v - W + u)\cdot(W + u + v), & z &= (W - u + v)\cdot(u - v + W).
\end{align*}
where
\begin{alignat*}{2}
a &= \sqrt{xYZ},                        & b &= \sqrt{yZX},\\
c &= \sqrt{zXY},                        & d &= \sqrt{xyz},\\
X &= (w - U + v)\cdot(U + v + w),\qquad & x &= (U - v + w)\cdot(v - w + U),\\
Y &= (u - V + w)\cdot(V + w + u),\qquad & y &= (V - w + u)\cdot(w - u + V),\\
Z &= (v - W + u)\cdot(W + u + v),\qquad & z &= (W - u + v)\cdot(u - v + W).
\end{alignat*}
\end{document}

Note that no thin spaces should be added in the denominator; between the )( pairs in the square root they may be good.

Note also that amsfonts and amssymb are useless if you load fourier.

enter image description here

  • Second versione with \qquad is very nice – marchetto Feb 22 '14 at 16:25
5
\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{fourier}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\begin{document}
If $U$, $V$, $W$, $u$, $v$, $v$, $w$ are lengths of edges of the tetrahedron (first three form a triangle; $u$  opposite to $U$ and so on), 
\[\text{volume} = \frac{\sqrt {\,( - a + b + c + d)\,(a - b + c + d)\,(a + b - c + d)\,(a + b + c - d)}}{192\,u\,v\,w}\]
where
\begin{align*}
a  &= \sqrt{xYZ}, & b &= \sqrt{yZX},\\
c  &= \sqrt{zXY}, & d &= \sqrt{xyz},\\
X  &= (w - U + v)\cdot(U + v + w), & x&= (U - v + w)\cdot(v - w + U),\\
Y  &= (u - V + w)\cdot(V + w + u), & y&= (V - w + u)\cdot(w - u + V),\\
Z  &= (v - W + u)\cdot(W + u + v), & z&= (W - u + v)\cdot(u - v + W).
\end{align*}
\end{document}

2

If you don't like the a, b, c, and d being offset to the right, then this would work:

\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{fourier}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\usepackage{tabstackengine}
\stackMath
\begin{document}
If $U$, $V$, $W$, $u$, $v$, $v$, $w$ are lengths of edges of the tetrahedron (first three form a triangle; $u$ opposite to $U$ and so on), 
\[\text{volume} = \frac{\sqrt {\,( - a + b + c + d)\,(a - b + c + d)\,(a + b - c + d)\,(a + b + c - d)}}{192\,u\,v\,w}\]
where

{\centering\setstackEOL{\#}\TABbinary%
\tabbedLongstack[l]{
a&=& \sqrt{xYZ},\#
c&=& \sqrt{zXY},\#
X&=& (w - U + v)\cdot(U + v + w),\#
Y&=& (u - V + w)\cdot(V + w + u),\#
Z&=& (v - W + u)\cdot(W + u + v),
}
$\qquad\qquad$\tabbedLongstack[l]{
b&=& \sqrt{yZX},\#
d&=& \sqrt{xyz},\#
x&=& (U - v + w)\cdot(v - w + U),\#
y&=& (V - w + u)\cdot(w - u + V),\#
z&=& (W - u + v)\cdot(u - v + W).
}\par
}
\end{document}

enter image description here

Furthermore, if you would prefer the variables on the left to be centered wrt each other, then a \tabularLongstack would suffice, as such:

{\centering\setstackEOL{\#}\setstacktabulargap{0pt}\TABbinary%
\tabularLongstack{ccl}{
a&=& \sqrt{xYZ},\#
c&=& \sqrt{zXY},\#
X&=& (w - U + v)\cdot(U + v + w),\#
Y&=& (u - V + w)\cdot(V + w + u),\#
Z&=& (v - W + u)\cdot(W + u + v),
}
$\qquad\qquad$\tabularLongstack{ccl}{
b&=& \sqrt{yZX},\#
d&=& \sqrt{xyz},\#
x&=& (U - v + w)\cdot(v - w + U),\#
y&=& (V - w + u)\cdot(w - u + V),\#
z&=& (W - u + v)\cdot(u - v + W).
}\par
}

enter image description here

Incidentally, the stackEOL is changed from \\ to \# because \centering redefines \\ in a way that breaks the TABstacks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.