# Aligning equal signs in equations

Up to now, I use the align environment. As I want to give each equation a specific reference number, I want to use the equation environment. So I tried this, which works for align:

$$x &=2 \\ &=1+1$$


But this throws errors. Why doesn't it work?

Of course, I've searched for similar questions but there was no question out there, that handles specific this issue. (It was always very complex code; no minimal example)

• equation cannot be split accross lines by design. That is why we have align and others, for example split. Why do you want to go to equation? Oct 16, 2016 at 13:54
• align number each line of equations! you should make effort to skip this nubering, so I do not understand your question Oct 16, 2016 at 13:54
• If you want only one number for the whole thing I would suggest sticking \nonumber at the end of lines you don't want numbered. There may also be a way to use align* and tell LaTeX to make an exception for the lines you want numbered. Oct 16, 2016 at 13:56
• within equation you could use the split environment, which aligns the = signs but results in only one number. see that amsmath documentation: texdoc amsmath. Oct 16, 2016 at 14:13

OK, the answer is trivial and has already been given in the comments, but since you insist on asking for a minimal working example (boldfaced :-), here it is:

\documentclass[a4paper]{article}
\usepackage{amsmath}

\begin{document}
Text before the equation.
$$\begin{split} x &= 2 \\ &= 1+1 \end{split} \label{eq:x=2=1+1}$$
Text after equation~\eqref{eq:x=2=1+1}, with a reference to the equation itself.
\end{document}

• I cannot understand why this trivial answer got so many upvotes (or rather, any upvote at all! :-)
– GuM
Oct 16, 2016 at 19:22
• If you insist, I can downvote… ;o) Oct 16, 2016 at 20:12
• @Bernard: Well, I guess that, after all, this is sort of a compensation for other situations in which you write a pretty deep answer to some though question, and you get just one upvote… ;-)
– GuM
Oct 16, 2016 at 22:54
• This has been reported by many. The simple and obvious solutions get upvotes. If you want to gain rep quickly, don't spend more than five minutes on an answer. Oct 17, 2016 at 16:47
• I searched for "aligning equal sign in equations" in the TeX.SE search bar and got exactly what I (as a novice user) needed. As they say, SE helps future visitors, too! :o) Mar 8, 2017 at 14:50