# How to align the beginning and = sign of equations of different length

I have been struggling with aligning equations of different length. By using this align code (so only using & before the = sign)

\begin{align}
a &= a + b \\
c + d &= e + f + g\\
h + i + j &= k\\
\end{align}


I get this as result:

The =signs are aligned, but each equation starts on a different place. If I add a & at the start of each equation, the =signs aren't aligned anymore. Ideally I would like all Equations to start at the same place, then add some white space if needed in order to also align all =signs. So I would like it to look it like this:

How to do this?

Kind regards!

You can obtain it with alignat:

\documentclass{article}
\usepackage{mathtools}

\begin{document}

\begin{alignat}{2}
& a & &= a + b \\
& c + d & &= e + f + g\\
& h + i + j & &= k
\end{alignat}

\end{document}


• +1: Very nice! What is the {2} for? Oct 17 '20 at 6:12
• With alignat, you have to indicate the number of alignment columns – here, two, hence three &. Oct 17 '20 at 9:09
• Thank you! Suchs a clean and easy way Oct 17 '20 at 13:13
• Is there also a way to have the equations alligned like above, but instead of appearing in the center of the page, let them appear on the left? Oct 17 '20 at 13:33
• Yes: either you want it be the same for all displayed equations, and you have to use the fleqn as an option to your document class, or it is only for some specific equations, and you have to nest them in a fleqn environment defined by the nccmath package (to be loaded before mathtools). Oct 17 '20 at 13:45