TransWikia.com

Writing an Equation wirh Multiple =, -, + in Multiple Lines

TeX - LaTeX Asked by samsambakster on June 29, 2021

I have this equation

documentclass{article}
usepackage[a4paper, total={6in, 8in}]{geometry}
usepackage[utf8]{inputenc}
usepackage{breqn}
usepackage{amsmath}
usepackage{comment}
usepackage{xfrac}

begin{equation}
 begin{split}
     g(z; mu, b) & = KL(widetilde{p}(z^{(1)}) vert vert widetilde{q}(z^{(1)}))
     & = int_{z}widetilde{p}(z^{(1)}) log (frac{widetilde{p}(z^{(1)})}{widetilde{q}(z^{(1)})}) dz 
     & = int_{z} widetilde{p}(z^{(1)}) log (widetilde{p}(z^{(1)})) dz - int_{z} widetilde{p}(z^{(1)}) log (widetilde{q}(z^{(1)})) dz 
     & = int_{z} widetilde{p}(z^{(1)}) log (widetilde{p}(z^{(1)})) dz 
     & = int_{z}p(z^{(1)}|z^{(0)})q(z^{(0)})log(p(z^{(1)}|z^{(0)})q(z^{(0)})) dz- int_{z}p(z^{(1)}|z^{(0)})q(z^{(0)})log(widetilde{q}(z^{(1)}))dz 
     & = int_{z}p(z^{(1)}|z^{(0)})q(z^{(0)}) log(p(z^{(1)}|z^{(0)})) dz + int_{z}p(z^{(1)}|z^{(0)})q(z^{(0)})log (q(z^{(0)})) dz 
     & - int_{z}p(z^{(1)}|z^{(0)})q(z^{(0)})log(widetilde{q}(z^{(1)}))dz 
     
 end{split}
 end{equation}

When compiling, the – sign (on the last line) is placed directly underneath = sign. I want it to be placed a bit to its right. Is there such a possibility?

I tried with begin{dmath} as well.

begin{dmath}
       g(z; mu, b)  
       = KL(widetilde{p}(z^{(1)}) vert vert widetilde{q}(z^{(1)}))
      = int_{z}widetilde{p}(z^{(1)}) log (frac{widetilde{p}(z^{(1)})}{widetilde{q}(z^{(1)})}) dz 
      = int_{z} widetilde{p}(z^{(1)}) log (widetilde{p}(z^{(1)})) dz - int_{z} widetilde{p}(z^{(1)}) log (widetilde{q}(z^{(1)})) dz 
      = int_{z} widetilde{p}(z^{(1)}) log (widetilde{p}(z^{(1)})) dz 
      = int_{z}p(z^{(1)}|z^{(0)})q(z^{(0)})log(p(z^{(1)}|z^{(0)})q(z^{(0)})) dz- int_{z}p(z^{(1)}|z^{(0)})q(z^{(0)})log(widetilde{q}(z^{(1)}))dz 
      = int_{z}p(z^{(1)}|z^{(0)})q(z^{(0)}) log(p(z^{(1)}|z^{(0)})) dz + int_{z}p(z^{(1)}|z^{(0)})q(z^{(0)})log (q(z^{(0)})) dz 
      - int_{z}p(z^{(1)}|z^{(0)})q(z^{(0)})log(widetilde{q}(z^{(1)}))dz 
      
end{dmath}

but for some reason, it does not compile as it supposed to! I used it one day before and it worked but today it just doesn’t!

Any help is immensely appreciated 🙂

One Answer

You could change & to &qquad for lines that need to be indented a bit.

enter image description here

documentclass{article}
usepackage[a4paper, total={6in, 8in}]{geometry}
usepackage[T1]{fontenc}
usepackage{amsmath}
begin{document}
begin{equation}
begin{split}
     g(z; mu, b) 
     & = KL(tilde{p}(z^{(1)}) ,Vert, tilde{q}(z^{(1)}))
     & = int_{z}tilde{p}(z^{(1)}) log Bigl(frac{tilde{p}(z^{(1)})}{tilde{q}(z^{(1)})}Bigr), dz 
     & = int_{z} tilde{p}(z^{(1)}) log (tilde{p}(z^{(1)})), dz 
     &qquad - int_{z} tilde{p}(z^{(1)}) log (tilde{q}(z^{(1)})), dz 
     & = int_{z} tilde{p}(z^{(1)}) log (tilde{p}(z^{(1)})), dz 
     & = int_{z}p(z^{(1)}mid z^{(0)})q(z^{(0)})log(p(z^{(1)}mid z^{(0)})q(z^{(0)})), dz 
     &qquad - int_{z}p(z^{(1)}mid z^{(0)})q(z^{(0)})log(tilde{q}(z^{(1)}))dz 
     & = int_{z}p(z^{(1)}mid z^{(0)})q(z^{(0)}) log(p(z^{(1)}mid z^{(0)})), dz 
     &qquad + int_{z}p(z^{(1)}mid z^{(0)})q(z^{(0)})log (q(z^{(0)})), dz 
     &qquad - int_{z}p(z^{(1)}mid z^{(0)})q(z^{(0)})log(tilde{q}(z^{(1)}))dz     
end{split}
end{equation}
end{document}

Correct answer by Mico on June 29, 2021

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