General ⇒ my \newcommand not working :-(
my \newcommand not working :-(
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
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
Re: my \newcommand not working :-(
\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!