\documentclass{beamer}
%\usepackage{etoolbox} (this is necessary for old beamer versions)
%\usepackage{graphicx}
%\usepackage{color}
\usetheme{Madrid}
% Definition %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\definecolor{studentbrown}{RGB}{124,71,50}
\BeforeBeginEnvironment{definition}{%
\setbeamercolor{block title}{fg=white,bg=studentbrown}
\setbeamercolor{block body}{fg=black, bg=studentbrown!20!white}
}
\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}
test
\end{definition}
\end{frame}
\end{document}
我想将棕色改为其他颜色
答案1
更改命令中的颜色\definecolor{studentbrown}{RGB}{3,14,159}
\documentclass{beamer}
%\usepackage{etoolbox} (this is necessary for old beamer versions)
%\usepackage{graphicx}
%\usepackage{color}
\usetheme{Madrid}
% Definition %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\definecolor{studentbrown}{RGB}{3,14,159}
\BeforeBeginEnvironment{definition}{%
\setbeamercolor{block title}{fg=white,bg=studentbrown}
\setbeamercolor{block body}{fg=black, bg=studentbrown!20!white}
}
\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}
test
\end{definition}
\end{frame}
\end{document}