texlive[62401] Master/texmf-dist: create-theorem (4mar22)
commits+karl at tug.org
commits+karl at tug.org
Fri Mar 4 22:46:46 CET 2022
Revision: 62401
http://tug.org/svn/texlive?view=revision&revision=62401
Author: karl
Date: 2022-03-04 22:46:46 +0100 (Fri, 04 Mar 2022)
Log Message:
-----------
create-theorem (4mar22)
Modified Paths:
--------------
trunk/Master/texmf-dist/doc/latex/create-theorem/README.md
trunk/Master/texmf-dist/doc/latex/create-theorem/create-theorem-doc.pdf
trunk/Master/texmf-dist/doc/latex/create-theorem/create-theorem-doc.tex
trunk/Master/texmf-dist/tex/latex/create-theorem/create-theorem.sty
Modified: trunk/Master/texmf-dist/doc/latex/create-theorem/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/create-theorem/README.md 2022-03-04 21:46:28 UTC (rev 62400)
+++ trunk/Master/texmf-dist/doc/latex/create-theorem/README.md 2022-03-04 21:46:46 UTC (rev 62401)
@@ -2,7 +2,7 @@
# `create-theorem` - Initializing theorem-like environments with multilingual support
-The package `create-theorem` provides the commands `\NameTheorem` and `\CreateTheorem` for naming and initializing theorem-like environments. They both have key-value based interface and are especially useful in multi-language documents, allowing you to easily declare theorem-like environments that automatically adapt to the language settings.
+The package `create-theorem` provides the commands `\NameTheorem`, `\CreateTheorem` and `\SetTheorem` for naming, initializing and configuring theorem-like environments. All of these commands have key-value based interface and are especially useful in multi-language documents, allowing the easy declaration of theorem-like environments that can automatically adapt to the language settings.
*For more information, please refer to its documentation.*
Modified: trunk/Master/texmf-dist/doc/latex/create-theorem/create-theorem-doc.pdf
===================================================================
(Binary files differ)
Modified: trunk/Master/texmf-dist/doc/latex/create-theorem/create-theorem-doc.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/create-theorem/create-theorem-doc.tex 2022-03-04 21:46:28 UTC (rev 62400)
+++ trunk/Master/texmf-dist/doc/latex/create-theorem/create-theorem-doc.tex 2022-03-04 21:46:46 UTC (rev 62401)
@@ -5,10 +5,6 @@
\usepackage{ProjLib}
-\makeatletter
-\pretocmd{\@maketitle}{\vspace*{-2.5\baselineskip}}{}{}
-\makeatother
-
%%================================
%% For typesetting code
%%================================
@@ -41,7 +37,9 @@
Crefthe,Crefthename,
selectlanguage,
theoremstyle,
- NameTheorem, CreateTheorem,
+ NameTheorem,
+ CreateTheorem,
+ SetTheorem,
regexpatchcmd,
}
}
@@ -89,7 +87,7 @@
\title{\createtheorempackage{}\\\smallskip\itshape Initializing theorem-like environments with multilingual support}
\author{Jinwen XU}
-\thanks{Corresponding to: \texttt{\createtheorempackage{} 2022/03/01}}
+\thanks{Corresponding to: \texttt{\createtheorempackage{} 2022/03/03}}
\date{March 2022, in Paris}
\maketitle
@@ -96,7 +94,7 @@
\begin{abstract}
\raggedleft
- The package \createtheorempackage{} provides the commands \lstinline|\NameTheorem| and \lstinline|\CreateTheorem| for naming and initializing theorem-like environments. They both have key-value based interface and are especially useful in multi-language documents, allowing you to easily declare theorem-like environments that automatically adapt to the language settings.
+ The package \createtheorempackage{} provides commands for naming, initializing and configuring theorem-like environments. All of these commands have key-value based interface and \\are especially useful in multi-language documents, allowing the easy declaration of \\theorem-like environments that can automatically adapt to the language settings.
\end{abstract}
\vspace{-.5\baselineskip}
@@ -117,12 +115,13 @@
Since \createtheorempackage{} uses \textsf{cleveref} internally, it should usually be placed near the last of your preamble --- notably, it needs to be loaded after \textsf{varioref} and \textsf{hyperref}.
\end{tip}
+\medskip
It has the following options:
\begin{itemize}
- \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.
- \end{itemize}
+ % \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.
+ % \end{itemize}
\item \packageoption{name as context}
\begin{itemize}
\item When referencing, the names correspond to the current language context. For example, the English names will be displayed when referencing a theorem-like environment in English context, no matter which language context the original environment is in.
@@ -170,6 +169,11 @@
\end{code}
\end{itemize}
\end{itemize}
+ \item \commandoption{heading style}\lstinline| = |\meta{style}
+ \begin{itemize}
+ \item The style of the heading, you can specify the font, text style, color, etc.
+ \item Synonymous names: \commandoption{heading-style} \,$|$\, \commandoption{headingstyle}
+ \end{itemize}
\item \commandoption{crefname}\lstinline| = |\meta{configuration}
\begin{itemize}
\item The name for \lstinline|\cref| the environment, where \meta{configuration} can be:
@@ -187,13 +191,29 @@
[(*\meta{singular definite article}*)]{(*\meta{singular name}*)}[(*\meta{plural definite article}*)]{(*\meta{plural name}*)}
\end{code}
\end{itemize}
+ \item \commandoption{crefname style}\lstinline| = |\meta{style}
+ \begin{itemize}
+ \item The style of the ``crefname'', you can specify the font, text style, color, etc.
+ \item Synonymous names: \commandoption{crefname-style} \,$|$\, \commandoption{crefnamestyle}
+ \end{itemize}
\item \commandoption{Crefname}
\begin{itemize}
\item The name for \lstinline|\Cref| the environment, its syntax is the same as that of \commandoption{crefname}.
\item Also supports the syntax of \lstinline|\Crefthename|.
\end{itemize}
+ \item \commandoption{Crefname style}\lstinline| = |\meta{style}
+ \begin{itemize}
+ \item The style of the ``Crefname'', you can specify the font, text style, color, etc.
+ \item Synonymous names: \commandoption{Crefname-style} \,$|$\, \commandoption{Crefnamestyle}
+ \end{itemize}
+ \item \commandoption{numbering style}\lstinline| = |\meta{style}
+ \begin{itemize}
+ \item The style of numbering in the reference, you can specify the font, text style, color, etc.
+ \item Synonymous names: \commandoption{numbering-style} \,$|$\, \commandoption{numberingstyle}
+ \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.
@@ -216,8 +236,13 @@
\begin{itemize}
\item \commandoption{name}\lstinline| = |\meta{configuration}
\begin{itemize}
- \item Same as \lstinline|\NameTheorem{|\meta{name of environment}\lstinline|}{|\meta{configuration}\lstinline|}|.
+ \item Setting the names. Same as \lstinline|\NameTheorem{|\meta{name of environment}\lstinline|}{|\meta{configuration}\lstinline|}|.
\end{itemize}
+ \item \commandoption{name style}\lstinline| = |\meta{configuration}
+ \begin{itemize}
+ \item Setting the style of names. Same as using \lstinline|\NameTheorem|.
+ \item Synonymous names: \commandoption{name-style} \,$|$\, \commandoption{namestyle}
+ \end{itemize}
\item \commandoption{style}\lstinline| = |\meta{theorem style}
\begin{itemize}
\item Specifying the \lstinline|\theoremstyle| for the current environment.
@@ -256,11 +281,11 @@
\begin{center}
\itshape
- If you're feeling confused, don't worry, check out the Examples section below.
+ 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{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 define your own ones.
+ 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{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}
\medskip
@@ -267,15 +292,44 @@
Please note that, by default, an normal environment \meta{env} and its starred relative \meta{env}\texttt{*} do \emph{not} share the same set of names, for the sake of generality. However, with proper usage of \commandoption{create starred version} and \commandoption{copy existed}, you are already able to produce all of the following combinations that shares the same set of names: 1$)$ numbered \meta{env}, numbered \meta{env}\texttt{*} ; 2$)$ numbered \meta{env}, unnumbered \meta{env}\texttt{*} ; 3$)$ unnumbered \meta{env}, numbered \meta{env}\texttt{*} ; and 4$)$ unnumbered \meta{env}, unnumbered \meta{env}\texttt{*}. I left it as an easy exercise for you ;-)
-% \subsection[Configuring theorem-like environments]{Configuring theorem-like environments with \texttt{\textbackslash\textcolor{maintheme}{SetTheorem}}}
-% Even after defining the environments, you can still configure them with \lstinline|\SetTheorem|. The syntax of which is as follows:
+\bigskip
+\subsection[Configuring theorem-like environments]{Configuring theorem-like environments with \texttt{\textbackslash\textcolor{maintheme}{SetTheorem}}}
-% \begin{code}
-% \SetTheorem{(*\meta{list of the name of environments}*)}{(*\meta{key-value configuration}*)}
-% \end{code}
+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:
+\begin{code}
+\SetTheorem{(*\meta{list of the name of environments}*)}{(*\meta{key-value configuration}*)}
+\end{code}
+\begin{tip}
+ \lstinline|\SetTheorem| should only be used in the preamble of your document.
+\end{tip}
+
+Supported keys are:
+\vspace{-.2\baselineskip}
+\begin{itemize}
+ \item \commandoption{name style}\lstinline| = |\meta{configuration}
+ \begin{itemize}
+ \item Same as \lstinline|\NameTheorem{|\meta{name of environment}\lstinline|}{|\meta{configuration}\lstinline|}|.
+ \item Note that this configuration can overwrite those already specified in \lstinline|\NameTheorem|.
+ \item Synonymous names: \commandoption{name-style} \,$|$\, \commandoption{namestyle}
+ \end{itemize}
+ \item \commandoption{parent counter}\lstinline| = |\meta{parent counter}
+ \begin{itemize}
+ \item Specifying the \meta{parent counter} for the current environment, \emph{i.e.}, numbering will restart whenever that sectional level is encountered.
+ \item Note that this configuration can overwrite those already specified in \lstinline|\CreateTheorem|.
+ \item Synonymous names: \commandoption{parent-counter} \,$|$\, \commandoption{parentcounter} \,$|$\, \\\phantom{Synonymous names: }\commandoption{number within} \,$|$\, \commandoption{number-within} \,$|$\, \commandoption{numberwithin}
+ \end{itemize}
+ \item \commandoption{shared counter}\lstinline| = |\meta{shared counter}
+ \begin{itemize}
+ \item Specifying the \meta{shared counter} for the current environment, \emph{i.e.}, numbering will progress sequentially for all theorem-like environments using this counter.
+ \item Note that this configuration can overwrite those already specified in \lstinline|\CreateTheorem|.
+ \item Synonymous names: \commandoption{shared-counter} \,$|$\, \commandoption{sharedcounter} \,$|$\, \\\phantom{Synonymous names: }\commandoption{number like} \,$|$\, \commandoption{number-like} \,$|$\, \commandoption{numberlike}
+ \end{itemize}
+\end{itemize}
+
+
\section{Examples}
\subsection{The environment \texttt{idea}}
@@ -288,7 +342,7 @@
(*\commandoption{crefname}*) = {idea}{ideas},
(*\commandoption{Crefname}*) = {Idea}{Ideas},
}
-\CreateTheorem{idea}{ parent counter = section }
+\CreateTheorem{idea}{ (*\commandoption{parent counter}*) = section }
\end{code}
or to do it in one turn:
@@ -328,7 +382,7 @@
\subsection{Let's play with numbering}
-Remember the exercise I left you at the end of the previous section? Let's do it together now.
+Remember the exercise I left you in the previous section? Let's do it together now.
\subsubsection{Numbered \texttt{idea} and numbered \texttt{idea*}}
Modified: trunk/Master/texmf-dist/tex/latex/create-theorem/create-theorem.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/create-theorem/create-theorem.sty 2022-03-04 21:46:28 UTC (rev 62400)
+++ trunk/Master/texmf-dist/tex/latex/create-theorem/create-theorem.sty 2022-03-04 21:46:46 UTC (rev 62401)
@@ -13,14 +13,11 @@
\RequirePackage{l3keys2e}
\ProvidesExplPackage
{create-theorem}
- {2022/03/01} {}
+ {2022/03/03} {}
{Initializing theorem-like environments with multilingual support}
\keys_define:nn { create-theorem }
{
- , draft .bool_set:N = \l__crthm_fast_bool
- , draft .initial:n = { false }
- , fast .bool_set:N = \l__crthm_fast_bool
, name-as-context .bool_set:N = \l__crthm_regionalref_bool
, name-as-context .initial:n = { true }
, name~as~context .bool_set:N = \l__crthm_regionalref_bool
@@ -85,41 +82,74 @@
\keys_define:nn { create-theorem-naming }
{
- , heading .code:n = { \crthm_set_name_heading:ee { \l__crthm_current_env_tl } { #1 } }
- , heading .value_required:n = true
- , crefname .code:n = { \crthm_set_name_crefname:ee { \l__crthm_current_env_tl } { #1 } }
- , crefname .value_required:n = true
- , Crefname .code:n = { \crthm_set_name_Crefname:ee { \l__crthm_current_env_tl } { #1 } }
- , Crefname .value_required:n = true
- , unknown .code:n = {}
+ , heading .code:n = { \crthm_set_name_heading:en { \l__crthm_current_env_tl } { #1 } }
+ , heading .value_required:n = true
+ , crefname .code:n = { \crthm_set_name_crefname:en { \l__crthm_current_env_tl } { #1 } }
+ , crefname .value_required:n = true
+ , Crefname .code:n = { \crthm_set_name_Crefname:en { \l__crthm_current_env_tl } { #1 } }
+ , Crefname .value_required:n = true
+ , heading~style .code:n = { \crthm_set_name_style_heading:en { \l__crthm_current_env_tl } { #1 } }
+ , heading~style .value_required:n = true
+ , heading-style .meta:n = { heading~style = #1 }
+ , heading-style .value_required:n = true
+ , heading style .meta:n = { heading~style = #1 }
+ , heading style .value_required:n = true
+ , crefname~style .code:n = { \crthm_set_name_style_crefname:en { \l__crthm_current_env_tl } { #1 } }
+ , crefname~style .value_required:n = true
+ , crefname-style .meta:n = { crefname~style = #1 }
+ , crefname-style .value_required:n = true
+ , crefname style .meta:n = { crefname~style = #1 }
+ , crefname style .value_required:n = true
+ , Crefname~style .code:n = { \crthm_set_name_style_Crefname:en { \l__crthm_current_env_tl } { #1 } }
+ , Crefname~style .value_required:n = true
+ , Crefname-style .meta:n = { Crefname~style = #1 }
+ , Crefname-style .value_required:n = true
+ , Crefname style .meta:n = { Crefname~style = #1 }
+ , Crefname style .value_required:n = true
+ , numbering~style .code:n = { \crthm_set_name_style_numbering:en { \l__crthm_current_env_tl } { #1 } }
+ , numbering~style .value_required:n = true
+ , numbering-style .meta:n = { numbering~style = #1 }
+ , numbering-style .value_required:n = true
+ , numbering style .meta:n = { numbering~style = #1 }
+ , numbering style .value_required:n = true
+ , unknown .code:n = {}
}
-\cs_new:Nn \crthm_set_name_heading:nn
- % #1 = env name
- % #2 = the settings
+\cs_new:Nn \__crthm_set_generic:nnn
{
\str_if_in:nnTF { #2 } { = }
{% key-value definition
\keyval_parse:nnn
{}
- { \__crthm_set_name_heading:nnn { #1 } }
+ { \use:c { __crthm_ #3 :nnn } { #1 } }
{ #2 }
}
{% simple definition
\clist_map_inline:Nn \g_crthm_supported_language_clist
{
- \__crthm_set_name_heading:nnn { #1 } { ##1 } { #2 }
+ \use:c { __crthm_ #3 :nnn } { #1 } { ##1 } { #2 }
}
}
}
-\cs_generate_variant:Nn \crthm_set_name_heading:nn { ee }
+\cs_new:Nn \crthm_set_name_heading:nn
+ % #1 = env name
+ % #2 = the settings
+ {
+ \__crthm_set_generic:nnn { #1 } { #2 } { set_name_heading }
+ }
+\cs_generate_variant:Nn \crthm_set_name_heading:nn { en }
+
\cs_new:Nn \__crthm_set_name_heading:nnn
% #1 = env name
% #2 = language name
% #3 = corresponding heading name
{
- \tl_gset:cn { g_crthm_name_heading_ #1 _ #2 _tl } { #3 }
+ \tl_if_exist:cF { g_crthm_style_heading_ #1 _ #2 _tl }
+ {
+ \tl_new:c { g_crthm_style_heading_ #1 _ #2 _tl }
+ }
+ \tl_gset:cn { g_crthm_name_heading_ #1 _ #2 _tl } { \tl_use:c { g_crthm_style_heading_ #1 _ #2 _tl } { #3 } }
}
\cs_new:Nn \crthm_set_name_crefname:nn
@@ -128,7 +158,7 @@
{
\crthm_set_name_crefname_generic:nnn { #1 } { #2 } { c }
}
-\cs_generate_variant:Nn \crthm_set_name_crefname:nn { ee }
+\cs_generate_variant:Nn \crthm_set_name_crefname:nn { en }
\cs_new:Nn \crthm_set_name_Crefname:nn
% #1 = env name
@@ -136,7 +166,7 @@
{
\crthm_set_name_crefname_generic:nnn { #1 } { #2 } { C }
}
-\cs_generate_variant:Nn \crthm_set_name_Crefname:nn { ee }
+\cs_generate_variant:Nn \crthm_set_name_Crefname:nn { en }
\cs_new:Nn \crthm_set_name_crefname_generic:nnn
% #1 = env name
@@ -143,19 +173,7 @@
% #2 = the settings
% #3 = c or C
{
- \str_if_in:nnTF { #2 } { = }
- {% key-value definition
- \keyval_parse:nnn
- {}
- { \use:c { __crthm_set_name_ #3 refname:nnn } { #1 } }
- { #2 }
- }
- {% simple definition
- \clist_map_inline:Nn \g_crthm_supported_language_clist
- {
- \use:c { __crthm_set_name_ #3 refname:nnn } { #1 } { ##1 } { #2 }
- }
- }
+ \__crthm_set_generic:nnn { #1 } { #2 } { set_name_ #3 refname }
}
\cs_new:Nn \__crthm_set_name_crefname:nnn
@@ -181,22 +199,35 @@
{
\tl_if_blank:eTF { #3 }
{
- \tl_gset:cn { g_crthm_name_ #7 ref_article_singular_ #1 _ #2 _tl } { \crefthemark{ \!\! } }
- \tl_gset:cn { g_crthm_name_ #7 ref_article_plural_ #1 _ #2 _tl } { \crefthemark{ \!\! } }
+ \tl_gset:cn { g_crthm_name_ #7 ref_article_singular_ #1 _ #2 _tl } { \crefthemark{ \skip_horizontal:n { -1ex } } }
+ \tl_gset:cn { g_crthm_name_ #7 ref_article_plural_ #1 _ #2 _tl } { \crefthemark{ \skip_horizontal:n { -1ex } } }
}
{
\tl_gset:cn { g_crthm_name_ #7 ref_article_singular_ #1 _ #2 _tl } { \crefthemark { #3 } }
\tl_gset:cn { g_crthm_name_ #7 ref_article_plural_ #1 _ #2 _tl } { \crefthemark { #5 } }
}
- \tl_gset:cn { g_crthm_name_ #7 ref_singular_ #1 _ #2 _tl } { #4 }
- \tl_gset:cn { g_crthm_name_ #7 ref_plural_ #1 _ #2 _tl } { #6 }
+ \tl_if_exist:cF { g_crthm_style_ #7 refname_ #1 _ #2 _tl }
+ {
+ \tl_new:c { g_crthm_style_ #7 refname_ #1 _ #2 _tl }
+ }
+
+ \tl_gset:cn { g_crthm_name_ #7 ref_singular_ #1 _ #2 _tl } { \tl_use:c { g_crthm_style_ #7 refname_ #1 _ #2 _tl } { #4 } }
+ \tl_gset:cn { g_crthm_name_ #7 ref_plural_ #1 _ #2 _tl } { \tl_use:c { g_crthm_style_ #7 refname_ #1 _ #2 _tl } { #6 } }
+
\bool_if:NTF \l__crthm_regionalref_bool
{% "regionalref" mode
\use:c { __crthm_set_name_ #7 refname_do:nnn } { #1 _crthm_regional } { #1 } { \languagename }
}
{% "originalref" mode
- \tl_if_exist:cF { c@ #1 _crthm_original_ #2 } { \newaliascnt { #1 _crthm_original_ #2 } { #1 } }
+ \tl_if_exist:cF { c@ #1 _crthm_original_ #2 }
+ {
+ \newaliascnt { #1 _crthm_original_ #2 } { #1 }
+ \hook_gput_code:nnn { begindocument/before } { crthm }
+ {
+ \cs_set_eq:cc { the #1 _crthm_original_ #2 } { the #1 }
+ }
+ }
\use:c { __crthm_set_name_ #7 refname_do:nnn } { #1 _crthm_original_ #2 } { #1 } { #2 }
}
}
@@ -237,7 +268,8 @@
}
}
\tl_gset:cn { #4 ref@ #1 @name at plural }
- { % Use the definite article of the original language, with name's casing depends on the preposition and the article
+ { % Use the definite article of the original language,
+ % with name's casing depends on the preposition and the article
\tl_use:c { g_crthm_name_ #4 ref_article_plural_ #2 _ #3 _tl }
\bool_if:NTF \g__crefthe_has_prep_bool
{
@@ -247,113 +279,218 @@
\tl_use:c { g_crthm_name_ #4 ref_plural_ #2 _ #3 _tl }
}
}
- %% Use the definite article of the original language, with name's casing correspond to the article
- % \tl_gset:cn { #4 ref@ #1 @name }
- % {
- % \tl_use:c { g_crthm_name_ #4 ref_article_singular_ #2 _ #3 _tl }
- % \tl_use:c { g_crthm_name_ #4 ref_singular_ #2 _ #3 _tl }
- % }
- % \tl_gset:cn { #4 ref@ #1 @name at plural }
- % {
- % \tl_use:c { g_crthm_name_ #4 ref_article_plural_ #2 _ #3 _tl }
- % \tl_use:c { g_crthm_name_ #4 ref_plural_ #2 _ #3 _tl }
- % }
- %% Use the definite article of the current language, with name's casing correspond to the article
- % \tl_gset:cn { #4 ref@ #1 @name }
- % {
- % \tl_use:c { g_crthm_name_ #4 ref_article_singular_ #2 _ \languagename _tl }
- % \tl_use:c { g_crthm_name_ #4 ref_singular_ #2 _ #3 _tl }
- % }
- % \tl_gset:cn { #4 ref@ #1 @name at plural }
- % {
- % \tl_use:c { g_crthm_name_ #4 ref_article_plural_ #2 _ \languagename _tl }
- % \tl_use:c { g_crthm_name_ #4 ref_plural_ #2 _ #3 _tl }
- % }
\seq_if_in:NnF \g__crthm_format_already_set_seq { #2 _ #3 }
{
- \@crefcopyformats { #2 _ #3 } { #1 }
+ \@crefdefineallformats { #1 }
\seq_gput_right:Nn \g__crthm_format_already_set_seq { #2 _ #3 }
}
- \bool_if:NF \l__crthm_fast_bool
- { % Patch the cref formats so that definite articles are placed outside the hyperlinks
- \bool_if:NT \l__crthm_nameinlink_bool
- { % Use the definite article of the original language, with name's casing depends on the preposition and the article
- \crefthe_patch_format:nnnn { #4 ref@ #1 @format } { #4 ref@ #1 @name }
- { \tl_use:c { g_crthm_name_ #4 ref_article_singular_ #2 _ #3 _tl } }
- {
- \bool_if:NTF \g__crefthe_has_prep_bool
- {
- \tl_use:c { g_crthm_name_ cref_singular_ #2 _ #3 _tl }
- }
- {
- \tl_use:c { g_crthm_name_ #4 ref_singular_ #2 _ #3 _tl }
- }
- }
- \crefthe_patch_format:nnnn { #4 ref@ #1 @format at first } { #4 ref@ #1 @name at plural }
- { \tl_use:c { g_crthm_name_ #4 ref_article_plural_ #2 _ #3 _tl } }
- {
- \bool_if:NTF \g__crefthe_has_prep_bool
- {
- \tl_use:c { g_crthm_name_ cref_plural_ #2 _ #3 _tl }
- }
- {
- \tl_use:c { g_crthm_name_ #4 ref_plural_ #2 _ #3 _tl }
- }
- }
- \crefthe_patch_format:nnnn { #4 refrange@ #1 @format } { #4 ref@ #1 @name at plural }
- { \tl_use:c { g_crthm_name_ #4 ref_article_plural_ #2 _ #3 _tl } }
- {
- \bool_if:NTF \g__crefthe_has_prep_bool
- {
- \tl_use:c { g_crthm_name_ cref_plural_ #2 _ #3 _tl }
- }
- {
- \tl_use:c { g_crthm_name_ #4 ref_plural_ #2 _ #3 _tl }
- }
- }
- \crefthe_patch_format:nnnn { #4 refrange@ #1 @format at first } { #4 ref@ #1 @name at plural }
- { \tl_use:c { g_crthm_name_ #4 ref_article_plural_ #2 _ #3 _tl } }
- {
- \bool_if:NTF \g__crefthe_has_prep_bool
- {
- \tl_use:c { g_crthm_name_ cref_plural_ #2 _ #3 _tl }
- }
- {
- \tl_use:c { g_crthm_name_ #4 ref_plural_ #2 _ #3 _tl }
- }
- }
- %% Use the definite article of the original language, with name's casing correspond to the article
- % \crefthe_patch_format:nnnn { #4 ref@ #1 @format } { #4 ref@ #1 @name }
- % { \tl_use:c { g_crthm_name_ #4 ref_article_singular_ #2 _ #3 _tl } }
- % { \tl_use:c { g_crthm_name_ #4 ref_singular_ #2 _ #3 _tl } }
- % \crefthe_patch_format:nnnn { #4 ref@ #1 @format at first } { #4 ref@ #1 @name at plural }
- % { \tl_use:c { g_crthm_name_ #4 ref_article_plural_ #2 _ #3 _tl } }
- % { \tl_use:c { g_crthm_name_ #4 ref_plural_ #2 _ #3 _tl } }
- % \crefthe_patch_format:nnnn { #4 refrange@ #1 @format } { #4 ref@ #1 @name at plural }
- % { \tl_use:c { g_crthm_name_ #4 ref_article_plural_ #2 _ #3 _tl } }
- % { \tl_use:c { g_crthm_name_ #4 ref_plural_ #2 _ #3 _tl } }
- % \crefthe_patch_format:nnnn { #4 refrange@ #1 @format at first } { #4 ref@ #1 @name at plural }
- % { \tl_use:c { g_crthm_name_ #4 ref_article_plural_ #2 _ #3 _tl } }
- % { \tl_use:c { g_crthm_name_ #4 ref_plural_ #2 _ #3 _tl } }
- %% Use the definite article of the current language, with name's casing correspond to the article
- % \crefthe_patch_format:nnnn { #4 ref@ #1 @format } { #4 ref@ #1 @name }
- % { \tl_use:c { g_crthm_name_ #4 ref_article_singular_ #2 _ \languagename _tl } }
- % { \tl_use:c { g_crthm_name_ #4 ref_singular_ #2 _ #3 _tl } }
- % \crefthe_patch_format:nnnn { #4 ref@ #1 @format at first } { #4 ref@ #1 @name at plural }
- % { \tl_use:c { g_crthm_name_ #4 ref_article_plural_ #2 _ \languagename _tl } }
- % { \tl_use:c { g_crthm_name_ #4 ref_plural_ #2 _ #3 _tl } }
- % \crefthe_patch_format:nnnn { #4 refrange@ #1 @format } { #4 ref@ #1 @name at plural }
- % { \tl_use:c { g_crthm_name_ #4 ref_article_plural_ #2 _ \languagename _tl } }
- % { \tl_use:c { g_crthm_name_ #4 ref_plural_ #2 _ #3 _tl } }
- % \crefthe_patch_format:nnnn { #4 refrange@ #1 @format at first } { #4 ref@ #1 @name at plural }
- % { \tl_use:c { g_crthm_name_ #4 ref_article_plural_ #2 _ \languagename _tl } }
- % { \tl_use:c { g_crthm_name_ #4 ref_plural_ #2 _ #3 _tl } }
+ \tl_if_exist:cF { g_crthm_number_style_ #2 _tl }
+ {
+ \tl_new:c { g_crthm_number_style_ #2 _tl }
+ }
+
+ % Redefine the cref formats so that definite articles are placed outside the hyperlinks
+ \crthm_define_format_short_version:nnnn { #2 } { #4 ref@ #1 @format }
+ { \tl_use:c { g_crthm_name_ #4 ref_article_singular_ #2 _ #3 _tl } }
+ {
+ \bool_if:NTF \g__crefthe_has_prep_bool
+ {
+ \tl_use:c { g_crthm_name_ cref_singular_ #2 _ #3 _tl }
}
+ {
+ \tl_use:c { g_crthm_name_ #4 ref_singular_ #2 _ #3 _tl }
+ }
}
+ \crthm_define_format_short_version:nnnn { #2 } { #4 ref@ #1 @format at first }
+ { \tl_use:c { g_crthm_name_ #4 ref_article_plural_ #2 _ #3 _tl } }
+ {
+ \bool_if:NTF \g__crefthe_has_prep_bool
+ {
+ \tl_use:c { g_crthm_name_ cref_plural_ #2 _ #3 _tl }
+ }
+ {
+ \tl_use:c { g_crthm_name_ #4 ref_plural_ #2 _ #3 _tl }
+ }
+ }
+ \cs_set:cpn { #4 ref@ #1 @format at second } ##1##2##3
+ {
+ \crefpairconjunction
+ \crthm_format_short_generic:nnn { \tl_use:c { g_crthm_number_style_ #2 _tl } { ##1 } } { ##2 } { ##3 }
+ }
+ \cs_set:cpn { #4 ref@ #1 @format at middle } ##1##2##3
+ {
+ \crefmiddleconjunction
+ \crthm_format_short_generic:nnn { \tl_use:c { g_crthm_number_style_ #2 _tl } { ##1 } } { ##2 } { ##3 }
+ }
+ \cs_set:cpn { #4 ref@ #1 @format at last } ##1##2##3
+ {
+ \creflastconjunction
+ \crthm_format_short_generic:nnn { \tl_use:c { g_crthm_number_style_ #2 _tl } { ##1 } } { ##2 } { ##3 }
+ }
+
+ \crthm_define_format_long_version:nnnn { #2 } { #4 refrange@ #1 @format }
+ { \tl_use:c { g_crthm_name_ #4 ref_article_plural_ #2 _ #3 _tl } }
+ {
+ \bool_if:NTF \g__crefthe_has_prep_bool
+ {
+ \tl_use:c { g_crthm_name_ cref_plural_ #2 _ #3 _tl }
+ }
+ {
+ \tl_use:c { g_crthm_name_ #4 ref_plural_ #2 _ #3 _tl }
+ }
+ }
+ \crthm_define_format_long_version:nnnn { #2 } { #4 refrange@ #1 @format at first }
+ { \tl_use:c { g_crthm_name_ #4 ref_article_plural_ #2 _ #3 _tl } }
+ {
+ \bool_if:NTF \g__crefthe_has_prep_bool
+ {
+ \tl_use:c { g_crthm_name_ cref_plural_ #2 _ #3 _tl }
+ }
+ {
+ \tl_use:c { g_crthm_name_ #4 ref_plural_ #2 _ #3 _tl }
+ }
+ }
+ \cs_set:cpn { #4 refrange@ #1 @format at second } ##1##2##3##4##5##6
+ {
+ \crefpairconjunction
+ \crthm_format_long_generic:nnnnnn
+ { \tl_use:c { g_crthm_number_style_ #2 _tl } { ##1 } }
+ { \tl_use:c { g_crthm_number_style_ #2 _tl } { ##2 } }
+ { ##3 } { ##4 } { ##5 } { ##6 }
+ }
+ \cs_set:cpn { #4 refrange@ #1 @format at middle } ##1##2##3##4##5##6
+ {
+ \crefmiddleconjunction
+ \crthm_format_long_generic:nnnnnn
+ { \tl_use:c { g_crthm_number_style_ #2 _tl } { ##1 } }
+ { \tl_use:c { g_crthm_number_style_ #2 _tl } { ##2 } }
+ { ##3 } { ##4 } { ##5 } { ##6 }
+ }
+ \cs_set:cpn { #4 refrange@ #1 @format at last } ##1##2##3##4##5##6
+ {
+ \creflastconjunction
+ \crthm_format_long_generic:nnnnnn
+ { \tl_use:c { g_crthm_number_style_ #2 _tl } { ##1 } }
+ { \tl_use:c { g_crthm_number_style_ #2 _tl } { ##2 } }
+ { ##3 } { ##4 } { ##5 } { ##6 }
+ }
}
+\cs_new:Nn \crthm_define_format_short_version:nnnn
+ { % #1 = name of the environment
+ % #2 = name of the format command
+ % #3 = content before the hyperlink beginning mark
+ % #4 = content after the hyperlink beginning mark
+ \cs_if_exist:cF { crthm_format_ #2 :nnn }
+ {
+ \cs_new:cn { crthm_format_ #2 :nnn }
+ {
+ #3 ##2 #4 \nobreakspace { \tl_use:c { g_crthm_number_style_ #1 _tl } { ##1 } } ##3
+ }
+ \cs_set_eq:cc { #2 } { crthm_format_ #2 :nnn }
+ }
+ }
+\cs_new:Nn \crthm_define_format_long_version:nnnn
+ { % #1 = name of the environment
+ % #2 = name of the format command
+ % #3 = content before the hyperlink beginning mark
+ % #4 = content after the hyperlink beginning mark
+ \cs_if_exist:cF { crthm_format_ #2 :nnnnnn }
+ {
+ \cs_new:cn { crthm_format_ #2 :nnnnnn }
+ {
+ #3 ##3 #4
+ \nobreakspace \crefrangepreconjunction
+ { \tl_use:c { g_crthm_number_style_ #1 _tl } { ##1 } }
+ ##4 \crefrangeconjunction
+ ##5 { \tl_use:c { g_crthm_number_style_ #1 _tl } { ##2 } } ##6
+ \crefrangepostconjunction
+ }
+ \cs_set_eq:cc { #2 } { crthm_format_ #2 :nnnnnn }
+ }
+ }
+
+\cs_new:Nn \crthm_format_short_generic:nnn
+ {
+ #2 { #1 } #3
+ }
+\cs_new:Nn \crthm_format_long_generic:nnnnnn
+ {
+ \crefrangepreconjunction
+ #3 { #1 } #4
+ \crefrangeconjunction
+ #5 { #2 } #6
+ \crefrangepostconjunction
+ }
+
+
+\cs_new:Nn \crthm_set_name_style_heading:nn
+ % #1 = env name
+ % #2 = the settings
+ {
+ \__crthm_set_generic:nnn { #1 } { #2 } { set_name_style_heading }
+ }
+\cs_generate_variant:Nn \crthm_set_name_style_heading:nn { en }
+
+\cs_new:Nn \__crthm_set_name_style_heading:nnn
+ % #1 = env name
+ % #2 = language name
+ % #3 = corresponding heading style
+ {
+ \tl_gset:cn { g_crthm_style_heading_ #1 _ #2 _tl } { \normalfont #3 }
+ }
+
+\cs_new:Nn \crthm_set_name_style_crefname:nn
+ % #1 = env name
+ % #2 = the settings
+ {
+ \__crthm_set_generic:nnn { #1 } { #2 } { set_name_style_crefname }
+ }
+\cs_generate_variant:Nn \crthm_set_name_style_crefname:nn { en }
+
+\cs_new:Nn \__crthm_set_name_style_crefname:nnn
+ % #1 = env name
+ % #2 = language name
+ % #3 = corresponding crefname style
+ {
+ \tl_gset:cn { g_crthm_style_crefname_ #1 _ #2 _tl } { \normalfont #3 }
+ }
+
+\cs_new:Nn \crthm_set_name_style_Crefname:nn
+ % #1 = env name
+ % #2 = the settings
+ {
+ \__crthm_set_generic:nnn { #1 } { #2 } { set_name_style_Crefname }
+ }
+\cs_generate_variant:Nn \crthm_set_name_style_Crefname:nn { en }
+
+\cs_new:Nn \__crthm_set_name_style_Crefname:nnn
+ % #1 = env name
+ % #2 = language name
+ % #3 = corresponding Crefname style
+ {
+ \tl_gset:cn { g_crthm_style_Crefname_ #1 _ #2 _tl } { \normalfont #3 }
+ }
+
+\cs_new:Nn \crthm_set_name_style_numbering:nn
+ % #1 = env name
+ % #2 = the settings
+ {
+ \__crthm_set_generic:nnn { #1 } { #2 } { set_name_style_numbering }
+ }
+\cs_generate_variant:Nn \crthm_set_name_style_numbering:nn { en }
+
+\cs_new:Nn \__crthm_set_name_style_numbering:nnn
+ % #1 = env name
+ % #2 = language name
+ % #3 = corresponding numbering style
+ {
+ \tl_gset:cn { g_crthm_number_style_ #1 _tl } { #3 }
+ }
+
+
\NewDocumentCommand \NameTheorem { m m }
{
\crthm_name_theorem:nn { #1 } { #2 }
@@ -362,10 +499,14 @@
\cs_new:Nn \crthm_name_theorem:nn
{
\tl_set:Nn \l__crthm_current_env_tl { #1 }
- \newcounter { #1 }
+ \cs_if_exist:cF { c@ #1 }
+ {
+ \newcounter { #1 }
+ }
\keys_set:nn { create-theorem-naming } { #2 }
}
+
\bool_new:N \l__crthm_creating_apply_style_bool
\tl_new:N \l__crthm_creating_apply_style_tl
\bool_new:N \l__crthm_creating_numberless_bool
@@ -376,6 +517,12 @@
{
, name .code:n = { \exp_args:Ne \NameTheorem { \l__crthm_current_env_tl } { #1 } }
, name .value_required:n = true
+ , name~style .code:n = { \exp_args:Ne \NameTheorem { \l__crthm_current_env_tl } { #1 } }
+ , name~style .value_required:n = true
+ , name-style .meta:n = { name~style = #1 }
+ , name-style .value_required:n = true
+ , name style .meta:n = { name~style = #1 }
+ , name style .value_required:n = true
, style .code:n = { \bool_set_true:N \l__crthm_creating_apply_style_bool
\tl_set:Nn \l__crthm_creating_apply_style_tl { #1 } }
, style .value_required:n = true
@@ -399,12 +546,14 @@
, copy-existed .value_required:n = true
, copy existed .meta:n = { copy~existed = #1 }
, copy existed .value_required:n = true
+ , quiet .bool_set:N = \l__crthm_creating_quiet_bool
+ , quiet .initial:n = { false }
, unknown .code:n = {}
}
\keys_define:nn { create-theorem-creating / counter-management }
{
- , parent~counter .code:n = { \crthm_counter_within:ee { \l__crthm_current_env_tl } { #1 } }
+ , parent~counter .code:n = { \crthm_counter_within:en { \l__crthm_current_env_tl } { #1 } }
, parent~counter .value_required:n = true
, parent-counter .meta:n = { parent~counter = #1 }
, parent-counter .value_required:n = true
@@ -416,7 +565,7 @@
, number-within .value_required:n = true
, number within .meta:n = { parent~counter = #1 }
, number within .value_required:n = true
- , shared~counter .code:n = { \crthm_counter_alias:ee { \l__crthm_current_env_tl } { #1 } }
+ , shared~counter .code:n = { \crthm_counter_alias:en { \l__crthm_current_env_tl } { #1 } }
, shared~counter .value_required:n = true
, shared-counter .meta:n = { shared~counter = #1 }
, shared-counter .value_required:n = true
@@ -431,6 +580,7 @@
, unknown .code:n = {}
}
+
\NewDocumentCommand \CreateTheorem { m m }
{
\clist_map_inline:nn { #1 }
@@ -439,8 +589,26 @@
}
}
+\msg_new:nnn { create-theorem }
+ { env-not-created }
+ { The~theorem-like~environment~"#1"~cannot~be~created,~an~environment~with~the~same~name~has~already~existed. }
+
\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
@@ -449,10 +617,10 @@
\keys_set:nn { create-theorem-creating } { #2 }
\bool_if:NTF \l__crthm_creating_copy_existed_bool
{
- \__crthm_define_env:ee { #1 } { \l__crthm_creating_copy_existed_tl }
+ \__crthm_define_env:en { #1 } { \l__crthm_creating_copy_existed_tl }
\bool_if:NT \l__crthm_creating_create_starred_bool
{
- \__crthm_define_env:ee { #1 * } { \l__crthm_creating_copy_existed_tl * }
+ \__crthm_define_env:en { #1 * } { \l__crthm_creating_copy_existed_tl * }
}
}
{
@@ -473,7 +641,13 @@
% 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"
{
- \begin{ #1 _crthm_regional }[##1]
+ \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 }
@@ -496,13 +670,13 @@
\cs_set_eq:cc { #1 } { #2 }
\cs_set_eq:cc { end #1 } { end #2 }
}
-\cs_generate_variant:Nn \__crthm_define_env:nn { ee }
+\cs_generate_variant:Nn \__crthm_define_env:nn { en }
\cs_new:Nn \crthm_counter_within:nn
{
\counterwithin { #1 } { #2 }
}
-\cs_generate_variant:Nn \crthm_counter_within:nn { ee }
+\cs_generate_variant:Nn \crthm_counter_within:nn { en }
\cs_new:Nn \crthm_counter_alias:nn
{
@@ -509,9 +683,57 @@
\cs_set_eq:cc { c@ #1 } { c@ #2 }
\cs_set_eq:cc { the #1 } { the #2 }
}
-\cs_generate_variant:Nn \crthm_counter_alias:nn { ee }
+\cs_generate_variant:Nn \crthm_counter_alias:nn { en }
+\keys_define:nn { create-theorem-setting }
+ {
+ , name .code:n = { \exp_args:Ne \NameTheorem { \l__crthm_current_env_tl } { #1 } }
+ , name .value_required:n = true
+ , name~style .code:n = { \exp_args:Ne \NameTheorem { \l__crthm_current_env_tl } { #1 } }
+ , name~style .value_required:n = true
+ , name-style .meta:n = { name~style = #1 }
+ , name-style .value_required:n = true
+ , name style .meta:n = { name~style = #1 }
+ , name style .value_required:n = true
+ , parent~counter .code:n = { \crthm_counter_within:en { \l__crthm_current_env_tl } { #1 } }
+ , parent~counter .value_required:n = true
+ , parent-counter .meta:n = { parent~counter = #1 }
+ , parent-counter .value_required:n = true
+ , parent counter .meta:n = { parent~counter = #1 }
+ , parent counter .value_required:n = true
+ , number~within .meta:n = { parent~counter = #1 }
+ , number~within .value_required:n = true
+ , number-within .meta:n = { parent~counter = #1 }
+ , number-within .value_required:n = true
+ , number within .meta:n = { parent~counter = #1 }
+ , number within .value_required:n = true
+ , shared~counter .code:n = { \crthm_counter_alias:en { \l__crthm_current_env_tl } { #1 } }
+ , shared~counter .value_required:n = true
+ , shared-counter .meta:n = { shared~counter = #1 }
+ , shared-counter .value_required:n = true
+ , shared counter .meta:n = { shared~counter = #1 }
+ , shared counter .value_required:n = true
+ , number~like .meta:n = { shared~counter = #1 }
+ , number~like .value_required:n = true
+ , number-like .meta:n = { shared~counter = #1 }
+ , number-like .value_required:n = true
+ , number like .meta:n = { shared~counter = #1 }
+ , number like .value_required:n = true
+ , unknown .code:n = {}
+ }
+
+
+\NewDocumentCommand \SetTheorem { m m }
+ {
+ \clist_map_inline:nn { #1 }
+ {
+ \tl_set:Nn \l__crthm_current_env_tl { ##1 }
+ \keys_set:nn { create-theorem-setting } { #2 }
+ }
+ }
+
+
\bool_if:NF \l__crthm_presetname_bool { \endinput }
More information about the tex-live-commits
mailing list.