# Shadow of a non rounded block in beamer

My question is simple: Is it possible to add shadow to a NON rounded block in beamer?

I've been trying it with:

\setbeamertemplate{blocks}[rounded=false][shadow=true]


But no success. I'm using the marburg theme. Here is the preamble code:

\documentclass[serif]{beamer}

\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{epstopdf}
\usepackage[spanish]{babel}
\usepackage{mathpazo}

\author{Lorem ipsum}
\title{LOrem ipsum}

\usetheme[hideallsubsections,left,width=2cm]{Marburg}

\usecolortheme{rose}
\setbeamercolor{titlelike}{bg=structure,fg=white}

\logo{\includegraphics[height=1.5cm]{../Fotos/Logo.png}}

\setbeamertemplate{sidebar left}{
\begin{minipage}{2cm}
\centering
\vspace{\baselineskip}
\insertlogo

\vspace{\baselineskip}
\color{white}{\insertshorttitle[width={2cm},center,respectlinebreaks]}

\insertshortauthor[width={2cm},center,respectlinebreaks] \vspace{\baselineskip}

\vspace{10\baselineskip}

\end{minipage}
}

\begin{document}
...


Charlie

• Are you using any outer or inner additional themes? Can you show at least the relevant parts of your preamble? – Gonzalo Medina May 9 '14 at 17:43
• No, just the color theme called rose. I posted the preamble of the code. – Charlie May 9 '14 at 17:47
• This can be really hard, since the shadow is only defined for rounded boxes and the definitions for the case rounded and not rounded boxes are different. I have a possible work-around (in my mind, I've not written any code yet), but do you plan to apply shadows to all possible boxes (theorem -like blocks, exampleblock, alertblock, etc.)? – Gonzalo Medina May 9 '14 at 18:52
• So far, I only have regular blocks, exampleblocks and alertblocks. I don't think I will be inserting other types of blocks. – Charlie May 9 '14 at 18:55
• I'm thinking of maybe attach a tikz transparent block with a certain offset behind a regular block, but I don't know if this is actually possible. – Charlie May 9 '14 at 18:58

Unfortunately this is not easy natively in beamer (but there's an easy way to achieve it using external tools) since shadows are applied only to rounded boxes (which are built using beamerboxesrounded) but not to non-rounded boxes (which are built separately using beamercolorbox).

As an alternative, I offer you here a possibility using the tcolorbox package to define blocks emulating those defined by the beamer class, but adding the shadow. In the following example I show how to easily do this defining a proper style and building shadowed clones for exampleblock and alertblock:

\documentclass[]{beamer}
\usepackage{mathpazo}
\usepackage[many]{tcolorbox}

\usetheme[hideallsubsections,left,width=2cm]{Marburg}
\usefonttheme{serif}
\usecolortheme{rose}

\setbeamercolor{titlelike}{bg=structure,fg=white}

\setbeamertemplate{sidebar left}{%
\begin{minipage}{2cm}
\centering
\vspace{\baselineskip}
\insertlogo%
\vspace{\baselineskip}
\color{white}{\insertshorttitle[width={2cm},center,respectlinebreaks]}%
\insertshortauthor[width={2cm},center,respectlinebreaks] \vspace{\baselineskip}
\vspace{10\baselineskip}
\end{minipage}%
}

\makeatletter
\tikzset{beamer@color/.style={top color=\kvtcb@colback,bottom color=\kvtcb@colback}}
\makeatother

\tcbset{
tcbeamer/.style={
beamer,
width=\textwidth+3pt,
enlarge left by=-3pt,
bottom=0pt,
top=0pt,
left=1pt,
right=1pt,
arc=0pt,
outer arc=0pt,
toptitle=0pt,
bottomtitle=-1pt,
}
}

\newenvironment<>{tcexampleblock}[1]
{\begin{actionenv}#2\begin{tcolorbox}[
tcbeamer,
colback=block body example.bg,
colframe=block title example.bg,
fonttitle=\large\color{block title example.fg}
]
}
{\end{tcolorbox}\end{actionenv}}

{\begin{actionenv}#2\begin{tcolorbox}[
tcbeamer,
]
}
{\end{tcolorbox}\end{actionenv}}

\begin{document}

\begin{frame}

\begin{exampleblock}<1->{Test exampleblock}
This is a block provided by the \texttt{beamer} class.
\end{exampleblock}

\begin{tcexampleblock}<2->{Test tcexampleblock}
This is a block provided by the \texttt{tcolorbox} package.
\end{tcexampleblock}

This is a block provided by the \texttt{beamer} class.

This is a block provided by the \texttt{tcolorbox} package.

\end{frame}

\end{document}


The result, showing the new overlay-aware environments in action:

Notice that the serif class option is obsolete, so instead of

\documentclass[serif]{beamer}


you should use

\usefonttheme{serif}

• Hi Gonzalo! When I try to insert the tcalertblock or tcexampleblock latex says: ! Package xcolor Error: Undefined color block body alerted.bg'. What could be producing this? – Charlie May 9 '14 at 21:46
• @Charlie Hi. No idea. In my system there's no errors; I even asked in chat for an independent compilation (you can see the transcript here) and other user compiled successfully the code. If you replace that color by a "usual one", such as red` does the problem disappear? – Gonzalo Medina May 9 '14 at 22:32
• I think it was layer 8 error :P. It compiles but I can see that the new blocks, apparently, don't admit overlays. I'm going to accept your answer because despite the lack of tools and the complexity, you were able to make a work around successfully. Do you think it's possible to make them admit overlays? – Charlie May 9 '14 at 22:42
• @Charlie Ah, I can make them overlay aware, if you want to. – Gonzalo Medina May 9 '14 at 22:43
• That'd be great! – Charlie May 9 '14 at 23:26