6

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

  • 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
8

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.