# How can I have a horizontally shaded block title in beamer?

\documentclass{beamer}
\usetheme{Rochester}

\setbeamertemplate{block title}[horizontal shading][left=black, right=white]

\begin{document}
\begin{frame}
\frametitle{MWE}
\begin{block}{Title}
Test
\end{block}
\end{frame}
\end{document}


The template sidebar canvas left can be set in this fashion; is there any way the same can be done for block titles using templates?

-

## 1 Answer

Unfortunately, due to the way boxes are built in beamer (take a look at the definition of \beamerboxesrounded and \endbeamerboxesrounded in beamerbaseboxes.sty to see how different chunks are pieced together to build a box), this would require a major rewriting of the code producing the boxes and quite frankly I am not sure if the work is worthy the effort.

You can however, get this effect using the beamer skin for a tcolorbox and a convenient definition for interior titled code using \shade; something along these lines:

\documentclass[dvipsnames,svgnames,x11names]{beamer}
\usetheme{PaloAlto}
\usepackage[many]{tcolorbox}
\usetikzlibrary{shadings}

\newtcolorbox{myblock}[1][]{
beamer,
width=\textwidth+7pt,
enlarge left by=-3pt,
colback=structure,
colframe=block body.bg,
bottom=0pt,
top=-2pt,
left=0pt,
right=0pt,
toptitle=-1pt,
bottomtitle=-1pt,
fonttitle=\normalfont,
adjusted title=#1,
interior titled code={
\shade[left color=Maroon!80,right color=Dandelion,middle color=Salmon]
(title.south west) --
(title.south east) {[rounded corners] --
(title.north east)  --
(title.north west)} --
(title.south west);
}
}

\begin{document}

\begin{frame}

\begin{block}{The title}
This box ia a box provided by the \texttt{beamer} class.
\end{block}

\begin{myblock}[An example with \texttt{tcolorbox}]
This box looks like a box provided by the \texttt{beamer} class.
\end{myblock}
\end{frame}

\end{document}


-