我正在使用以下beamer命令

\newcommand{\imgslide}[2]{
        {\setbeamertemplate{background canvas}{
        \includegraphics [width=\paperwidth,height=\paperheight]{images/#1}} 
            \begin{frame}[plain]
                \txtonimg{#2}
            \end{frame}
        }
}

我反复遇到错误。

手动编写效果很好的内容相同。

上面命令中包含的命令是:

\newcommand{\txtonimg}[1]{
\begin{center}
 \fcolorbox{red}{black}{
 \textcolor{white}
 {#1}
 }
 \end{center}
 }

错误是:

]
! Too many }'s.
\endframe ->\egroup 
            \begingroup \def \@currenvir {frame}
l.107       \end{frame}

在重复测试中,一切对我来说似乎都很好。

有帮助吗?

解决方案

Beamer使用了很多 \catcode- 相关的骗局,这很可能是导致您的问题的原因。由于如果没有最小的例子,我无法重现您的错误,所以我只能推测(通常将来,如果您想要最有效的帮助,请提供一个 完全的 最小的例子表现出了这个问题 - 这样做通常会自己缩小它,但至少您确保其他人可以忠实地复制它)。

尝试添加 fragile 定义中框架的选项,如

\begin{frame}[plain,fragile]

我不确定权衡是什么,但这会导致 frame 环境的行为更像是正常的环境。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top