diff options
Diffstat (limited to 'macros/latex/contrib/coloredtheorem/coloredtheorem.sty')
-rw-r--r-- | macros/latex/contrib/coloredtheorem/coloredtheorem.sty | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/macros/latex/contrib/coloredtheorem/coloredtheorem.sty b/macros/latex/contrib/coloredtheorem/coloredtheorem.sty new file mode 100644 index 0000000000..dd553ba75d --- /dev/null +++ b/macros/latex/contrib/coloredtheorem/coloredtheorem.sty @@ -0,0 +1,59 @@ +%% This is file `tcbtheorem.sty', +%% +%% Copyright (C) 2024 by João Lourenço <joao.lourenco@fct.unl.pt> +%% +%% This file may be distributed and/or modified under the conditions of +%% the LaTeX Project Public License, either version 1.3c of this license +%% or (at your option) any later version. The latest version of this +%% license is in: +%% +%% http://www.latex-project.org/lppl.txt +%% +%% and version 1.3c or later is part of all distributions of LaTeX +%% version 2006/05/20 or later. +%% +\NeedsTeXFormat{LaTeX2e}[2020/06/01] +\ProvidesPackage{coloredtheorem} + [2024/03/31 v1.0 - a theorem-like environment inside a tcolobox] + +\RequirePackage{tcolorbox} +\tcbuselibrary{breakable} + +\gdef\tcbth{cth} + +\expandafter\NewDocumentCommand\csname\tcbth newtheorem\endcsname { m m O{} }{% + \expandafter\newcounter\expandafter{\tcbth#1}% + \expandafter\gdef\csname\tcbth#1name\endcsname{#2}% + \expandafter\gdef\csname\tcbth list#1name\endcsname{List of #2s}% + \expandafter\gdef\csname#1autorefname\endcsname{#2}% + \AtEndPreamble{% + \ifdefined\crefname\expandafter\crefname\csname\tcbth#1\endcsname{#2}{#2s}\fi}% + \expandafter\gdef\csname\tcbth listof#1s\endcsname + {% + \section*{\csname\tcbth list#1name\endcsname}% + \expandafter\@starttoc\expandafter{lo#1}% + } + \expandafter\NewDocumentEnvironment\expandafter{\tcbth#1} {O{} m O{}}% + {% \begin{tcb<SOMETHING>} + \begin{center}% + \ifx\relax##1\relax + \ifx\relax##2\relax\else + \expandafter\refstepcounter\expandafter{\tcbth#1}% + \expandafter\addcontentsline\expandafter{lo#1}{subsection} + {\protect\numberline{\csname the\tcbth#1\endcsname}##2}% + \fi + \else + \expandafter\addcontentsline\expandafter{lo#1}{subsection} + {\protect\numberline{\csname the\tcbth#1\endcsname}##1}% + \fi + \begin{tcolorbox}[breakable, + title={\textbf{\csname\tcbth#1name\endcsname + \ifx\relax##2\relax\else + ~\csname the\tcbth#1\endcsname\fi}~~##2}, + #3, ##3, + ]% + }{% \end{tcb<SOMETHING>} + \end{tcolorbox}% + \end{center}% + }% +} |