[Tex/LaTex] Beamer boxes with flat shadows

beamershadowstikz-pgf

Is there a possibility to change the 'faded out' shadows from beamer boxes to 'flat shadows'?

With flat shadow I am referring to a shadow of a single color without a gradient. Ideally, I would like to have an opaque drop shadow in the style of the tikz.shadows library. It can be used as follows to add a flat shadow to a node:

 \node[draw,drop shadow={opacity=.25, shadow xshift=0.07, shadow yshift=-0.07, color=green}] at (0,0) {node with green shadow};

This is my MWE beamer document containing a single box with a fading shadow:

\documentclass{beamer}

\setbeamertemplate{blocks}[rounded][shadow=true] % use rounded blocks with standard beamer shadow

\begin{document}
\begin{frame}{Example frame}
  \begin{block}{Block with shadow}
    I, box, have a gradient shadow but I want a flat shadow.
  \end{block}
\end{frame}
\end{document}

The definition of the box shadows is most certainly contained in beamerbasedboxes.sty of the beamer package. Unfortunately, I do not understand the code since it mostly uses low level pgf commands instead of tikz commands. So far, I have tried to modify several commands in this file, but without success. Or maybe I have simply overlooked an option of the blocks template?

Best Answer

While someone provides a only-beamer-solution, you could consider to use tcolorbox and its easily customizable boxes.

\documentclass{beamer}

\usepackage[most]{tcolorbox}

\setbeamertemplate{blocks}[rounded][shadow=true] % use rounded blocks with standard beamer shadow

\begin{document}
\begin{frame}{Example frame}
  \begin{block}{Block with shadow}
    I, box, have a gradient shadow but I want a flat shadow.
  \end{block}

\begin{tcolorbox}[enhanced,drop shadow, title=Example with tcolorbox]
    I, box, have a flat shadow.
\end{tcolorbox}  

\end{frame}
\end{document}

enter image description here

2nd version:

Although I'm don't know what I did, after some tests I've got

enter image description here

from:

\documentclass{beamer}

\setbeamertemplate{blocks}[rounded][shadow=true] % use rounded blocks with standard beamer shadow

\makeatletter
\pgfdeclareradialshading[black,bg]{bmb@shadowball}{\pgfpointorigin}{%
  color(0bp)=(black!20!bg); color(4bp)=(black!20!bg)}
\pgfdeclareradialshading[black,bg]{bmb@shadowballlarge}{\pgfpointorigin}{%
  color(0bp)=(black!20!bg); color(4bp)=(black!20!bg); color(8bp)=(black!20!bg)}\pgfdeclareverticalshading[black,bg]{bmb@shadow}{200cm}{%
  color(0bp)=(black!20!bg); color(4bp)=(black!20!bg); color(6bp)=(black!20!bg)}
\makeatother

\begin{document}
\begin{frame}{Example frame}
  \begin{block}{Block with shadow}
    I, box, have a gradient shadow but I want a flat shadow.
  \end{block}  

\end{frame}
\end{document}