# How to create a filled colored box in Beamer?

I'm creating a presentation with Beamer, and I want to include a text that will be inside a filled colored box. At first I thought creating the filled colored box using TikZ, and I have the following:

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}

\begin{frame}{Test}

\begin{center}
\begin{tikzpicture}
\node[preaction={fill=cyan,fill opacity=0.5},rounded corners=1ex,font=\fontsize{12pt}{12pt}\itshape] {This is a \textcolor{blue}{\textbf{very}}, \textcolor{red}{\textbf{long}} and \textcolor{blue}{\textbf{stupid}} \\line of text without purpose};
\end{tikzpicture}
\end{center}
\end{frame}

\end{document}


The problem is that because my sentence is kind of long, I wanted to put half of in the new line using \\, but it gives me an error. Any idea how to circumvent the problem, or create what I want in another way?

• What is wrong with \begin{beamercolorbox}...\end{beamercolorbox}, for example? – user31729 Jan 6 '17 at 21:40
• @ChristianHupfer I didn't know about it at all. Can you give an example? – typos Jan 6 '17 at 21:55

The 'shortest' example to show the basic usage of beamercolorbox.

Please note that there are 'better/nicer' boxes such as beamerboxrounded or tcolorbox package to produce such setup.

\documentclass{beamer}

\usepackage{blindtext}
\begin{document}
\begin{frame}{Foo}
\setbeamercolor{coloredboxstuff}{fg=yellow,bg=white!10!blue}
\begin{beamercolorbox}[wd=0.9\textwidth,sep=1em]{coloredboxstuff}
\blindtext
\end{beamercolorbox}
\end{frame}
\end{document}


• @typos: You're welcome. Happy TeXing. Please have a look into the beamer manual etc. for more options to the environment. – user31729 Jan 6 '17 at 22:28

Not sure what you are actually trying to do, but the beamer way is probably using blocks:

\documentclass{beamer}
\usecolortheme{rose}

\setbeamerfont{structure}{series=\bfseries}