我正在尝试创建一个definition
基于的新编号环境exampleblock
,但它没有按预期工作。
我的代码:
% !TEX program = xelatex
\documentclass[serif, compress]{beamer}
\usetheme{Warsaw}
\useoutertheme{miniframes}
\begin{document}
\newcounter{definition}
\renewenvironment{definition}[1][]
{\stepcounter{definition}\begin{exampleblock}{Definition\,\arabic{definition}}}
{\end{exampleblock}}
\begin{frame}
\onslide<1->
\begin{definition}
qwq1 % expected to be "Definition 1"
\end{definition}
\onslide<2->
\begin{definition}
qwq2 % expected to be "Definition 2"
\end{definition}
\end{frame}
\end{document}
然而,幻灯片看起来像
有人可以告诉我如何\onslide
正确使用计数器吗?
答案1
无需重新发明轮子,只需使用在definition
环境中构建的投影仪并激活定理数字:
\documentclass{beamer}
\setbeamertemplate{theorems}[numbered]
\begin{document}
\begin{frame}
\begin{definition}<1->
qwq1 % expected to be "Definition 1"
\end{definition}
\begin{definition}<2->
qwq2 % expected to be "Definition 2"
\end{definition}
\end{frame}
\end{document}
如果您觉得此环境的蓝色definition
令人困扰,可以这样更改:
\documentclass{beamer}
\setbeamertemplate{theorems}[numbered]
\BeforeBeginEnvironment{definition}{%
\setbeamercolor{block title}{fg=white,bg=example text.fg!75!black}
\setbeamercolor{block body}{fg=black, bg=block title.bg!10!bg}
}
\AfterEndEnvironment{definition}{
\setbeamercolor{block title}{use=structure,fg=white,bg=structure.fg!75!black}
\setbeamercolor{block body}{parent=normal text,use=block title,bg=block title.bg!10!bg}
}
\begin{document}
\begin{frame}
\begin{definition}<1->
qwq1 % expected to be "Definition 1"
\end{definition}
\begin{definition}<2->
qwq2 % expected to be "Definition 2"
\end{definition}
\end{frame}
\end{document}