1

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%
    \quad\iff\quad%
    X && = 1XXXXXXXXXXX
\end{alignat}
\end{document}
3
  • Why are you using alignat for a single-line formula?
    – AboAmmar
    Jun 29, 2019 at 11:41
  • 1
    @AboAmmar: Maybe to make the example code as minimal as possible…
    – Bernard
    Jun 29, 2019 at 11:42
  • @Bernand is correct.
    – bers
    Jun 29, 2019 at 11:43

1 Answer 1

2

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%
&\quad\iff\quad%
    X& = 1XXXXXXXXXXX
\end{alignat}

\end{document} 

enter image description here

8
  • 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
  • 1
    @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.
    – Bernard
    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).
    – Bernard
    Jun 29, 2019 at 20:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.