3

I have two sets of equation in aligned environment. The problem is that one of the equations (As shown in slide below) is too long to fit on a single line. I want to split this equation without changing the rest of my slide.

enter image description here

I want to move the last equation to right as indicated by the green marker.

here is the code: \documentclass{beamer} \usepackage[english]{babel}

\begin{document}
\begin{frame}
\frametitle{MWE:Split one equation in align environment}
%\begin{center}
\begin{align}
L_e(c_k^{(i)}) &=\log\frac{f_n(\tilde{c}_k|c_k^{(i)}=p)}{f_n(\tilde{c}_k|c_k^{(m)}=q)} \\&=\log\frac{f_n(\tilde{c}_k-p)}{f_n(\tilde{c}_k-q)} \notag\\
              % &=\frac{1}{2\sigma_q^2}\big( (\tilde{c}_k-q)^2-(\tilde{c}_k-p)^2\big) \notag\\
               &=\frac{1}{2\sigma_q^2}\big((p^2-q^2)-2\tilde{c}_k(p-q)\big)
\intertext{Combining $(m-1)$ terms yields}
\sum_{i=1}^{(m-1)}L_e(c_k^{(i)})&=\frac{1}{2\sigma_q^2}\Bigg(\sum_{i=1}^{(m-1)}\big((c_k^{(i)})^2-(c_k^{(m)})^2\big)\notag\\&-2\tilde{c}_k\sum_{i=1}^{(m-1)}\big(c_k^{(i)}-c_k^{(m)}\big)\Bigg)
\end{align}
%\end{center}
\end{frame}

\end{document}
1

Here is one of the typical ways to achieve this alignment with respect to the = sign:

enter image description here

\documentclass{beamer}

\begin{document}

\begin{frame}
  \frametitle{MWE:Split one equation in align environment}
  \begin{align}
    L_e(c_k^{(i)}) ={}& \log\frac{f_n(\tilde{c}_k|c_k^{(i)}=p)}{f_n(\tilde{c}_k|c_k^{(m)}=q)} \\
                   ={}& \log\frac{f_n(\tilde{c}_k-p)}{f_n(\tilde{c}_k-q)} \notag \\
                   ={}& \frac{1}{2\sigma_q^2}\bigl((p^2-q^2)-2\tilde{c}_k(p-q)\bigr)
  \intertext{Combining $(m-1)$ terms yields}
    \sum_{i=1}^{(m-1)}L_e(c_k^{(i)}) ={}& \frac{1}{2\sigma_q^2}\Biggl(\sum_{i=1}^{(m-1)}\bigl((c_k^{(i)})^2-(c_k^{(m)})^2\bigr) \notag \\
                                        &-2\tilde{c}_k\sum_{i=1}^{(m-1)}\bigl(c_k^{(i)}-c_k^{(m)}\bigr)\Biggr)
  \end{align}
\end{frame}

\end{document}

Note how & designates the point of alignment. So we use ={}& for the first part of the equation, and only & for the second part. Using {} ensures that = is considered a binary relation (since it contains an empty group to the right of it, in addition to some content to the left).


If you want the content to align with the \Bigg brackets, then you might be interested in this construction using \phantom:

enter image description here

\documentclass{beamer}

\begin{document}

\begin{frame}
  \frametitle{MWE:Split one equation in align environment}
  \begin{align}
    L_e(c_k^{(i)}) ={}& \log\frac{f_n(\tilde{c}_k|c_k^{(i)}=p)}{f_n(\tilde{c}_k|c_k^{(m)}=q)} \\
                   ={}& \log\frac{f_n(\tilde{c}_k-p)}{f_n(\tilde{c}_k-q)} \notag \\
                   ={}& \frac{1}{2\sigma_q^2}\bigl((p^2-q^2)-2\tilde{c}_k(p-q)\bigr)
  \intertext{Combining $(m-1)$ terms yields}
    \sum_{i=1}^{(m-1)}L_e(c_k^{(i)}) ={}& \frac{1}{2\sigma_q^2}\Biggl(\sum_{i=1}^{(m-1)}\bigl((c_k^{(i)})^2-(c_k^{(m)})^2\bigr) \notag \\
                                        & \phantom{\frac{1}{2\sigma_q^2}\Biggl(}-2\tilde{c}_k\sum_{i=1}^{(m-1)}\bigl(c_k^{(i)}-c_k^{(m)}\bigr)\Biggr)
  \end{align}
\end{frame}

\end{document}

As a side-note: Consider indenting (and aligning) your code to make reading it a little easier to read and debug

  • Thank you for your code. But there is a problem. All the equality signs are not aligned in the output. – NAASI Jun 16 '16 at 20:38
  • @NAASI: Sorry, corrected. – Werner Jun 16 '16 at 20:44
1

You can use the multlined environment from mathtools. I took the liberty to replace the pairs of \big( … \big) and the like with \bigl( … \bigr).

\documentclass{beamer}
\usepackage{mathtools}

\begin{document}

\begin{frame}
\frametitle{MWE:Split one equation in align environment}
\begin{align}
L_e(c_k^{(i)}) &=\log\frac{f_n(\tilde{c}_k|c_k^{(i)}=p)}{f_n(\tilde{c}_k|c_k^{(m)}=q)} \\&=\log\frac{f_n(\tilde{c}_k-p)}{f_n(\tilde{c}_k-q)} \notag\\
              % &=\frac{1}{2\sigma_q^2}\big( (\tilde{c}_k-q)^2-(\tilde{c}_k-p)^2\big) \notag\\
               &=\frac{1}{2\sigma_q^2}\bigl((p^2-q^2)-2\tilde{c}_k(p-q)\bigr)
\intertext{Combining $(m-1)$ terms yields}
\sum_{i=1}^{(m-1)}L_e(c_k^{(i)})&=\!\begin{multlined}[t]\frac{1}{2\sigma_q^2}
\Biggl(\sum_{i=1}^{m-1}\bigl((c_k^{(i)})^2-(c_k^{(m)})^2\bigr) \\-2\tilde{c}_k \sum_{i=1}^{m-1}\bigl(c_k^{(i)}-c_k^{(m)}\bigr)\Biggr)
\end{multlined}
\end{align}
\end{frame}

\end{document} 

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.