How can I create a block in LaTeX Beamer in "Sandwich Style", i.e., that has both a title and a footer. Ideally, the background colors could even be different. Here is an illustration (with incorrect spacing):
2 Answers
With tcolorbox
is easy to make a sandwich box. This one uses bicolor
skin. There also exists a beamer
skin which produces more 'a la beamer' boxes, but I don't know how to set a different background color for lower
text part like bicolor
does.
\documentclass{beamer}
\usepackage{tcolorbox}
\tcbuselibrary{skins}
\newtcolorbox{sandwich}[1]{bicolor, colframe=blue!75!black, colback=red!50!white, colbacklower=blue!75!black, collower=white,title=#1}
\begin{document}
\begin{frame}{Sandwich box with tcolorbox}
\begin{sandwich}{Testing 1-2-3}
This is a text
\tcblower
Yet another text
\end{sandwich}
\end{frame}
\end{document}
To complete Ignasi's answer, it is possible produce more " a la Beamer " sandwich boxes rounding corners, removing the frame and adding shadows, or alternatively use a beamer
skin and a bicolor
skin together, in that order. The MWE show both cases:
\documentclass{beamer}
\usetheme{Madrid}
\usecolortheme[RGB={128,128,255}]{structure}
\setbeamercolor*{block title example}{fg=red!50!black,bg= green!80!black!50}
\setbeamercolor*{block body example}{fg=green!20!black, bg= green!15}
\setbeamercolor*{block body alerted}{fg= orange!50!black, bg= orange!15}
\setbeamercolor*{block title alerted}{fg=yellow!50, bg= orange!50!red}
\usepackage[skins]{tcolorbox}
\begin {document}
\begin{frame}{Sandwich box a la Beamer}
\begin{columns}[c]
\begin{column}{.3\linewidth}
\begin{block}{Block}Text\end{block}
\begin{exampleblock}{Example block}Text\end{exampleblock}
\begin{alertblock}{Alert block}Text\end{alertblock}
\end{column}
\begin{column}{.4\linewidth}
% Without beamer skin:
\begin{tcolorbox}[
left=1mm,right=1mm,top=1mm,bottom=1mm,middle=1mm,
skin=bicolor,
arc=5pt,
bottomrule=0pt,
leftrule=0pt,
rightrule=0pt,
toprule=0pt,
colback=block body alerted.bg,
colbacklower=block body example.bg,
collower=block title.bg,
colframe=block title.bg, %structure, %blue!75!black,
frame style={left color=block title.bg,
right color=block title example.bg!100!black},
% better shadow than beamer skin
fuzzy shadow={1mm}{-1mm}{-.25mm}{.5pt}{structure!20!black}% blue!30!black!80}
,title=Testing 1-2-3]
A bicolor box
\tcblower
a la \dotfill \alert{no} Beamer mode
\end{tcolorbox}
\bigskip
% With beamer skin:
\begin{tcolorbox}[
left=1mm,right=1mm,top=1mm,bottom=1mm,middle=1mm,
beamer, % Warning: must be before of bicolor skin
skin=bicolor,
colback=block body.bg,
colbacklower=block body example.bg,
collower=block body alerted.fg,
colupper=block body example.fg,
%colframe=block title.bg,
coltitle=block title alerted.fg,
frame style={draw=none,fill=none, left color=block title.bg, right color=block title.bg!70!black},
interior style={left color=block body alerted.bg, right color=block title alerted.bg},
,title=Testing 1-2-3]
A bicolor box
\tcblower
a la Beamer mode
\end{tcolorbox}
\end{column}
\end{columns}
\end{frame}
\end{document}
As showed above, it is possible have 3 color and even gradients. I recommend to be cautious with this, using with moderation Beamer colours to be consistent with the rest of the presentation. Note that above code is only to show how to do, it is not intended to be an model of good taste (Get a elegant color scheme is a task for you.)
-
Thanks a lot for your indeed elegant answer. Do you know if there is a way to get the spacing exactly as with the classical beamer boxes? For example, the top right box has a caption with more height than the classical beamer box. Thanks!– DCTLibNov 14, 2013 at 18:42
-
@Ruedi, try to add
toptitle=-.5mm, bottomtitle=-1mm,
as first options in eachtcolorbox
.– FranNov 14, 2013 at 19:07