# Redefine block environment in beamer

I'm trying to redefine the block environment in beamer so that the itemize/enumerate bullets follow the color of block title instead of structure:

\documentclass{beamer}

\renewenvironment<>{block}[1]{%
\begin{actionenv}#2%
\def\insertblocktitle{#1}%
\par%
\mode<presentation>{%
\setbeamercolor{local structure}{use=block title,%
fg=block title.bg}}%
\usebeamertemplate{block begin}}
{\par%
\usebeamertemplate{block end}%
\end{actionenv}}


But this immediately throws the error

ERROR: LaTeX Error: Command \beamerx@\block already defined.


This seems very similar to the problem discussed at: How to redefine the \emph command in Beamer?

The aforementioned thread culminated in the discovery of a bug in beamer which was patched 4 years ago, and I'm wondering if this might be a similar bug in beamer's renewenvironment.

Yes, this seems to be also a similar bug with \newenvironment in beamer. The problem is the same mentioned by Loop Space in his answer to How to redefine the \emph command in Beamer?. The problem seems to be the same mentioned in the linked answer and the "solution" is similar.


\documentclass{beamer}

% Fix'' for possible bug
\makeatletter
\long\def\beamer@newenvnoopt#1#2#3#4{%
\expandafter\renewcommand\expandafter<\expandafter>\csname#1\endcsname[#2]{#3}%<- here
\expandafter\long\expandafter\def\csname end#1\endcsname{#4}%
}
\long\def\beamer@newenvopt#1#2[#3]#4#5{%
\expandafter\renewcommand\expandafter<\expandafter>\csname#1\endcsname[#2][#3]{#4}%<- here
\expandafter\long\expandafter\def\csname end#1\endcsname{#5}%
}
\makeatother

\renewenvironment<>{block}[1]{%
\begin{actionenv}#2%
\def\insertblocktitle{#1}%
\par%
\mode<presentation>{%
\setbeamercolor{local structure}{use=block title,%
fg=block title.bg}}%
\usebeamertemplate{block begin}}
{\par%
\usebeamertemplate{block end}%
\end{actionenv}}

\begin{document}

\begin{frame}
\begin{block}{A test new block}
test
\end{block}
\end{frame}

\end{document}


I've contacted one of the beamer maintainers about this.

• Thanks! I knew the answer would be something similar to this, but my TeX wizard level wasn't quite high enough. I have opened a bug report with your proposed fix on the development repository: bitbucket.org/rivanvx/beamer/issues/322/… – Grady Sep 14 '15 at 11:09
• This was eventually fixed in 2017 AFAICT: github.com/josephwright/beamer/commit/… Debian stretch (TexLive 2016) does not contain it, but buster (TL2018) does. – stefanct Jul 9 '19 at 14:01
• This solution does not work if you want to wrap/reuse the old block definition. If you try to do so (by using \originalblock & \endoriginalblock or with \LetLtxMacro manually) you end up with an endless loop. – stefanct Jul 9 '19 at 14:13