Latex alignat syntax

Viewed 12682

To align several equations in Latex, I write a code like this:

\begin{alignat*}{7}
    d &= \frac{1}{1 + 0.2316419x} & \quad & a_1 &= 0.31938153 & \quad & a_2 &= -0.356563782 \\
    a_3 &= 1.781477937 & \quad & a_4 &= -1.821255978 & \quad & a_5 &= 1.330274429
\end{alignat*}

And I got something like this. What I got

I don't understand why there is a space between a_1 and '='. Could you please tell me how to eliminate that space ? Thank you for your time.

2 Answers

You can use the following approach:

\begin{alignat*}{3}
    & d   = \frac{1}{1 + 0.2316419x}  \quad && a_1  = 0.31938153   \quad && a_2 = -0.356563782 \\
    & a_3 = 1.781477937               \quad && a_4  = -1.821255978 \quad && a_5 = 1.330274429
\end{alignat*}

that results into:

enter image description here

Another question about alginat has an answer that explains what happens ( https://tex.stackexchange.com/questions/49014/aligning-equations-with-text-with-alignat).

The idea is that alginat uses an rl alignment structure. This means that the first column is right aligned and the second is left aligned. This is what happened with you, as "a_1" is left aligned and "= 0.31938153 " is right aligned. Because of the negative sign in the line below this creates unwanted space.

To deal with this, as xiawi pointed out, you simply add another column. Alignat doesn't add extra space, so this will not mess up your spacing, and make both columns left aligned. However, you could also move the equality sign to the previous column if you want to keep the space to emphasise the sign difference.

Related