Sarmate.net Sarmate.net
Home Features Pricing Documentation Contact
Log in Sign up

Colored boxes with tcolorbox

The tcolorbox package allows you to create colored boxes for theorems, definitions, remarks and other environments. It offers full control over colors, borders, titles and numbering.

Save time with our visual editor
Create your colored boxes visually — choose colors, style and dimensions with your mouse. The LaTeX code is generated automatically.
Open the editor

Installation and setup

LaTeX
\usepackage[most]{tcolorbox}

The [most] option loads most libraries, including theorems, skins and breakable.

Simple box

LaTeX
% In the preamble:
\newtcolorbox{remarque}{
  enhanced, breakable,
  colback=yellow!10, colframe=orange!80!black,
  fonttitle=\bfseries, title=Remark}

% In the document:
\begin{remarque}
  Remark content here...
\end{remarque}

\newtcolorbox creates an unnumbered environment. Ideal for remarks, warnings or examples.

Numbered environment

For theorems, definitions and properties, you need numbered environments with \newtcbtheorem:

LaTeX
% In the preamble:
\newtcbtheorem[number within=section]{theoreme}{Theorem}{
  enhanced, breakable,
  colback=blue!5, colframe=blue!50!black,
  colbacktitle=blue!50!black, coltitle=white,
  fonttitle=\bfseries, boxrule=1pt, arc=4pt,
  separator sign={\ --},
  description delimiters parenthesis,
}{th}

% In the document:
\begin{theoreme}{Pythagoras}{pyth}
  In a right triangle...
\end{theoreme}

The syntax is: \newtcbtheorem[counter]{name}{display label}{options}{prefix}

  • number within=section — numbering per section (1.1, 1.2, 2.1...)
  • separator sign={\ --} — separator between number and title
  • description delimiters parenthesis — title in parentheses: Theorem 1.1 (Pythagoras)
  • {th} — prefix for \label/\ref (e.g. \ref{th:pyth})

Popular styles

Side bar

LaTeX
\newtcolorbox{remarque}{
  enhanced, breakable,
  colback=orange!8, colframe=orange!8,
  colbacktitle=orange!8, coltitle=orange!70!black,
  fonttitle=\bfseries, title=Remark,
  boxrule=0pt, arc=0pt,
  borderline west={3pt}{0pt}{orange!70!black},
  left=8mm
}

\begin{remarque}
  Content here...
\end{remarque}

Detached cartouche

LaTeX
\newtcbtheorem[number within=section]{propriete}{Property}{
  enhanced, breakable,
  colback=violet!5, colframe=violet!50!black,
  colbacktitle=violet!50!black, coltitle=white,
  fonttitle=\bfseries, boxrule=1pt, arc=4pt,
  top=6mm,
  attach boxed title to top left=
    {yshift=-\dimexpr\tcboxedtitleheight/2, xshift=5mm},
  boxed title style={boxrule=1pt, arc=3pt},
  separator sign={\ --},
  description delimiters parenthesis,
}{prop}

\begin{propriete}{Commutativity}{comm}
  For all real numbers $a$ and $b$:
  $a + b = b + a$
\end{propriete}

Inset cartouche

LaTeX
\newtcbtheorem[number within=section]{definition}{Definition}{
  enhanced, breakable,
  colback=white, colframe=green!40!black,
  colbacktitle=green!40!black, coltitle=white,
  fonttitle=\bfseries, boxrule=1pt, arc=4pt,
  top=8mm,
  attach boxed title to top left=
    {yshift=-\tcboxedtitleheight},
  boxed title style={boxrule=0pt, sharp corners,
    rounded corners=southeast, arc=3pt},
  separator sign={\ --},
  description delimiters parenthesis,
}{def}

\begin{definition}{Prime number}{prime}
  A natural integer is prime when...
\end{definition}

Sharp top corners

LaTeX
\newtcbtheorem[number within=section]{theoreme}{Theorem}{
  enhanced, breakable,
  colback=white, colframe=blue!60!black,
  colbacktitle=blue!60!black, coltitle=white,
  fonttitle=\bfseries, boxrule=1.5pt, arc=6pt,
  sharp corners=north,
  separator sign={\ --},
  description delimiters parenthesis,
}{th}

\begin{theoreme}{Pythagoras}{pyth}
  $a^2 + b^2 = c^2$
\end{theoreme}

Important options

OptionDescription
colbackBody background color
colframeBorder color
colbacktitleTitle background color
coltitleTitle text color
colupperBody text color
arcCorner radius
boxruleBorder thickness
enhancedEnable advanced drawing features
breakableAllow page breaks
sharp corners=northSharp top corners
fuzzy shadowFuzzy shadow

Defining colors

For precise colors, use \definecolor with HTML hex codes:

LaTeX
\definecolor{mon-bleu}{HTML}{1A3FC7}
\definecolor{mon-bleu-clair}{HTML}{EEF2FF}

\newtcbtheorem[number within=section]{theoreme}{Theorem}{
  colback=mon-bleu-clair,
  colframe=mon-bleu,
  colbacktitle=mon-bleu,
  % ...
}{th}
Tip
Our visual editor automatically generates the \definecolor commands with the colors you choose.

Ready to create your boxes?

Present your content professionally

Create a free account