This is a screen capture from Pragmatic Bookshelf.
How to make this boxed text with LaTeX? It has it\'s own heading with underline, and uses color.
And
You should use the color package.
For example,
\colorbox{red}{Black text on red background}
creates a black text, with a red background. A good description of the color capabilities can be seen here, and an extended example here.
color