3

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 :)

1
  • 2
    You should try inserting something like \quad or \qquad just before the -.
    – Werner
    Commented Jun 9, 2021 at 15:33

1 Answer 1

6

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}

You must log in to answer this question.

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