26  Colored text, highlights and boxes

Colored text in Beamer is produced using the standard LaTeX \textcolor command, as in:

\textcolor{blue}{This text is in blue} 

[image]

Remark: The command \structure{This is colored text} may be used to draw the specified text in the presentation’s structure color. See Direct use of the structure color for details.

Text background color is set using the \colorbox command:

\colorbox{yellow}{This text is highlighted in yellow} 

[image]

You may combine various color and font elements to achieve interesting results. For example:

\colorbox{yellow}{ 
    \textcolor{red}{ 
        \textbf{ 
            Bold text in red, highlighted in yellow 
        } 
    } 
} 

[image]

To enclose text in a bordered box:

    \fcolorbox{red}{yellow}{A yellow box with red border} 

[image]

The border’s thickness is controlled by the LaTeX variable \fboxrule. Let’s set the border’s thickness to 4 points:

\setlength{\fboxrule}{4pt} 
\fcolorbox{red}{white}{A white box with a red border of thickness 4 points} 

[image]

The separation between the border and the enclosed object is controlled by the LaTeX variable \fboxsep. Let’s set the separation to zero:

\setlength{\fboxrule}{4pt} 
\setlength{\fboxsep}{0pt} 
\fcolorbox{red}{white}{A white box with a red border and separation of 0 points}

[image]


Also see UMBC boxes for fancier boxes that may contain text or math.