Contents

How to Make a Color Box in LaTeX

In many documents, especially math documents, it is useful to place a definition, formula, or note inside a colored frame. This helps the reader focus on important content and makes the page easier to scan.

Here is one example.

Example of a color box in LaTeX

The most common package for this purpose is tcolorbox. Add it to the preamble:

\usepackage{tcolorbox}

With tcolorbox, you can control the frame color, background color, title placement, and many other details. The official documentation is available on CTAN: https://www.ctan.org/pkg/tcolorbox.

Here are a few simple examples.

In this example, the title appears like a small label attached to the main content box.

\begin{tcolorbox}[
  colback=white,
  colframe=blue!70!black,
  title=Definition
]
A linear equation in one variable is an equation with exactly one variable
whose highest power is one.
\end{tcolorbox}

The output looks like this.

Creating colorbox in LaTeX

You can also emphasize the title by placing it in a small box above the main body.

\begin{tcolorbox}[
  enhanced,
  colback=yellow!10,
  colframe=red!70!black,
  coltitle=white,
  boxed title style={colback=red!70!black},
  title=Definition
]
Let $a$, $b$, and $c$ be real numbers with $a \ne 0$.
A quadratic equation has the general form
\[
ax^2 + bx + c = 0.
\]
\end{tcolorbox}

The output looks like this.

Creating colorbox in LaTeX

What if you want a more decorative box like the following?

Example of a color box with bclogo

For that style, you can use the bclogo package.

\usepackage{bclogo}

Then create the box like this:

\begin{bclogo}[couleur=blue!15, arrondi=0.1, logo=\bcinfo]{Note}
If two parallel lines are cut by another line, then corresponding angles
have the same measure.
\end{bclogo}

Those examples show the basic idea of building color boxes in LaTeX. You can extend them further with different colors, icons, border styles, and title layouts.

That is a short guide to creating color boxes in LaTeX. This feature is especially useful when writing worksheets, lecture notes, or math handouts that need clear visual emphasis.

Related Content