我有一个带有 eqnarray 的 beamer 文档。我希望框看起来漂亮又干净。具体来说,我希望方程式各部分周围的框显示正确的大小。实际代码(如下)给出了以下输出:
正如您所见,盒子放置的位置正确,但它们太短了(蓝色和绿色)。
\begin{frame}
Details on computations leading to the following expression of $R_i$ are reported in the paper. Here it is worth noticing that the generalization error can be split into 6 components, namely:
\tikzstyle{na} = [baseline=-1.3ex]
\begin{itemize}[<+-| alert@+>]
\item Coriolis acceleration
\tikz[na] \node[coordinate] (n1) {};
\end{itemize}
%\begin{eqnarray}
% \tikz[baseline]{
% \node[fill=blue!20,anchor=base] (t1)
% {$2\vec{\omega}_{ib}\times\frac{{}^bd}{dt}\vec{r}$};
%}
%\end{eqnarray}
{\footnotesize
\begin{eqnarray}\label{eq:generalization_error_FE_var}
&&{R_i\left(\{\underline{x}_{n,t}\}_{n=1,\ldots,N}^{t=1,\ldots,T}\right)} \nonumber \\
&& \tikz[baseline]{
\node[fill=blue!20,anchor=base,height=3em, width=130mm] (t1)
{$\frac{\sigma^2}{{T}^2} \underline{1}_{{T}}' {X_i} \left(\sum_{n=1}^N {\ddot{X}_n'\Phi^{+} \ddot{X}_n}\right)^{-1} {X_i'} \underline{1}_{{T}}$}}
+\tikz[baseline]{
\node[fill=red!20,anchor=base] (t1) {$\frac{\sigma^2}{{T}^2}\underline{1}_{{T}}' {\Psi} \underline{1}_{{T}}$}}
\nonumber \\
&&- \tikz[baseline]{
\node[fill=green!20,anchor=base] (t1) {$\frac{2 {\sigma^2}}{{T}^2} \underline{1}_{{T}}' {X_i} \left(\sum_{n=1}^N {\ddot{X}_n'\Phi^{+} \ddot{X}_n} \right)^{-1} {\ddot{X}_i'\Phi^{+} Q_T} {\Psi} \underline{1}_{{T}}$}} \nonumber \\
&& + \sigma^2 \mathbb{E} \Bigg\{\left(\underline{x}_i^{test}\right)'\left(\sum_{n=1}^N {\ddot{X}_n'\Phi^{+} \ddot{X}_n} \right)^{-1} \underline{x}_i^{test} {\big| \{\underline{x}_{n,t}\}_{n=1,\ldots,N}^{t=1,\ldots,T}} \Bigg\} \nonumber \\
&&-\frac{2 \sigma^2}{{T}} \underline{1}_{{T}}' {X_i} \left(\sum_{n=1}^N {\ddot{X}_n'\Phi^{+} \ddot{X}_n}\right)^{-1} \mathbb{E} \left\{\underline{x}_i^{test} \right\} \nonumber \\
&& +\frac{2 {\sigma^2}}{{T}} \left({Q_T} {\Psi} \underline{1}_{{T}}\right)' {\Phi^{+} \ddot{X}_i} \left(\sum_{n=1}^N {\ddot{X}_n' \Phi^{+} \ddot{X}_n} \right)^{-1} \mathbb{E} \left\{\underline{x}_i^{test} \right\}\,,
\end{eqnarray}
}
\end{frame}
我该如何修复它?我还希望出现并显示箭头:第一部分(在蓝色矩形上)、第二部分(在红色矩形上)和第三部分(在绿色矩形上)
答案1
我只考虑方程(它太大了,我怀疑你是否能够在这个框架中插入遗漏的东西):
以上是您想要的吗?我尝试稍微改进您的方程式布局,但这样做可能会引入一些数学错误。因此请检查它是否仍然正确。
\documentclass{beamer}
\usepackage{tikz}
\usepackage{mathtools}
\tikzset{every picture/.append style = {baseline},
box/.style = {fill=#1, minimum height=9ex, anchor=base},
}
\begin{document}
\begin{frame}
\footnotesize
\begin{align}\label{eq:generalization_error_FE_var}
\MoveEqLeft
R_i\left(\bigl\{\underline{x}_{n,t}\bigr\}_{n=1,\ldots,N}^{t=1,\ldots,T}\right) \notag \\
& = \tikz{\node[box=blue!20] (t1)
{$\displaystyle\frac{\sigma^2}{{T}^2} \underline{1}_{{T}}' {X_i} \left(\sum_{n=1}^N {\ddot{X}_n'\Phi^{+} \ddot{X}_n}\right)^{-1} {X_i'} \underline{1}_{{T}}$}}
+ \tikz{ \node[box=red!20] (t2)
{$\displaystyle\frac{\sigma^2}{{T}^2}\underline{1}_{{T}}' {\Psi} \underline{1}_{{T}}$}} \notag \\
%
& - \tikz{\node[box=green!20] (t3)
{$\displaystyle\frac{2 {\sigma^2}}{{T}^2} \underline{1}_{{T}}' {X_i}
\left(\sum_{n=1}^N {\ddot{X}_n'\Phi^{+} \ddot{X}_n} \right)^{-1} {\ddot{X}_i'\Phi^{+} Q_T} {\Psi} \underline{1}_{{T}}$}} \notag \\
%
& + \sigma^2 \mathbb{E} \left\{\left(\underline{x}_i^\mathrm{test}\right)'\left(\sum_{n=1}^N {\ddot{X}_n'\Phi^{+} \ddot{X}_n} \right)^{-1}
\underline{x}_i^\mathrm{test} \middle| \bigl\{\underline{x}_{n,t}\bigr\}_{n=1,\ldots,N}^{t=1,\ldots,T} \right\} \notag \\
%
& - \frac{2 \sigma^2}{{T}} \underline{1}_{{T}}' {X_i} \left(\sum_{n=1}^N {\ddot{X}_n'\Phi^{+} \ddot{X}_n}\right)^{-1} \mathbb{E} \left\{\underline{x}_i^\mathrm{test} \right\} \notag \\
%
& + \frac{2 {\sigma^2}}{{T}} \left({Q_T} {\Psi} \underline{1}_{{T}}\right)' {\Phi^{+} \ddot{X}_i} \left(\sum_{n=1}^N {\ddot{X}_n' \Phi^{+} \ddot{X}_n} \right)^{-1} \mathbb{E} \left\{\underline{x}_i^\mathrm{test} \right\}\,,
\end{align}
\end{frame}
\end{document}
笔记:如果您想拥有问题中所示的盒装布局,那么您只需要将box
样式更改为如下形式:
box/.style = {draw, fill=#1, minimum height=9ex, anchor=base,
drop shadow},
并加载 Ti钾Z 库shadows
到文档序言。
附录:
如果你在其他框架节点中使用与此同名的样式,但有不同的选项,与上面的 MWE 中使用的相矛盾,那么简单的解决方案(当其他框架的内容未知时)是\tikzset
将此框架移动到框架内(使其成为本地)并添加选项“脆弱到框架:
\documentclass{beamer}
\usepackage{tikz}
\usepackage{mathtools}
\begin{document}
\begin{frame}[fragile] % <---
\tikzset{every picture/.append style = {baseline},
box/.style = {fill=#1, minimum height=9ex, anchor=base},
}
\footnotesize
\begin{align}\label{eq:generalization_error_FE_var}
\MoveEqLeft
R_i\left(\bigl\{\underline{x}_{n,t}\bigr\}_{n=1,\ldots,N}^{t=1,\ldots,T}\right) \notag \\
& = \tikz{\node[box=blue!20] (t1)
{$\displaystyle\frac{\sigma^2}{{T}^2} \underline{1}_{{T}}' {X_i} \left(\sum_{n=1}^N {\ddot{X}_n'\Phi^{+} \ddot{X}_n}\right)^{-1} {X_i'} \underline{1}_{{T}}$}}
+ \tikz{ \node[box=red!20] (t2)
{$\displaystyle\frac{\sigma^2}{{T}^2}\underline{1}_{{T}}' {\Psi} \underline{1}_{{T}}$}} \notag \\
%
& - \tikz{\node[box=green!20] (t3)
{$\displaystyle\frac{2 {\sigma^2}}{{T}^2} \underline{1}_{{T}}' {X_i}
\left(\sum_{n=1}^N {\ddot{X}_n'\Phi^{+} \ddot{X}_n} \right)^{-1} {\ddot{X}_i'\Phi^{+} Q_T} {\Psi} \underline{1}_{{T}}$}} \notag \\
%
& + \sigma^2 \mathbb{E} \left\{\left(\underline{x}_i^\mathrm{test}\right)'\left(\sum_{n=1}^N {\ddot{X}_n'\Phi^{+} \ddot{X}_n} \right)^{-1}
\underline{x}_i^\mathrm{test} \middle| \bigl\{\underline{x}_{n,t}\bigr\}_{n=1,\ldots,N}^{t=1,\ldots,T} \right\} \notag \\
%
& - \frac{2 \sigma^2}{{T}} \underline{1}_{{T}}' {X_i} \left(\sum_{n=1}^N {\ddot{X}_n'\Phi^{+} \ddot{X}_n}\right)^{-1} \mathbb{E} \left\{\underline{x}_i^\mathrm{test} \right\} \notag \\
%
& + \frac{2 {\sigma^2}}{{T}} \left({Q_T} {\Psi} \underline{1}_{{T}}\right)' {\Phi^{+} \ddot{X}_i} \left(\sum_{n=1}^N {\ddot{X}_n' \Phi^{+} \ddot{X}_n} \right)^{-1} \mathbb{E} \left\{\underline{x}_i^\mathrm{test} \right\}\,,
\end{align}
\end{frame}
\end{document}
结果和以前一样。