From e247b78b2fce9bdb26193826aca0a62ae26c8a8b Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Sun, 17 Apr 2022 03:03:02 +0000 Subject: CTAN sync 202204170303 --- .../contrib/create-theorem/create-theorem-doc.pdf | Bin 117843 -> 119390 bytes .../contrib/create-theorem/create-theorem-doc.tex | 26 ++- .../contrib/create-theorem/create-theorem.sty | 221 +++++++++++++-------- 3 files changed, 149 insertions(+), 98 deletions(-) (limited to 'macros/latex/contrib/create-theorem') diff --git a/macros/latex/contrib/create-theorem/create-theorem-doc.pdf b/macros/latex/contrib/create-theorem/create-theorem-doc.pdf index 58aaba6d86..0d2a1a19bb 100644 Binary files a/macros/latex/contrib/create-theorem/create-theorem-doc.pdf and b/macros/latex/contrib/create-theorem/create-theorem-doc.pdf differ diff --git a/macros/latex/contrib/create-theorem/create-theorem-doc.tex b/macros/latex/contrib/create-theorem/create-theorem-doc.tex index cefc160ade..e6f8b84538 100644 --- a/macros/latex/contrib/create-theorem/create-theorem-doc.tex +++ b/macros/latex/contrib/create-theorem/create-theorem-doc.tex @@ -97,7 +97,7 @@ \begin{document} -\def\PackageVersion{2022/04/02} +\def\PackageVersion{2022/04/16} \title{\createtheorempackage{}\\\smallskip\itshape Initializing theorem-like environments with multilingual support} \author{Jinwen XU} @@ -122,7 +122,7 @@ First, you need a backend to provide the command \lstinline|\newtheorem| with the usual behaviour, for example, \textsf{amsthm}. After that, you can simply load the current package with: \begin{code} -\usepackage{create-theorem} +\usepackage[(*\meta{options}*)]{create-theorem} \end{code} \begin{tip} @@ -207,7 +207,7 @@ Supported keys are: \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 The style of the \textquote{crefname}, you can specify the font, text style, color, etc. \item Synonymous names: \commandoption{crefname-style} \,$|$\, \commandoption{crefnamestyle} \end{itemize} \item \commandoption{Crefname} @@ -217,7 +217,7 @@ Supported keys are: \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 The style of the \textquote{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} @@ -225,6 +225,11 @@ Supported keys are: \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} + \item \commandoption{use name}\lstinline| = |\meta{list of existed environment(s) separated with semicolon \textquote{ ; }} + \begin{itemize} + \item Use the name(s) and style(s) of given environment(s). If there are multiple ones specified, the result would be a string combining the names, separated with \textquote{\texttt{-}}. + \item Synonymous names: \commandoption{combined} \,$|$\, \commandoption{use-name} \,$|$\, \commandoption{usename} + \end{itemize} \end{itemize} \vspace{-.3\baselineskip} @@ -243,14 +248,15 @@ The syntax of \lstinline|\CreateTheorem| is as follows: Supported keys are: \vspace{-.2\baselineskip} \begin{itemize}[label=,leftmargin=1.25em,itemindent=-1.25em] - \item \commandoption{name}\lstinline| = |\meta{configuration} + \item \commandoption{name}\lstinline| = |\meta{configuration} \quad or \quad \commandoption{name style}\lstinline| = |\meta{configuration} \begin{itemize} \item Setting the names. Same as \lstinline|\NameTheorem{|\meta{name of environment}\lstinline|}{|\meta{configuration}\lstinline|}|. + \item Synonymous names: \commandoption{name-style} \,$|$\, \commandoption{namestyle} \end{itemize} - \item \commandoption{name style}\lstinline| = |\meta{configuration} + \item \commandoption{use name}\lstinline| = |\meta{list of existed environment(s) separated with semicolon \textquote{ ; }} \begin{itemize} - \item Setting the style of names. Same as using \lstinline|\NameTheorem|. - \item Synonymous names: \commandoption{name-style} \,$|$\, \commandoption{namestyle} + \item Using existed name(s). Same as in \lstinline|\NameTheorem|. + \item Synonymous names: \commandoption{combined} \,$|$\, \commandoption{use-name} \,$|$\, \commandoption{usename} \end{itemize} \item \commandoption{style}\lstinline| = |\meta{theorem style} \begin{itemize} @@ -289,7 +295,7 @@ Supported keys are: \end{itemize} \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. + The names for the following environments have been preset: \texttt{application}, \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 there is no need to specify the key \textquote{\commandoption{name}} while creating them, otherwise you shall have to use the package option \textquote{\packageoption{no preset names}} to disable the presets and then define your own ones. \end{tip} \medskip @@ -385,7 +391,7 @@ This is not exciting at all. Now, let's say we are writing a bilingual note in E } \end{code} -With this, if you use \lstinline|\selectlanguage{french}|, the \texttt{idea} environment shall be automatically displayed as ``Idée''. And if you \lstinline|\crefthe| it, the definite article and the name showed up properly just as expected. +With this, if you use \lstinline|\selectlanguage{french}|, the \texttt{idea} environment shall be automatically displayed as \textquote{Idée}. And if you \lstinline|\crefthe| it, the definite article and the name showed up properly just as expected. \medskip Next we shall deal with the numbering problem. Let's continue to use this environment \texttt{idea} for demonstration -- suppose that we have set the names up with \lstinline|\NameTheorem|. diff --git a/macros/latex/contrib/create-theorem/create-theorem.sty b/macros/latex/contrib/create-theorem/create-theorem.sty index 2156f23ecd..73d9302416 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/04/02} {} + {2022/04/16} {} {Initializing theorem-like environments with multilingual support} \keys_define:nn { create-theorem } @@ -112,6 +112,14 @@ , numbering-style .value_required:n = true , numbering style .meta:n = { numbering~style = { #1 } } , numbering style .value_required:n = true + , use~name .code:n = { \crthm_set_name_with_existed_names:en { \l__crthm_current_env_tl } { #1 } } + , use~name .value_required:n = true + , use-name .meta:n = { use~name = { #1 } } + , use-name .value_required:n = true + , use name .meta:n = { use~name = { #1 } } + , use name .value_required:n = true + , combined .meta:n = { use~name = { #1 } } + , combined .value_required:n = true , unknown .code:n = {} } @@ -199,10 +207,15 @@ { \tl_if_blank:eTF { #3 } { - \tl_gset:cn { g_crthm_name_ #7 ref_article_singular_ #1 _ #2 _tl } { \crefthemark{ \skip_horizontal:n { -.5ex } } } - \tl_gset:cn { g_crthm_name_ #7 ref_article_plural_ #1 _ #2 _tl } { \crefthemark{ \skip_horizontal:n { -.5ex } } } + %% The spacing here is rather strange, but I haven't came up with a better method yet + \tl_gset:cn { g_crthm_core_name_ #7 ref_article_singular_ #1 _ #2 _tl } { \skip_horizontal:n { -.75ex } } + \tl_gset:cn { g_crthm_core_name_ #7 ref_article_plural_ #1 _ #2 _tl } { \skip_horizontal:n { -.75ex } } + \tl_gset:cn { g_crthm_name_ #7 ref_article_singular_ #1 _ #2 _tl } { \crefthemark { \skip_horizontal:n { -.5ex } } } + \tl_gset:cn { g_crthm_name_ #7 ref_article_plural_ #1 _ #2 _tl } { \crefthemark { \skip_horizontal:n { -.5ex } } } } { + \tl_gset:cn { g_crthm_core_name_ #7 ref_article_singular_ #1 _ #2 _tl } { #3 } + \tl_gset:cn { g_crthm_core_name_ #7 ref_article_plural_ #1 _ #2 _tl } { #5 } \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 } } } @@ -503,6 +516,67 @@ } +\tl_new:N \g_crthm_combined_name_sep_tl +\tl_gset:Nn \g_crthm_combined_name_sep_tl { - } + +\cs_new:Nn \crthm_set_name_with_existed_names:nn + % #1 = env name + % #2 = list of existed environments + { + \clist_map_inline:Nn \g_crthm_supported_language_clist + { % ##1 = language name + \seq_gclear_new:c { g_crthm_name_heading_ #1 _ ##1 _seq } + \seq_gclear_new:c { g_crthm_name_cref_article_singular_ #1 _ ##1 _seq } + \seq_gclear_new:c { g_crthm_name_cref_article_plural_ #1 _ ##1 _seq } + \seq_gclear_new:c { g_crthm_name_cref_singular_ #1 _ ##1 _seq } + \seq_gclear_new:c { g_crthm_name_cref_plural_ #1 _ ##1 _seq } + \seq_gclear_new:c { g_crthm_name_Cref_article_singular_ #1 _ ##1 _seq } + \seq_gclear_new:c { g_crthm_name_Cref_article_plural_ #1 _ ##1 _seq } + \seq_gclear_new:c { g_crthm_name_Cref_singular_ #1 _ ##1 _seq } + \seq_gclear_new:c { g_crthm_name_Cref_plural_ #1 _ ##1 _seq } + \bool_set_true:N \l_tmpa_bool + \regex_split:nnN { \s* ; \s* } { #2 } { \l_tmpa_seq } + \seq_map_inline:Nn \l_tmpa_seq + { % ####1 = existed environments + \bool_if:NT \l_tmpa_bool + { % use the first environment's definite article as that of the combined environment + \tl_gset:cn { g_crthm_saved_name_cref_article_singular_ #1 _ ##1 _tl } { \tl_use:c { g_crthm_core_name_cref_article_singular_ ####1 _ ##1 _tl } } + \tl_gset:cn { g_crthm_saved_name_cref_article_plural_ #1 _ ##1 _tl } { \tl_use:c { g_crthm_core_name_cref_article_plural_ ####1 _ ##1 _tl } } + \tl_gset:cn { g_crthm_saved_name_Cref_article_singular_ #1 _ ##1 _tl } { \tl_use:c { g_crthm_core_name_Cref_article_singular_ ####1 _ ##1 _tl } } + \tl_gset:cn { g_crthm_saved_name_Cref_article_plural_ #1 _ ##1 _tl } { \tl_use:c { g_crthm_core_name_Cref_article_plural_ ####1 _ ##1 _tl } } + \bool_set_false:N \l_tmpa_bool + } + \seq_gput_right:cn { g_crthm_name_heading_ #1 _ ##1 _seq } { \tl_use:c { g_crthm_name_heading_ ####1 _ ##1 _tl } } + \seq_gput_right:cn { g_crthm_name_cref_singular_ #1 _ ##1 _seq } { \tl_use:c { g_crthm_name_cref_singular_ ####1 _ ##1 _tl } } + \seq_gput_right:cn { g_crthm_name_cref_plural_ #1 _ ##1 _seq } { \tl_use:c { g_crthm_name_cref_plural_ ####1 _ ##1 _tl } } + \seq_gput_right:cn { g_crthm_name_Cref_singular_ #1 _ ##1 _seq } { \tl_use:c { g_crthm_name_Cref_singular_ ####1 _ ##1 _tl } } + \seq_gput_right:cn { g_crthm_name_Cref_plural_ #1 _ ##1 _seq } { \tl_use:c { g_crthm_name_Cref_plural_ ####1 _ ##1 _tl } } + % set the numbering style to be the same as the last environment + \tl_gset:cn { g_crthm_number_style_ #1 _tl } { \tl_use:c { g_crthm_number_style_ ####1 _tl } } + } + % set heading name for the combined environment + \tl_gset:cn { g_crthm_name_heading_ #1 _ ##1 _tl } { \seq_use:cn { g_crthm_name_heading_ #1 _ ##1 _seq } { \g_crthm_combined_name_sep_tl } } + % set crefname for the combined environment + \__crthm_set_name_crefname:nnn { #1 } { ##1 } + { + [ \tl_use:c { g_crthm_saved_name_cref_article_singular_ #1 _ ##1 _tl } ] + { \seq_use:cn { g_crthm_name_cref_singular_ #1 _ ##1 _seq } { \g_crthm_combined_name_sep_tl } } + [ \tl_use:c { g_crthm_saved_name_cref_article_plural_ #1 _ ##1 _tl } ] + { \seq_use:cn { g_crthm_name_cref_plural_ #1 _ ##1 _seq } { \g_crthm_combined_name_sep_tl } } + } + % set Crefname for the combined environment + \__crthm_set_name_Crefname:nnn { #1 } { ##1 } + { + [ \tl_use:c { g_crthm_saved_name_Cref_article_singular_ #1 _ ##1 _tl } ] + { \seq_use:cn { g_crthm_name_Cref_singular_ #1 _ ##1 _seq } { \g_crthm_combined_name_sep_tl } } + [ \tl_use:c { g_crthm_saved_name_Cref_article_plural_ #1 _ ##1 _tl } ] + { \seq_use:cn { g_crthm_name_Cref_plural_ #1 _ ##1 _seq } { \g_crthm_combined_name_sep_tl } } + } + } + } +\cs_generate_variant:Nn \crthm_set_name_with_existed_names:nn { en } + + \NewDocumentCommand \NameTheorem { m m } { \crthm_name_theorem:nn { #1 } { #2 } @@ -535,6 +609,14 @@ , name-style .value_required:n = true , name style .meta:n = { name~style = { #1 } } , name style .value_required:n = true + , use~name .code:n = { \exp_args:Ne \NameTheorem { \l__crthm_current_env_tl } { use~name = #1 } } + , use~name .value_required:n = true + , use-name .meta:n = { use~name = { #1 } } + , use-name .value_required:n = true + , use name .meta:n = { use~name = { #1 } } + , use name .value_required:n = true + , combined .meta:n = { use~name = { #1 } } + , combined .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 @@ -659,7 +741,7 @@ % 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 } + \tl_if_blank:nTF { ##1 } { \begin{ #1 _crthm_regional } } @@ -764,6 +846,49 @@ % --- Preset Names --- %============================= +\NameTheorem { application } + { + , heading = { + , english = Application + , french = Application + , ngerman = Anwendung + , italian = Applicazione + , portuguese = Aplicação + , brazilian = Aplicação + , spanish = Aplicación + , schinese = 应用 + , tchinese = 應用 + , japanese = 応用 + , russian = Применение + } + , crefname = { + , english = {application}{applications} + , french = [l']{application}[les]{applications} + , ngerman = {Anwendung}{Anwendungen} + , italian = [l']{applicazione}[le]{applicazioni} + , portuguese = [a]{aplicação}[as]{aplicações} + , brazilian = [a]{aplicação}[as]{aplicações} + , spanish = [la]{aplicación}[las]{aplicaciones} + , schinese = {应用}{应用} + , tchinese = {應用}{應用} + , japanese = {応用}{応用} + , russian = {применение}{приложения} + } + , Crefname = { + , english = {Application}{Applications} + , french = [L']{application}[Les]{applications} + , ngerman = {Anwendung}{Anwendungen} + , italian = [L']{applicazione}[Le]{applicazioni} + , portuguese = [A]{aplicação}[As]{aplicações} + , brazilian = [A]{aplicação}[As]{aplicações} + , spanish = [La]{aplicación}[Las]{aplicaciones} + , schinese = {应用}{应用} + , tchinese = {應用}{應用} + , japanese = {応用}{応用} + , russian = {Применение}{Приложения} + } + } + \NameTheorem { assertion } { , heading = { @@ -1710,91 +1835,11 @@ } } -\NameTheorem { definition-proposition } - { - , heading = { - , english = Definition-Proposition - , french = Définition-Proposition - , ngerman = Definition-Proposition - , italian = Definizione-Proposizione - , portuguese = Definição-Proposição - , brazilian = Definição-Proposição - , spanish = Definición-Proposición - , schinese = 定义-命题 - , tchinese = 定義-命題 - , japanese = 定義-命題 - , russian = Определение-Предложение - } - , crefname = { - , english = {definition-proposition}{definition-propositions} - , french = [la]{définition-proposition}[les]{définition-propositions} - , ngerman = {Definition-Proposition}{Definitionen-Propositionen} - , italian = [la]{definizione-proposizione}[le]{definizioni-proposte} - , portuguese = [a]{definição-proposição}[as]{definições-proposições} - , brazilian = [a]{definição-proposição}[as]{definições-proposições} - , spanish = [la]{definición-proposición}[las]{definiciones-proposiciones} - , schinese = {定义-命题}{定义-命题} - , tchinese = {定義-命題}{定義-命題} - , japanese = {定義-命題}{定義-命題} - , russian = {определение-предложение}{определения-предложения} - } - , Crefname = { - , english = {Definition-proposition}{Definition-propositions} - , french = [La]{définition-proposition}[Les]{définition-propositions} - , ngerman = {Definition-Proposition}{Definitionen-Propositionen} - , italian = [La]{definizione-proposizione}[Le]{definizioni-proposte} - , portuguese = [A]{definição-proposição}[As]{definições-proposições} - , brazilian = [A]{definição-proposição}[As]{definições-proposições} - , spanish = [La]{definición-proposición}[Las]{definiciones-proposiciones} - , schinese = {定义-命题}{定义-命题} - , tchinese = {定義-命題}{定義-命題} - , japanese = {定義-命題}{定義-命題} - , russian = {Определение-предложение}{Определения-предложения} - } - } +\NameTheorem { definition-proposition } { combined = { definition ; proposition } } +\NameTheorem { definition-theorem } { combined = { definition ; theorem } } -\NameTheorem { definition-theorem } - { - , heading = { - , english = Definition-Theorem - , french = Définition-Théorème - , ngerman = Definition-Satz - , italian = Definizione-Teorema - , portuguese = Definição-Teorema - , brazilian = Definição-Teorema - , spanish = Definición-Teorema - , schinese = 定义-定理 - , tchinese = 定義-定理 - , japanese = 定義-定理 - , russian = Определение-Теорема - } - , crefname = { - , english = {definition-theorem}{definition-theorems} - , french = [la]{définition-théorème}[les]{définition-théorèmes} - , ngerman = {Definition-Satz}{Definitionen-Sätze} - , italian = [la]{definizione-teorema}[le]{definizioni-teoremi} - , portuguese = [a]{definição-teorema}[as]{definições-teoremas} - , brazilian = [a]{definição-teorema}[as]{definições-teoremas} - , spanish = [la]{definición-teorema}[las]{definiciones-teoremas} - , schinese = {定义-定理}{定义-定理} - , tchinese = {定義-定理}{定義-定理} - , japanese = {定義-定理}{定義-定理} - , russian = {определение-теорема}{определения-теоремы} - } - , Crefname = { - , english = {Definition-theorem}{Definition-theorems} - , french = [La]{définition-théorème}[Les]{définition-théorèmes} - , ngerman = {Definition-Satz}{Definitionen-Sätze} - , italian = [La]{definizione-teorema}[Le]{definizioni-teoremi} - , portuguese = [A]{definição-teorema}[As]{definições-teoremas} - , brazilian = [A]{definição-teorema}[As]{definições-teoremas} - , spanish = [La]{definición-teorema}[Las]{definiciones-teoremas} - , schinese = {定义-定理}{定义-定理} - , tchinese = {定義-定理}{定義-定理} - , japanese = {定義-定理}{定義-定理} - , russian = {Определение-теорема}{Определения-теоремы} - } - } +\NameTheorem { proposition-definition } { combined = { proposition ; definition } } +\NameTheorem { theorem-definition } { combined = { theorem ; definition } } \endinput %% -- cgit v1.2.3