2

Input:

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

Output:

enter image description here

Question: Note that example's blocks are green and all other blocks are blue. How to define a specific color for each kind of block? For example, red for theorems and yellow for definitions. It is important to keep the automatic consecutive numbering.

2
  • If the answer solved your problem, consider accepting it by clicking on the tick mark to help reduce the number of unanswered questions.
    – Diaa
    Aug 25, 2016 at 20:00
  • @DiaaAbidou Accepted!
    – Pedro
    Aug 25, 2016 at 20:18

1 Answer 1

3

This is what you need to put in your preamble

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

}

Complete 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}

enter image description here

3
  • Thanks, but I found one more problem. The particular block \begin{proof} Text \end{proof} has a automatic blue square inside the text area. The given code \AtBeginEnvironment{proof}... changes the color of the block but doesn't affect the square's color. Is it possible to change the color of that square?
    – Pedro
    Aug 25, 2016 at 20:10
  • @Pedro Modify \setbeamercolor{qed symbol}{fg=orange}, or whatever you like. Aug 25, 2016 at 20:14
  • @Pedro it worked without problems. Check my update.
    – Diaa
    Aug 25, 2016 at 20:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .