# [Tex/LaTex] How to align the equal signs in this equation such that the first line and last 2 lines align

alignequations

so I have an equation below.

My latex code for it is:

\begin{align*}
CoJPoD_{   \{I_1, \cdots, I_{k-1}, I_{k+1}, \cdots, I_{n}\} | I_{k} }  = CoJPoD_{ \{system \backslash I_{k}\} | I_k}  \\
= P\left( X_1 \ge X_d^{I_1}, \cdots, X_{k-1} \ge X_d^{I_{k-1}}, X_{k+1} \ge X_d^{I_{k+1}}, \cdots, X_n \ge X_d^{I_n} | X_k \ge X_d^{I_k}\right) \\
= \frac{    P\left( X_1 \ge X_d^{I_1}, \cdots, X_{k-1} \ge X_d^{I_{k-1}}, X_k \ge X_d^{I_k}, X_{k+1} \ge X_d^{I_{k+1}}, \cdots, X_n \ge X_d^{I_n}\right)         }{P\left(X_k \ge X_d^{I_k}\right)} \\
= \frac{JPoD_{\{I_1, I_2, \cdots, I_n\}}}{PoD_{I_k}} \\
= \frac{JPoD_{system}}{PoD_{I_k}}
\end{align*}


My question is, how do I make the equal sign in the first line, align with the equal signs in the last 2 lines so that they appear in the "middle" and align the 2 equal signs in line 2 and 3 on the far left. E.g, make it look like this: (I rearranged it in paint lol)

\documentclass{amsart}
\begin{document}
\begin{align*}
&CoJPoD_{   \{I_1, \dots, I_{k-1}, I_{k+1}, \dots, I_{n}\} \mid I_{k} }  \\
&= CoJPoD_{ \{\mathrm{system} \backslash I_{k}\} \mid I_k}  \\
&= P\bigl( X_1 \ge X_d^{I_1}, \dots, X_{k-1} \ge X_d^{I_{k-1}}, X_{k+1} \ge X_d^{I_{k+1}}, \dots, X_n \ge X_d^{I_n} \mid X_k \ge X_d^{I_k}\bigr) \\
&=\frac{P\bigl( X_1 \ge X_d^{I_1}, \dots, X_{k-1} \ge X_d^{I_{k-1}}, X_k \ge X_d^{I_k}, X_{k+1} \ge X_d^{I_{k+1}}, \dots, X_n \ge X_d^{I_n}\bigr)}{P\bigl(X_k \ge X_d^{I_k}\bigr)} \\
&= \frac{JPoD_{\{I_1, I_2, \dots, I_n\}}}{PoD_{I_k}}\\
&= \frac{JPoD_{\mathrm{system}}}{PoD_{I_k}}
\end{align*}
\end{document}


Some of the changes I have made are:

• indicating how the equations should be aligned by using the & syntax.
• using \mathrm{text} for subscripts which are text of length more than 1.
• replace the \cdots directive by \dots so that amsclasses figure what is best to do.
• replace | by \mid.
• replace \left(...\right) by \bigl(...\bigr).

You'd find this entire document a very useful read. In particular, I'd like to draw you attention to the examples and discussion of the various align environments in Section 3 (pp. 3-9).

Output