From f5e9f60b848589c005e635efa285af6848cc7733 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Fri, 5 Apr 2024 21:20:56 +0000 Subject: coloredtheorem (5apr24) git-svn-id: svn://tug.org/texlive/trunk@70865 c570f23f-e606-0410-a88d-b1316a301751 --- .../texmf-dist/doc/latex/coloredtheorem/README.md | 112 +++++++++----- .../latex/coloredtheorem/coloredtheorem-doc.pdf | Bin 201428 -> 214341 bytes .../latex/coloredtheorem/coloredtheorem-doc.tex | 170 +++++++++++++-------- .../tex/latex/coloredtheorem/coloredtheorem.sty | 17 ++- 4 files changed, 196 insertions(+), 103 deletions(-) diff --git a/Master/texmf-dist/doc/latex/coloredtheorem/README.md b/Master/texmf-dist/doc/latex/coloredtheorem/README.md index 805393b7387..77ec725fd11 100644 --- a/Master/texmf-dist/doc/latex/coloredtheorem/README.md +++ b/Master/texmf-dist/doc/latex/coloredtheorem/README.md @@ -1,6 +1,6 @@ # coloredtheorem -A colourful boxed theorem environment, combining `tcolorbox` and breakable boxes. It supports full `tcolorbox` customization, automatic numbering, `\label{...}` and `\ref{…}`, and `\listof…` +A colorful boxed theorem environment, combining `tcolorbox` and breakable boxes. It supports full `tcolorbox` customization, automatic numbering, `\label{...}` and `\ref{…}`, and `\listof…` +## About + +* **Package:** coloredtheorem — A colorful boxed theorem environment +* **Copyright:** 2024 © João M. Lourenço +* **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, which takes no options, and that allows to write stuff inside boxes from `tcolorbox`. So, this packages includes `tcolorbox` if necessary. You may include `tcolorbox` with your own favourite options prior to including this package. +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/numnering. Notice that `\label{...}` and `\ref{...}` work as expected. The is also a command to generate the corresponding `\listof...` +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 `coloredtheorem` package. This package will load `tcolorbox` if necessary. * `\cthnewtheorem{}{}[]` - * Load the tcbtheorem package. This package will load tcolorbox if not already loaded. -* `\cthnewtheorem{}{}[]` - * `` is the environment name, e.g., theorem. - * `` is the name for new environment being defined, e.g., Theorem. - * `` options to be passed to the `tcolorbox` environment to customize the boxes for the given environment (this argument is optional). + * Create a new boxed algorithm-like environment. + * `` is the suffix for the new environment being defined, e.g., `algoritm`. The effective environment name will be `cth`, e.g., `cthalgorithm`. + * `` is the (printable) name or the new environment being defined, e.g., _Algorithm_. + * `` default options for the environment being defined (this argument is optional). These options are passed straight to the `tcolorbox` environment, so anything valid for `tcolorbox` is also valid here. * `\begin{}{}[]\end{}` - * `` is the environment name, e.g., theorem. - * `` is the caption/title of the box. - * `` options to be passed to the `tcolorbox` environment, which will override the defaults given in `\cthnewtheorem`. - * `` the contents to by typeset inside the coulored environment. + * Create a new _algorithm-like_ box with the given contents. + ∗ `` is the alternative caption for the `\cthlistofs` (see below). + * `` is the sffix for environment name, e.g., `algorithm`. + * `` is the caption/title of the box. If the caption is left empty, this box will not be listed with the `\cthlistofs` (see below). + * `` options to be passed to the `tcolorbox` environment, which will override the defaults given in `\cthnewalgorithm` (this argument is optional). + * `` the contents to by typeset inside the colored environment. * `\listofs` - * Where `` is the environment name, e.g., `\listoftheorems`. Please notice that there is a ‘s’ (plural) after ``. + * `` is the environment name suffix, e.g., `\cthlistofalgorithms`. Please +notice that there is a ‘s’ (plural) after ``. ## 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. +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. + +```latex +\cthnewtheorem{algorithm}{Algorithm}[coltitle=black, colback=yellow!10, + colframe=black!15] +\cthnewtheorem{example}{Example}[coltitle=black, colback=black!5, + colframe=black!30] +``` + +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: + +```latex +\begin{cthalgorithm}{Advance a counter to the next value in a domain + $\omega \in \mathbb{N}$.} + + Algorithm body here! +\end{cthalgorithm} +``` + +image - \cthnewtheorem{algorithm}{Algorithm}[coltitle=black, colback=yellow!10, - colframe=black!15] - \cthnewtheorem{example}{Example}[coltitle=black, colback=black!5, - colframe=black!30] +_(page break here)_ -An algorithm box will be created with: +image - \begin{cthalgorithm}{Advance a counter to the next value in a domain - $\omega \in \mathbb{N}$.} - Algorithm body here! - \end{cthalgorithm} +The box Example 1, which uses the default visual for the environment (as given to `\cthnewtheorem...`), was created with: -image +```latex +\begin{cthexample}{This is an example!} + Example body here! +\end{cthexample} +``` -Now, let's rewrite Algorithm 1, but now with a different customized visual, just for this entry! The customization (3rd) argument is passed straight to the `tcolorbox` environment, so anything valid for `tcolorbox` is also valid here. +image -image +Now, let’s create a new box for Algorithm 1, but with a different customized visual, which will affect only this entry! Notice that the customization argument is passed straight to the `tcolorbox` environment, so anything valid for `tcolorbox` is also valid here. Algorithm 2 was created with the following code: -(page break here!) +```latex +\begin{cthalgorithm} + {Advance a counter to the next value in a domain $\omega \in + \mathbb{N}$, but now with a customized visual. Also, notice + that this algorithm breaks the page boundaries.} + [coltitle=white, colback=green!10, colframe=green!70!black, + colbacktitle=\sffamily\bfseries\large, fonttitle=red!50!white] + Algorithm body here! +\end{cthalgorithm} +``` -image +image -Now, let’s add an example here, this time using the default visual that was given when creating the environment with `\cthnewtheorem`… +_(page break here)_ -image +image And now and example with no caption and a different visual... this example will not go into the` \listofexamples` below! -image +image -Now let’s print the lists of algorithms and examples. Remember to add the prefix cthth to the listof, i.e., `\cthlistofalgorithms` and `\cthlistofexamples`! +Now let’s print the lists of algorithms and examples. Remember to add the prefix `cthth` to the `listof`, i.e., `\cthlistofalgorithms` and `\cthlistofexamples`! ## List of Algorithms -image +image ## List of Examples -image +image diff --git a/Master/texmf-dist/doc/latex/coloredtheorem/coloredtheorem-doc.pdf b/Master/texmf-dist/doc/latex/coloredtheorem/coloredtheorem-doc.pdf index 046c79dcc6d..abccef51676 100644 Binary files a/Master/texmf-dist/doc/latex/coloredtheorem/coloredtheorem-doc.pdf and b/Master/texmf-dist/doc/latex/coloredtheorem/coloredtheorem-doc.pdf differ diff --git a/Master/texmf-dist/doc/latex/coloredtheorem/coloredtheorem-doc.tex b/Master/texmf-dist/doc/latex/coloredtheorem/coloredtheorem-doc.tex index 55ae3d3ae5c..875851d6002 100644 --- a/Master/texmf-dist/doc/latex/coloredtheorem/coloredtheorem-doc.tex +++ b/Master/texmf-dist/doc/latex/coloredtheorem/coloredtheorem-doc.tex @@ -1,22 +1,14 @@ \documentclass{article} -\usepackage[margin=1.6in]{geometry} -\usepackage{fancyvrb} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% AMSMATH stuff -% \usepackage{amsthm} -% \usepackage{thmtools} -% \usepackage{amsfonts} - - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% TCBTHEOREM stuff \usepackage{coloredtheorem} - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% EXAMPLE document +\usepackage[margin=1.6in]{geometry} +\usepackage{fancyvrb} +\usepackage{minted} \usepackage{amsfonts} \usepackage{kantlipsum} \usepackage{tabularx} @@ -48,7 +40,7 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% MAIN DOCUMENT \begin{document} - \title{The \tcthrm package} + \title{The \tcthrm package {\footnotesize(v1.0.2)}} \author{João M. Lourenço\\\texttt{\small joao.lourenco@fct.unl.pt}} \date{March 31, 2024} @@ -58,61 +50,98 @@ \section{Introduction} \label{sec:introduction} -The \tcthrm package is a simple environment, which takes no options, and that allows to write stuff inside boxes from \texttt{tcolorbox}. So, this packages includes \texttt{tcolorbox} if necessary. You may include \texttt{tcolorbox} with your own favourite options prior to including this package. +The \tcthrm package is a simple environment that allows to write stuff inside boxes from \texttt{tcolorbox}. If necessary the boxes gracefully overflow to the next page. This package takes no options and includes \texttt{tcolorbox} if necessary. You may include \texttt{tcolorbox} with your own favourite options prior to including this package. -Akin to \verb!\newtheorem! from the \verb!amsmath! package, the user should start by defining a new \emph{theorem/box} group and customize its aspect. Each new environment will have its own counter/numbering. Notice that \verb!\label{…}! and \verb!\ref{…}! work as expected. The is also a command to generate the corresponding \emph{list of …} +Akin to \mintinline{TeX}+\newtheorem+ from the \texttt{amsmath} package, the user should start by defining a new \emph{theorem/box} group and customize its aspect. Each new environment will have its own counter/numbering. Notice that \mintinline{TeX}+\label{…}+ and \mintinline{TeX}+\ref{…}+ work as expected. There is also a command to generate the corresponding \emph{list of …} \section{Usage} \label{sec:usage} -\begin{description} - \item[]{\bfseries\verb+\usepackage{coloredtheorem}+} - \begin{description} - \item[]Load the \texttt{coloredtheorem} package. This package will load \texttt{tcolorbox} if necessary. - \end{description} - \item[]{\bfseries\Verb[commandchars=!()]+\!tcbth()newtheorem{}{}[]+} - \begin{description} - \item[]\verb++ is the environment name, e.g., \verb!theorem!. - \item[]\verb++ is the name for new environment being defined, e.g., \emph{Theorem}. - \item[]\verb++ options to be passed to the \verb+tcolorbox+ environment to customize the boxes for the given environment (this argument is optional). - \end{description} - \item[]{\bfseries\Verb[commandchars=!()]+\begin{!tcbth()}{}[]\end{!tcbth()}+} - \begin{description} - \item[]\verb++ is the environment name, e.g., \verb+theorem+. - \item[]\verb++ is the caption/title of the box. - \item[]\verb++ options to be passed to the \verb+tcolobox+ environment, which will override the defaults given in \verb+\cthnewtheorem+. - \item[]\verb++ the contents to by typeset inside the coulored environment. - \end{description} - \item[]{\bfseries\Verb[commandchars=!()]+\!tcbth()listofs+} - \begin{description} - \item[]\verb++ is the environment name, e.g., e.g., \Verb[commandchars=!()]+\!tcbth()listoftheorems+. Please notice that there is a `s' (plural) after \verb++. - \end{description} -\end{description} +\definecolor{mycgreen}{RGB}{57,126,27} +\newcommand\ca[1]{\textcolor{blue}{#1}} +\newcommand\co[1]{\textcolor{blue!50}{#1}} +\newcommand\cc[1]{\textcolor{red!50!black}{#1}} +\newcommand\ck[1]{\textcolor{mycgreen}{#1}} + +\begin{itemize} + \item \mintinline{TeX}+\usepackage{coloredtheorem}+ + \begin{itemize} + \item Load the \texttt{coloredtheorem} package. + This package will load \texttt{tcolorbox} if necessary. + \end{itemize} + + \item \mintinline[escapeinside=||]{TeX}+\cthnewtheorem{|\ca{}|}{|\ca{}|}[|\co{}|]+ + \begin{itemize} + \item Create a new boxed \emph{algorithm-like} environment. + \begin{itemize} + \item \mintinline[escapeinside=||]{TeX}+|\ca{}|+ is the suffix for the + new environment being defined, e.g., \ca{\texttt{algoritm}}. The effective environment name will be \mintinline[escapeinside=||]{TeX}+|\ca{cth}|+, e.g., \ca{\texttt{cthalgorithm}}. + \item \mintinline[escapeinside=||]{TeX}+|\ca{}|+ is the (printable) name + or the new environment being defined, e.g., \emph{Algorithm}. + \item \mintinline[escapeinside=||]{TeX}+|\co{}|+ default + options for the environment being defined (this argument is optional). + These options are passed straight to the \texttt{tcolorbox} environment, + so anything valid for \texttt{tcolorbox} is also valid here. + \end{itemize} + \end{itemize} + + \item \begin{minted}[escapeinside=||]{TeX} +\begin{|\ca{ctb}|}[|\co{}|]{|\ca{}|}[|\co{}|] + |\cc{}| +\end{|\ca{ctb}|} +\end{minted} + \begin{itemize} + \item Create a new \emph{algorithm-like} box with the given contents. + \begin{itemize} + \item \mintinline[escapeinside=||]{TeX}+|\co{}|+ is the alternative + caption for the + \mintinline[escapeinside=||]{TeX}+\cthlistof|\ck{s}|+ + (see below). + \item \mintinline[escapeinside=||]{TeX}+|\ca{}|+ is the suffix for environment name, + e.g., \verb+algorithm+. + \item \mintinline[escapeinside=||]{TeX}+|\ca{}|+ is the caption/title of + the box. If the caption is left empty, this box will not be listed with the + \mintinline[escapeinside=||]{TeX}+\cthlistof|\ck{s}|+ + (see below). + \item \mintinline[escapeinside=||]{TeX}+|\co{}|+ options to be + passed to the \verb+tcolorbox+ environment, which will override the defaults + given in \mintinline{TeX}+\cthnewalgorithm+ (this argument is optional). + \item \mintinline[escapeinside=||]{TeX}+|\cc{}|+ the contents to by typeset inside the colored environment. + \end{itemize} + \end{itemize} + + \item \mintinline[escapeinside=||]{TeX}+\cthlistof|\ck{s}|+ + \begin{itemize} + \item \mintinline[escapeinside=||]{TeX}+|\ca{}|+ is the environment name + suffix, e.g., \mintinline[escapeinside=||]{TeX}+\cthlistofalgorithms+. + Please notice that there is a `s' (plural) after + \mintinline[escapeinside=||]{TeX}+|\ca{}|+. + \end{itemize} +\end{itemize} \section{Example} \label{sec:examples} Let's start by creating two new environments, one for \emph{algorithms} and another for \emph{examples}, both defaulting to a gray frame, the former with a yellowish background and the latter with a lighter gray background. -\begin{verbatim} -\cthnewtheorem{algorithm}{Algorithm}[coltitle=black, colback=yellow!10, - colframe=black!15] -\cthnewtheorem{example}{Example}[coltitle=black, colback=black!5, - colframe=black!30] -\end{verbatim} +\begin{minted}[bgcolor=red!5,fontsize=\small,escapeinside=||]{TeX} +\cthnewtheorem{|\ca{algorithm}|}{|\ca{Algorithm}|}[|\co{coltitle=}|black, |\co{colback=}|yellow!10, + |\co{colframe=}|black!15] +\cthnewtheorem{|\ca{example}|}{|\ca{Example}|}[|\co{coltitle=}|black, |\co{colback}|=black!5, + |\co{colframe=}|black!30] +\end{minted} \cthnewtheorem{algorithm}{Algorithm}[coltitle=black, colback=yellow!10, colframe=black!15] \cthnewtheorem{example}{Example}[coltitle=black, colback=black!5, colframe=black!30] -An algorithm box will be created with: -\begin{verbatim} -\begin{cthalgorithm}{Advance a counter to the next value in a domain - $\omega \in \mathbb{N}$.} - -Algorithm body here! -\end{cthalgorithm} -\end{verbatim} +The box with \autoref{alg:advance1}, which uses the default visual that was given when creating the environment with \mintinline{TeX}+\cthnewtheorem+ and gracefully overflows onto the next page, was created with: +\begin{minted}[bgcolor=red!5,fontsize=\small,escapeinside=||]{TeX} +\begin{|\ca{cthalgorithm}|}{|\co{Advance a counter to the next value in a domain}| + $\omega \in \mathbb{N}$.} + |\cc{Algorithm body here!}| +\end{|\ca{cthalgorithm}|} +\end{minted} \newcommand{\bracesemptyset}{\ensuremath{\lbrace\,\rbrace}} @@ -145,9 +174,34 @@ Algorithm body here! \end{algorithmic} \end{cthalgorithm} -Now, let's rewrite \autoref{alg:advance1}, but now with a different customized visual, just for this entry! The customization (3rd) argument is passed straight to the \texttt{tcolorbox} environment, so anything valid for \texttt{tcolorbox} is also valid here. +The box \autoref{expl:explstd}, which uses the default visual for the environment (as given to \mintinline{TeX}+\cthnewtheorem...+), was created with: -\begin{cthalgorithm}{Advance a counter to the next value in a domain $\omega \in \mathbb{N}$, but now with a customized visual. Also, notice that this algorithm breaks the page boundaries.}[coltitle=white, colback=green!10, colframe=green!70!black, fonttitle=\sffamily\bfseries\large, colbacktitle=red!50!white] +\begin{minted}[bgcolor=red!5,fontsize=\small,escapeinside=||]{TeX} +\begin{|\ca{cthexample}|}{|\co{This is an example!}|} + |\cc{Example body here!}| +\end{|\ca{cthexample}|} +\end{minted} + + +\begin{cthexample}{This is an example!} + \label{expl:explstd} + \emph{As is shown in the writings of Aristotle, the things in themselves (and it remains a mystery why this is the case) are a representation of time. Our concepts have lying before them the paralogisms of natural reason, but our a posteriori concepts have lying before them the practical emploument of our experience.} +\end{cthexample} + +Now, let's create a new box for \autoref{alg:advance1}, but with a different customized visual, which will affect only this entry! Notice that the customization argument is passed straight to the \texttt{tcolorbox} environment, so anything valid for \texttt{tcolorbox} is also valid here. \autoref{alg:advance2} was created with the following code: + +\begin{minted}[bgcolor=red!5,fontsize=\small,escapeinside=||]{TeX} +\begin{|\ca{cthalgorithm}|} + {|\ca{Advance a counter to the next value in a domain}| $\omega \in + \mathbb{N}$|\ca{, but now with a customized visual. Also, notice}| + |\ca{that this algorithm breaks the page boundaries.}|} + [|\co{coltitle}=|white, |\co{colback}=|green!10, |\co{colframe}=|green!70!black, + |\co{colbacktitle}=|\sffamily\bfseries\large, |\co{fonttitle}|=red!50!white] + |\cc{Algorithm body here!}| +\end{|\ca{cthalgorithm}|} +\end{minted} + +\begin{cthalgorithm}{Advance a counter to the next value in a domain $\omega \in \mathbb{N}$, but now with a customized visual. Notice that this algorithm also breaks the page boundaries.}[coltitle=white, colback=red!10, colframe=red!50!black, fonttitle=\sffamily\bfseries\large, colbacktitle=red!70!black] \label{alg:advance2} \begin{algorithmic}[1] \Statex \Input $\alpha$: The current value; and $\omega$: the domain. @@ -176,19 +230,13 @@ Now, let's rewrite \autoref{alg:advance1}, but now with a different customized v \end{algorithmic} \end{cthalgorithm} -Now, let's add an example here, this time using the default visual that was given when creating the environment with \verb+\cthnewtheorem+… - -\begin{cthexample}{This is an example!} - \emph{\kant[3]} -\end{cthexample} - -And now an example with no caption and a different visual… this example will not go into the \verb+\listofexamples+ below! +And now an example with no caption and a different visual… this example will not go into the \mintinline{TeX}+\listofexamples+ below! \begin{cthexample}{}[coltitle=yellow, colback=blue!30, colframe=blue!70] \emph{\kant[4]} \end{cthexample} -Now let's print the lists of algorithms and examples. Remember to add the prefix \texttt{cthth} to the \texttt{listof}, i.e., \verb+\cthlistofalgorithms+ and \verb+\cthlistofexamples+! +Now let's print the lists of algorithms and examples. Remember to add the prefix \ck{\texttt{cth}} to the \ck{\texttt{listof}}, i.e., \mintinline{TeX}+\cthlistofalgorithms+ and \mintinline{TeX}+\cthlistofexamples+! \cthlistofalgorithms diff --git a/Master/texmf-dist/tex/latex/coloredtheorem/coloredtheorem.sty b/Master/texmf-dist/tex/latex/coloredtheorem/coloredtheorem.sty index dd553ba75d2..4e128bf80bb 100644 --- a/Master/texmf-dist/tex/latex/coloredtheorem/coloredtheorem.sty +++ b/Master/texmf-dist/tex/latex/coloredtheorem/coloredtheorem.sty @@ -1,4 +1,4 @@ -%% This is file `tcbtheorem.sty', +%% This is file `coloredtheorem.sty', %% %% Copyright (C) 2024 by João Lourenço %% @@ -14,7 +14,7 @@ %% \NeedsTeXFormat{LaTeX2e}[2020/06/01] \ProvidesPackage{coloredtheorem} - [2024/03/31 v1.0 - a theorem-like environment inside a tcolobox] + [2024/04/03 v1.0.2 - A colorful boxed theorem environment] \RequirePackage{tcolorbox} \tcbuselibrary{breakable} @@ -36,15 +36,16 @@ \expandafter\NewDocumentEnvironment\expandafter{\tcbth#1} {O{} m O{}}% {% \begin{tcb} \begin{center}% - \ifx\relax##1\relax - \ifx\relax##2\relax\else - \expandafter\refstepcounter\expandafter{\tcbth#1}% + \ifx\relax##2\relax + \else + \expandafter\refstepcounter\expandafter{\tcbth#1}% + \ifx\relax##1\relax \expandafter\addcontentsline\expandafter{lo#1}{subsection} {\protect\numberline{\csname the\tcbth#1\endcsname}##2}% - \fi - \else - \expandafter\addcontentsline\expandafter{lo#1}{subsection} + \else + \expandafter\addcontentsline\expandafter{lo#1}{subsection} {\protect\numberline{\csname the\tcbth#1\endcsname}##1}% + \fi \fi \begin{tcolorbox}[breakable, title={\textbf{\csname\tcbth#1name\endcsname -- cgit v1.2.3