# Changing style of alert environment in beamer

I would like to specify a background color in the alert environment. I can, for example, use

\setbeamercolor{alerted text}{fg=blue}


to change the colour of the alterted text to blue, but this

\setbeamercolor{alerted text}{bg=blue}


does not work. Is there a way to get around this?

I find that the font colours that the alert environment makes are too subtle and I'd like to add a coloured highlight box around my text in addition to changing the fg colour.

-

You can also create a new macro and use \alt in order to achieve to redefine an alert and use a colorbox. I highly recommend the tutorial "A beamer tutorial in Beamer". It contains many useful commands.

\documentclass{beamer}
\usepackage{color}

\begin{document}
\begin{frame}
\onslide<3->{\boxalert{3}{3 hello out of the itemize!}}
\begin{itemize}
\item<1-> 1
\item<2-> 2
\item<4-> 4
\item<5-> 5
\end{itemize}
\end{frame}

\begin{frame}
\begin{itemize}
\item<1-> 1
\item<2-> 2
\item<4-> 4
\item<5-> 5
\end{itemize}
\end{frame}
\end{document}

-
Welcome to TeX.SX! –  mafp Jul 27 '13 at 22:36

Since (La)TeX doesn't have a “background color” for text, you would have to put your text inside a box which you can then color. Consider the following example using \colorbox.

\documentclass{beamer}

}}

\begin{document}
\begin{frame}
\end{frame}
\end{document}


Which renders

Edit: I'm no expert in beamer internals, so the following is nothing more than a hack. However, if you would like \boxalert to work with overlays, something like the following “seems” to work:

\newenvironment{boxalertenv}{\begin{altenv}%


This breaks if you use overlays with alert, like so: \alert<+->{Text} –  Seamus Feb 17 '11 at 17:55
Thanks for pointing that out! I changed the answer defining a new command instead of trying to redefine \alert, I've also provided some sort of hack to get the new command working with overlays. –  Juan A. Navarro Feb 18 '11 at 10:46