0

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:

That's not how I want it

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?

3
  • 3
    You should use \begin{alignat*}{2} instead of \begin{flalign*} (with \end{alignat*}, of course); use &&= in front of the second =.
    – egreg
    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.
    – egreg
    Jan 17, 2017 at 9:43
  • Do you want your equations to begin at the left margin? This is not clear.
    – Bernard
    Jan 17, 2017 at 9:43

1 Answer 1

2

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}

enter image description here

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}

enter image description here

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .