# What's wrong with my align code?

I want to align some equations, but it's not aligning properly, code:

\begin{center}
\begin{align*}

a*b=&h_1k_1h_2k_2\\
=&h_1(h_2h_2^{-1})k_1h_2k_2\\
=&h_1h_2(h_2^{-1}k_1h_2)k_2\\
=&h_1h_2(h_2k_1h_2^{-1})^{-1}k_2

\end{align*}
\end{center}


I want them lined up by the equal signs, but upon compiling that is not at all what's happening and I really wonder why. My preamble is \usepackage{amsmath, amssymb, amsfonts, mathtools}. Thanks in advance.

• If you want to align by the equal signs, you need to put ampersands before them i.e., &=. Also, you don't need center environment because align centers the formula (in the default setting). Feb 22 '17 at 6:05
• Aside/off-topic: The mathtools package loads the amsmath package automatically; thus, no need to load amsmath separately.
– Mico
Feb 22 '17 at 6:14

Three suggestions: (i) Don't encase the align* environment in a center environment; (ii) don't allow blank lines inside an align* (or other display math) environment; and (iii) write &= rather than =& if you want proper spacing around the = symbols.

The corrected code:

\begin{align*}
a*b&=h_1k_1h_2k_2\\
&=h_1(h_2h_2^{-1})k_1h_2k_2\\
&=h_1h_2(h_2^{-1}k_1h_2)k_2\\
&=h_1h_2(h_2k_1h_2^{-1})^{-1}k_2
\end{align*}

• Thanks alot! That solves all, but one problem which I discovered now, namely that the text below this align is indented. I'm trying to comment i.e. use % before and right after the align, but it's still being indented. Any suggestions? Again thanks. Feb 22 '17 at 6:10
• @Thomas - Do you mean to say that the text below the display math environment starts with a paragraph indentation? If so, don't leave any blank lines (which generate a paragraph break) between \end{align*} and the start of the text.
– Mico
Feb 22 '17 at 6:12
• Thanks again, that solved all of my problems this morning. You're a Latex hero! Feb 22 '17 at 6:23