3

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?

2 Answers 2

5

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}
3
  • Nice solutions! I will accept them if no further answers will appear. A brief comment to your second solution: It seems great at first, but there is unfortunately a minor glitch on the right-hand side of the box (a dark vertical line), which looks quite ugly if enlarged.
    – Hendrik
    Nov 25, 2015 at 11:40
  • @Hendrik I've seen the problem at right-hand side but as I don't know where it comes from i don't have a better solution. I hope some guru could solve it.
    – Ignasi
    Nov 25, 2015 at 14:43
  • @ Ignasi: Ok! I have found it that the effect can be mostly eliminated by commenting out the big block \ifbmb@shadow% { \color{black!50!bg} ....... } in the file beamerbaseboxes.sty. However, I have no idea why. The code is pretty heavy.
    – Hendrik
    Nov 25, 2015 at 14:57
2

You could use the tcolorbox inner theme and add a flat shadow like this:

\documentclass{beamer}

\usetheme{Warsaw}

\useinnertheme[rounded,shadow=false]{tcolorbox}
\tcbset{
  drop 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}

enter image description here

You must log in to answer this question.

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