我在 beamer 上。我把下面的代码放在一个块内创建一个表。
\begin{block}{}
\begin{tabular}{l|l}
\multirow{2}{*}{$y = \begin{bmatrix}
w_{0}\\
w_{1}\\
\vdots \\
w_{D}\\
\end{bmatrix}^{T} * \begin{bmatrix}
x_{0}\\
x_{1}\\
\vdots \\
x_{D}\\
\end{bmatrix} = W^T * X$} & $\hat{y} = W^T * X + \epsilon$ \\
& $\hat{y} = \sum_{j=0}^{D}w_{j}x_{j}+\epsilon$
\end{tabular}
\end{block}
\small where,
\begin{itemize}
\small\item value of $x_0$ is $1$.
\small\item $\epsilon$ is the residual error.
\small\item $W^T$ are the weight (coefficient of $x$) vector.
\small\item $\hat{y}$ is the predicted value.
\small\item \textcolor{red}{$D+1$} is the \textcolor{red}{dimension} of the vector $W$ and $x$.
\end{itemize}
但我得到以下输出,
桌子为什么坏了?有没有更好的方法来解决这样的事情。
答案1
\multirow
不知道表格会有多大,也不会告诉 TeX 它占用了多少空间。相反,用户必须告诉\multirow
它允许占用多少行。然而,中的方程\multirow
远高于两个行。矩阵已经使用了四行。
解决方法是提供所需的空间:
\documentclass{beamer}
\usetheme{Madrid}
\usepackage{multirow}
\begin{document}
\begin{frame}
\begin{block}{}
\begin{tabular}{l|l}
\multirow{2}{*}{%
$y = \begin{bmatrix}
w_{0}\\
w_{1}\\
\vdots \\
w_{D}\\
\end{bmatrix}^{T} * \begin{bmatrix}
x_{0}\\
x_{1}\\
\vdots \\
x_{D}\\
\end{bmatrix} = W^T * X$}
& $\hat{y} = W^T * X + \epsilon$ \\
& $\hat{y} = \sum_{j=0}^{D}w_{j}x_{j}+\epsilon$\\[13mm]
\end{tabular}
\end{block}
\small where,
\begin{itemize}
\item value of $x_0$ is $1$.
\item $\epsilon$ is the residual error.
\item $W^T$ are the weight (coefficient of $x$) vector.
\item $\hat{y}$ is the predicted value.
\item \textcolor{red}{$D+1$} is the \textcolor{red}{dimension}
of the vector $W$ and $x$.
\end{itemize}
\end{frame}
\end{document}
下一个示例使用一些简单的纯 TeX 框命令来设置两列并将它们对齐到公式的顶部(而不是第一行的基线)。multirow
这里不需要包:
\begin{block}{}
\mbox{%
\vtop{%
\kern0pt
\hbox{%
$y = \begin{bmatrix}
w_{0}\\
w_{1}\\
\vdots \\
w_{D}\\
\end{bmatrix}^{T} * \begin{bmatrix}
x_{0}\\
x_{1}\\
\vdots \\
x_{D}\\
\end{bmatrix} = W^T * X$%
}%
}
\kern\tabcolsep
\vrule
\kern\tabcolsep
\vtop{%
\kern0pt
\hbox{$%
\begin{gathered}
\hat{y} = W^T * X + \epsilon \\
\hat{y} = \sum_{j=0}^{D}w_{j}x_{j}+\epsilon
\end{gathered}%
$}%
}%
}
\end{block}
答案2
基于Micos 的回答,但使用 beamers 自己的柱机制:
\documentclass{beamer}
\usetheme{Madrid}
\begin{document}
\begin{frame}
\begin{block}{}
\vskip-\baselineskip
\begin{columns}[T]
\begin{column}{.55\textwidth}
\vskip-0.2cm
\[
y = \begin{bmatrix}
w_{0}\\
w_{1}\\
\vdots \\
w_{D}\\
\end{bmatrix}^{T}
\begin{bmatrix}
x_{0}\\
x_{1}\\
\vdots \\
x_{D}\\
\end{bmatrix} + \epsilon = W^T X+\epsilon
\]
\end{column}
\vrule
\begin{column}{.35\textwidth}
\begin{align*}
\hat{y} &= W^T X \\
&= \sum_{j=0}^{D} w_{j}x_{j}
\end{align*}
\end{column}
\end{columns}
\end{block}
\bigskip
where
\begin{itemize}
\item $X$ is the vector of observed or predicted factors. $x_0\equiv1$
\item $W$ is the coefficient vector
\item $\epsilon$ is the error term (a scalar)
\item $\hat{y}$ is the fitted or predicted value
\item \alert{$D+1$} is the \alert{dimension} of the vectors $W$ and $X$
\end{itemize}
\end{frame}
\end{document}
答案3
这是一个在环境内使用两个并排minipage
环境的解决方案block
。(没有垂直规则是故意的,因为我认为它既不需要也没什么用。)
请注意,我也试图简化一些术语。
\documentclass{beamer}
\usetheme{Madrid} % just for this example
\begin{document}
\begin{frame}
\begin{block}{}
\vskip-\baselineskip % per @samcarter's suggestion :-)
\begin{minipage}{0.6\textwidth}
\[
y = \begin{bmatrix}
w_{0}\\
w_{1}\\
\vdots \\
w_{D}\\
\end{bmatrix}^{T}
\begin{bmatrix}
x_{0}\\
x_{1}\\
\vdots \\
x_{D}\\
\end{bmatrix} + \epsilon = W^T X+\epsilon
\]
\end{minipage}%
\begin{minipage}{0.3\textwidth}
\begin{align*}
\hat{y} &= W^T X \\
&= \sum_{j=0}^{D} w_{j}x_{j}
\end{align*}
\end{minipage}
\end{block}
\bigskip
where
\begin{itemize}
\item $X$ is the vector of observed or predicted factors. $x_0\equiv1$
\item $W$ is the coefficient vector
\item $\epsilon$ is the error term (a scalar)
\item $\hat{y}$ is the fitted or predicted value
\item \alert{$D+1$} is the \alert{dimension} of the vectors $W$ and $X$
\end{itemize}
\end{frame}
\end{document}
答案4
环境\multirow
中等式的右边没有和:aligned
\documentclass{beamer}
\usetheme{Madrid}
\usepackage{amsmath}
\begin{document}
\begin{frame}
\begin{block}{}
\setlength\tabcolsep{12pt}
\begin{tabular}{l|l}
$y = \begin{bmatrix}
w_{0}\\
w_{1}\\
\vdots \\
w_{D}\\
\end{bmatrix}^{T} \ast \begin{bmatrix}
x_{0}\\
x_{1}\\
\vdots \\
x_{D}\\
\end{bmatrix} = W^T \ast X$
& $\begin{aligned}\hat{y} & = W^T \ast X + \epsilon \\
& = \sum_{j=0}^{D}w_{j}x_{j}+\epsilon
\end{aligned}$
\end{tabular}
\end{block}
\small
where,
\begin{itemize}
\item value of $x_0$ is $1$.
\item $\epsilon$ is the residual error.
\item $W^T$ are the weight (coefficient of $x$) vector.
\item $\hat{y}$ is the predicted value.
\item \textcolor{red}{$D+1$} is the \textcolor{red}{dimension}
of the vector $W$ and $x$.
\end{itemize}
\end{frame}
\end{document}