I would like to know if it is possible to have to different kinds of blocks and how to do it in beamer.
As an example, one rounded for examples and one not rounded for theorems.
Is it possible to do this ?
Thanks
beamerblockrounded-corners
I would like to know if it is possible to have to different kinds of blocks and how to do it in beamer.
As an example, one rounded for examples and one not rounded for theorems.
Is it possible to do this ?
Thanks
I stumbled in a similar problem and solved it with the tcolorbox
package.
Here is the code:
\documentclass[final]{beamer}
\usepackage[orientation=portrait,size=a0,scale=1.4,debug]{beamerposter}
\usepackage{tcolorbox} %
\tcbuselibrary{skins} % preamble
\usepackage{tikz} %
\usetikzlibrary{shadows,shadings} %
\tikzset{myshadow/.style={ % custom shadow with tikz
opacity=.85,
shadow xshift=0.15,
shadow yshift=-0.15,
shade,
shading=axis,
shading angle=230}
}
\tcbset{ % set a custom tcolorbox
skin=enhanced, % enables use of shadows
frame style={fill=gray,drop shadow={myshadow}}, % sets the frame color and the shadow properties
bottom=7mm, % distance between the body text and the bottom frame
top=14mm, % distance between the body text and the top frame
boxrule=0mm, % frame width
bottomtitle=5mm, % distance between the title text and the bottom title frame
toptitle=5mm, % distance between the title text and the top title frame
lefttitle=1cm % title text left margin
}
\begin{document}
\begin{frame}
\begin{columns}
\begin{column}{.3\textwidth}
\begin{tcolorbox}[title=\large Fontsizes]
\centering
{\tiny tiny}\par
{\scriptsize scriptsize}\par
{\footnotesize footnotesize}\par
{\normalsize normalsize}\par
\end{tcolorbox}
\end{column}
\end{columns}
\end{frame}
\end{document}
the result is this:
for comparison:
I tried to explain everything in the code. If you want all the tcolorboxes to be like this, just put the \tcbset
code in the preamble, otherwise start a group just before the tcolorboxes you want to customize in that way.
The only thing that doesn't really look the same is the shadow (my shadow isn't blurred), but with some tweaks and the shadows.blur
tikzlibrary it should be possible to obtain the exact same result.
The document class beamer
internally uses \pgfpathqmoveto
, \pgfpathqcurveto
and \pgfpathlineto
to build the rounded boxes, so you can play with the values used in the original definition (it can be found in the file beamerbaseboxes.sty
).
In the code below I show a variation in which I changed the values for the rounded corners for the upper part of the blocks (these changes have to be made in the definition of \beamerboxesrounded
, which builds the upper part of the blocks); the original definitions appear commented out and marked with % original
at the end of the lines; the modified lines appear right afterwards and are marked with % NEW
.
To change the rounded corners for the bottom of the blocks you will have to make similar changes in some lines of \endbeamerboxesrounded
(which builds the lower part of the blocks); the lines in which changes will have to be made are marked with % original:change
.
\documentclass{beamer}
\usetheme{Warsaw}
\setbeamertemplate{blocks}[rounded]
\makeatletter
\renewcommand\beamerboxesrounded[2][]{%
\global\let\beamer@firstlineitemizeunskip=\relax%
\vbox\bgroup%
\setkeys{beamerboxes}{upper=block title,lower=block body,width=\textwidth,shadow=false}%
\setkeys{beamerboxes}{#1}%
{%
\usebeamercolor{\bmb@lower}%
\globalcolorstrue%
\colorlet{lower.bg}{bg}%
}%
{%
\usebeamercolor{\bmb@upper}%
\globalcolorstrue%
\colorlet{upper.bg}{bg}%
}%
%
% Typeset head
%
\vskip4bp
\setbox\bmb@box=\hbox{%
\begin{minipage}[b]{\bmb@width}%
\usebeamercolor[fg]{\bmb@upper}%
#2%
\end{minipage}}%
\ifdim\wd\bmb@box=0pt%
\setbox\bmb@box=\hbox{}%
\ht\bmb@box=1.5pt%
\bmb@prevheight=-4.5pt%
\else%
\wd\bmb@box=\bmb@width%
\bmb@temp=\dp\bmb@box%
\ifdim\bmb@temp<1.5pt%
\bmb@temp=1.5pt%
\fi%
\setbox\bmb@box=\hbox{\raise\bmb@temp\hbox{\box\bmb@box}}%
\dp\bmb@box=0pt%
\bmb@prevheight=\ht\bmb@box%
\fi%
\bmb@temp=\bmb@width%
\bmb@dima=\bmb@temp\advance\bmb@dima by2.2bp%
\bmb@dimb=\bmb@temp\advance\bmb@dimb by4bp%
\hbox{%
\begin{pgfpicture}{0bp}{+-\ht\bmb@box}{0bp}{+-\ht\bmb@box}
\ifdim\wd\bmb@box=0pt%
\color{lower.bg}%
\else%
\color{upper.bg}%
\fi%
% \pgfpathqmoveto{-4bp}{-1bp}% original
% \pgfpathqcurveto{-4bp}{1.2bp}{-2.2bp}{3bp}{0bp}{3bp}% original
\pgfpathqmoveto{-4bp}{-6bp}% NEW
\pgfpathqcurveto{-4bp}{-0.8bp}{-1.2bp}{2bp}{5bp}{3bp}% NEW
% \pgfpathlineto{\pgfpoint{\bmb@temp}{3bp}}% original
\pgfpathlineto{\pgfpoint{\bmb@temp-6pt}{3bp}}% NEW
\pgfpathcurveto%
% {\pgfpoint{\bmb@dima}{3bp}}% original
% {\pgfpoint{\bmb@dimb}{1.2bp}}% original
% {\pgfpoint{\bmb@dimb}{-1bp}}% original
{\pgfpoint{\bmb@dima-2bp}{1bp}}% NEW
{\pgfpoint{\bmb@dimb-2bp}{-1.2bp}}% NEW
{\pgfpoint{\bmb@dimb}{-6bp}}% NEW
\bmb@dima=-\ht\bmb@box%
\advance\bmb@dima by-2pt%
\pgfpathlineto{\pgfpoint{\bmb@dimb}{\bmb@dima}}
\pgfpathlineto{\pgfpoint{-4bp}{\bmb@dima}}
\pgfusepath{fill}
\end{pgfpicture}%
\copy\bmb@box%
}%
\nointerlineskip%
\vskip-1pt%
\ifdim\wd\bmb@box=0pt%
\else%
\hbox{%
\begin{pgfpicture}{0pt}{0pt}{\bmb@width}{6pt}
\bmb@dima=\bmb@width%
\advance\bmb@dima by8bp%
\pgfpathrectangle{\pgfpoint{-4bp}{-1bp}}{\pgfpoint{\bmb@dima}{8bp}}
\pgfusepath{clip}
{\pgftransformshift{\pgfpoint{-4bp}{0bp}}\pgftext[left,base]{\pgfuseshading{bmb@transition}}}%
\end{pgfpicture}%
}%
\nointerlineskip%
\vskip-0.5pt%
\fi%
\ifbmb@shadow%
\setbox\bmb@boxshadow=\hbox{\pgfuseshading{bmb@shadow}}%
\setbox\bmb@boxshadowball=\hbox{\pgfuseshading{bmb@shadowball}}%
\setbox\bmb@boxshadowballlarge=\hbox{\pgfuseshading{bmb@shadowballlarge}}%
\fi%
\setbox\bmb@colorbox=\hbox{{\pgfpicturetrue\pgfsetcolor{lower.bg}}}%
\setbox\bmb@box=\hbox\bgroup\begin{minipage}[b]{\bmb@width}%
\vskip2pt%
\usebeamercolor[fg]{\bmb@lower}%
\colorlet{beamerstructure}{upper.bg}%
\colorlet{structure}{upper.bg}%
%\color{.}%
}
\def\endbeamerboxesrounded{%
\end{minipage}\egroup%
\wd\bmb@box=\bmb@width%
\bmb@temp=\dp\bmb@box%
\advance\bmb@temp by.5pt%
\setbox\bmb@box=\hbox{\raise\bmb@temp\hbox{\box\bmb@box}}%
\dp\bmb@box=0pt%
\bmb@temp=\wd\bmb@box%
\bmb@dima=\bmb@temp\advance\bmb@dima by2.2bp%
\bmb@dimb=\bmb@temp\advance\bmb@dimb by4bp%
\hbox{%
\begin{pgfpicture}{0bp}{0bp}{0bp}{0bp}
\ifbmb@shadow%
{\pgftransformshift{\pgfpoint{4bp}{-3bp}}\pgftext{\copy\bmb@boxshadowball}}
\begin{pgfscope}
{%
\advance\bmb@temp by-1bp%
\pgfpathrectangle{\pgfpoint{\bmb@temp}{-7bp}}{\pgfpoint{9bp}{9bp}}%
\pgfusepath{clip}
}%
{\pgftransformshift{\pgfpoint{\bmb@temp}{1bp}}\pgftext{\box\bmb@boxshadowballlarge}}
\end{pgfscope}
\begin{pgfscope}
\advance\bmb@temp by-4bp%
\pgfpathrectangle{\pgfpoint{4bp}{-7bp}}{\pgfpoint{\bmb@temp}{5bp}}
\pgfusepath{clip}
{\pgftransformshift{\pgfpoint{4bp}{-7bp}}\pgftext[left,base]{\copy\bmb@boxshadow}}%
\end{pgfscope}
\begin{pgfscope}
\advance\bmb@temp by 4bp%
\bmb@dima=\ht\bmb@box%
\advance\bmb@dima by\bmb@prevheight%
\advance\bmb@dima by 4bp%
\pgfpathrectangle{\pgfpoint{\bmb@temp}{1bp}}{\pgfpoint{4bp}{\bmb@dima}}
\pgfusepath{clip}
\advance\bmb@dima by-4bp%
{\pgftransformshift{\pgfpoint{\bmb@temp}{\bmb@dima}}\pgftext{\box\bmb@boxshadowball}}
\advance\bmb@dima by-1bp%
\pgfpathrectangle{\pgfpoint{\bmb@temp}{1bp}}{\pgfpoint{4bp}{\bmb@dima}}
\pgfusepath{clip}
\advance\bmb@temp by4bp%
{\pgftransformshift{\pgfpoint{\bmb@temp}{-3bp}}%
\pgftransformrotate{90}%
\pgftext[left,base]{\box\bmb@boxshadow}}%
\end{pgfscope}
\fi%
\unhbox\bmb@colorbox%
\pgfpathqmoveto{-4bp}{1bp}% original:change
\pgfpathqcurveto{-4bp}{-1.2bp}{-2.2bp}{-3bp}{0bp}{-3bp}% original:change
\pgfpathlineto{\pgfpoint{\the\bmb@temp}{-3bp}}% original:change
\pgfpathcurveto%
{\pgfpoint{\the\bmb@dima}{-3bp}}% original:change
{\pgfpoint{\the\bmb@dimb}{-1.2bp}}% original:change
{\pgfpoint{\the\bmb@dimb}{1bp}}% original:change
{
\bmb@dima=\ht\bmb@box%
\pgfpathlineto{\pgfpoint{\bmb@dimb}{\bmb@dima}}
\pgfpathlineto{\pgfpoint{-4bp}{\bmb@dima}}
\pgfusepath{fill}
}
\ifbmb@shadow%
{
\color{black!50!bg}
\pgfsetlinewidth{0pt}
\pgfpathmoveto{\pgfpoint{\bmb@dimb}{-.5bp}}
\bmb@dima=\ht\bmb@box%
\advance\bmb@dima by\bmb@prevheight%
\advance\bmb@dima by 1bp%
\pgfpathlineto{\pgfpoint{\bmb@dimb}{\bmb@dima}}
\pgfusepath{stroke}
\bmb@temp=\bmb@dima
\advance\bmb@dima by 1bp%
\color{black!31!bg}
\pgfpathmoveto{\pgfpoint{\bmb@dimb}{\bmb@temp}}
\pgfpathlineto{\pgfpoint{\bmb@dimb}{\bmb@dima}}
\pgfusepath{stroke}
\advance\bmb@dima by 1bp%
\advance\bmb@temp by 1bp%
\color{black!19!bg}
\pgfpathmoveto{\pgfpoint{\bmb@dimb}{\bmb@temp}}
\pgfpathlineto{\pgfpoint{\bmb@dimb}{\bmb@dima}}
\pgfusepath{stroke}
\advance\bmb@dima by 1bp%
\advance\bmb@temp by 1bp%
\color{black!6!bg}
\pgfpathmoveto{\pgfpoint{\bmb@dimb}{\bmb@temp}}
\pgfpathlineto{\pgfpoint{\bmb@dimb}{\bmb@dima}}
\pgfusepath{stroke}
\advance\bmb@dima by 1.5bp%
\advance\bmb@temp by 1bp%
\color{bg}
\pgfpathmoveto{\pgfpoint{\bmb@dimb}{\bmb@temp}}
\pgfpathlineto{\pgfpoint{\bmb@dimb}{\bmb@dima}}
\pgfusepath{stroke}
}
\fi
\end{pgfpicture}%
\box\bmb@box%
}%
\ifbmb@shadow%
\vskip4bp minus 2bp%
\else%
\vskip2bp%
\fi%
\egroup% of \vbox\bgroup
}
\makeatother
\begin{document}
\begin{frame}
\begin{exampleblock}{test}
test
\end{exampleblock}
\end{frame}
\end{document}
Best Answer
Shamelessly combined from this nice answer by samcarter and this nice answer by samcarter. Only improvement: load the
tikzmarmots
package (by samcarter).