summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/create-theorem
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2022-04-03 03:00:36 +0000
committerNorbert Preining <norbert@preining.info>2022-04-03 03:00:36 +0000
commit506de1e2d3515161cdbc7018b4ccc9e49d7f86e8 (patch)
tree45724bd3d77239b332b9251b099af3b16e8b8108 /macros/latex/contrib/create-theorem
parent0a334de875944625912f2bf2d918122bb55c0dad (diff)
CTAN sync 202204030300
Diffstat (limited to 'macros/latex/contrib/create-theorem')
-rw-r--r--macros/latex/contrib/create-theorem/create-theorem-doc.pdfbin117509 -> 117843 bytes
-rw-r--r--macros/latex/contrib/create-theorem/create-theorem-doc.tex126
-rw-r--r--macros/latex/contrib/create-theorem/create-theorem.sty105
3 files changed, 117 insertions, 114 deletions
diff --git a/macros/latex/contrib/create-theorem/create-theorem-doc.pdf b/macros/latex/contrib/create-theorem/create-theorem-doc.pdf
index 4f64d0b5d5..58aaba6d86 100644
--- a/macros/latex/contrib/create-theorem/create-theorem-doc.pdf
+++ b/macros/latex/contrib/create-theorem/create-theorem-doc.pdf
Binary files differ
diff --git a/macros/latex/contrib/create-theorem/create-theorem-doc.tex b/macros/latex/contrib/create-theorem/create-theorem-doc.tex
index 526eb15385..cefc160ade 100644
--- a/macros/latex/contrib/create-theorem/create-theorem-doc.tex
+++ b/macros/latex/contrib/create-theorem/create-theorem-doc.tex
@@ -1,64 +1,76 @@
%! TEX program = xelatex
\documentclass[classical]{einfart}
-% \linenumbers
-
\usepackage{ProjLib}
%%================================
%% For typesetting code
%%================================
\usepackage{listings}
-\definecolor{maintheme}{RGB}{70,130,180}
-\definecolor{forestgreen}{RGB}{21,122,81}
-\definecolor{lightergray}{gray}{0.99}
-\lstset{language=[LaTeX]TeX,
- keywordstyle=\color{maintheme},
- basicstyle=\ttfamily,
- commentstyle=\color{forestgreen}\ttfamily,
- stringstyle=\rmfamily,
- showstringspaces=false,
- breaklines=true,
- frame=lines,
- backgroundcolor=\color{lightergray},
- flexiblecolumns=true,
- escapeinside={(*}{*)},
- % numbers=left,
- numberstyle=\scriptsize, stepnumber=1, numbersep=5pt,
- % firstnumber=last,
+\usepackage{xcolor}
+\usepackage{setspace}
+\definecolor{code-main}{RGB}{70,130,180}
+\definecolor{code-expl3}{RGB}{240,50,60}
+\definecolor{code-option}{RGB}{40,110,20}
+\definecolor{code-keys}{RGB}{100,130,150}
+\definecolor{code-comment}{RGB}{20,120,80}
+\definecolor{code-background}{gray}{0.99}
+\lstset{
+ language = [LaTeX]TeX,
+ basicstyle = \ttfamily,
+ keywordstyle = \color{code-main},
+ commentstyle = \color{code-comment},
+ showstringspaces = false,
+ breaklines = true,
+ frame = lines,
+ backgroundcolor = \color{code-background},
+ flexiblecolumns = true,
+ escapeinside = {(*}{*)},
+ alsoletter = {_,:},
+ % numbers = left,
+ % firstnumber = last,
+ numberstyle = \scriptsize\ttfamily,
+ stepnumber = 1,
+ numbersep = 5pt,
}
-\providecommand{\meta}[1]{$\langle${\normalfont\itshape#1}$\rangle$}
-\lstset{moretexcs=%
- {
+\newcommand{\meta}[1]{$\langle${\normalfont\itshape#1}$\rangle$}
+\lstset{% LaTeX2 commands
+ classoffset = 0,
+ texcsstyle =* \color{code-main},
+ moretexcs =
+ {
cref,crefname,
Cref,Crefname,
crefformat,
- crefthe,crefthename,crefthemark,
+ crefthe,crefthename,
Crefthe,Crefthename,
+ crefthemark,
selectlanguage,
theoremstyle,
NameTheorem,
CreateTheorem,
SetTheorem,
- regexpatchcmd,
- }
-}
-\lstnewenvironment{code}%
-{\setstretch{1.07}\LocallyStopLineNumbers%
-\setkeys{lst}{columns=fullflexible,keepspaces=true}%
+ }
}
-{\ResumeLineNumbers\vspace{-.25\baselineskip}}
-\lstnewenvironment{code*}%
-{\setstretch{1.07}\LocallyStopLineNumbers%
-\setkeys{lst}{numbers=left,columns=fullflexible,keepspaces=true}%
+\lstset{% LaTeX3 commands
+ classoffset = 1,
+ texcsstyle =* \color{code-expl3},
+ moretexcs =
+ {
+ }
}
-{\ResumeLineNumbers}
+\lstnewenvironment{code}{\setstretch{1.05}\LocallyStopLineNumbers}{\ResumeLineNumbers\vspace{-.3\baselineskip}\vspace{-.5\parskip}}
+\lstnewenvironment{code*}{\setstretch{1.05}\lstset{numbers=left}\LocallyStopLineNumbers}{\ResumeLineNumbers\vspace{-.3\baselineskip}\vspace{-.5\parskip}}
+
+\newcommand{\packageoption}[1]{\texttt{\textcolor{code-option}{#1}}}
+\newcommand{\commandoption}[1]{\texttt{\textcolor{code-keys}{#1}}}
%%================================
%% tip
%%================================
\usepackage[many]{tcolorbox}
-\newenvironment{tip}[1][Tip]{%
+\newenvironment{tip}[1][Tip]
+ {%
\LocallyStopLineNumbers%
\begin{tcolorbox}[breakable,
enhanced,
@@ -74,18 +86,18 @@
top = 2.5mm,
bottom = 1.5mm,
title={\scshape\sffamily #1}]%
-}{\end{tcolorbox}\ResumeLineNumbers}
-
-
-\newcommand{\packageoption}[1]{\texttt{\textcolor{black!67!green}{#1}}}
-\newcommand{\commandoption}[1]{\texttt{\textcolor{black!67!cyan}{#1}}}
+ }
+ {%
+ \end{tcolorbox}%
+ \ResumeLineNumbers%
+ }
\newcommand{\createtheorempackage}{\textsf{create-theorem}}
\begin{document}
-\def\PackageVersion{2022/03/18}
+\def\PackageVersion{2022/04/02}
\title{\createtheorempackage{}\\\smallskip\itshape Initializing theorem-like environments with multilingual support}
\author{Jinwen XU}
@@ -119,7 +131,7 @@ First, you need a backend to provide the command \lstinline|\newtheorem| with th
\medskip
It has the following options:
-\begin{itemize}
+\begin{itemize}[label=,leftmargin=1.25em,itemindent=-1.25em]
% \item \packageoption{draft} or \packageoption{fast}
% \begin{itemize}
% \item Fast mode. The functionality will be appropriately reduced to get faster compilation speed, recommended to use during the writing stage.
@@ -148,7 +160,7 @@ It has the following options:
\section{How to use it}
-\subsection[Naming theorem-like environments]{Naming theorem-like environments with \texttt{\textbackslash\textcolor{maintheme}{NameTheorem}}}
+\subsection[Naming theorem-like environments]{Naming theorem-like environments with \texttt{\textbackslash\textcolor{code-main}{NameTheorem}}}
The syntax of \lstinline|\NameTheorem| is as follows:
\begin{code}
@@ -157,7 +169,7 @@ The syntax of \lstinline|\NameTheorem| is as follows:
Supported keys are:
\vspace{-.2\baselineskip}
-\begin{itemize}
+\begin{itemize}[label=,leftmargin=1.25em,itemindent=-1.25em]
\item \commandoption{heading}\lstinline| = |\meta{configuration}
\begin{itemize}
\item The heading of the environment, where \meta{configuration} can be:
@@ -215,18 +227,13 @@ Supported keys are:
\end{itemize}
\end{itemize}
-\medskip
-\begin{center}
- \itshape
- If you're feeling confused, don't worry, there is an Examples section later illustrating its usage.
-\end{center}
-
+\vspace{-.3\baselineskip}
\begin{tip}
You can also define the names within \lstinline|\CreateTheorem| while initializing the theorem-like environments. \lstinline|\NameTheorem| is especially useful for package or class authors who wish to preset suitable names (with styles) in their packages or classes.
\end{tip}
-\subsection[Initializing theorem-like environments]{Initializing theorem-like environments with \texttt{\textbackslash\textcolor{maintheme}{CreateTheorem}}}
+\subsection[Initializing theorem-like environments]{Initializing theorem-like environments with \texttt{\textbackslash\textcolor{code-main}{CreateTheorem}}}
The syntax of \lstinline|\CreateTheorem| is as follows:
\begin{code}
@@ -235,7 +242,7 @@ The syntax of \lstinline|\CreateTheorem| is as follows:
Supported keys are:
\vspace{-.2\baselineskip}
-\begin{itemize}
+\begin{itemize}[label=,leftmargin=1.25em,itemindent=-1.25em]
\item \commandoption{name}\lstinline| = |\meta{configuration}
\begin{itemize}
\item Setting the names. Same as \lstinline|\NameTheorem{|\meta{name of environment}\lstinline|}{|\meta{configuration}\lstinline|}|.
@@ -281,11 +288,6 @@ Supported keys are:
\end{itemize}
\end{itemize}
-\begin{center}
- \itshape
- If you're feeling confused, don't worry, there is an Examples section later illustrating its usage.
-\end{center}
-
\begin{tip}
The names for the following environments have been preset: \texttt{assertion}, \texttt{assumption}, \texttt{axiom}, \texttt{conclusion}, \texttt{conjecture}, \texttt{convention}, \texttt{corollary}, \texttt{definition}, \texttt{definition-proposition}, \texttt{definition-theorem}, \texttt{example}, \texttt{exercise}, \texttt{fact}, \texttt{hypothesis}, \texttt{lemma}, \texttt{notation}, \texttt{observation}, \texttt{postulate}, \texttt{problem}, \texttt{property}, \texttt{proposition}, \texttt{question}, \texttt{remark} and \texttt{theorem}. If you are fine with the preset names, then you don't need to specify the key ``\commandoption{name}'' while creating them, otherwise you shall have to use the package option ``\packageoption{no preset names}'' to disable the presets and then define your own ones.
\end{tip}
@@ -296,7 +298,7 @@ Please note that, by default, an normal environment \meta{env} and its starred r
\bigskip
-\subsection[Configuring theorem-like environments]{Configuring theorem-like environments with \texttt{\textbackslash\textcolor{maintheme}{SetTheorem}}}
+\subsection[Configuring theorem-like environments]{Configuring theorem-like environments with \texttt{\textbackslash\textcolor{code-main}{SetTheorem}}}
The previous two commands are especially useful for package or class writers, while this one is more for the users. If you are not satisfied with preset name styles or numbering settings, then even after initializing the environments, you can still further configure them by means of \lstinline|\SetTheorem|, the syntax of which is as follows:
@@ -310,7 +312,7 @@ The previous two commands are especially useful for package or class writers, wh
Supported keys are:
\vspace{-.2\baselineskip}
-\begin{itemize}
+\begin{itemize}[label=,leftmargin=1.25em,itemindent=-1.25em]
\item \commandoption{name}\lstinline| = |\meta{configuration} and \commandoption{name style}\lstinline| = |\meta{configuration}
\begin{itemize}
\item Same as \lstinline|\NameTheorem{|\meta{name of environment}\lstinline|}{|\meta{configuration}\lstinline|}|.
@@ -331,6 +333,12 @@ Supported keys are:
\end{itemize}
\end{itemize}
+\bigskip
+\begin{center}
+ \itshape
+ If you're feeling confused, don't worry. Let's now take a look at some examples.
+\end{center}
+
\section{Examples}
diff --git a/macros/latex/contrib/create-theorem/create-theorem.sty b/macros/latex/contrib/create-theorem/create-theorem.sty
index b86af841ee..2156f23ecd 100644
--- a/macros/latex/contrib/create-theorem/create-theorem.sty
+++ b/macros/latex/contrib/create-theorem/create-theorem.sty
@@ -13,7 +13,7 @@
\RequirePackage{l3keys2e}
\ProvidesExplPackage
{create-theorem}
- {2022/03/18} {}
+ {2022/04/02} {}
{Initializing theorem-like environments with multilingual support}
\keys_define:nn { create-theorem }
@@ -611,20 +611,6 @@
\cs_new:Nn \crthm_create_theorem:nn
{
- \cs_if_exist:cTF { #1 }
- {
- \bool_if:NF \l__crthm_creating_quiet_bool
- {
- \msg_warning:nnn { create-theorem } { env-not-created } { #1 }
- }
- }
- {
- \__crthm_create_theorem:nn { #1 } { #2 }
- }
- }
-
-\cs_new:Nn \__crthm_create_theorem:nn
- {
\tl_set:Nn \l__crthm_current_env_tl { #1 }
\bool_set_false:N \l__crthm_creating_apply_style_bool
\bool_set_false:N \l__crthm_creating_numberless_bool
@@ -633,72 +619,81 @@
\keys_set:nn { create-theorem-creating } { #2 }
\bool_if:NTF \l__crthm_creating_copy_existed_bool
{
- \__crthm_define_env:en { #1 } { \l__crthm_creating_copy_existed_tl }
+ \__crthm_copy_env:ee { \l__crthm_current_env_tl } { \l__crthm_creating_copy_existed_tl }
\bool_if:NT \l__crthm_creating_create_starred_bool
{
- \__crthm_define_env:en { #1 * } { \l__crthm_creating_copy_existed_tl * }
+ \__crthm_copy_env:ee { \l__crthm_current_env_tl * } { \l__crthm_creating_copy_existed_tl * }
}
}
{
- \cs_if_exist:cTF { c@ #1 }
+ \cs_if_exist:cTF { #1 }
{
- \group_begin:
- \bool_if:NTF \l__crthm_creating_apply_style_bool
+ \bool_if:NF \l__crthm_creating_quiet_bool
{
- \exp_args:No \theoremstyle { \l__crthm_creating_apply_style_tl }
+ \msg_warning:nnn { create-theorem } { env-not-created } { #1 }
}
+ }
+ {
+ \cs_if_exist:cTF { c@ #1 }
{
- \tl_if_exist:cT { c_crthm_theorem_style_preset_ #1 _tl }
+ \group_begin:
+ \bool_if:NTF \l__crthm_creating_apply_style_bool
{
- \exp_args:Nv \theoremstyle { c_crthm_theorem_style_preset_ #1 _tl }
+ \exp_args:No \theoremstyle { \l__crthm_creating_apply_style_tl }
}
- }
- \bool_if:NTF \l__crthm_creating_numberless_bool
- {
- \newtheorem*{ #1 _crthm_regional } { \tl_use:c { g_crthm_name_heading_ #1 _ \languagename _tl } }
- }
- {
- \newtheorem { #1 _crthm_regional } [#1] { \tl_use:c { g_crthm_name_heading_ #1 _ \languagename _tl } }
- }
- \group_end:
- \NewDocumentEnvironment { #1 } { O{} }
- % In "regionalref" mode, the counter received by the referencing system is "#1 _crthm_regional"
- % while in "originalref" mode, the counter received is "#1 _crthm_original_\languagename"
- {
- \tl_if_blank:eTF { ##1 }
{
- \begin{ #1 _crthm_regional }
+ \tl_if_exist:cT { c_crthm_theorem_style_preset_ #1 _tl }
+ {
+ \exp_args:Nv \theoremstyle { c_crthm_theorem_style_preset_ #1 _tl }
+ }
}
+ \bool_if:NTF \l__crthm_creating_numberless_bool
{
- \begin{ #1 _crthm_regional }[##1]
+ \newtheorem*{ #1 _crthm_regional } { \tl_use:c { g_crthm_name_heading_ #1 _ \languagename _tl } }
}
- \bool_if:NF \l__crthm_regionalref_bool
- {
- \addtocounter { #1 _crthm_original_\languagename } { -1 }
- \refstepcounter { #1 _crthm_original_\languagename }
- }
- }
- {
- \end{ #1 _crthm_regional }
+ {
+ \newtheorem { #1 _crthm_regional } [#1] { \tl_use:c { g_crthm_name_heading_ #1 _ \languagename _tl } }
+ }
+ \group_end:
+ \NewDocumentEnvironment { #1 } { O{} }
+ % In "regionalref" mode, the counter received by the referencing system is "#1 _crthm_regional"
+ % while in "originalref" mode, the counter received is "#1 _crthm_original_\languagename"
+ {
+ \tl_if_blank:eTF { ##1 }
+ {
+ \begin{ #1 _crthm_regional }
+ }
+ {
+ \begin{ #1 _crthm_regional }[##1]
+ }
+ \bool_if:NF \l__crthm_regionalref_bool
+ {
+ \addtocounter { #1 _crthm_original_\languagename } { -1 }
+ \refstepcounter { #1 _crthm_original_\languagename }
+ }
+ }
+ {
+ \end{ #1 _crthm_regional }
+ }
+ \bool_if:NT \l__crthm_creating_create_starred_bool
+ {
+ \newtheorem*{ #1 * } { \tl_use:c { g_crthm_name_heading_ #1 _ \languagename _tl } }
+ }
+ \keys_set:nn { create-theorem-creating / counter-management } { #2 }
}
- \bool_if:NT \l__crthm_creating_create_starred_bool
{
- \newtheorem*{ #1 * } { \tl_use:c { g_crthm_name_heading_ #1 _ \languagename _tl } }
+ \msg_error:nnn { create-theorem } { env-not-named } { #1 }
}
- \keys_set:nn { create-theorem-creating / counter-management } { #2 }
- }
- {
- \msg_error:nnn { create-theorem } { env-not-named } { #1 }
}
}
}
-\cs_new:Nn \__crthm_define_env:nn
+\cs_new:Nn \__crthm_copy_env:nn
{
\cs_set_eq:cc { #1 } { #2 }
\cs_set_eq:cc { end #1 } { end #2 }
}
-\cs_generate_variant:Nn \__crthm_define_env:nn { en }
+\cs_generate_variant:Nn \__crthm_copy_env:nn { ee }
\cs_new:Nn \crthm_counter_within:nn
{