Directory macros/latex/contrib/coloredtheorem
coloredtheorem
A colorful boxed theorem environment, combining tcolorbox and breakable boxes. It supports full tcolorbox customization, automatic numbering, \label{...} and \ref{…}, and \listof…
<picture> <source media="(prefers-color-scheme: dark)" srcset=" https://api.star-history.com/svg?repos=joaomlourenco/coloredtheorem&type=Date&theme=dark " /> <source media="(prefers-color-scheme: light)" srcset=" https://api.star-history.com/svg?repos=joaomlourenco/coloredtheorem&type=Date " /> <img width="400" alt="Star History Chart" src="https://api.star-history.com/svg?repos=joaomlourenco/coloredtheorem&type=Date" /> </picture>
If you opt for using this project, please give it a star by clicking the (⭐️) at the top right of the project's page.
About
- Package: coloredtheorem — A colorful boxed theorem environment
- Copyright: 2024 © João M. Lourenço <joao.lourenco@fct.unl.pt>
- CTAN: https://ctan.org/pkg/coloredtheorem
- Repository: https://github.com/joaomlourenco/coloredtheorem
- License: The LaTeX Project Public License 1.3c
Introduction
The coloredtheorem package is a simple environment that allows to write stuff inside boxes from tcolorbox. If necessary the boxes gracefully overflow to the next page. This package takes no options and includes tcolorbox if necessary. You may include tcolorbox with your own favourite options prior to including this package.
Akin to \newtheorem from the amsmath package, the user should start by defining a new theorem/box group and customize its aspect. Each new environment will have its own counter/numbering. Notice that \label{...} and \ref{...} work as expected. There is also a command to generate the corresponding listof...
Usage
\usepackage{coloredtheorem}- Load Load the
coloredtheorempackage. This package will loadtcolorboxif necessary.
- Load Load the
\cthnewtheorem{<envname>}{<Name>}[<tcolorbox options>]- Create a new boxed algorithm-like environment.
<envname>is the suffix for the new environment being defined, e.g.,algoritm. The effective environment name will becth<envname>, e.g.,cthalgorithm.<Name>is the (printable) name or the new environment being defined, e.g., Algorithm.<tcolorbox options>default options for the environment being defined (this argument is optional). These options are passed straight to thetcolorboxenvironment, so anything valid fortcolorboxis also valid here.
- Create a new boxed algorithm-like environment.
\begin{<envname>}{<Caption>}[<tcolorbox options>]<Contents>\end{<envname>}- Create a new algorithm-like box with the given contents. ∗
<AltCaption>is the alternative caption for the\cthlistof<envname>s(see below).<envname>is the sffix for environment name, e.g.,algorithm.<Caption>is the caption/title of the box. If the caption is left empty, this box will not be listed with the\cthlistof<envname>s(see below).<tcolorbox options>options to be passed to thetcolorboxenvironment, which will override the defaults given in\cthnewalgorithm(this argument is optional).<Contents>the contents to by typeset inside the colored environment.
- Create a new algorithm-like box with the given contents. ∗
\listof<envname>s<envname>is the environment name suffix, e.g.,\cthlistofalgorithms. Please
notice that there is a ‘s’ (plural) after <envname>.
Example
Let’s start by creating two new environments, one for algorithms and another for examples, both defaulting to a gray frame, the former with a yellowish background and the latter with a lighter gray background.
\cthnewtheorem{algorithm}{Algorithm}[coltitle=black, colback=yellow!10, colframe=black!15] \cthnewtheorem{example}{Example}[coltitle=black, colback=black!5, colframe=black!30] \cthnewtheorem{thought}{Though}[enhanced, coltitle=green!60!black, colbacktitle=green!10, colback=green!10, frame hidden, boxrule=0pt, attach title to upper={\\[0.5ex]}, borderline west={1mm}{-2mm}{green!60!black}]
And this is a shiny thought!
The box with Algorithm 1, which uses the default visual that was given when creating the environment with \cthnewtheorem and gracefully overflows onto the next page, was created with:
\begin{cthalgorithm}{Advance a counter to the next value in a domain $\omega \in \mathbb{N}$.} Algorithm body here! \end{cthalgorithm}
Download the contents of this package in one zip archive (239.8k).
coloredtheorem – A colourful boxed theorem environment
This packages provides a colourful boxed theorem environment, combining tcolorbox and breakable boxes.
| Package | coloredtheorem |
| Home page | https://github.com/joaomlourenco/coloredtheorem |
| Support | https://github.com/joaomlourenco/coloredtheorem/discussions |
| Bug tracker | https://github.com/joaomlourenco/coloredtheorem/issues |
| Version | 1.1.2 2025-04-01 |
| Licenses | The LaTeX Project Public License 1.3c |
| Copyright | 2024, 2025 João M. Lourenço |
| Maintainer | João M. Lourenço |
| Contained in | TeX Live as coloredtheorem MiKTeX as coloredtheorem |
| Topics | Box breaking Colour Maths theorem Boxing Decoration |
| See also | thmbox Shaded theorems |