# alignat introduces extra space with fleqn option

In my MWE below, there is extra space introduced after the second =. How can I get rid of it? I am forced to use the fleqn option by my document class:

\PassOptionsToPackage{fleqn}{amsmath}
\documentclass{article}

\usepackage{amsmath}
\begin{document}
\begin{alignat}{2}
X &  = 1XXXXXXXXXX%
X && = 1XXXXXXXXXXX
\end{alignat}
\end{document}

• Why are you using alignat for a single-line formula? Jun 29, 2019 at 11:41
• @AboAmmar: Maybe to make the example code as minimal as possible… Jun 29, 2019 at 11:42
• @Bernand is correct.
– bers
Jun 29, 2019 at 11:43

This is linked with, on one hand the equation being too long and overflowing into the right margin, and on the other hand, a not very sensible placement of the 2nd ampersand. With this code, you have no problem:

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

\begin{document}

\begin{alignat}{2}
X & = 1XXXXXXXXXX%
X& = 1XXXXXXXXXXX
\end{alignat}

\end{document}


• In this example, the & before the second equals sign isn't needed. On the other hand, additional lines may make this irrelevant. Jun 29, 2019 at 15:13
• @barbarabeeton: With a single line, no & is actually needed. For more lines, I have no code from the O.P. to say whatever. I only supposed an alignment on the = signs was required – the most usual case, and found out, a little by chance, that this other placement seemed to solve the problem, without explaining it. Jun 29, 2019 at 15:27
• @barbarabeeton my second line would be \\& = 2&& = 3, forcing both =s to be aligned. With only one & in each line, 3 would be forced to the right end of the line.
– bers
Jun 29, 2019 at 19:49
• @Bernard indeed, splitting the double & fixes the problem, thank you. But the underlying issue is indeed a line that is too long, apparent by the equation number reaching into the margin (in my full document at least). Once I fixed that, the double & was not a problem anymore. Thanks!
– bers
Jun 29, 2019 at 19:55
• Yes, I also noticed the problem disappeared loading geometry, which defines by default more sensible margins. Note the fleqn option does not make equation start at the left margin, but at the math margin(which is \left margin + something). Jun 29, 2019 at 20:00