texlive[64044] Master/texmf-dist: create-theorem (4aug22)

commits+karl at tug.org commits+karl at tug.org
Thu Aug 4 22:32:32 CEST 2022


Revision: 64044
          http://tug.org/svn/texlive?view=revision&revision=64044
Author:   karl
Date:     2022-08-04 22:32:32 +0200 (Thu, 04 Aug 2022)
Log Message:
-----------
create-theorem (4aug22)

Modified Paths:
--------------
    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/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-08-04 20:32:19 UTC (rev 64043)
+++ trunk/Master/texmf-dist/doc/latex/create-theorem/create-theorem-doc.tex	2022-08-04 20:32:32 UTC (rev 64044)
@@ -39,6 +39,8 @@
     texcsstyle =* \color{code-main},
     moretexcs =
       {
+        ExplSyntaxOn,ExplSyntaxOff,
+        NewDocumentCommand,NewDocumentEnvironment,
         cref,crefname,
         Cref,Crefname,
         crefformat,
@@ -47,9 +49,11 @@
         crefthemark,
         selectlanguage,
         theoremstyle,
+        proofname,
         NameTheorem,
         CreateTheorem,
         SetTheorem,
+        SetTheoremBinding,
       }
 }
 \lstset{% LaTeX3 commands
@@ -57,6 +61,9 @@
     texcsstyle =* \color{code-expl3},
     moretexcs =
       {
+        tl_new:N,
+        tl_set:Nn,
+        cs_undefine:c,
       }
 }
 \lstnewenvironment{code}{\setstretch{1.05}\LocallyStopLineNumbers}{\ResumeLineNumbers\vspace{-.3\baselineskip}\vspace{-.5\parskip}}
@@ -97,7 +104,7 @@
 
 \begin{document}
 
-\def\PackageVersion{2022/07/31}
+\def\PackageVersion{2022/08/04}
 
 \title{\createtheorempackage{}\\\smallskip\itshape Initializing theorem-like environments with multilingual support}
 \author{Jinwen XU}
@@ -357,6 +364,12 @@
         \end{itemize}
 \end{itemize}
 
+\medskip
+In some cases, you may define an internal environment (for example, a generic version) first and then use it to define the final environment. You may wish to hide the internal names from the users so that they can use \lstinline|\SetTheorem| with the name of the final environments. This can be done with the following command:
+\begin{code}
+\SetTheoremBinding{(*\meta{list of the name of environments}*)}{(*\meta{the environment to bind with}*)}
+\end{code}
+
 \bigskip
 \begin{center}
     \itshape
@@ -366,9 +379,9 @@
 
 \section{Examples}
 
-\subsection{The environment \texttt{idea}}
+\subsection{The environment {\normalfont\texttt{idea}}}
 
-First, let's getting familiar with these two commands by creating the environment \texttt{idea}.
+First, let's getting familiar with these two commands by creating the environment {\normalfont\texttt{idea}}.
 
 \begin{code}
 \NameTheorem{idea}{
@@ -409,16 +422,16 @@
 }
 \end{code}
 
-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.
+With this, if you use \lstinline|\selectlanguage{french}|, the {\normalfont\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|.
+Next we shall deal with the numbering problem. Let's continue to use this environment {\normalfont\texttt{idea}} for demonstration -- suppose that we have set the names up with \lstinline|\NameTheorem|.
 
 \subsection{Let's play with numbering}
 
 Remember the exercise I left you in the previous section? Let's do it together now.
 
-\subsubsection{Numbered \texttt{idea} and numbered \texttt{idea*}}
+\subsubsection{Numbered {\normalfont\texttt{idea}} and numbered {\normalfont\texttt{idea*}}}
 
 This is easy, \commandoption{copy existed} suffices:
 
@@ -427,7 +440,7 @@
 \CreateTheorem{idea*}{(*\commandoption{copy existed}*) = idea}
 \end{code}
 
-\subsubsection{Numbered \texttt{idea} and unnumbered \texttt{idea*}}
+\subsubsection{Numbered {\normalfont\texttt{idea}} and unnumbered {\normalfont\texttt{idea*}}}
 
 This is the easiest, \commandoption{create starred version} will do.
 
@@ -438,11 +451,11 @@
 }
 \end{code}
 
-Notice that you cannot use \lstinline|\CreateTheorem{idea*}{|\commandoption{numberless}\lstinline|}| here, since we don't have names defined for \texttt{idea*}.
+Notice that you cannot use \lstinline|\CreateTheorem{idea*}{|\commandoption{numberless}\lstinline|}| here, since we don't have names defined for {\normalfont\texttt{idea*}}.
 
-\subsubsection{Unnumbered \texttt{idea} and numbered \texttt{idea*}}
+\subsubsection{Unnumbered {\normalfont\texttt{idea}} and numbered {\normalfont\texttt{idea*}}}
 
-This is a bit tricky: by default we can only create numbered \texttt{idea} or unnumbered \texttt{idea*}, and the question is how to switch them. We shall need an intermediary.
+This is a bit tricky: by default we can only create numbered {\normalfont\texttt{idea}} or unnumbered {\normalfont\texttt{idea*}}, and the question is how to switch them. We shall need an intermediary.
 
 \begin{code}
 \CreateTheorem{idea}{(*\commandoption{create starred version}*)}
@@ -451,9 +464,9 @@
 \CreateTheorem{idea}{(*\commandoption{copy existed}*) = idea-temp}
 \end{code}
 
-\subsubsection{Unnumbered \texttt{idea} and unnumbered \texttt{idea*}}
+\subsubsection{Unnumbered {\normalfont\texttt{idea}} and unnumbered {\normalfont\texttt{idea*}}}
 
-This is the combination of the first two cases --- we need to create \texttt{idea*} first and then copy it to \texttt{idea}:
+This is the combination of the first two cases --- we need to create {\normalfont\texttt{idea*}} first and then copy it to {\normalfont\texttt{idea}}:
 
 \begin{code}
 \CreateTheorem{idea}{(*\commandoption{create starred version}*)}
@@ -461,7 +474,7 @@
 \end{code}
 
 \smallskip
-In each case, the two environments \texttt{idea} and \texttt{idea*} share the same set of names.
+In each case, the two environments {\normalfont\texttt{idea}} and {\normalfont\texttt{idea*}} share the same set of names.
 
 \subsection{The \emph{proofless} version -- theorems with a Q.E.D. symbol}
 
@@ -473,9 +486,54 @@
 \CreateTheorem { theorem+* } { (*\commandoption{copy existed}*) = theorem*, (*\commandoption{qed}*) }
 \end{code}
 
-The code above defines two new environments \lstinline|theorem+| and \lstinline|theorem+*| in addition to \lstinline|theorem| and \lstinline|theorem*|. The \lstinline|+| version behaves exactly the same as the usual version, except it has a Q.E.D. symbol.
+The code above defines two new environments \lstinline|theorem+| and \lstinline|theorem+*| in addition to \lstinline|theorem| and \lstinline|theorem*|. The \lstinline|+| version behaves exactly the same as the usual version, except that it has a Q.E.D. symbol.
 
+\subsection{Redefine the {\normalfont\texttt{proof}} environment}
 
+If you wish to have a {\normalfont\texttt{proof}} environment with a custom theorem style, or to have a numbered version {\normalfont\texttt{proof*}} of it, the following code could be helpful:
+
+\begin{code}
+\ExplSyntaxOn
+
+\newcounter { proof }
+\tl_new:N \l_mymodule_name_of_proof_tl
+\CreateTheorem { proof_inner }
+  {
+    (*\commandoption{name}*) = { (*\commandoption{heading}*) = { \l_mymodule_name_of_proof_tl } },
+    (*\commandoption{create-starred-version}*),
+    (*\commandoption{style}*) = remark,
+    (*\commandoption{qed}*),
+    (*\commandoption{shared-counter}*) = proof,
+  }
+
+\cs_undefine:c { proof }
+\cs_undefine:c { endproof }
+\NewDocumentEnvironment { proof } { O{\proofname} }
+  {
+    \tl_set:Nn \l_mymodule_name_of_proof_tl { #1 }
+    \begin { proof_inner* }
+  }
+  {
+    \end { proof_inner* }
+  }
+\NewDocumentEnvironment { proof* } { O{\proofname} }
+  {
+    \tl_set:Nn \l_mymodule_name_of_proof_tl { #1 }
+    \begin { proof_inner }
+  }
+  {
+    \end { proof_inner }
+  }
+
+\SetTheoremBinding { proof } { proof_inner* }
+\SetTheoremBinding { proof* } { proof_inner }
+
+\ExplSyntaxOff
+\end{code}
+
+It defines an environment \lstinline|proof_inner| (with its starred variant) with theorem style \lstinline|remark| to mimic the default style (you are welcome to use your own style here), and with the name to be a variable which is latter used to define the actual environments \lstinline|proof| and \lstinline|proof*|. These two environments are defined in such a way that \lstinline|proof| is the usual unnumbered version and \lstinline|proof*| is the numbered version. The \lstinline|\SetTheoremBinding| lines are to ensure that user can directly write \lstinline|\SetTheorem{proof}| rather than \lstinline|\SetTheorem{proof_inner}|.
+
+
 \bigskip
 \section{Known issues}
 

Modified: trunk/Master/texmf-dist/tex/latex/create-theorem/create-theorem.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/create-theorem/create-theorem.sty	2022-08-04 20:32:19 UTC (rev 64043)
+++ trunk/Master/texmf-dist/tex/latex/create-theorem/create-theorem.sty	2022-08-04 20:32:32 UTC (rev 64044)
@@ -12,7 +12,7 @@
 \NeedsTeXFormat{LaTeX2e}[2022-06-01]
 \ProvidesExplPackage
   {create-theorem}
-  {2022/07/31} {}
+  {2022/08/04} {}
   {Initializing theorem-like environments with multilingual support}
 
 \keys_define:nn { create-theorem }
@@ -702,6 +702,8 @@
 
 \bool_new:N \l__crthm_creating_apply_style_bool
 \tl_new:N   \l__crthm_creating_apply_style_tl
+\bool_new:N \l__crthm_creating_qed_bool
+\tl_new:N   \l__crthm_creating_qed_tl
 \bool_new:N \l__crthm_creating_numberless_bool
 \bool_new:N \l__crthm_creating_create_starred_bool
 \bool_new:N \l__crthm_creating_copy_existed_bool
@@ -733,15 +735,8 @@
     , apply-style                 .value_required:n   = true
     , apply style                 .meta:n             = { style = { #1 } }
     , apply style                 .value_required:n   = true
-    , qed                         .code:n             = {
-                                                          \exp_args:Nx \hook_gput_code:nnn { env/ \l__crthm_current_env_tl /begin } { crthm } { \cs_set:Npn \qedsymbol { \ensuremath { #1 } } \pushQED{\qed} }
-                                                          \exp_args:Nx \hook_gput_code:nnn { env/ \l__crthm_current_env_tl /end } { crthm } { \popQED }
-                                                          \bool_if:NT \l__crthm_creating_create_starred_bool
-                                                            {
-                                                              \exp_args:Nx \hook_gput_code:nnn { env/ \l__crthm_current_env_tl * /begin } { crthm } { \cs_set:Npn \qedsymbol { \ensuremath { #1 } } \pushQED{\qed} }
-                                                              \exp_args:Nx \hook_gput_code:nnn { env/ \l__crthm_current_env_tl * /end } { crthm } { \popQED }
-                                                            }
-                                                        }
+    , qed                         .code:n             = { \bool_set_true:N \l__crthm_creating_qed_bool
+                                                          \tl_set:Nn \l__crthm_creating_qed_tl { #1 }  }
     , qed                         .default:n          = \c__crthm_original_qedsymbol_tl
     , qed~symbol                  .meta:n             = { qed = #1 }
     , qed~symbol                  .default:n          = \c__crthm_original_qedsymbol_tl
@@ -885,6 +880,17 @@
                     \end{ #1 _crthm_regional }
                   }
                 \keys_set:nn { create-theorem-creating / counter-management } { #2 }
+
+                \bool_if:NT \l__crthm_creating_qed_bool
+                  {
+                    \exp_args:Nx \hook_gput_code:nnn { env/ \l__crthm_current_env_tl /begin } { crthm } { \cs_set:Npn \qedsymbol { \ensuremath { \l__crthm_creating_qed_tl } } \pushQED{\qed} }
+                    \exp_args:Nx \hook_gput_code:nnn { env/ \l__crthm_current_env_tl /end } { crthm } { \popQED }
+                    \bool_if:NT \l__crthm_creating_create_starred_bool
+                      {
+                        \exp_args:Nx \hook_gput_code:nnn { env/ \l__crthm_current_env_tl * /begin } { crthm } { \cs_set:Npn \qedsymbol { \ensuremath { \l__crthm_creating_qed_tl } } \pushQED{\qed} }
+                        \exp_args:Nx \hook_gput_code:nnn { env/ \l__crthm_current_env_tl * /end } { crthm } { \popQED }
+                      }
+                  }
               }
               {
                 \msg_error:nnn  { create-theorem } { env-not-named } { #1 }



More information about the tex-live-commits mailing list.