[Tex/LaTex] Beamer: set block title bg equal to the block body bg

beamercolorthemestitles

I'm using the beaver color theme with the Boadilla beamer theme.

I want to get rid of the bluish blocks, that are not redefined to a color fitting the color theme I chose. So I put this in my preamble:

\definecolor{darkred}{rgb}{0.8,0,0}
\setbeamercolor{structure}{fg=darkred}

However, this produces something pinkish, which is ok, but it is way too pinkish when my blocks have a title. What I would like to do is to turn off the color difference between block title and block body, and use the block body color, that was automatically defined by \setbeamercolor{structure}{fg=darkred}, also in the block title.

I tried to put

\setbeamercolor{block title}{use=block body,fg=darkred,bg=block body.bg}

in my preamble, after the two definitions quoted above, but this results in

! TeX capacity exceeded, sorry [grouping levels=255].

errors wherever I put blocks in my frames.

Apparently, this questions was not asked by anybody around the net so far. Any help would be appreciated 🙂

Minimal working example:

\documentclass[10pt,xcolor=dvipsnames,pdflatex]{beamer}
\usetheme{Boadilla}
\usecolortheme{beaver}
\definecolor{darkred}{rgb}{0.8,0,0}
\setbeamercolor{structure}{fg=darkred}
\begin{document}
\begin{frame}{My pink slide}
\begin{block}{Oh my god}\centering
this is so girlish.\\
Especially when\\
the block is\\
so big\\
that it\\
is close\\
to the\\
red/grey\\
frame title.
\end{block}
\vfill
\begin{block}{}
Nice, bright block!\\
I like this and would not change its bg color.
\end{block}
\end{frame}
\end{document}

Best Answer

To achieve the goal, you have to understand how the block colors are defined for the Boadilla theme.

Boadilla uses rose as color theme in charge of customizing the blocks; it sets:

\setbeamercolor{block title}{use=structure,fg=structure.fg,bg=structure.fg!20!bg}
\setbeamercolor{block body}{parent=normal text,use=block title,bg=block title.bg!50!bg}

As you can see, the background color of the block body depends on the background color of the block title. So, basically, you want to reproduce in the block title the same color of the block body:

\setbeamercolor{block title}{fg=darkred,bg=structure.fg!20!bg!50!bg}

where: structure.fg!20!bg is the original background block title color and !50!bg is added to let him be exactly the color of the background block body. Now, the latter should be:

\setbeamercolor{block body}{use=block title,bg=block title.bg}

and that's it.

A complete example:

\documentclass[10pt,xcolor=dvipsnames,pdflatex]{beamer}
\usetheme{Boadilla}
\usecolortheme{beaver}
\definecolor{darkred}{rgb}{0.8,0,0}
\setbeamercolor{structure}{fg=darkred}

\setbeamercolor{block title}{fg=darkred,bg=structure.fg!20!bg!50!bg}
\setbeamercolor{block body}{use=block title,bg=block title.bg}


\begin{document}
\begin{frame}{My pink slide}
\begin{block}{Oh my god}\centering
this is so girlish.\\
Especially when\\
the block is\\
so big\\
that it\\
is close\\
to the\\
red/grey\\
frame title.
\end{block}
\vfill
\begin{block}{}
Nice, bright block!\\
I like this and would not change its bg color.
\end{block}
\end{frame}
\end{document}

The result:

enter image description here