在 dynblocks 环境中编号方程

在 dynblocks 环境中编号方程

我正在尝试在为自定义块创建的环境中对方程进行编号,其中包含的方程式如下如何调整投影仪块宽度以适应其内容的大小?。但是插入环境时出现错误\align{}。有什么建议吗?

答案1

这些错误都是我的代码问题。但我们应该区分:

  • 编号问题;
  • 问题align

至于编号问题,它很容易解决:目前方程式没有编号,因为调用

\opaqueblock<#1>[\wd\mybox]{\[\BODY\]}

当然,替换\[\BODY\]

\opaqueblock<#1>[\wd\mybox]{\begin{equation}\BODY\end{equation}}

有帮助,但我们仍然忽略了一个事实,即我们之前测量的宽度$\BODY$没有数字,所以框的宽度是错误的。一个解决方法是:

\NewEnviron{cdyn}[1]{%
    \sbox{\mybox}{$\BODY \qquad (1)$}%
    \begin{center}
    \begin{dynblock}
    \opaqueblock<#1>[\wd\mybox]{\begin{equation}\BODY\end{equation}}
    \end{dynblock}
    \end{center}
}{}%

完整示例:

\documentclass[t]{beamer}
\usepackage{lmodern}
\usetheme{Madrid}
\usepackage[customcolors,shadow,roundedcorners]{dynblocks}
% setting the block body color
\usebeamercolor{block body}
\definecolor{my block body}{named}{bg}
\setbordercolor{my block body}
\setblockcolor{my block body}

% new enviroment always centered

\usepackage{environ}
\newsavebox\mybox
% new environment cdyn: #1 => overlay specification

\NewEnviron{cdyn}[1]{%
    \sbox{\mybox}{$\BODY \qquad (1)$}%
    \begin{center}
    \begin{dynblock}
    \opaqueblock<#1>[\wd\mybox]{\begin{equation}\BODY\end{equation}}
    \end{dynblock}
    \end{center}
}{}%

\begin{document}

\begin{frame}{Test}
\abovedisplayskip=0pt

\begin{cdyn}{1-}
c^2=a^2+b^2
\end{cdyn}

\begin{cdyn}{2-}
x+y=400
\end{cdyn}

\begin{cdyn}{3-}
\sum_{l _1+\dots+ l _p=l}\prod^p_{i=1} \binom{n_i}{l _i}+
\sum_{l _1+\dots+ l _p=l}\prod^p_{i=1} \binom{n_i}{l _i}\label{eq:sum}
\end{cdyn}

\begin{cdyn}{4-}
q_{n+1}=q_n-\Delta_n+\theta_n \qquad \Delta_n=
\begin{cases}
1 \quad q_n>0\\
0 \quad q_n=0
\end{cases}
\end{cdyn}

\only<4->{I'm referring to \eqref{eq:sum}.}

\end{frame}

\end{document}

结果:

在此处输入图片描述

对于另一个问题,插入align环境,不幸的是我没有解决方案。事实上,只是改变

\opaqueblock<#1>[\wd\mybox]{\begin{equation}\BODY\end{equation}}

\opaqueblock<#1>[\wd\mybox]{\begin{align}\BODY\end{align}}

是不够的。实际上,它适用于上面提供的示例,但如果你改变

\begin{cdyn}{3-}
\sum_{l _1+\dots+ l _p=l}\prod^p_{i=1} \binom{n_i}{l _i}+
\sum_{l _1+\dots+ l _p=l}\prod^p_{i=1} \binom{n_i}{l _i}\label{eq:sum}
\end{cdyn}

进入

\begin{cdyn}{3-}
\sum_{l _1+\dots+ l _p=l}\prod^p_{i=1} \binom{n_i}{l _i}\\
\sum_{lu _1+\dots+ l _p=l}\prod^p_{i=1} \binom{n_i}{l _i}\label{eq:sum}
\end{cdyn}

你会收到这些错误

! LaTeX Error: There's no line here to end.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.54 \end{frame}

Your command was ignored.
Type  I <command> <return>  to replace it with another command,
or  <return>  to continue without it.

! Missing $ inserted.
<inserted text> 
                $
l.54 \end{frame}

I've inserted a begin-math/end-math symbol since I think
you left one out. Proceed, with fingers crossed.


! LaTeX Error: Something's wrong--perhaps a missing \item.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.54 \end{frame}

Try typing  <return>  to proceed.
If that doesn't work, type  X <return>  to quit.

! Missing $ inserted.
<inserted text> 
                $
l.54 \end{frame}

I've inserted a begin-math/end-math symbol since I think
you left one out. Proceed, with fingers crossed.

这里的问题是如何测量盒子:

\sbox{\mybox}{$\BODY + \qquad (1)$}%

不适用于断线的环境(我猜)而且我不知道如何将这样的东西推入框中并测量其宽度。当然,你总是可以手动完成:

\begin{center}
\begin{dynblock}
\opaqueblock<3->[0.8\textwidth]{%
\begin{align}
\sum_{l _1+\dots+ l _p=l}\prod^p_{i=1} \binom{n_i}{l _i}\\
\sum_{lu _1+\dots+ l _p=l}\prod^p_{i=1} \binom{n_i}{l _i}\label{eq:sum}
\end{align}
}
\end{dynblock}
\end{center}

完整性的 mwe:

\documentclass[t]{beamer}
\usepackage{lmodern}
\usetheme{Madrid}
\usepackage[customcolors,shadow,roundedcorners]{dynblocks}
% setting the block body color
\usebeamercolor{block body}
\definecolor{my block body}{named}{bg}
\setbordercolor{my block body}
\setblockcolor{my block body}

% new enviroment always centered

\usepackage{environ}
\newsavebox\mybox
% new environment cdyn: #1 => overlay specification

\NewEnviron{cdyn}[1]{%
    \sbox{\mybox}{$\BODY \qquad (1)$}%
    \begin{center}
    \begin{dynblock}
    \opaqueblock<#1>[\wd\mybox]{\begin{equation}\BODY\end{equation}}
    \end{dynblock}
    \end{center}
}{}%

\begin{document}

\begin{frame}{Test}
\abovedisplayskip=0pt

\begin{cdyn}{1-}
c^2=a^2+b^2
\end{cdyn}

\begin{cdyn}{2-}
x+y=400
\end{cdyn}

\begin{center}
\begin{dynblock}
\opaqueblock<3->[0.35\textwidth]{%
\begin{align}
\sum_{l _1+\dots+ l _p=l}\prod^p_{i=1} \binom{n_i}{l _i}\\
\sum_{lu _1+\dots+ l _p=l}\prod^p_{i=1} \binom{n_i}{l _i}\label{eq:sum}
\end{align}
}
\end{dynblock}
\end{center}

\begin{cdyn}{4-}
q_{n+1}=q_n-\Delta_n+\theta_n \qquad \Delta_n=
\begin{cases}
1 \quad q_n>0\\
0 \quad q_n=0
\end{cases}
\end{cdyn}

\only<4->{I'm referring to \eqref{eq:sum}.}

\end{frame}

\end{document}

结果:

在此处输入图片描述

相关内容