Payload LogoOctree

Colored Boxes in LaTeX: tcolorbox Complete Guide

Date Published

Colored Boxes with tcolorbox

The tcolorbox package creates beautiful, customizable boxes for callouts, theorems, and highlights.

Getting Started

\usepackage{tcolorbox}

For more features:

\tcbuselibrary{skins, breakable, theorems}

Basic Box

\begin{tcolorbox} This is a basic colored box. \end{tcolorbox}

Box with Title

\begin{tcolorbox}[title=My Title] Content goes here. \end{tcolorbox}

Colors

Background Color

\begin{tcolorbox}[colback=blue!10] Light blue background. \end{tcolorbox}

Frame Color

\begin{tcolorbox}[colframe=red] Red frame. \end{tcolorbox}

Title Colors

\begin{tcolorbox}[ title=Title, colbacktitle=green!50, coltitle=black ] Content. \end{tcolorbox}

Shadows

Drop Shadow

\begin{tcolorbox}[enhanced, drop shadow] Box with shadow. \end{tcolorbox}

Shadow Options

\begin{tcolorbox}[ enhanced, drop shadow={opacity=0.5, shadow xshift=2mm, shadow yshift=-2mm} ] Customized shadow. \end{tcolorbox}

Fuzzy Shadow

\begin{tcolorbox}[enhanced, fuzzy shadow] Soft blurred shadow. \end{tcolorbox}

Box Styles

Rounded Corners

\begin{tcolorbox}[arc=4mm] Rounded corners. \end{tcolorbox}

Sharp Corners

\begin{tcolorbox}[sharp corners] Sharp corners. \end{tcolorbox}

No Frame

\begin{tcolorbox}[frame hidden] No visible frame. \end{tcolorbox}

Theorem-like Boxes

Create numbered theorems:

\newtcbtheorem{theorem}{Theorem}{colback=blue!5, colframe=blue!50}{th}

\begin{theorem}{Pythagorean}{pyth} In a right triangle, $a^2 + b^2 = c^2$. \end{theorem}

Breakable Boxes

For boxes that span pages:

\begin{tcolorbox}[breakable] Long content that may span multiple pages. \end{tcolorbox}

Predefined Styles

Warning Box

\begin{tcolorbox}[ colback=yellow!10, colframe=orange, title=Warning ] Warning message. \end{tcolorbox}

Info Box

\begin{tcolorbox}[ colback=blue!5, colframe=blue!50, title=Note ] Informational note. \end{tcolorbox}

Success Box

\begin{tcolorbox}[ colback=green!5, colframe=green!50, title=Success ] Success message. \end{tcolorbox}

Error Box

\begin{tcolorbox}[ colback=red!5, colframe=red!50, title=Error ] Error message. \end{tcolorbox}

Custom Styles

Define reusable styles:

\tcbset{mystyle/.style={ colback=gray!10, colframe=gray!50, fonttitle=\bfseries, arc=2mm, enhanced, drop shadow }}

\begin{tcolorbox}[mystyle, title=Custom] Using the custom style. \end{tcolorbox}

Sidebars and Margins

Left Bar

\begin{tcolorbox}[ blanker, borderline west={3pt}{0pt}{blue} ] Box with left border only. \end{tcolorbox}

Inline Boxes

\tcbox{inline box} — small inline colored box

Create Boxes with Octree

Octree simplifies tcolorbox:

- Visual box builder - Preview styles instantly - AI suggests color schemes - Export polished documents

Try it at https://useoctree.com