# How to vertically align an equation with three "sides"

I am trying to add this to latex, but can't find how to do it. I tried using

    \begin {align*}
x+1 &=  y   &=  x   \\
x   &=  y+1 &=  x   \\
\end {align*}


but it doesn't work.. Also the {equation} only works for 2 sides Any ideas?

• How do you mean " the {equation} only works for 2 sides Any ideas?" ? Feb 11 '18 at 4:03

It seems you're looking for alignat.

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{alignat*}{5}
&& x+1 &=  y   &&=  x   \\
&& x   &=  y+1 &&=  x   \\
\end{alignat*}
\end{document}


• My thoughts exactly =) The only downside is the poor spacing around the second = signs, y + 1= x is very bad with that spacing between the 1 and the =, do you know how that can be fixed, possibly a nice &{}=? Feb 11 '18 at 4:07
• @Au101 You're right, it was not pretty. Now it's slightly better, I hope.
– user121799
Feb 11 '18 at 4:13
• Yes that's much better! I'd give you another +1 if I had another to give :P I was also wondering about && but I didn't have enough confidence never actually having used alignat myself. I was about to start experimenting, but you already answered, so I thought a comment would be better =) Feb 11 '18 at 4:17
• @Au101 I also try to avoid this as much as possible. Especially if the equation reads x+1=...=x ;-)
– user121799
Feb 11 '18 at 4:19