TransWikia.com

aligning equations without spacing

TeX - LaTeX Asked by framago on December 30, 2020

I have the following code:

begin{align*}

&mathbb{P}bigl((X,tilde{X})=(x,tilde{x})_S,(Z,tilde{Z})=(z,tilde{z})_Sbigr)  

&=mathbb{P}bigl((Z,tilde{Z}=(z,tilde{z})_Sbigr),mathbb{P}bigl((X,tilde{X})=(x,tilde{x})_Smid (Z,tilde{Z})=(z,tilde{z})_Sbigr)

&!begin{aligned}[t]

&=mathbb{P}bigl((Z,tilde{Z}=(z,tilde{z})_Sbigr)&&prod_{jin S}bigl[mathbb{P}(X_j=tilde{x}_jmid Z_j=tilde{z}_j),mathbb{P}(tilde{X}_j=x_jmid tilde{Z}_j=z_j)bigr] 

&&cdot&prod_{jnotin S}bigl[mathbb{P}(X_j=x_jmid Z_j=z_j),mathbb{P}(tilde{X}_j=tilde{x}_jmid tilde{Z}_j=tilde{z}_j)bigr]

&=mathbb{P}bigl((Z,tilde{Z}=(z,tilde{z})_Sbigr)&&prod_{jin S}bigl[f_j(tilde{x}_jmidtilde{z}_j)f_j(x_jmid z_j)bigr]

&&cdot&prod_{jnotin S}bigl[f_j(x_jmid z_j)f_j(tilde{x}_jmidtilde{z}_j)bigr]

&=mathbb{P}bigl((Z,tilde{Z}=(z,tilde{z})_Sbigr)&&prod_{jin [p]}bigl[f_j(tilde{x}_jmidtilde{z}_j)f_j(x_jmid z_j)bigr]
end{aligned}
end{align*}

This is what I get:

enter image description here
I would like to align the big products with the correct spacing before them, but I can’t do that!

Can anyone help me?
Thank you

One Answer

I think this looks good. I used an aligned environment in each line that is cut in two parts. I also adjusted the width of the subscript in the last product, because [p] is slightly larger than S so it messes up with the alignment a little.

documentclass{article}
usepackage{amsmath}
usepackage{amssymb}
usepackage{calc}
begin{document}
begin{align*}
&mathbb{P}bigl((X,tilde{X})=(x,tilde{x})_S,(Z,tilde{Z})=(z,tilde{z})_Sbigr)  
& = mathbb{P}bigl((Z,tilde{Z}=(z,tilde{z})_Sbigr),mathbb{P}bigl((X,tilde{X})=(x,tilde{x})_Smid (Z,tilde{Z})=(z,tilde{z})_Sbigr) 
& = begin{aligned}[t]
    mathbb{P}bigl((Z,tilde{Z}=(z,tilde{z})_Sbigr) & prod_{jin S}bigl[mathbb{P}(X_j=tilde{x}_jmid Z_j=tilde{z}_j),mathbb{P}(tilde{X}_j=x_jmid tilde{Z}_j=z_j)bigr]  
    cdot & prod_{jnotin S}bigl[mathbb{P}(X_j=x_jmid Z_j=z_j),mathbb{P}(tilde{X}_j=tilde{x}_jmid tilde{Z}_j=tilde{z}_j)bigr]
end{aligned} 
& = begin{aligned}[t] 
    mathbb{P}bigl((Z,tilde{Z}=(z,tilde{z})_Sbigr) & prod_{jin S}bigl[f_j(tilde{x}_jmidtilde{z}_j)f_j(x_jmid z_j)bigr] 
    cdot & prod_{jnotin S}bigl[f_j(x_jmid z_j)f_j(tilde{x}_jmidtilde{z}_j)bigr]
end{aligned} 
& = mathbb{P}bigl((Z,tilde{Z}=(z,tilde{z})_Sbigr) prod_{makebox[widthof{(scriptstyle jin S)}]{(scriptstyle jin [p])}}bigl[f_j(tilde{x}_jmidtilde{z}_j)f_j(x_jmid z_j)bigr]
end{align*}
end{document}

Correct answer by Vincent on December 30, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP