I am just starting to learn LaTeX, and am having some struggles aligning math equations. This is for writing up my homework solutions, so I would like to have multiple lines of math, with multiple alignment points. For example, in the following scenario, I would like the = after b to be aligned with = after e, as well as = before h to be aligned with = before i. (Ignore underscore, only there to align the text how I would like it).
a + b = c + d
___e = f + g = h
___________= i + j
Please let me know the best way to do this. Thanks!
Math & Science ⇒ Align equations with multiple align points
Re: Align equations with multiple align points
Check out the
amsmath user's guide.
alignat
environment in the 
Re: Align equations with multiple align points
Thank you. This was helpful. I am now having an issue where if one of the equations is too long, it will correspondingly shift the alignment to the right, and it looks very awkward. Here is an example of what I mean: https://www.overleaf.com/read/ntrzwbgzgtkf#0b5327
Any suggestions?
Any suggestions?
- Stefan Kottwitz
- Site Admin
- Posts: 10281
- Joined: Mon Mar 10, 2008 9:44 pm
Re: Align equations with multiple align points
That's because of the alignment of the whole structure; if one row has a longer entry, the other rows must align.
You can create nested structures using the "aligned" environment inside alignat. Or smash the width of some pieces like this, as a quick way:
Stefan
You can create nested structures using the "aligned" environment inside alignat. Or smash the width of some pieces like this, as a quick way:
Code: Select all
\documentclass{article}
\usepackage{amsmath,mathtools}
\begin{document}
\begin{alignat*}{2}
a &= \mathrlap{b + c + d + e + f} \\
g &= h + i &&= j \\
&&&= \mathrlap{k + l + m}
\end{alignat*}
\end{document}
LaTeX.org admin
Re: Align equations with multiple align points
Thank you!! This is exactly what I needed :)