texlive[72360] Master/texmf-dist: keytheorems (23sep24)

commits+karl at tug.org commits+karl at tug.org
Mon Sep 23 23:19:50 CEST 2024


Revision: 72360
          https://tug.org/svn/texlive?view=revision&revision=72360
Author:   karl
Date:     2024-09-23 23:19:50 +0200 (Mon, 23 Sep 2024)
Log Message:
-----------
keytheorems (23sep24)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/keytheorems/CHANGELOG.md
    trunk/Master/texmf-dist/doc/latex/keytheorems/README.md
    trunk/Master/texmf-dist/doc/latex/keytheorems/keytheorems-doc.pdf
    trunk/Master/texmf-dist/doc/latex/keytheorems/keytheorems-doc.tex
    trunk/Master/texmf-dist/tex/latex/keytheorems/class-support/keythms-amsart-support.tex
    trunk/Master/texmf-dist/tex/latex/keytheorems/class-support/keythms-amsbook-support.tex
    trunk/Master/texmf-dist/tex/latex/keytheorems/class-support/keythms-amsproc-support.tex
    trunk/Master/texmf-dist/tex/latex/keytheorems/class-support/keythms-memoir-support.tex
    trunk/Master/texmf-dist/tex/latex/keytheorems/keytheorems.sty

Modified: trunk/Master/texmf-dist/doc/latex/keytheorems/CHANGELOG.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/keytheorems/CHANGELOG.md	2024-09-23 21:19:41 UTC (rev 72359)
+++ trunk/Master/texmf-dist/doc/latex/keytheorems/CHANGELOG.md	2024-09-23 21:19:50 UTC (rev 72360)
@@ -1,5 +1,12 @@
 # Changelog for keytheorems package
 
+## [v0.1.4]
+- add `store-sets-label` option
+- add `restatable*` environment for `thmtools-compat`
+- add `numberfont` style key
+- add `restate-keys` key
+- styles defined with `\newkeytheoremstyle` now work as expected with `\theoremstyle`
+
 ## [v0.1.3]
 - add `noteseparator` key
 - add `\IfRestatingT`, `\IfRestatingF`
@@ -20,6 +27,7 @@
 ## 0.1.0 - 2024-09-04
 - First release
 
+[v0.1.4]: https://github.com/mbertucci47/keytheorems/compare/v0.1.3...v0.1.4
 [v0.1.3]: https://github.com/mbertucci47/keytheorems/compare/v0.1.2...v0.1.3
 [v0.1.2]: https://github.com/mbertucci47/keytheorems/compare/v0.1.1...v0.1.2
 [v0.1.1]: https://github.com/mbertucci47/keytheorems/compare/v0.1.0...v0.1.1
\ No newline at end of file

Modified: trunk/Master/texmf-dist/doc/latex/keytheorems/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/keytheorems/README.md	2024-09-23 21:19:41 UTC (rev 72359)
+++ trunk/Master/texmf-dist/doc/latex/keytheorems/README.md	2024-09-23 21:19:50 UTC (rev 72360)
@@ -93,7 +93,7 @@
   
   as in the former, `bodyfont` is `\normalfont`, not the default `\itshape`.
   This package keeps the defaults unless a key is specifically given.
-- There is no `restatable` environment except with package option `thmtools-compat`. Use the
+- There is no `restatable(*)` environment except with package option `thmtools-compat`. Use the
   `store` (alias `restate`) key. For counters and labels pointing to the restated theorem,
   use `store*` (alias `restate*`).
 - Rather than `restate=foo` defining a command `\foo*`, theorems are retrieved with `\getkeytheorem{foo}`.

Modified: trunk/Master/texmf-dist/doc/latex/keytheorems/keytheorems-doc.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/keytheorems/keytheorems-doc.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/keytheorems/keytheorems-doc.tex	2024-09-23 21:19:41 UTC (rev 72359)
+++ trunk/Master/texmf-dist/doc/latex/keytheorems/keytheorems-doc.tex	2024-09-23 21:19:50 UTC (rev 72360)
@@ -20,7 +20,7 @@
 \usepackage{cleveref}
 \usepackage{amssymb}
 
-\def\version{0.1.3}
+\def\version{0.1.4}
 
 \title{%
   \pkg{keytheorems} package \\[1ex]
@@ -31,7 +31,6 @@
 \author{Matthew Bertucci}
 
 \newkeytheoremstyle{breaksty}{break}
-
 \newkeytheorem{theorem}
 \newkeytheorem{mythm}[name=Some Name]
 \newkeytheorem{theorem*}[name=Theorem,numbered=false]
@@ -132,6 +131,19 @@
     \path[fill=red!40!black,draw=none] (interior.south west) rectangle node[white]{\LARGE\bfseries !} ([xshift=4mm]interior.north west);
     },
   drop fuzzy shadow,#1}
+\makeatletter
+% allow for optional argument specifying printed text, mostly for starred keys
+\RenewDocumentCommand\tcb at ref@doc{msom}{%
+  \hyperref[{#1:#4}]{%
+  \IfValueTF{#3}{\texttt{#3}}{\texttt{\ref*{#1:#4}}}%
+  \IfBooleanTF{#2}{}{%
+    \ifnum\getpagerefnumber{#1:#4}=\thepage\relax%
+    \else%
+      \kvtcb at doc@format at page{{\fontfamily{pzd}\fontencoding{U}\fontseries{m}\fontshape{n}\selectfont\char213}%
+      \,\kvtcb at text@pageshort\,\pageref*{#1:#4}}%
+    \fi}}%
+}
+\makeatother
 \makeindex
 
 \begin{document}
@@ -150,7 +162,7 @@
 Without using the \refKey{tcolorbox} or \refKey{tcolorbox-no-titlebar} options, the package loads the \pkg{aliascnt}, \pkg{amsthm}, \pkg{refcount}, \pkg{translations}, and \pkg{unique} packages.
 A \LaTeX{} kernel no older than 2023-06-01 is required; if older than 2024-06-01, \pkg{nameref} is required.
     
-\section{Global Options}
+\section{Global options}
 
 \begin{docCommand}{keytheoremset}
   {\marg{options}}
@@ -183,7 +195,8 @@
 \docAuxCommand*{addtotheoremprefoothook}\\
 \docAuxCommand*{addtotheorempostfoothook}\\
 \end{tabular} & \refCom{addtotheoremhook} \\
-\docAuxEnvironment*{restatable} environment & \refKey{store} key
+\docAuxEnvironment*{restatable} environment & \refKey{store} key \\
+\docAuxEnvironment*{restatable*} environment & \refKey[store*]{store} key
 \end{tabular}
 \end{center}
 Also defined are the \docAuxKey*{shaded} and \docAuxKey*{thmbox} keys, implemented internally with \pkg{tcolorbox} rather than the \pkg{shadethm} and \pkg{thmbox} packages, respectively.
@@ -224,8 +237,14 @@
 These texts can be manually customized with the \refKey{title} and \refKey{continues-code} keys, respectively.
 \end{docKey}
 
-\section{Defining Theorems}
+\begin{docKey}{store-sets-translate}
+  {}
+  {initially unset}
+Defines the \refKey{store} key to also set \refKey{label}, i.e. it makes |store=|\meta{tag} equivalent to |store=|\meta{tag}|,label=|\meta{tag}. Similarly for \refKey[store*]{store}.
+\end{docKey}
 
+\section{Defining theorems}
+
 \begin{docCommand}{newkeytheorem}
   {\marg{env name}\oarg{options}}
 Defines a theorem environment \meta{env name} which itself takes a few options (see \autoref{in-doc-keys}).
@@ -317,7 +336,10 @@
   {\sarg=\meta{tag}}
   {initially unset}
 Alias \docAuxKey{restate}\sarg.
-Stores the the theorem to be restated at any point in the document with \refCom{getkeytheorem}. With the starred version, counters and labels are taken from the copy called with \cs{getkeytheorem}, so in this case can only be restated once. This allows you, for example, to write all theorems and proofs in the appendix and call \cs{getkeytheorem} at the appropriate time mid-document.
+Stores the the theorem to be restated at any point in the document with \refCom{getkeytheorem}.
+With the starred version, counters and labels are taken from the copy called with \cs{getkeytheorem}, so in this case can only be restated once.
+This allows you, for example, to write all theorems and proofs in the appendix and call \cs{getkeytheorem} at the appropriate time mid-document.
+For the numbering to be correct, the unstarred key will need at most two runs and the starred key at most three runs.
 
 \begin{keythmscode}[]
 \begin{theorem}[store=blub]
@@ -349,6 +371,24 @@
 
 \end{docKey}
 
+\begin{docKey}{restate-keys}
+  {=\marg{list of keys}}
+  {initially unset}
+Allows passing different keys to the restated theorem.
+At the moment this is only useful with the \refKey{note} key.
+
+\begin{keythmscode}[]
+\begin{theorem}[
+  store=rktest,
+  note=ORIGINAL,
+  restate-keys={note=RESTATED}]
+Wow, yet another theorem.
+\end{theorem}
+\getkeytheorem{rktest}
+\end{keythmscode}
+
+\end{docKey}
+
 \begin{docKey}{listhack}
   {=\docValue*{true}\textbar\docValue*{false}}
   {initially |false|}
@@ -647,7 +687,7 @@
 \end{mytheo}
 \end{keythmscode}
 
-\section{Theorem Styles}
+\section{Theorem styles}
 
 \begin{docCommand}{newkeytheoremstyle}
   {\marg{name}\marg{options}}
@@ -656,6 +696,8 @@
 Note that unlike \pkg{amsthm}'s \cs{newtheoremstyle}, this command will error if a style has already been defined.
 To overwrite an existing style, there is the analogous \docAuxCommand{renewkeytheoremstyle}.
 For completeness, there is also \docAuxCommand{declarekeytheoremstyle} and \docAuxCommand{providekeytheoremstyle}.
+
+The defined style can be used with either the \refKey{style} key or the traditional \cs{theoremstyle}.
 \end{docCommand}
 
 \begin{notebox}
@@ -741,6 +783,12 @@
 The code inserted before the note, and printed only if there is a note. This is executed \emph{before} the font commands set by \refKey{notefont} take effect.
 \end{docKey}
 
+\begin{docKey}{numberfont}
+  {=\meta{font declarations}}
+  {initially |\upshape|}
+For almost all theorem styles, it is recommended that you \emph{do not} change this setting.
+\end{docKey}
+
 \begin{docKey}{inherit-style}
   {=\meta{style name}}
   {initially unset}
@@ -748,7 +796,7 @@
 Additionally, the three styles predefined by \pkg{amsthm} are possible values: \docValue{plain}, \docValue{definition}, and \docValue{remark}.
 \end{docKey}
 
-\section{Restating Theorems}
+\section{Restating theorems}
 
 When a theorem is given the \refKey{store} key, the contents of the theorem are saved and written to a |.thlist| file.
 At the start of the next run, this file is input at the beginning of the document and allows you to retrieve the stored theorems at any point, before or after the original theorem.
@@ -800,7 +848,7 @@
 
 \end{docCommands}
 
-\section{Listing Theorems}
+\section{Listing theorems}
 
 \begin{docCommand}{listofkeytheorems}
   {\oarg{options}}
@@ -979,7 +1027,7 @@
 
 \end{docCommand}
 
-\section{Theorem Hooks} \label{keythms-hooks}
+\section{Theorem hooks} \label{keythms-hooks}
 
 \begin{docCommand}{addtotheoremhook}
   {\oarg{env name}\marg{hook name}\marg{code}}
@@ -1040,6 +1088,10 @@
 This may change if I think of good reasons to do so\dots
 \end{docCommand}
 
+\section{Miscellaneous notes for the ambitious}
+
+Inside theorem environments, as well as in all of the theorem hooks, you have access to the theorem's environment and counter name in the token list variable |\l_keythms_thmuse_envname_tl|.
+
 \section{Further examples}
 
 More examples will be added soon -- rather, eventually\dots{}

Modified: trunk/Master/texmf-dist/tex/latex/keytheorems/class-support/keythms-amsart-support.tex
===================================================================
--- trunk/Master/texmf-dist/tex/latex/keytheorems/class-support/keythms-amsart-support.tex	2024-09-23 21:19:41 UTC (rev 72359)
+++ trunk/Master/texmf-dist/tex/latex/keytheorems/class-support/keythms-amsart-support.tex	2024-09-23 21:19:50 UTC (rev 72360)
@@ -1,7 +1,7 @@
 % Maintained by Matthew Bertucci, 2024-present
 % Please report all issues and feature requests at https://github.com/mbertucci47/keytheorems
 % This work is licensed under the LPPL version 1.3c or later: https://www.latex-project.org/lppl.txt
-\ProvidesExplFile{keythms-amsart-support}{2024-09-19}{0.1.3}
+\ProvidesExplFile{keythms-amsart-support}{2024-09-22}{0.1.4}
   {keytheorems~support~for~the~amsart~class}
 
 \__keythms_support_AMSshared_code:
@@ -18,6 +18,7 @@
         headfont      = \@acmplainheadfont,
         headpunct     = {.},
         postheadspace = .5em,
+        numberfont    = \upshape,
         notefont      = \@acmplainnotefont,
         notebraces    = {(}{)},
         noteseparator = {~},

Modified: trunk/Master/texmf-dist/tex/latex/keytheorems/class-support/keythms-amsbook-support.tex
===================================================================
--- trunk/Master/texmf-dist/tex/latex/keytheorems/class-support/keythms-amsbook-support.tex	2024-09-23 21:19:41 UTC (rev 72359)
+++ trunk/Master/texmf-dist/tex/latex/keytheorems/class-support/keythms-amsbook-support.tex	2024-09-23 21:19:50 UTC (rev 72360)
@@ -1,7 +1,7 @@
 % Maintained by Matthew Bertucci, 2024-present
 % Please report all issues and feature requests at https://github.com/mbertucci47/keytheorems
 % This work is licensed under the LPPL version 1.3c or later: https://www.latex-project.org/lppl.txt
-\ProvidesExplFile{keythms-amsbook-support}{2024-09-19}{0.1.3}
+\ProvidesExplFile{keythms-amsbook-support}{2024-09-22}{0.1.4}
   {keytheorems~support~for~the~amsbook~class}
 
 \__keythms_support_AMSshared_code:
@@ -15,6 +15,7 @@
     headfont      = \scshape,
     headpunct     = {.},
     postheadspace = 5pt plus 1pt minus 1pt,
+    numberfont    = \upshape,
     notefont      = \fontseries\mddefault\upshape,
     notebraces    = {(}{)},
     noteseparator = {~},

Modified: trunk/Master/texmf-dist/tex/latex/keytheorems/class-support/keythms-amsproc-support.tex
===================================================================
--- trunk/Master/texmf-dist/tex/latex/keytheorems/class-support/keythms-amsproc-support.tex	2024-09-23 21:19:41 UTC (rev 72359)
+++ trunk/Master/texmf-dist/tex/latex/keytheorems/class-support/keythms-amsproc-support.tex	2024-09-23 21:19:50 UTC (rev 72360)
@@ -1,7 +1,7 @@
 % Maintained by Matthew Bertucci, 2024-present
 % Please report all issues and feature requests at https://github.com/mbertucci47/keytheorems
 % This work is licensed under the LPPL version 1.3c or later: https://www.latex-project.org/lppl.txt
-\ProvidesExplFile{keythms-amsproc-support}{2024-09-19}{0.1.3}
+\ProvidesExplFile{keythms-amsproc-support}{2024-09-22}{0.1.4}
   {keytheorems~support~for~the~amsproc~class}
 
 \__keythms_support_AMSshared_code:
@@ -15,6 +15,7 @@
     headfont      = \scshape,
     headpunct     = {.},
     postheadspace = 5pt plus 1pt minus 1pt,
+    numberfont    = \upshape,
     notefont      = \fontseries\mddefault\upshape,
     notebraces    = {(}{)},
     noteseparator = {~},

Modified: trunk/Master/texmf-dist/tex/latex/keytheorems/class-support/keythms-memoir-support.tex
===================================================================
--- trunk/Master/texmf-dist/tex/latex/keytheorems/class-support/keythms-memoir-support.tex	2024-09-23 21:19:41 UTC (rev 72359)
+++ trunk/Master/texmf-dist/tex/latex/keytheorems/class-support/keythms-memoir-support.tex	2024-09-23 21:19:50 UTC (rev 72360)
@@ -1,7 +1,7 @@
 % Maintained by Matthew Bertucci, 2024-present
 % Please report all issues and feature requests at https://github.com/mbertucci47/keytheorems
 % This work is licensed under the LPPL version 1.3c or later: https://www.latex-project.org/lppl.txt
-\ProvidesExplFile{keythms-memoir-support}{2024-09-19}{0.1.3}
+\ProvidesExplFile{keythms-memoir-support}{2024-09-22}{0.1.4}
   {keytheorems~support~for~the~memoir~class}
 
 \bool_new:N \l__keythms_support_titlecode_bool

Modified: trunk/Master/texmf-dist/tex/latex/keytheorems/keytheorems.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/keytheorems/keytheorems.sty	2024-09-23 21:19:41 UTC (rev 72359)
+++ trunk/Master/texmf-dist/tex/latex/keytheorems/keytheorems.sty	2024-09-23 21:19:50 UTC (rev 72360)
@@ -2,7 +2,7 @@
 % Please report all issues and feature requests at https://github.com/mbertucci47/keytheorems
 % This work is licensed under the LPPL version 1.3c or later: https://www.latex-project.org/lppl.txt
 \NeedsTeXFormat{LaTeX2e}[2023-06-01]
-\ProvidesExplPackage{keytheorems}{2024-09-19}{0.1.3}{l3keys interface to amsthm}
+\ProvidesExplPackage{keytheorems}{2024-09-22}{0.1.4}{l3keys interface to amsthm}
 
 \IfFormatAtLeastTF { 2024-06-01 } { }
   {
@@ -14,6 +14,8 @@
     \cs_generate_variant:Nn \tl_put_right:Nn { Ne }
     \ProvideDocumentCommand \IfPackageLoadedT { m m }
       { \IfPackageLoadedTF{#1}{#2}{ } }
+    \ProvideDocumentCommand \IfPackageLoadedF { m m }
+      { \IfPackageLoadedTF{#1}{ }{#2} }
     \ProvideDocumentCommand \IfClassLoadedT { m m }
       { \IfClassLoadedTF{#1}{#2}{ } }
   }
@@ -118,6 +120,7 @@
 \bool_gset_false:N \g__keythms_listof_writefile_bool
 \bool_new:N \g__keythms_thmtoolscompat_bool
 \bool_gset_false:N \g__keythms_thmtoolscompat_bool
+\bool_new:N \l__keythms_listofheading_storereversed_bool
 \bool_new:N \l__keythms_thm_numbered_bool
 \bool_new:N \l__keythms_thm_unlessunique_bool
 \bool_new:N \l__keythms_thmuse_listhack_bool
@@ -134,7 +137,7 @@
 \tl_new:N \l__keythms_thmstyle_defaultkeys_tl
 \tl_new:N \l__keythms_thmstyle_lnotebrace_tl
 \tl_new:N \l__keythms_thmstyle_rnotebrace_tl
-\tl_new:N \l__keythms_thmuse_envname_tl
+\tl_new:N \l_keythms_thmuse_envname_tl
 \tl_new:N \g__keythms_thmuse_temprestatedata_tl
 \tl_new:N \g__keythms_thmuse_temprestatedatareversed_tl
 
@@ -193,6 +196,7 @@
     postheadspace .tl_set:N = \l__keythms_thmstyle_postheadspace_tl,
     break         .meta:n   = { postheadspace = \newline }, % add error if postheadspace set
     break         .value_forbidden:n = true,
+    numberfont    .tl_set:N = \l__keythms_thmstyle_numberfont_tl,
     notefont      .tl_set:N = \l__keythms_thmstyle_notefont_tl,
     notebraces    .code:n   = \exp_after:wN \__keythms_thmstyle_setbraces:nn #1,
     noteseparator .tl_set:N = \l__keythms_thmstyle_noteseparator_tl,
@@ -244,7 +248,13 @@
 \cs_new:Npn \NAME { \keythms_thmstyle_thmname:n { ##1 } }
 \cs_new:Npn \NUMBER
   {
-    \keythms_thmstyle_thmnumber:n { \textup { ##2 } }
+    \keythms_thmstyle_thmnumber:n
+      {
+        \group_begin:
+        \exp_not:V \l__keythms_thmstyle_numberfont_tl
+        ##2
+        \group_end:
+      }
   }
 \cs_new:Npn \NOTE
   {
@@ -260,7 +270,13 @@
 \cs_new:Npn \keythms_thmstyle_headcmd_default:nnn #1#2#3
   {
     \keythms_thmstyle_thmname:n { #1 }
-    \keythms_thmstyle_thmnumber:n { ~ \textup { #2 } }
+    \keythms_thmstyle_thmnumber:n
+      { ~
+        \group_begin:
+        \exp_not:V \l__keythms_thmstyle_numberfont_tl
+        #2
+        \group_end:
+      }
     \keythms_thmstyle_thmnote:n
       { \exp_not:V \l__keythms_thmstyle_noteseparator_tl
         \group_begin: % group so notefont doesn't affect headpunct
@@ -285,6 +301,7 @@
     headfont      = \bfseries,
     headpunct     = {.},
     postheadspace = 5pt plus 1pt minus 1pt,
+    numberfont    = \upshape,
     notefont      = \fontseries\mddefault\upshape,
     notebraces    = {(}{)},
     noteseparator = {~},
@@ -505,10 +522,14 @@
     \tl_use:N \l__keythms_thm_defaultkeys_tl
     % First set style so we can pick up additional thm keys, then overwrite if necessary
     \keys_set_groups:nnn { keytheorems/thm } { style-comes-first } { #2 }
-    \tl_if_empty:NF \l__keythms_thm_style_tl
+    % Store theorem style
+    \tl_set:Ne \l__keythms_thm_currentthmstyle_tl { \the\thm at style }
+    \tl_if_empty:NTF \l__keythms_thm_style_tl
+      { % if \theoremstyle set, also use saved thm keys
+        \tl_if_exist:cT {l__keythms_thmstyle_ \l__keythms_thm_currentthmstyle_tl _savedkeys_tl}
+          { \tl_use:c {l__keythms_thmstyle_ \l__keythms_thm_currentthmstyle_tl _savedkeys_tl} }
+      }
       {
-        % Store theorem style
-        \tl_set:Ne \l__keythms_thm_currentthmstyle_tl { \the\thm at style }
         % Temporarily set theorem style
         \__keythms_theoremstyle:n { \l__keythms_thm_style_tl }
         % If thm keys given in style, call now (possibly overwritten in next step)
@@ -674,46 +695,32 @@
       { keythms_tcbox } { after } { keythms_hook_keys }
     \hook_gset_rule:nnnn { keytheorems/#1/prefoot }
       { keythms_tcbox } { after } { keythms_qed }
-    \bool_if:NTF \l__keythms_thm_numbered_bool
+    \tcbset
       {
+        keythms_tcbox_#1/.style =
+          {
+            savedelimiter=#1,
+            title={ \__keythms_thm_tcboxtemphead: },
+          }
+      }
+    \bool_if:NT \l__keythms_thm_numbered_bool
+      {
         \hook_gput_code:nnn { begindocument } { . }
           {
-            \IfPackageLoadedTF{cleveref}
+            \IfPackageLoadedF{cleveref}
               { % hyperref doesn't patch \@thm if cleveref loaded
-                \hook_gput_code:nnn { keytheorems/#1/posthead }
-                  { keythms_tcbox }
+                \tcbset
                   {
-                    \begin{tcolorbox}[
-                      savedelimiter=#1,
-                      title={ \__keythms_thm_tcboxtemphead: },
-                      #2]
+                    keythms_tcbox_#1/.append~style = % fix hyperlinking
+                      { phantom={ \MakeLinkTarget*{\@currentHref} } }
                   }
               }
-              {
-                \hook_gput_code:nnn { keytheorems/#1/posthead }
-                  { keythms_tcbox }
-                  {
-                    \begin{tcolorbox}[
-                      savedelimiter=#1,
-                      title={ \__keythms_thm_tcboxtemphead: },
-                      phantom={ \MakeLinkTarget*{\@currentHref} }, % fix hyperlinking
-                      #2]
-                  }
-              }
           }
       }
-      {
-        \hook_gput_code:nnn { keytheorems/#1/posthead }
-          { keythms_tcbox }
-          {
-            \begin{tcolorbox}[
-              savedelimiter=#1,
-              title={ \__keythms_thm_tcboxtemphead: },
-              #2]
-          }
-      }
-    \hook_gput_code:nnn { keytheorems/#1/prefoot }
-      { keythms_tcbox } { \end{tcolorbox} }
+    \hook_gput_code:nnn { keytheorems/#1/posthead } { keythms_tcbox }
+      { \begin{tcolorbox}[keythms_tcbox_#1,#2] }
+    \hook_gput_code:nnn { keytheorems/#1/prefoot } { keythms_tcbox }
+      { \end{tcolorbox} }
   }
 \cs_new_protected:Npn \__keythms_thm_qedcode:nn #1#2
   {
@@ -815,10 +822,11 @@
   {
     label      .tl_set:N = \l__keythms_thmuse_label_tl,
     note       .tl_set:N = \l__keythms_thmuse_note_tl,
+    note       .initial:n = {},
     name       .meta:n   = { note = #1 },
     % ^ for compatibility. "name" is ambiguous and doesn't match amsthm language
     short-note .code:n   = {}, % these do nothing at point of use
-    short-name .code:n   = {}, % ^ worthwhile compatibility?
+    short-name .code:n   = {},
     continues  .tl_set:N = \l__keythms_thmuse_contlabel_tl,
     continues* .code:n   =
       {
@@ -830,12 +838,12 @@
               { note = \l__keythms_tmpa_tl }
           }
       },
-    store      .tl_set:N = \l__keythms_thmuse_store_tl,
+    store      .tl_set:N = \l__keythms_thmuse_store_tl, % should this be .tl_set_e:N ?
     %store      .default:n = \q_no_value, % ={name} causes issues
-    restate    .meta:n   = { store = #1 },
-    % ^ thmtools compatibility
-    store*   .tl_set:N = \l__keythms_thmuse_storereversed_tl,
-    restate* .meta:n   = { store* = #1 },
+    restate    .meta:n   = { store = #1 }, % thmtools compatibility
+    store*     .tl_set:N = \l__keythms_thmuse_storereversed_tl,
+    restate*   .meta:n   = { store* = #1 },
+    restate-keys .clist_set:N = \l__keythms_thmuse_restatekeys_clist,
     listhack   .choice:, % need equals sign
     listhack / true .code:n = \bool_set_true:N \l__keythms_thmuse_listhack_bool,
     listhack / false .code:n = \bool_set_false:N \l__keythms_thmuse_listhack_bool,
@@ -846,7 +854,7 @@
 \cs_new_protected:Npn \keythms_keyify_theorem:n #1
   { % #1 = theorem name
     \DeclareEnvironmentCopy { keythms_orig_#1 } { #1 }
-    \DeclareDocumentEnvironment { keythms_grab_#1 } { m O{} +b }
+    \DeclareDocumentEnvironment { keythms_grab_#1 } { m m +b }
       { % ##1 = keys, ##2 = note, ##3 = theorem body
         \__keythms_thm_prehead_code:n { #1 }
         \begin{keythms_orig_#1}[{##2}]
@@ -868,7 +876,7 @@
         \__keythms_thm_postfoot_code:n { #1 }
       }
       {}
-    \DeclareDocumentEnvironment { keythms_grabreversed_#1 } { m O{} +b }
+    \DeclareDocumentEnvironment { keythms_grabreversed_#1 } { m m +b }
       { % ##1 = keys, ##2 = note, ##3 = theorem body
         \tl_if_exist:cTF
           { c__keythms_storeatbegin_ \l__keythms_thmuse_storereversed_tl _restatecounters_tl }
@@ -939,7 +947,6 @@
           \tl_if_empty:NF \l__keythms_thmuse_store_tl
             {
               \bool_gset_true:N \g__keythms_listof_writefile_bool
-              \cs_set_eq:NN \__keythms_withhooks_begin:nn \__keythms_grab_begin:nn
               \cs_set_eq:NN \__keythms_withhooks_begin:nnn \__keythms_grab_begin:nnn
               \cs_set_eq:NN \__keythms_withhooks_begin:nnV \__keythms_grab_begin:nnV
               \cs_set_eq:NN \__keythms_withhooks_end:n \__keythms_grab_end:n
@@ -947,18 +954,12 @@
           \tl_if_empty:NF \l__keythms_thmuse_storereversed_tl
             {
               \bool_gset_true:N \g__keythms_listof_writefile_bool
-              \cs_set_eq:NN \__keythms_withhooks_begin:nn \__keythms_grabreversed_begin:nn
               \cs_set_eq:NN \__keythms_withhooks_begin:nnn \__keythms_grabreversed_begin:nnn
               \cs_set_eq:NN \__keythms_withhooks_begin:nnV \__keythms_grabreversed_begin:nnV
               \cs_set_eq:NN \__keythms_withhooks_end:n \__keythms_grabreversed_end:n
             }
           \__keythms_thm_prehead_continues_code:n { #1 }
-          \tl_if_empty:NTF \l__keythms_thmuse_note_tl
-            { \__keythms_withhooks_begin:nn { #1 } { ##1 } }
-            {
-              \__keythms_withhooks_begin:nnV { #1 } { ##1 }
-                \l__keythms_thmuse_note_tl
-            }
+          \__keythms_withhooks_begin:nnV { #1 } { ##1 } \l__keythms_thmuse_note_tl
         }
         {
           \__keythms_withhooks_end:n { #1 }
@@ -1009,14 +1010,6 @@
   }
 \cs_new:Npn \__keythms_use_iii_v_braced:nnnnn #1#2#3#4#5 { {#3}{#5} }
 
-\cs_new_protected:Npn \__keythms_withhooks_begin:nn #1#2
-  { % #1 = theorem name, #2 = keys
-    \__keythms_thm_prehead_code:n { #1 }
-    \begin{keythms_orig_#1}
-    \__keythms_thm_posthead_code:n { #1 }
-    \__keythms_thm_addcontentsdata:nnnn { #1 } { } { #2 } { }
-    \ignorespaces % I hope this is alright
-  }
 \cs_new_protected:Npn \__keythms_withhooks_begin:nnn #1#2#3
   { % #1 = theorem name, #2 = keys, #3 = note
     \__keythms_thm_prehead_code:n { #1 }
@@ -1032,30 +1025,21 @@
     \end{keythms_orig_#1}
     \__keythms_thm_postfoot_code:n { #1 }
   }
-\cs_new_protected:Npn \__keythms_grab_begin:nn #1#2
-  { % #1 = theorem name, #2 = keys
-    \begin{keythms_grab_#1}{#2}
-  }
 \cs_new_protected:Npn \__keythms_grab_begin:nnn #1#2#3
   { % #1 = theorem name, #2 = keys, #3 = note
-    \begin{keythms_grab_#1}{#2}[{#3}]
+    \begin{keythms_grab_#1}{#2}{#3}
   }
 \cs_generate_variant:Nn \__keythms_grab_begin:nnn { nnV }
 \cs_new_protected:Npn \__keythms_grab_end:n #1 { \end{keythms_grab_#1} }
 
-\cs_new_protected:Npn \__keythms_grabreversed_begin:nn #1#2
-  { % #1 = theorem name, #2 = keys
-    \begin{keythms_grabreversed_#1}{#2}
-  }
 \cs_new_protected:Npn \__keythms_grabreversed_begin:nnn #1#2#3
   { % #1 = theorem name, #2 = keys, #3 = note
-    \begin{keythms_grabreversed_#1}{#2}[{#3}]
+    \begin{keythms_grabreversed_#1}{#2}{#3}
   }
 \cs_generate_variant:Nn \__keythms_grabreversed_begin:nnn { nnV }
 \cs_new_protected:Npn \__keythms_grabreversed_end:n #1
   { \end{keythms_grabreversed_#1} }
 
-\cs_new_protected:Npn \__keythms_orig_begin:n #1 { \begin{keythms_orig_#1} }
 \cs_new_protected:Npn \__keythms_orig_begin:nn #1#2
   { \begin{keythms_orig_#1}[{#2}] }
 \cs_generate_variant:Nn \__keythms_orig_begin:nn { nV }
@@ -1063,7 +1047,7 @@
 
 \cs_new_protected:Npn \__keythms_thm_prehead_code:n #1
   { % #1 = theorem name
-    \tl_set:Nn \l__keythms_thmuse_envname_tl { #1 }
+    \tl_set:Nn \l_keythms_thmuse_envname_tl { #1 }
     \hook_use:n { keytheorems/#1/prehead }
     \hook_use:n { keytheorems/allthms/prehead }
   }
@@ -1173,11 +1157,11 @@
 
 \keys_define:nn { keytheorems/storeatbegin }
   {
-    store   .tl_set:N = \l__keythms_storeatbegin_store_tl,
-    restate .meta:n   = { store=#1 },
-    store*   .tl_set:N = \l__keythms_storeatbegin_storereversed_tl,
-    restate* .meta:n   = { store*=#1 },
-    unknown .code:n   = { } % do nothing with unknown keys
+    store    .tl_set:N    = \l__keythms_storeatbegin_store_tl,
+    restate  .meta:n      = { store=#1 },
+    store*   .tl_set:N    = \l__keythms_storeatbegin_storereversed_tl,
+    restate* .meta:n      = { store*=#1 },
+    unknown  .code:n      = { } % do nothing with unknown keys
   }
 
 \cs_new_protected:Npn \KeyThmsContentsLine #1 { #1 }
@@ -1302,13 +1286,12 @@
     \cs_set_eq:NN \setuniqmark \use_none:n % work with numbered=unless-unique
     % QUESTION: also disable \hyper@@anchor? \MakeLinkTarget?
     \keys_set:nn { keytheorems/thmuse } { #4 }
+    \keys_set:no { keytheorems/thmuse } { \l__keythms_thmuse_restatekeys_clist }
     \hook_use:n { keytheorems/#1/restated }
     \hook_use:n { keytheorems/allthms/restated }
     \__keythms_thm_prehead_continues_code:n { #1 }
     \__keythms_thm_prehead_code:n { #1 }
-    \tl_if_empty:NTF \l__keythms_thmuse_note_tl
-      { \__keythms_orig_begin:n { #1 } }
-      { \__keythms_orig_begin:nV { #1 } \l__keythms_thmuse_note_tl }
+    \__keythms_orig_begin:nV { #1 } \l__keythms_thmuse_note_tl
     \__keythms_thm_posthead_code:n { #1 }
     #5
     \__keythms_thm_prefoot_code:n { #1 }
@@ -1357,11 +1340,10 @@
     \group_begin:
     \bool_set_false:N \l__keythms_thmuse_restating_bool
     \keys_set:nn { keytheorems/thmuse } { #2 }
+    \keys_set:no { keytheorems/thmuse } { \l__keythms_thmuse_restatekeys_clist }
     \__keythms_thm_prehead_continues_code:n { #1 }
     \__keythms_thm_prehead_code:n { #1 }
-    \tl_if_empty:NTF \l__keythms_thmuse_note_tl
-      { \__keythms_orig_begin:n { #1 } }
-      { \__keythms_orig_begin:nV { #1 } \l__keythms_thmuse_note_tl }
+    \__keythms_orig_begin:nV { #1 } \l__keythms_thmuse_note_tl
     \clist_map_inline:Nn \g__keythms_restatecounters_clist
       {
         \prop_gput:Nne \g__keythms_thmuse_othercounters_prop { ##1 }
@@ -1680,6 +1662,9 @@
           }
       },
     seq     .tl_set:N = \l__keythms_listofheading_seq_tl,
+    store*  .code:n = \bool_set_true:N \l__keythms_listofheading_storereversed_bool,
+    restate* .meta:n = { store*=#1 },
+    restate-keys .clist_set:N = \l__keythms_listofheading_restatekeys_clist,
     unknown .code:n = { } % do nothing with unknown keys
     % ^ this is OK because we have total control over possible keys; if invalid
     %   key is given to theorem then an error will be raised there
@@ -1719,6 +1704,11 @@
   { % #1 = keys, #2 = list command
     \group_begin:
     \keys_set:nn { keytheorems/listofheading } { #1 }
+    \bool_if:NT \l__keythms_listofheading_storereversed_bool
+      {
+        \keys_set:no { keytheorems/listofheading }
+          { \l__keythms_listofheading_restatekeys_clist }
+      }
     \tl_if_empty:NTF \l__keythms_listofheading_contlabel_tl
       { #2 }
       {
@@ -1886,6 +1876,22 @@
     store-all        .usage:n = preamble,
     auto-translate   .bool_gset:N = \g__keythms_autotranslate_bool,
     auto-translate   .initial:n = true,
+    store-sets-label .code:n =
+      {
+        \keys_define:nn { keytheorems/thmuse }
+          {
+            store .code:n =
+              {
+                \tl_set:Nn \l__keythms_thmuse_label_tl { ##1 }
+                \tl_set:Nn \l__keythms_thmuse_store_tl { ##1 }
+              },
+            store* .code:n =
+              {
+                \tl_set:Nn \l__keythms_thmuse_label_tl { ##1 }
+                \tl_set:Nn \l__keythms_thmuse_storereversed_tl { ##1 }
+              },
+          }
+      },
   }
 
 \cs_generate_variant:Nn \__keythms_thmuse_continues:n { V }
@@ -1927,7 +1933,25 @@
         \newkeytheorem { ##2 } [ ##1 ]
       }
     \ProvideDocumentEnvironment { restatable } { O{} m m }
-      { % set store outside [] so keyless note is recognized
+      { % need to redefine this to add store to thlist since we set it outside env
+        \cs_set_protected:Npn \__keythms_thm_addcontentsdata:nnnn ####1####2####3####4
+          { % #1 = theorem name, #2 = stored counters, #3 = keys, #4 = body
+            \keythms_listof_chaptervspacehack:
+            \iow_shipout:Ne \@auxout
+              {
+                \exp_not:N \@writefile { thlist }
+                  {
+                    \KeyThmsSavedTheorem{ ####1 }
+                      { \@currentlabel }
+                      { \@currentHref }
+                      { \thepage }
+                      { ####2 }
+                      { store=\l__keythms_thmuse_store_tl,\exp_not:n { ####3 } } % this line is changed
+                      { \exp_not:n { ####4 } }
+                  }
+              }
+          }
+        % set store outside [] so keyless note is recognized
         \keys_set:nn { keytheorems/thmuse } { store=##3 }
         \begin{##2}[##1]
       }
@@ -1936,10 +1960,38 @@
         \cs_new_protected:cpn { ##3 }
           { % make \foo and \foo* identical
             \peek_meaning_remove:NTF *
-              { \use:c { __keythms_getthm_ ##3 _theorem } }
-              { \use:c { __keythms_getthm_ ##3 _theorem } }
+              { \getkeytheorem{ ##3 } }
+              { \getkeytheorem{ ##3 } }
           }
       }
+    \ProvideDocumentEnvironment { restatable* } { O{} m m }
+      { % need to redefine this to add store* to thlist since we set it outside env
+        \cs_set_protected:Npn \__keythms_thm_addstoredreverseddata:nnn ####1####2####3
+          {
+            \iow_shipout:Ne \@auxout
+              {
+                \exp_not:N \@writefile { thlist }
+                  {
+                    \KeyThmsSavedTheoremReversed { \l__keythms_thmuse_storereversed_tl }
+                      { ####1 }
+                      { store*=\l__keythms_thmuse_storereversed_tl,\exp_not:n { ####2 } } % this line is changed
+                      { \exp_not:n { ####3 } }
+                  }
+              }
+          }
+        % set store* outside [] so keyless note is recognized
+        \keys_set:nn { keytheorems/thmuse } { store*=##3 }
+        \begin{##2}[##1]
+      }
+      {
+        \end{##2}
+        \cs_new_protected:cpn { ##3 }
+          { % make \foo and \foo* identical
+            \peek_meaning_remove:NTF *
+              { \getkeytheorem{ ##3 } }
+              { \getkeytheorem{ ##3 } }
+          }
+      }
     \ProvideDocumentCommand { \listoftheorems } { } { \listofkeytheorems }
     \ProvideDocumentCommand { \addtotheorempreheadhook } { O{allthms} m }
       {
@@ -2254,7 +2306,6 @@
 
 \cs_new_protected:Npn \__keythms_storeall_code:
   {
-    \cs_set_eq:NN \__keythms_withhooks_begin:nn \__keythms_grab_begin:nn
     \cs_set_eq:NN \__keythms_withhooks_begin:nnn \__keythms_grab_begin:nnn
     \cs_set_eq:NN \__keythms_withhooks_begin:nnV \__keythms_grab_begin:nnV
     \cs_set_eq:NN \__keythms_withhooks_end:n \__keythms_grab_end:n



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