TransWikia.com

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

TeX - LaTeX Asked by Carlijn on January 3, 2021

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:
enter image description here

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:

enter image description here

How to do this?

Kind regards!

One Answer

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}

enter image description here

Correct answer by Bernard on January 3, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP