更改某些块的颜色

更改某些块的颜色
    \documentclass{beamer}
   \usepackage[T1]{fontenc}
    %-----
   \usepackage{amsmath,amssymb,amsfonts} %math
    \usepackage{color}
    \usetheme{Madrid}

   \begin{document}

   \begin{frame}{}
   \begin{exampleblock}{theorem}
   test
   \end{exampleblock}
  \begin{alertblock}{proposition}
   \end{alertblock}
   \begin{block}{Definition}

  \end{block}
  \begin{block}{lemma}

  \end{block}    
   \end{frame}

 \end{document}

在此处输入图片描述 谢谢你!

我的目标是获得具有标题的区块定义有了新的颜色,比如棕色的

答案1

Beamer 内置了定义环境。它的颜色与普通块的颜色相同,但您可以通过更改定义前后的块颜色来使它们不同。等也一样theoremlemma

\documentclass{beamer}

%\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}
}

% Theorem %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\BeforeBeginEnvironment{theorem}{
    \setbeamercolor{block title}{use=example text,fg=white,bg=example text.fg!75!black}
    \setbeamercolor{block body}{parent=normal text,use=block title example,bg=block title example.bg!10!bg}
}
\AfterEndEnvironment{theorem}{
        \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}
}

% Proposition %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newtheorem{proposition}{Proposition}
\BeforeBeginEnvironment{proposition}{
        \setbeamercolor{block title}{use=alerted text,fg=white,bg=alerted text.fg!75!black}
        \setbeamercolor{block body}{parent=normal text,use=block title alerted,bg=block title alerted.bg!10!bg}
}
\AfterEndEnvironment{proposition}{
        \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{theorem}
test
\end{theorem}

\begin{proposition}
test
\end{proposition}

\begin{definition}
test
\end{definition}

\begin{lemma}
test
\end{lemma}    

\end{frame}

\end{document} 

在此处输入图片描述

相关内容