# Align last part of equation left, too

I have these equations:

\begin{flalign*}
p(C = c_1 | X = t) &= \frac{p(X = t | C = c_1) p(C = c_1)}{p(X = t)} &= \frac{\theta_1 \pi_1}{\theta_1 \pi_1 + \theta_2 (1 - \pi_1)} \\
p(C = c_1 | X = h) &= \frac{p(X = h | C = c_1) p(C = c_1)}{p(X = h)} &= \frac{(1 - \theta_1) \pi_1}{(1 - \theta_1) \pi_1 + (1 - \theta_2) (1 - \pi_1)}
\end{flalign*}


They look like this:

But I want the rightmost part to be aligned to the left. Especially, I want the two last equals signs to be aligned, and move as far left as possible dragging the last part of the formular with them. How do I do that?

• You should use \begin{alignat*}{2} instead of \begin{flalign*} (with \end{alignat*}, of course); use &&= in front of the second =. Commented Jan 17, 2017 at 9:24
• By the way, flalign should be used very sparingly; it's not a “catch-all” environment. Use the specific tool for the job. Commented Jan 17, 2017 at 9:43
• Do you want your equations to begin at the left margin? This is not clear. Commented Jan 17, 2017 at 9:43

Please post a full working example next time.

You need to add a second &. It's always alterning between right aligned and left aligned.

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{flalign*}
p(C = c_1 | X = t) &= \frac{p(X = t | C = c_1) p(C = c_1)}{p(X = t)} &&= \frac{\theta_1 \pi_1}{\theta_1 \pi_1 + \theta_2 (1 - \pi_1)} \\
p(C = c_1 | X = h) &= \frac{p(X = h | C = c_1) p(C = c_1)}{p(X = h)} &&= \frac{(1 - \theta_1) \pi_1}{(1 - \theta_1) \pi_1 + (1 - \theta_2) (1 - \pi_1)}
\end{flalign*}
\end{document}


Edit: To get rid of the space before the last equation sign use the alignat environment as suggested by egreg.

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{alignat*}{2}
p(C = c_1 | X = t) &= \frac{p(X = t | C = c_1) p(C = c_1)}{p(X = t)} &&= \frac{\theta_1 \pi_1}{\theta_1 \pi_1 + \theta_2 (1 - \pi_1)} \\
p(C = c_1 | X = h) &= \frac{p(X = h | C = c_1) p(C = c_1)}{p(X = h)} &&= \frac{(1 - \theta_1) \pi_1}{(1 - \theta_1) \pi_1 + (1 - \theta_2) (1 - \pi_1)}
\end{alignat*}
\end{document}


• Space before second =sign? @egreg's comment gives right solution.
– user31034
Commented Jan 17, 2017 at 9:29