如何在投影仪的两列框架内拆分方程式?

如何在投影仪的两列框架内拆分方程式?

我想在投影仪的两列框架中输入方程式。这是我的原始方程式:

\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*}

由于方程的第一行很长,我必须将其拆分为两行。问题是 split 无法识别我的框架结构(两列)。我也尝试过\\手动使用并拆分它,但它不起作用(因为我有括号将两行分开)
我在 ubuntu 16 中使用 beamer 和 texlive full 2016。提前谢谢您,这是完整的框架:

\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}

答案1

对于分割方程,你需要设置锚点,即分割的位置。例如:

\begin{split}
J & = C\biggl[ \sum_{i=1}^{m} y_k^{(i)}log(h_\theta(x^{(i)})) + \\
  &   (1-y_k^{(i)})log(1-h_\theta(x^{(i)})) \biggr] 
                                    + \sum_{i=0}^{n}{\theta_i^2}
\end{split}

(注意添加了 & 符号\\)。

在此处输入图片描述

然而,在你的情况下,我会使用multlined来自以下环境mathtools

在此处输入图片描述

它不需要“与”符号,并且以更(在我看来)“自然”的方式将等式分成两行。

\documentclass[demo]{beamer}% <-- demo only for test, delete it in real document
\mode<presentation> {
  \usetheme{Madrid}
  \setbeamertemplate{footline}[page number]
}

\usepackage{booktabs}           % Allows the use of \toprule,
                                % \midrule and \bottomrule in tables
\usepackage{tikz}               % add background image
\usepackage{mathtools}               % 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{multlined}[0.9\linewidth]
J   = C\Biggl[ \sum_{i=1}^{m} y_k^{(i)}\log(h_\theta(x^{(i)})) + \\
      (1-y_k^{(i)})\log(1-h_\theta(x^{(i)})) \Biggr]
                                    + \sum_{i=0}^{n}{\theta_i^2}
\end{multlined}\\
                \text{for }C\gg 1 \qquad 
                        \min_\theta J(\theta) \text{ is equal to" }\\
                \quad   \min_\theta \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[width=\linewidth]{SVM-large-margin}
        \end{column}

    \end{columns}
\end{frame}
\end{document}

编辑: 我强烈建议你考虑米科在下面发表评论,就像我在上面 MWE 中的更改中所做的那样。在其中,我还graphicx从序言中删除了包(它已经加载了beamer!)并向添加了选项demobeamer这可以显示您的图形。当然,在实际文档中,您应该删除此选项。对于图形大小,我宁愿确定其最大宽度而不是缩放它。

答案2

环境split不会自动拆分其内容。它要求您指定拆分公式的位置。在下面的例子中,我确实指定了换行符。此外,我更改了两组括号的大小以使公式更清晰。手动拆分对您不起作用的原因可能是围绕加数的括号。它们并不是必需的。

\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\biggl(\sum_{i=1}^{m}\Bigl(y_k^{(i)}\log(h_\theta(x^{(i)}))\\
             &+ (1-y_k^{(i)})\log(1-h_\theta(x^{(i)}))\Bigr)\biggr)+\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}

相关内容