The tcolorbox package

Draws coloured boxes with a frame, a background and an optional title: the tcolorbox environment and \newtcolorbox for box types of your own.

Loading the package

\usepackage{tcolorbox}

\fbox draws a black frame around one line. A tcolorbox holds paragraphs, lists and formulas, has rounded corners, separate colours for frame and background, and a title bar. The options are keys in square brackets: colback for the background, colframe for the frame, title for the title.

\newtcolorbox{name}[1]{options} defines an environment with fixed options, for example one box type for notes and one for warnings, so the layout is defined in one place.

The base package covers boxes on one page. Further functions are libraries, loaded with \tcbuselibrary{...}: breakable for boxes that continue on the next page, skins for drawing with TikZ, theorems for numbered boxes. \usepackage[most]{tcolorbox} loads these three and several more.

Main commands

\begin{tcolorbox}[title=Note] ... \end{tcolorbox}Box with a title bar.
colback=blue!5, colframe=blue!60!blackBackground colour and frame colour.
\newtcolorbox{notebox}[1]{colback=blue!5, title={#1}}Defines the environment notebox with one argument for the title.
sharp corners, boxrule=1ptSquare corners and a frame of 1 pt.
\tcblowerSplits the box into an upper and a lower part with a dashed line between them.
\tcbox{text}Box that is as wide as its content; \tcbox[on line]{text} sits inside a line of text.
\tcbuselibrary{breakable}Loads a library; with it, the key breakable lets a box break across pages.

Complete example

\documentclass{article}
\usepackage{tcolorbox}
\newtcolorbox{notebox}[1]{colback=blue!5, colframe=blue!60!black, title={#1}}
\begin{document}
\begin{tcolorbox}
A box with the default colours.
\end{tcolorbox}

\begin{notebox}{Note}
The title comes from the argument of the environment.
\tcblower
The lower part follows after the dashed line.
\end{notebox}

\begin{tcolorbox}[colback=yellow!10, colframe=orange,
  sharp corners, boxrule=1pt, title=Warning]
Square corners and a thin frame.
\end{tcolorbox}
\end{document}
Result
The compiled example

Open in the editor

Compiled with pdfLaTeX from TeX Live 2023.

Pitfalls

Related pages