[Tex/LaTex] Centering equations within alignat command

alignamsmathmath-mode

I want to centre the formula inside the equals. So far I have

\begin{alignat*}{2}    
v_2(16)&=\frac{2}{5}[v_3(32)+v_3(8)] &&= 0, \\
v_2(4)&=\frac{2}{5}[v_3(8)+v_3(2)] &&= 1.20,\\   
v_2(1)&=\frac{2}{5}[v_3(2)+v_3(0.50)] &&= 3.
\end{alignat*}

Basically I have

 A =BBB = CC

 A =B   = CCCC

but I want

 A = BBB = CC

 A =  B  =CCCC

Best Answer

To have each of the three "columns" centered, you could use the array environment. Note (i) the specification of the = column dividers in the header of the array environment, to ensure math-appropriate spacing, and (ii) the reset of the \arraystretch parameter to get a look that's appropriate for a group of displayed equations.

\documentclass{article}
\begin{document}
\renewcommand\arraystretch{1.33} % default value: 1.0
\[
\begin{array}{c @{{}={}} c @{{}={}} c}
v_2(16) & \frac{2}{5}[v_3(32)+v_3(8)]    & 0, \\
v_2(4)  & \frac{2}{5}[v_3(8) +v_3(2)]    & 1.20,\\   
v_2(1 ) & \frac{2}{5}[v_3(2) +v_3(0.50)] & 3.
\end{array}
\]
\end{document}

enter image description here

If you want to typeset the left-most column flush-right against the first = sign and the right-most column flush-left against the second = sign, you could set {r @{{}={}} c @{{}={}} l} as the array header specification.


Rather than center-set the middle portions of the equations, I would actually recommend maintaining the alignat* environment while adding a further alignment point, at the + sign. I'd also use \tfrac rather than frac:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{alignat*}{3}    
v_2(16)&=\tfrac{2}{5}[v_3(32) &&+v_3(8)]    &&= 0, \\
v_2(4) &=\tfrac{2}{5}[v_3(8)  &&+v_3(2)]    &&= 1.20,\\   
v_2(1) &=\tfrac{2}{5}[v_3(2)  &&+v_3(0.50)] &&= 3.
\end{alignat*}
\end{document}

enter image description here