Hi Everyone/Anyone
Using Beamer, I occasionally want to customize the colors for a block title background and body background to match one of the colors in an illustration on that slide.
It goes like this:
\begin{frame}
\setbeamercolor{block title}{bg=earthGreen}
\setbeamercolor{block body}{ bg=earthGreen!40}
\begin{block}{BlockTitle}
This is green
\end{block}
\end{frame}
To simplify this, I created a new command:
\newcommand{\myColoredBlock}[4][40]{
\begin{block}{#2}{
\setbeamercolor{block title}{bg=#3}
\setbeamercolor{block body}{bg=#3!#1}
#4
\end{block}
I then use the new command:
\begin{myColoredBlock}[35]{BlockTitle}{earthGreen}{
This is green
}\end{myColoredBlock}
But it isn't green! Clearly there is something wrong with my command.
Any ideas, anyone?
Thanks,
Dave
General ⇒ my \newcommand not working :-(
NEW: TikZ book now 40% off at Amazon.com for a short time.

Re: my \newcommand not working :-(
Figured it out. The colors need to be set before the block is entered. Duh!
\newcommand{\myColorBlock}[4][30]{
\setbeamercolor{block title}{bg= #3}
\setbeamercolor{block body}{bg= #3!#1}
\begin{block}{#2}
#4
\end{block}
}
Now it works fine!
\newcommand{\myColorBlock}[4][30]{
\setbeamercolor{block title}{bg= #3}
\setbeamercolor{block body}{bg= #3!#1}
\begin{block}{#2}
#4
\end{block}
}
Now it works fine!