投影仪中编号定理的彩色块

投影仪中编号定理的彩色块

输入:

\documentclass{beamer}
\usetheme{Boadilla}
\usecolortheme{whale}
\usefonttheme{professionalfonts}

\setbeamertemplate{theorems}[numbered] 

\begin{document}

\section{First section} 
\begin{frame} 
\frametitle{Theorems} 
\begin{definition} 
    Text 
\end{definition} 
\begin{theorem} 
    Text
\end{theorem} 
\begin{lemma} 
    Text
\end{lemma}
\begin{theorem} 
    Text
\end{theorem} 
\begin{example} 
    Text
\end{example} 
\end{frame} 

\end{document}

输出:

在此处输入图片描述

问题:注意,示例的块是绿色的,其他所有块都是蓝色的。如何为每种块定义特定的颜色?例如,定理用红色,定义用黄色。保持自动连续编号非常重要。

答案1

这是你需要在序言中写的内容

\usepackage{etoolbox}% new package to be loaded
\AtBeginEnvironment{theorem}{% set of commands to be added
    \setbeamercolor{block title}{fg=white,bg=orange}% colors to change
    \setbeamercolor{block body}{fg=black,bg=yellow}% colors to change
}
\AtBeginEnvironment{proof}{%
    \setbeamercolor{block title}{fg=green,bg=red}
    \setbeamercolor{block body}{fg=black,bg=purple}

}

完成 MWE

\documentclass{beamer}
\usetheme{Boadilla}
\usecolortheme{whale}
\usefonttheme{professionalfonts}
\usepackage{etoolbox}
\setbeamertemplate{theorems}[numbered] 
\AtBeginEnvironment{theorem}{%
    \setbeamercolor{block title}{fg=white,bg=orange}
    \setbeamercolor{block body}{fg=black,bg=yellow}
}
\AtBeginEnvironment{proof}{%
    \setbeamercolor{block title}{fg=green,bg=red}
    \setbeamercolor{block body}{fg=black,bg=purple}
}

\setbeamercolor{normal text}{fg=black} 

\begin{document}

\section{First section} 
\begin{frame} 
\frametitle{Theorems}
\begin{proof} 
    Text 
\end{proof} 
\begin{definition} 
    Text 
\end{definition} 
\begin{theorem} 
    Text
\end{theorem} 
\begin{lemma} 
    Text
\end{lemma}
\begin{theorem} 
    Text
\end{theorem} 
\begin{example} 
    Text
\end{example} 
\end{frame} 

\end{document}

在此处输入图片描述

相关内容