I am trying to define a block with customizable colors. I want to put this in a file of common definitions (say common_defs.tex) and include it in each presentation and set its title and text background and foreground colors based on the theme of that presentation. Using the suggestion here I define the following in the common_defs.tex file

  \setbeamercolor{block title}{#2}
  \setbeamercolor{block body}{#3}

Now in the main beamer presentation I have the following:


\setbeamercolor{varblock text}{bg=red!20, fg=black}
\setbeamercolor{varblock title}{bg=red, fg=white}



\begin{varblock}{Block Title}
Some block text


This, understandably gives an error since it expects three arguments to \begin{varblock}. How can I change the definition to make this work?

1 Answer 1


Here is a solution using a macro \prevarblock that you can overwrite.


\renewcommand{\prevarblock}{% overwrite the maco as needed
  \setbeamercolor{block title}{bg=red!20, fg=black}%
  \setbeamercolor{block body}{bg=red, fg=white}%
    \begin{varblock}{Block Title} % demo varblock
      Some block text


\let\prevarblock\empty % dummy macro to overwrite
  \prevarblock% call the macro within every varblock
  • Perfect -- many thanks. Worked like a charm. Learn something new every day.
    – ozsu
    Commented Apr 5, 2021 at 17:45
  • Small suggestion: with \newenvironment<>{varblock}[1]{% \prevarblock% call the macro within every varblock \begin{block}#2{#1}}{\end{block}} you would retain the ability to use overlays for the blocks. Commented Jul 15 at 11:25
  • Thanks! Now I learned something new today :) Commented Jul 15 at 11:35
  • @jessexknight You're welcome! Commented Jul 15 at 11:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .