9

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?

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

2 Answers 2

11

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}

enter image description here

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

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}
\setbeamerfont{alerted text}{series=\bfseries}

\begin{document}

\begin{frame}{Test}
  \begin{block}{}
    This is a \structure{very}, \alert{long} and \structure{stupid} 

    line of text without purpose
  \end{block}
\end{frame}

\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .