44

I'm in the process of creating a custom Beamer theme. I know how to change the color of fonts for certain elements within an itemize or enumerate block, but I can't seem to figure out how to specific the color in a block as depicted below. For example:

\begin{block}{Change the font color here}
    some text
    some more text
\end{block}

I would like to alter the color of the {Change the font color here} area for my theme. I am trying to use this code in my .sty file to change the color to black:

\setbeamercolor{block}{fg=black}

What am I doing wrong?

dr.bunsen
  • 1,781

3 Answers3

57

I think I totally misunderstood this question, but for what it's worth, here's my answer to (what I thought was) the question.

You could define another environment like so:

\newenvironment{variableblock}[3]{%
  \setbeamercolor{block body}{#2}
  \setbeamercolor{block title}{#3}
  \begin{block}{#1}}{\end{block}}

Then you can set the colours of the blocks as optional arguments:

\begin{variableblock}{Title}{bg=blue,fg=white}{bg=green,fg=red}
  Stuff
\end{variableblock}

This makes the background of the body blue and the background of the title block green. It also makes the body text white and the block title text red.

blocks of variable colour

Seamus
  • 73,242
51

You can modify the color using the block title template:

\documentclass{beamer}

\setbeamercolor{block title}{bg=red!30,fg=black}

\begin{document}

\begin{frame}
\begin{block}{Change the font color here}
    some text
    some more text
\end{block}
\end{frame}

\end{document}

enter image description here

Gonzalo Medina
  • 505,128
34

You can also wrap the \setbeamercolor statement within a {} group. The change is only local

{
\setbeamercolor{block}{bg=red, fg=white}
\begin{block}{}
...
\end{block}
}

For temporary use, say highlighting something, you can also use

\only<1,3,7>{
\setbeamercolor{block}{bg=red, fg=white}
    }
Ottorino
  • 853
  • 7
  • 10