I want to enter the equation in two columns frame of beamer. This is my original equation:
\begin{gather*}
\begin{split}
J=C(\sum_{i=1}^{m}{y_k^{(i)}log(h_\theta(x^{(i)})) + (1-y_k^{(i)})log(1-h_\theta(x^{(i)})) })+\sum_{i=0}^{n}{\theta_i^2}
\end{split}\\
\text{for }C\gg 1 \qquad \underset{\theta}{minimize}\quad J(\theta) \text{ is equal to" }\\
\underset{\theta}{minimize}\quad\sum_{i=0}^{n}{\theta_i^2}\\
\qquad \qquad \qquad \qquad \text{s.t. }
\begin{cases}
\theta^T x >1, & y=1\\ \theta^T x<-1, & y=0
\end{cases}
\end{gather*}
Since the first line of equation is long, I have to split it to two lines. The problem is that split does not recognise my frame structure ( two columns). I have also tried to use \\
and splits it manually but it does not work (since I have parentheses which separate two to line)
I am using beamer in ubuntu 16 and texlive full 2016.
Thanks you in advance and this is the complete frame:
\documentclass{beamer}
\mode<presentation> {
\usetheme{Madrid}
\setbeamertemplate{footline}[page number]
}
\usepackage{graphicx} % Allows including images
\usepackage{booktabs} % Allows the use of \toprule,
% \midrule and \bottomrule in tables
\usepackage{tikz} % add background image
\begin{document}
\begin{frame}
\frametitle{SVM: Large Margin classifier}
\begin{columns}
\begin{column}{.64\textwidth}
\begin{block}{Large margin classifier}
For linearly separable case: SVM choose the boundary with largest margin
\begin{gather*}
\begin{split}
J=C(\sum_{i=1}^{m}{y_k^{(i)}log(h_\theta(x^{(i)})) + (1-y_k^{(i)})log(1-h_\theta(x^{(i)})) })+\sum_{i=0}^{n}{\theta_i^2}
\end{split}\\
\text{for }C\gg 1 \qquad \underset{\theta}{minimize}\quad J(\theta) \text{ is equal to" }\\
\underset{\theta}{minimize}\quad\sum_{i=0}^{n}{\theta_i^2}\\
\qquad \qquad \qquad \qquad \text{s.t. }
\begin{cases}
\theta^T x >1, & y=1\\ \theta^T x<-1, & y=0
\end{cases}
\end{gather*}
\end{block}
\end{column}
\begin{column}{.32\textwidth}
% \includegraphics[scale=.3]{SVM-large-margin}
\end{column}
\end{columns}
\end{frame}
\end{document}
Best Answer
For split equation, you need to set anchor, where it should be split. For example:
(note added ampersand and
\\
).However in your case I would use
multlined
environment frommathtools
:which doesn't need ampersands and broke equation into two line on more (to my opinion) "natural" way.
Edit: I strongly encourage you to consider Mico comment below as I do in changes in above MWE. In it I also remove package
graphicx
from preamble (it is already load withbeamer
!) and add optionsdemo
tobeamer
, which enable to show your figure. Of course, in real document you should delete this option. For figure size I would rather determine its maximal width than scale it.