In a beamer presentation I would like to create boxes without frame but filled with gradient from left (light grey) to right (dark grey) and text in the box. I also want the box to touch the edge of the paper (top, left, right), so put it on the slide without any margins. It is possible to do this with tcolorboxes?
2 Answers
Upon my EDIT, I still don't have a clue what I am doing, but I did manage to get things into beamer
. The use of physical dimensions, notably 4.2in for the \makebox
and 4.65in for the \tcbox
width, are given in physical dimensions because I don't know what the corresponding variable names are for beamer
margin widths, etc. They may, therefore need changing depending on your beamer
template.
\documentclass{beamer}
\usepackage{tcolorbox,lipsum}
\tcbuselibrary{skins}
\begin{document}
\begin{frame}
\raisebox{4cm}{\makebox[4.2in]{
\tcbox[enhanced, boxrule=0pt, arc=0pt, width=4.65in, top=.2in,bottom=.3in,
interior style={left color=gray!05,right color=gray!50}]
{\begin{minipage}{4.65in}
\lipsum[1]
\end{minipage}
}}}
\end{frame}
\end{document}
I employed bits and pieces from these three answers:
How to make more than two fancy gradient stripes in tcolorbox?
and
This is a variant of the answer of Steven B. Segletes. I made a new environment gradientbox
which takes optional tcolorbox
parameters. I tried to use dimension settings from the beamer
style files. Still, there is a fixed kerning of 2mm
for the top space which I could not find in reasonable time in the beamer implementation.
Frame should be used with the [t]
option and without title to get the box to the very top of the slide.
\documentclass{beamer}
\usepackage{tcolorbox,lipsum}
\tcbuselibrary{skins}
\makeatletter%
\newtcolorbox{gradientbox}[1][]{%
enhanced,boxrule=0pt,boxsep=0pt,sharp corners,
before=\nointerlineskip\kern-2mm,%
width=\paperwidth,
enlarge left by=-\beamer@leftmargin-\beamer@leftsidebar,
enlarge right by=-\beamer@rightmargin-\beamer@rightsidebar,
frame hidden,interior style={left color=gray!05,right color=gray!50},
#1
}
\makeatother%
\begin{document}
\begin{frame}[t]
\begin{gradientbox}
\lipsum[1]
\end{gradientbox}
\end{frame}
\begin{frame}[t]
\begin{gradientbox}[top=8mm,bottom=8mm,left=10mm,right=10mm]
\lipsum[1]
\end{gradientbox}
\end{frame}
\end{document}