[Tex/LaTex] Shadow of a non rounded block in beamer

beamerblockshadows

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}
\linespread{1.05} 

\author{Lorem ipsum}
\title{LOrem ipsum}
\setbeamertemplate{navigation symbols}{}

 \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}

\insertverticalnavigation{2cm}

\vspace{10\baselineskip}

\insertframenumber / \inserttotalframenumber
\end{minipage}
  }

\begin{document}
...

Thanks in advance,

Charlie

Best Answer

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}
\linespread{1.05} 

\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}
  \insertverticalnavigation{2cm}
  \vspace{10\baselineskip}
  \insertframenumber / \inserttotalframenumber
  \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}[
    adjusted title=#1,
    tcbeamer,
    colback=block body example.bg,
    colframe=block title example.bg,
    fonttitle=\large\color{block title example.fg}
    ]
  }
  {\end{tcolorbox}\end{actionenv}}

\newenvironment<>{tcalertblock}[1]
  {\begin{actionenv}#2\begin{tcolorbox}[
    adjusted title=#1,
    tcbeamer,
    colback=block body alerted.bg,
    colframe=block title alerted.bg,
    fonttitle=\large\color{block title alerted.fg},
    adjusted title=#1,
    ]
  }
  {\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}

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

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

\end{frame}

\end{document}

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

enter image description here

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

\documentclass[serif]{beamer}

you should use

\usefonttheme{serif}
Related Question