texlive[75013] Master/texmf-dist: keytheorems (24apr25)

commits+karl at tug.org commits+karl at tug.org
Thu Apr 24 22:26:06 CEST 2025


Revision: 75013
          https://tug.org/svn/texlive?view=revision&revision=75013
Author:   karl
Date:     2025-04-24 22:26:06 +0200 (Thu, 24 Apr 2025)
Log Message:
-----------
keytheorems (24apr25)

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-beamer-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	2025-04-24 20:25:51 UTC (rev 75012)
+++ trunk/Master/texmf-dist/doc/latex/keytheorems/CHANGELOG.md	2025-04-24 20:26:06 UTC (rev 75013)
@@ -1,5 +1,8 @@
 # Changelog for keytheorems package
 
+## [v0.2.6]
+- add `\externaltheorems` command to restate theorems from an external file
+
 ## [v0.2.5]
 - disable `\index` and `\glossary` in restated theorems
 - fix [\#11](https://github.com/mbertucci47/keytheorems/issues/11)
@@ -69,6 +72,7 @@
 ## 0.1.0 - 2024-09-04
 - First release
 
+[v0.2.6]: https://github.com/mbertucci47/keytheorems/compare/v0.2.5...HEAD
 [v0.2.5]: https://github.com/mbertucci47/keytheorems/compare/v0.2.4...v0.2.5
 [v0.2.4]: https://github.com/mbertucci47/keytheorems/compare/v0.2.3...v0.2.4
 [v0.2.3]: https://github.com/mbertucci47/keytheorems/compare/v0.2.2...v0.2.3

Modified: trunk/Master/texmf-dist/doc/latex/keytheorems/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/keytheorems/README.md	2025-04-24 20:25:51 UTC (rev 75012)
+++ trunk/Master/texmf-dist/doc/latex/keytheorems/README.md	2025-04-24 20:26:06 UTC (rev 75013)
@@ -261,6 +261,30 @@
 \end{document}
 ```
 
+### [Anyway to restate theorem in external file? #23](https://github.com/muzimuzhi/thmtools/issues/23)
+Use the `\externaltheorems` command.
+```tex
+% mycoolpaper.tex
+\documentclass{article}
+\usepackage{keytheorems}
+\newkeytheorem{theorem}
+\begin{document}
+\begin{theorem}[store=cooltheorem]
+My cool theorem.
+\end{theorem}
+\end{document}
+```
+```tex
+% myothercoolpaper.tex
+\documentclass{article}
+\usepackage{keytheorems}
+\externaltheorems[orig:]{mycoolpaper}
+\newkeytheorem{theorem}
+\begin{document}
+\getkeytheorem{orig:cooltheorem}
+\end{document}
+```
+
 ### [Option clash: numbered=no and thmbox #25](https://github.com/muzimuzhi/thmtools/issues/25)
 Fixed with keytheorem's implementation of the `thmbox` key with `thmtools-compat`.
 ```tex

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	2025-04-24 20:25:51 UTC (rev 75012)
+++ trunk/Master/texmf-dist/doc/latex/keytheorems/keytheorems-doc.tex	2025-04-24 20:26:06 UTC (rev 75013)
@@ -1,4 +1,7 @@
-% !TeX program = txs:///lualatex | txs:///makeindex | txs:///lualatex | txs:///view-pdf
+% !TeX TXS-program:compile = txs:///arara
+% arara: lualatex: { synctex:yes }
+% arara: makeindex
+% arara: lualatex: { synctex:yes } if found('log', 'Rerun to get')
 \PassOptionsToPackage{hyperindex}{hyperref}
 \PassOptionsToPackage{dvipsnames}{xcolor}
 \documentclass{ltxdoc}
@@ -143,7 +146,7 @@
 }
 \makeatother
 
-\NewTCBListing{keythmscode}{ O{} }
+\NewTCBListing{keythmscode}{ !O{} }
   {
     colback=ExampleBack,
     arc=0pt,
@@ -331,7 +334,7 @@
 
 As in \pkg{amsthm}, theorems can take an optional argument that contains a note or heading.
 
-\begin{keythmscode}[]
+\begin{keythmscode}
 \begin{theorem}[Bertrand's postulate]
 For every $n\geq 1$, there is a prime number $p$ with $n<p\leq 2n$.
 \end{theorem}
@@ -346,7 +349,7 @@
 This is the key-value equivalent of the optional argument described above.
 This syntax, however, allows the argument to contain other keys.
 
-\begin{keythmscode}[]
+\begin{keythmscode}
 \begin{theorem}[note=Legendre's formula]
 The number $n!$ contains the prime factor $p$ exactly
   \[ \sum_{k\geq 1} \Bigl\lfloor\frac{n}{p^k}\Bigr\rfloor \]
@@ -368,7 +371,7 @@
   {initially unset}
 This is the key-value equivalent of |\begin{theorem}| \cs{label}\marg{label name}.
 
-\begin{keythmscode}[]
+\begin{keythmscode}
 \begin{theorem}[label=bezout,note=Bézout's identity]
 Let $a$ and $b$ be integers. Then there exist integers $x$ and $y$ such that $ax+by=\gcd(a,b)$.
 \end{theorem}
@@ -378,12 +381,12 @@
 \end{docKey}
 
 \begin{docKey}{manual-num}
-  {=\marg{text}}
+  {=\meta{text}}
   {initially unset}
 Use this to override the printed number of a theorem.
 It is useful for making ``starred'' versions of other theorems, perhaps to represent a reformulated or more difficult version.
 
-\begin{keythmscode}[]
+\begin{keythmscode}
 \begin{theorem}[manual-num=\ref*{bezout}*]
 Let $a_1,\dots,a_n$ be integers. Then there exist integers $x_1,\dots,x_n$ such that $a_1x_1+\dots+a_nx_n=\gcd(a_1,\dots,a_n)$.
 \end{theorem}
@@ -401,7 +404,7 @@
 The printed text can be customized with the \refKey{continues-code} option.
 The starred version also copies the theorem \refKey{note} and \refKey{short-note} if they are nonempty.
 
-\begin{keythmscode}[]
+\begin{keythmscode}
 \begin{theorem}[continues=bezout]
 Moreover, the integers of the form $az+bt$ are exactly the multiples of $\gcd(a,b)$.
 \end{theorem}
@@ -421,7 +424,7 @@
 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{keythmscode}
 \begin{theorem}[store=blub]
 A theorem worth restating.
 \end{theorem}
@@ -458,7 +461,7 @@
 Allows passing different keys to the restated theorem.
 At the moment this is only useful with the \refKey{note} key.
 
-\begin{keythmscode}[]
+\begin{keythmscode}
 \begin{theorem}[
   store=rktest,
   note=Original,
@@ -962,7 +965,7 @@
 An optional \meta{property} can be given to retrieve only the corresponding part of the theorem.
 Currently only the property |body| is implemented, which retrieves the (unformatted) body of the theorem.
 
-\begin{keythmscode}[]
+\begin{keythmscode}
 \getkeytheorem{mytag}
 
 \begin{example}[store=mytag]
@@ -991,7 +994,7 @@
   }
 Executes \meta{true code} if being retrieved with \refCom{getkeytheorem} and \meta{false code} if in the original theorem. This is reversed if \texttt{store*} is used.
 
-\begin{keythmscode}[]
+\begin{keythmscode}
 \begin{example}[store=hmm]
 I am the \IfRestatingTF{restated}{original} example!
 \end{example}
@@ -1001,6 +1004,41 @@
 
 \end{docCommands}
 
+\subsection{Restating theorems from an external file}
+
+\begin{docCommand}{externaltheorems}
+  {\oarg{prefix}\marg{file name}}
+This is \pkg{keytheorems}' version of the \pkg{xr} package's \cs{externaldocument}.
+It allows the user to restate theorems from another document's |.thlist| file.
+Say you have a file |mycoolpaper.tex|,
+\begin{dispListing}
+% mycoolpaper.tex
+\documentclass{article}
+\usepackage{keytheorems}
+\newkeytheorem{theorem}
+\begin{document}
+\begin{theorem}[store=cooltheorem]
+My cool theorem.
+\end{theorem}
+\end{document}
+\end{dispListing}
+and you'd like to restate the theorem with tag |cooltheorem| in another file |myothercoolpaper.tex| with the same numbering as in the original paper.
+Since your new paper probably also has cool theorems that you may want to tag as |cooltheorem|, you'd like to give all restatable theorems from |mycoolpaper.tex| a prefix when retrieved with \refCom{getkeytheorem}, say ``|orig:|''.
+Just call |\externaltheorems[orig:]{mycoolpaper}| after loading \pkg{keytheorems} in the new document.
+Then any stored theorem from |mycoolpaper.tex| can be retrieved with \cs{getkeytheorem}\ttbraces{orig:\meta{tag}}.
+\begin{dispListing}
+% myothercoolpaper.tex
+\documentclass{article}
+\usepackage{keytheorems}
+\externaltheorems[orig:]{mycoolpaper}
+\newkeytheorem{theorem}
+\begin{document}
+\getkeytheorem{orig:cooltheorem}
+\end{document}
+\end{dispListing}
+It is important that the |theorem| environment is defined in both documents. 
+\end{docCommand}
+
 \section{Listing theorems}
 \label{listingthms}
 
@@ -1016,7 +1054,7 @@
 
 \end{docCommand}
 
-\begin{keythmscode}[]
+\begin{keythmscode}
 \listofkeytheorems
 \end{keythmscode}
 
@@ -1032,7 +1070,7 @@
   {}
   {initially unset}
   
-\begin{keythmscode}[]
+\begin{keythmscode}
 \listofkeytheorems[ignoreall,show=theorem]
 \listofkeytheorems[
   ignoreall, show=conjecture,
@@ -1124,7 +1162,7 @@
 Suppresses the title of the list of theorems.
 Useful for custom ordering of the list.
 
-\begin{keythmscode}[]
+\begin{keythmscode}
 \keytheoremlistset{ignoreall}
 \listofkeytheorems[show=example]
 \listofkeytheorems[show=solution, no-title]

Modified: trunk/Master/texmf-dist/tex/latex/keytheorems/class-support/keythms-beamer-support.tex
===================================================================
--- trunk/Master/texmf-dist/tex/latex/keytheorems/class-support/keythms-beamer-support.tex	2025-04-24 20:25:51 UTC (rev 75012)
+++ trunk/Master/texmf-dist/tex/latex/keytheorems/class-support/keythms-beamer-support.tex	2025-04-24 20:26:06 UTC (rev 75013)
@@ -96,7 +96,7 @@
   {
     \tl_if_novalue:nF { #2 } { \begin{actionenv}<#2> }
     \begin{tcolorbox}[
-      title={\usebeamerfont*{block title} #1},
+      title={\usebeamerfont*{block~title} #1},
       keythms_tcb_\l_keythms_thmuse_envname_tl
       ]
   }
@@ -109,7 +109,7 @@
     \tl_if_novalue:nF { #2 } { \begin{actionenv}<#2> }
     \begin{tcolorbox}[ keythms_tcb_\l_keythms_thmuse_envname_tl ]
       \group_begin:
-      \usebeamerfont*{block title} #1
+      \usebeamerfont*{block~title} #1
       \thmheadnl
       \hskip\thm at headsep
       \group_end:
@@ -119,7 +119,7 @@
     \tl_if_novalue:nF { #2 } { \end{actionenv} }
   }
 
-\cs_set_protected:Npn \keythms_keyify_theorem:n #1
+\cs_set_protected:Npn \__keythms_keyify_theorem:n #1
   { % #1 = theorem name
     \DeclareEnvironmentCopy { keythms_orig_#1 } { #1 }
     \DeclareDocumentEnvironment { keythms_beamer_grab_#1 } { m m m +b }
@@ -156,7 +156,7 @@
               { \tl_use:c { c__keythms_storeatbegin_ \l__keythms_thmuse_storereversed_tl _restatecounters_tl } }
             \prop_map_inline:Nn \l__keythms_restate_counters_prop
               {
-                \tl_set:ce { l_keythms_restate_current_####1_tl }
+                \tl_set:ce { l__keythms_restate_current_####1_tl }
                   { \the\value{####1} }
                 \setcounter { ####1 } { ####2 }
                 % ^ FIX: what if eq's numbered by section, theorem, etc.? The
@@ -201,7 +201,7 @@
         \prop_map_inline:Nn \l__keythms_restate_counters_prop
           {
             \exp_args:Nnc \setcounter { ####1 }
-              { l_keythms_restate_current_####1_tl }
+              { l__keythms_restate_current_####1_tl }
           }
       }
       { }

Modified: trunk/Master/texmf-dist/tex/latex/keytheorems/keytheorems.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/keytheorems/keytheorems.sty	2025-04-24 20:25:51 UTC (rev 75012)
+++ trunk/Master/texmf-dist/tex/latex/keytheorems/keytheorems.sty	2025-04-24 20:26:06 UTC (rev 75013)
@@ -2,8 +2,8 @@
 % 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]
-\def\@keythms at date{2025-01-22}
-\def\@keythms at version{0.2.5}
+\def\@keythms at date{2025-04-22}
+\def\@keythms at version{0.2.6}
 \ProvidesExplPackage{keytheorems}{\@keythms at date}{\@keythms at version}
   {l3keys interface to amsthm}
 
@@ -27,6 +27,12 @@
     \ProvideDocumentCommand \IfPackageLoadedWithOptionsT { m m +m }
       { \IfPackageLoadedWithOptionsTF{#1}{#2}{#3}{ } }
   }
+\cs_if_exist:NF \@gobble at som
+  { % defined in ltsect.dtx 1.1g
+    \DeclareExpandableDocumentCommand\@gobble at om{+o+m}{}
+    \DeclareExpandableDocumentCommand\@gobble at som{s+o+m}{}
+  }
+
 \RequirePackage{aliascnt}
 \RequirePackage{amsthm} % ams classes have way of ignoring this
 \RequirePackage{refcount}
@@ -57,8 +63,13 @@
   }
 \msg_new:nnn { keytheorems } { no-prop-for-stored-theorem }
   {
-    No~property~'#1'~found~for~stored~theorem~'#2'.
+    No~property~'#1'~found~for~stored~theorem~'#2'~\msg_line_context:.
   }
+\msg_new:nnn { keytheorems } { stored-tag-taken }
+  {
+    The~tag~'#1'~has~already~been~used!~
+    Each~value~of~the~'store'~key~must~be~unique.
+  }
 \msg_new:nnn { keytheorems } { store-reversed-not-got }
   {
     'store*=#1'~only~makes~sense~if~you've~called~\protect\getkeytheorem{#1}.~
@@ -76,46 +87,53 @@
   }
 \msg_new:nnn { keytheorems } { undefined-thm-hook }
   {
-    No~theorem~hook~'#1'.~Check~the~spelling.~
+    No~theorem~hook~'#1'~\msg_line_context:. \\
+    Check~the~spelling. \\
     Should~be~one~of~'prehead',~'posthead',~'prefoot',~'postfoot',~or~'restated'.
   }
 \msg_new:nnn { keytheorems } { refname-argcount }
   {
-    '#1'~accepts~either~one~or~two~comma-separated~items.
+    '#1'~accepts~either~one~or~two~comma-separated~items~\msg_line_context:.
   }
 \msg_new:nnn { keytheorems } { hyperref-Autoref }
   {
     You~have~not~loaded~hyperref.~The~\protect\Autoref\space command~needs~
-    hyperref~to~work.
+    hyperref~to~work~\msg_line_context:.
   }
 \msg_new:nnn { keytheorems } { no-Autorefname }
   {
-    No~Autoref~name~for~'#1'.~
+    No~Autoref~name~for~'#1'~\msg_line_context:. \\
     Please~define~\c_backslash_str #1Autorefname.
   }
 \msg_new:nnn { keytheorems } { ctrfmt-unnumbered }
   {
-    Theorem~'#1'~is~not~numbered.~Using~'counter-format'~does~not~make~sense.
+    Theorem~'#1'~is~not~numbered~\msg_line_context:. \\
+    Using~'counter-format'~does~not~make~sense.
   }
 \msg_new:nnn { keytheorems } { thmstyle-undefined }
   {
-    Theorem~style~'#1'~undefined.~
+    Theorem~style~'#1'~undefined~\msg_line_context:. \\
     Use~\protect\newkeytheoremstyle\space instead.
   }
 \msg_new:nnn { keytheorems } { thmstyle-defined }
   {
-    Theorem~style~'#1'~already~defined.~
+    Theorem~style~'#1'~already~defined~\msg_line_context:. \\
     Use~\protect\renewkeytheoremstyle\space instead.
   }
 \msg_new:nnn { keytheorems } { inherit-thmstyle-undefined }
   {
-    Theorem~style~'#1'~undefined.
+    Theorem~style~'#1'~undefined~\msg_line_context:.
   }
 \msg_new:nnn { keytheorems } { thm-undefined }
   {
-    Command~\c_backslash_str #1~undefined.~
+    Command~\c_backslash_str #1~undefined~\msg_line_context:.~
     Use~\protect\newkeytheorem\space instead.
   }
+\msg_new:nnn { keytheorems } { missing-ext-thlist }
+  {
+    File~'#1.thlist'~not~found~\msg_line_context:. \\
+    Theorems~will~not~be~imported.
+  }
 \msg_new:nnn { keytheorems } { title-code-with-AMS }
   {
     The~'title-code'~key~has~no~effect~with~an~AMS~class.
@@ -226,12 +244,17 @@
 \keys_define:nn { keytheorems/thmstyle }
   {
     bodyfont      .tl_set:N = \l__keythms_thmstyle_bodyfont_tl,
+    bodyfont      .value_required:n = true,
     break         .meta:n   = { postheadspace = \newline }, % add error if postheadspace set
     break         .value_forbidden:n = true,
     headfont      .tl_set:N = \l__keythms_thmstyle_headfont_tl,
+    headfont      .value_required:n = true,
     headformat    .meta:n   = { headstyle = {#1} }, % extra braces are necessary! Otherwise breaks if #1 contains comma
+    headformat    .value_required:n = true,
     headindent    .tl_set:N = \l__keythms_thmstyle_headindent_tl,
+    headindent    .value_required:n = true,
     headpunct     .tl_set:N = \l__keythms_thmstyle_headpunct_tl,
+    headpunct     .value_required:n = true,
     headstyle     .choice:,
     headstyle / margin .code:n =
       {
@@ -256,6 +279,7 @@
           }
       },
     headstyle / unknown .cs_set:Np = \keythms_thmstyle_headcmd:nnn #1#2#3,
+    headstyle     .value_required:n = true,
     inherit-style .code:n =
       {
         \tl_if_exist:cTF { g__keythms_thmstyle_#1_metakeys_tl }
@@ -265,24 +289,41 @@
           }
           { \msg_error:nnn { keytheorems } { inherit-thmstyle-undefined } { #1 } }
       },
+    inherit-style .value_required:n = true,
     notebraces    .code:n   = \exp_after:wN \__keythms_thmstyle_setbraces:nn #1,
+    notebraces    .value_required:n = true,
     notefont      .tl_set:N = \l__keythms_thmstyle_notefont_tl,
+    notefont      .value_required:n = true,
     noteseparator .tl_set:N = \l__keythms_thmstyle_noteseparator_tl,
+    noteseparator .value_required:n = true,
     numberfont    .tl_set:N = \l__keythms_thmstyle_numberfont_tl,
+    numberfont    .value_required:n = true,
     postheadspace .tl_set:N = \l__keythms_thmstyle_postheadspace_tl,
+    postheadspace .value_required:n = true,
     spaceabove    .tl_set:N = \l__keythms_thmstyle_spaceabove_tl,
+    spaceabove    .value_required:n = true,
     spacebelow    .tl_set:N = \l__keythms_thmstyle_spacebelow_tl,
+    spacebelow    .value_required:n = true,
     % thm keys that are saved for later
     counter-format        .code:n = \__keythms_thmstyle_savethmkey_reqval:n { #1 },
+    counter-format        .value_required:n = true,
     leftmargin            .code:n = \__keythms_thmstyle_savethmkey_reqval:n { #1 },
+    leftmargin            .value_required:n = true,
     numbered              .code:n = \__keythms_thmstyle_savethmkey_optval:n { #1 },
     numberlike            .code:n = \__keythms_thmstyle_savethmkey_reqval:n { #1 },
+    numberlike            .value_required:n = true,
     numberwithin          .code:n = \__keythms_thmstyle_savethmkey_reqval:n { #1 },
+    numberwithin          .value_required:n = true,
     parent                .code:n = \__keythms_thmstyle_savethmkey_reqval:n { #1 },
+    parent                .value_required:n = true,
     postfoothook          .code:n = \__keythms_thmstyle_savethmkey_reqval:n { #1 },
+    postfoothook          .value_required:n = true,
     postheadhook          .code:n = \__keythms_thmstyle_savethmkey_reqval:n { #1 },
+    postheadhook          .value_required:n = true,
     prefoothook           .code:n = \__keythms_thmstyle_savethmkey_reqval:n { #1 },
+    prefoothook           .value_required:n = true,
     preheadhook           .code:n = \__keythms_thmstyle_savethmkey_reqval:n { #1 },
+    preheadhook           .value_required:n = true,
     qed                   .code:n =
       { % qed needs special treatment to distinguish qed from qed={}
         \tl_if_novalue:nTF { #1 }
@@ -297,11 +338,15 @@
       },
     qed                   .default:o = \c_novalue_tl,
     rightmargin           .code:n = \__keythms_thmstyle_savethmkey_reqval:n { #1 },
+    rightmargin           .value_required:n = true,
     sharenumber           .code:n = \__keythms_thmstyle_savethmkey_reqval:n { #1 },
+    sharenumber           .value_required:n = true,
     sibling               .code:n = \__keythms_thmstyle_savethmkey_reqval:n { #1 },
+    sibling               .value_required:n = true,
     tcolorbox             .code:n = \__keythms_thmstyle_savethmkey_optval:n { #1 },
     tcolorbox-no-titlebar .code:n = \__keythms_thmstyle_savethmkey_optval:n { #1 },
     within                .code:n = \__keythms_thmstyle_savethmkey_reqval:n { #1 },
+    within                .value_required:n = true,
   }
 
 \cs_new_protected:Nn \keythms_thmstyle_thmname:n { \thmname{#1} }
@@ -554,9 +599,13 @@
 \keys_define:nn { keytheorems/thm }
   {
     counter-format .tl_set:N  = \l__keythms_thm_ctrfmt_tl,
+    counter-format .value_required:n = true,
     heading        .meta:n    = { name = {#1} },
+    heading        .value_required:n = true,
     leftmargin     .dim_set:N = \l__keythms_thm_leftmargin_dim,
+    leftmargin     .value_required:n = true,
     name           .tl_set:N  = \l__keythms_thm_name_tl,
+    name           .value_required:n = true,
     numbered       .choice:,
     numbered       .default:n = true,
     numbered / false .code:n  = \bool_set_false:N \l__keythms_thm_numbered_bool,
@@ -569,21 +618,34 @@
     numbered / unless~unique .meta:n = { numbered = unless-unique },
     numbered / yes .meta:n    = { numbered = true },
     numberlike     .meta:n    = { sibling = {#1} },
+    numberlike     .value_required:n = true,
     numberwithin   .meta:n    = { parent = {#1} },
+    numberwithin   .value_required:n = true,
     parent         .tl_set:N  = \l__keythms_thm_parent_tl,
+    parent         .value_required:n = true,
     postfoothook   .tl_set:N  = \l__keythms_thm_postfoothook_tl,
+    postfoothook   .value_required:n = true,
     postheadhook   .tl_set:N  = \l__keythms_thm_postheadhook_tl,
+    postheadhook   .value_required:n = true,
     prefoothook    .tl_set:N  = \l__keythms_thm_prefoothook_tl,
+    prefoothook    .value_required:n = true,
     preheadhook    .tl_set:N  = \l__keythms_thm_preheadhook_tl,
+    preheadhook    .value_required:n = true,
     qed            .tl_set:N  = \l__keythms_thm_qed_tl,
     qed            .default:o = \c_novalue_tl,
     % ^ distinguish between 'qed' and 'qed={}'
     refname        .tl_set:N  = \l__keythms_thm_refname_tl,
+    refname        .value_required:n = true,
     Refname        .tl_set:N  = \l__keythms_thm_Refname_tl,
+    Refname        .value_required:n = true,
     rightmargin    .dim_set:N = \l__keythms_thm_rightmargin_dim,
+    rightmargin    .value_required:n = true,
     sharenumber    .meta:n    = { sibling = {#1} },
+    sharenumber    .value_required:n = true,
     sibling        .tl_set:N  = \l__keythms_thm_sibling_tl,
+    sibling        .value_required:n = true,
     style          .tl_set:N  = \l__keythms_thm_style_tl,
+    style          .value_required:n = true,
     style          .groups:n  = { style-comes-first },
     tcolorbox      .code:n    =
       {
@@ -598,7 +660,9 @@
       },
     tcolorbox-no-titlebar .default:n = {},
     title          .meta:n    = { name = {#1} },
+    title          .value_required:n = true,
     within         .meta:n    = { parent = {#1} },
+    within         .value_required:n = true,
   }
 
 \keys_precompile:nnN { keytheorems/thm }
@@ -781,7 +845,7 @@
           }
       }
     % Store theorem def and redefine it with keys
-    \keythms_keyify_theorem:n { #1 }
+    \__keythms_keyify_theorem:n { #1 }
     % define \<env>autorefname and \<env>Autorefname, might be redefined next
     \exp_args:NnV \cs_set:cpn { #1 autorefname } \l__keythms_thm_name_tl
     \exp_args:NnV \cs_set:cpn { #1 Autorefname } \l__keythms_thm_name_tl
@@ -1136,17 +1200,23 @@
               { keytheorems/recordednote }
           }
       }
+    \IfFormatAtLeastTF { 2024-06-01 }
+      {
+        \property_new:nnnn { keytheorems/recordedshortnote } { now } { }
+          { \l__keythms_thmuse_shortnote_tl }
+        \cs_new:Npn \__keythms_getrecordedshortnote:n #1
+          {
+            \property_ref:nn { keythms_recordednote_#1 }
+              { keytheorems/recordedshortnote }
+          }
+      }
+      { % if format not new enough, just don't support continues* and short-note
+        \cs_new:Npn \__keythms_getrecordedshortnote:n #1 { }
+        % also need to cancel this definition
+        \cs_set:Npn \__keythms_thmuse_recordnote: { }
+      }
   }
 
-% this doesn't need to be at begindocument because doesn't depend on nameref
-\property_new:nnnn { keytheorems/recordedshortnote } { now } { }
-  { \l__keythms_thmuse_shortnote_tl }
-\cs_new:Npn \__keythms_getrecordedshortnote:n #1
-  {
-    \property_ref:nn { keythms_recordednote_#1 }
-      { keytheorems/recordedshortnote }
-  }
-
 \keys_define:nn { keytheorems/thmuse }
   {
     continues  .tl_set:N = \l__keythms_thmuse_contlabel_tl,
@@ -1181,7 +1251,7 @@
     store*     .tl_set:N = \l__keythms_thmuse_storereversed_tl,
   }
 
-\cs_new_protected:Npn \keythms_keyify_theorem:n #1
+\cs_new_protected:Npn \__keythms_keyify_theorem:n #1
   { % #1 = theorem name
     \DeclareEnvironmentCopy { keythms_orig_#1 } { #1 }
     \DeclareDocumentEnvironment { keythms_grab_#1 } { m m +b }
@@ -1216,7 +1286,7 @@
               { \tl_use:c { c__keythms_storeatbegin_ \l__keythms_thmuse_storereversed_tl _restatecounters_tl } }
             \prop_map_inline:Nn \l__keythms_restate_counters_prop
               {
-                \tl_set:ce { l_keythms_restate_current_####1_tl }
+                \tl_set:ce { l__keythms_restate_current_####1_tl }
                   { \the\value{####1} }
                 \setcounter { ####1 } { ####2 }
                 % ^ FIX: what if eq's numbered by section, theorem, etc.? The
@@ -1259,7 +1329,7 @@
         \prop_map_inline:Nn \l__keythms_restate_counters_prop
           {
             \exp_args:Nnc \setcounter { ####1 }
-              { l_keythms_restate_current_####1_tl }
+              { l__keythms_restate_current_####1_tl }
           }
       }
       { }
@@ -1531,16 +1601,23 @@
         \keys_set:nn { keytheorems/storeatbegin } { #6 }
         \tl_if_empty:NF \l__keythms_storeatbegin_store_tl
           {
-            \cs_new_protected:cpn
-              { __keythms_getthm_ \l__keythms_storeatbegin_store_tl _theorem }
+            \cs_if_exist:cTF { __keythms_getthm_ \l__keythms_storeatbegin_store_tl _theorem }
               {
-                \__keythms_getthm_theorem:nnnnn
-                  {#1}{#2}{#5}{#6}{#7}
+                \msg_error:nnV { keytheorems } { stored-tag-taken }
+                  \l__keythms_storeatbegin_store_tl
               }
-            \cs_new_protected:cpn
-              { __keythms_getthm_ \l__keythms_storeatbegin_store_tl _body }
               {
-                \__keythms_getthm_body:nnn {#1}{#5}{#7}
+                \cs_new_protected:cpn
+                  { __keythms_getthm_ \l__keythms_storeatbegin_store_tl _theorem }
+                  {
+                    \__keythms_getthm_theorem:nnnnn
+                      {#1}{#2}{#5}{#6}{#7}
+                  }
+                \cs_new_protected:cpn
+                  { __keythms_getthm_ \l__keythms_storeatbegin_store_tl _body }
+                  {
+                    \__keythms_getthm_body:nnn {#1}{#5}{#7}
+                  }
               }
           }
         \tl_if_empty:NF \l__keythms_storeatbegin_storereversed_tl
@@ -1562,8 +1639,16 @@
     \cs_set_protected:Npn \KeyThmsSavedTheoremReversed #1#2#3#4
       {
         \bool_new:c { g__keythms_restate_#1_called_bool }
-        \cs_gset:cpn { __keythms_getthm_#1_theorem }
-          { \__keythms_getthmreversed_theorem:nnn { #2 } { #3 } { #4 } }
+        \cs_if_exist:cTF { __keythms_getthm_#1_theorem }
+          {
+            \msg_error:nnn { keytheorems } { stored-tag-taken } { #1 }
+          }
+          {
+            \cs_gset:cpn { __keythms_getthm_#1_theorem }
+              {
+                \__keythms_getthmreversed_theorem:nnn { #2 } { #3 } { #4 }
+              }
+          }
         \hook_gput_code:nnn { begindocument/end } { . }
           {
             \cs_if_exist:cF { __keythms_getthm_#1_body }
@@ -1590,11 +1675,6 @@
 \NewDocumentCommand \IfRestatingT { } { \keythms_if_restating:T }
 \NewDocumentCommand \IfRestatingF { } { \keythms_if_restating:F }
 
-\cs_if_exist:NF \@gobble at som
-  { % defined in ltsect.dtx 1.1g
-    \DeclareExpandableDocumentCommand\@gobble at om{+o+m}{}
-    \DeclareExpandableDocumentCommand\@gobble at som{s+o+m}{}
-  }
 \hook_gput_code:nnn { keytheorems/allthms/restated } { . }
   { % code to disable things in restated theorems
     \cs_set_eq:NN \label \@gobble at om % opt arg in case cleveref loaded
@@ -1613,7 +1693,7 @@
     \prop_set_from_keyval:Nn \l__keythms_restate_counters_prop { #3 }
     \prop_map_inline:Nn \l__keythms_restate_counters_prop
       {
-        \tl_set:ce { l_keythms_restate_current_##1_tl } { \the\value{##1} }
+        \tl_set:ce { l__keythms_restate_current_##1_tl } { \the\value{##1} }
         \setcounter { ##1 } { ##2 }
         % ^ FIX: what if eq's numbered by section, theorem, etc.? The
         %        thmtools code is opaque.... Or maybe should be up to the
@@ -1647,7 +1727,7 @@
     \prop_map_inline:Nn \l__keythms_restate_counters_prop
       {
         \exp_args:Nnc \setcounter { ##1 }
-          { l_keythms_restate_current_##1_tl }
+          { l__keythms_restate_current_##1_tl }
       }
     \group_end:
   }
@@ -1659,7 +1739,7 @@
     \prop_set_from_keyval:Nn \l__keythms_restate_counters_prop { #2 }
     \prop_map_inline:Nn \l__keythms_restate_counters_prop
       {
-        \tl_set:ce { l_keythms_restate_current_##1_tl } { \the\value{##1} }
+        \tl_set:ce { l__keythms_restate_current_##1_tl } { \the\value{##1} }
         \setcounter { ##1 } { ##2 }
         % ^ FIX: what if eq's numbered by section, theorem, etc.? The
         %        thmtools code is opaque.... Or maybe should be up to the
@@ -1674,7 +1754,7 @@
     \prop_map_inline:Nn \l__keythms_restate_counters_prop
       {
         \exp_args:Nnc \setcounter { ##1 }
-          { l_keythms_restate_current_##1_tl }
+          { l__keythms_restate_current_##1_tl }
       }
     \group_end:
   }
@@ -1753,6 +1833,68 @@
       }
   }
 
+\NewDocumentCommand { \externaltheorems } { O{} m }
+  {
+    \group_begin:
+    \cs_set_protected:Npn \KeyThmsSavedTheorem ##1##2##3##4##5##6##7
+      {
+        \group_begin:
+        \keys_set:nn { keytheorems/storeatbegin } { ##6 }
+        \tl_if_empty:NF \l__keythms_storeatbegin_store_tl
+          {
+            \cs_if_exist:cTF
+              { __keythms_getthm_ #1 \l__keythms_storeatbegin_store_tl _theorem }
+              {
+                \msg_error:nne { keytheorems } { stored-tag-taken }
+                  { #1 \l__keythms_storeatbegin_store_tl }
+              }
+              {
+                \cs_new_protected:cpn
+                  { __keythms_getthm_ #1 \l__keythms_storeatbegin_store_tl _theorem }
+                  {
+                    \__keythms_getthm_theorem:nnnnn
+                      {##1}{##2}{##5}{##6}{##7}
+                  }
+                \cs_new_protected:cpn
+                  { __keythms_getthm_ #1 \l__keythms_storeatbegin_store_tl _body }
+                  {
+                    \__keythms_getthm_body:nnn {##1}{##5}{##7}
+                  }
+              }
+          }
+        \tl_if_empty:NF \l__keythms_storeatbegin_storereversed_tl
+          { % store* should behave just like store in an external document
+            \cs_if_exist:cTF
+              { __keythms_getthm_ #1 \l__keythms_storeatbegin_storereversed_tl _theorem }
+              {
+                \msg_error:nne { keytheorems } { stored-tag-taken }
+                  { #1 \l__keythms_storeatbegin_storereversed_tl }
+              }
+              {
+                \cs_new_protected:cpn
+                  { __keythms_getthm_ #1 \l__keythms_storeatbegin_storereversed_tl _theorem }
+                  {
+                    \__keythms_getthm_theorem:nnnnn
+                      {##1}{##2}{##5}{##6}{##7}
+                  }
+                \cs_new_protected:cpn
+                  { __keythms_getthm_ #1 \l__keythms_storeatbegin_storereversed_tl _body }
+                  {
+                    \__keythms_getthm_body:nnn {##1}{##5}{##7}
+                  }
+              }
+          }
+        \group_end:
+      }
+    % ignore \KeyThmsSavedTheoremReversed from external file
+    \cs_set_protected:Npn \KeyThmsSavedTheoremReversed ##1##2##3##4 { }
+    \file_if_exist_input:nF { #2.thlist }
+      {
+        \msg_warning:nnn { keytheorems } { missing-ext-thlist } { #2 }
+      }
+    \group_end:
+  }
+
 %%%%%%%%%%%%%%%%%%%%%
 %%% Theorem Hooks %%%
 %%%%%%%%%%%%%%%%%%%%%
@@ -1779,13 +1921,16 @@
   {
     chapter-skip-length .dim_set:N  = \keythms at listof@chaptervspace at dim,
     chapter-skip-length .initial:n  = 10pt,
+    chapter-skip-length .value_required:n = true,
     format-code         .cs_set:Np  = \__keythms_listof_misdirect:nnn #1#2#3,
     format-code         .initial:n  = \numberline{#2}#1#3,
+    format-code         .value_required:n = true,
     ignore              .code:n     =
       {
         \hook_gput_code:nnn { begindocument/before } { keytheorems }
           { \keythms_listof_ignore:n { #1 } }
       },
+    ignore              .value_required:n = true,
     ignoreall           .code:n     =
       { % in case called before theorem defined
         \hook_gput_code:nnn { begindocument/before } { keytheorems }
@@ -1797,6 +1942,7 @@
     ignoreall           .value_forbidden:n = true,
     indent              .dim_set:N  = \l__keythms_listof_indent_dim,
     indent              .initial:n  = 1.5em,
+    indent              .value_required:n = true,
     no-chapter-skip     .bool_set:N = \l__keythms_listof_nochapskip_bool,
     no-chapter-skip     .initial:n  = false,
     no-continues        .bool_set:N = \l__keythms_listof_nocont_bool, 
@@ -1807,8 +1953,10 @@
     no-toc              .initial:n  = false, % false does not mean "to-toc" for standard classes
     note-code           .cs_set:Np  = \__keythms_listof_notecmd:n #1,
     note-code           .initial:n  = { ~ (#1) },
+    note-code           .value_required:n = true,
     numwidth            .dim_set:N  = \l__keythms_listof_numwidth_dim,
     numwidth            .initial:n  = 2.3em,
+    numwidth            .value_required:n = true,
     onlynamed           .code:n     =
       {
         \hook_gput_code:nnn { begindocument/before } { keytheorems }
@@ -1840,6 +1988,7 @@
         \hook_gput_code:nnn { begindocument/before } { keytheorems }
           { \keythms_listof_show:n { #1 } }
       },
+    show                .value_required:n = true,
     showall             .code:n     =
       { % in case called before theorem defined
         \hook_gput_code:nnn { begindocument/before } { keytheorems }
@@ -1853,7 +2002,9 @@
     swapnumber          .initial:n  = false,
     title               .tl_set:N   = \l__keythms_listof_title_tl,
     title               .initial:n  = \GetTranslation{keythms_listof_title},
+    title               .value_required:n = true,
     title-code          .cs_set:Np  = \__keythms_listof_titlecmd:n #1,
+    title-code          .value_required:n = true,
   }
 
 \hook_gput_code:nnn { begindocument } { . }
@@ -2215,17 +2366,20 @@
       { % not sure how best to handle this translation
         \GetTranslation{keythms_continues}\pageref{#1}
       },
+    continues-code   .value_required:n    = true,
     overload         .code:n              = \__keythms_overload_code:,
     overload         .value_forbidden:n   = true,
     overload         .usage:n             = preamble,
     qed-symbol       .cs_set_protected:Np = \qedsymbol,
+    qed-symbol       .value_required:n    = true,
     restate-counters .code:n              =
       {
         \clist_map_inline:nn { #1 }
-          { \tl_new:c { l_keythms_restate_current_##1_tl } }
+          { \tl_new:c { l__keythms_restate_current_##1_tl } }
         \clist_gput_right:Nn \g__keythms_restatecounters_clist { #1 }
       },
     restate-counters .initial:n           = equation,
+    restate-counters .value_required:n    = true,
     store-all        .code:n              = \__keythms_storeall_code:,
     store-all        .value_forbidden:n   = true,
     store-all        .usage:n             = preamble,
@@ -2395,19 +2549,27 @@
       {
         textwidth   .code:n =
           \clist_put_right:Nn \l__keythms_tcbshaded_keys_clist { width=##1 },
+        textwidth   .value_required:n = true,
         bgcolor     .code:n =
           \clist_put_right:Nn \l__keythms_tcbshaded_keys_clist { colback=##1 },
+        bgcolor     .value_required:n = true,
         rulewidth   .code:n =
           \clist_put_right:Nn \l__keythms_tcbshaded_keys_clist { boxrule=##1 },
+        rulewidth   .value_required:n = true,
         rulecolor   .code:n =
           \clist_put_right:Nn \l__keythms_tcbshaded_keys_clist { colframe=##1 },
+        rulecolor   .value_required:n = true,
         margin      .code:n =
           \clist_put_right:Nn \l__keythms_tcbshaded_keys_clist { boxsep=##1 },
+        margin      .value_required:n = true,
         padding     .meta:n = { margin=##1 },
+        padding     .value_required:n = true,
         leftmargin  .code:n =
           \clist_put_right:Nn \l__keythms_tcbshaded_keys_clist { left~skip=##1 },
+        leftmargin  .value_required:n = true,
         rightmargin .code:n =
           \clist_put_right:Nn \l__keythms_tcbshaded_keys_clist { right~skip=##1 },
+        rightmargin .value_required:n = true,
       }
     \keys_define:nn { keytheorems/thm/thmbox }
       {
@@ -2416,16 +2578,19 @@
             \clist_put_right:Nn \l__keythms_tcbthmbox_keys_clist
               { keythms_tcbthmbox_L }
           },
+        L .value_forbidden:n = true,
         M .code:n =
           {
             \clist_put_right:Nn \l__keythms_tcbthmbox_keys_clist
               { keythms_tcbthmbox_M }
           },
+        M .value_forbidden:n = true,
         S .code:n =
           {
             \clist_put_right:Nn \l__keythms_tcbthmbox_keys_clist
               { keythms_tcbthmbox_S }
           },
+        S .value_forbidden:n = true,
         underline .choice:,
         underline / true .code:n = {},
         underline / false .code:n =
@@ -2435,6 +2600,7 @@
           },
         underline .default:n = true,
         nounderline .meta:n = { underline=false },
+        nounderline .value_forbidden:n = true,
         cut .choice:,
         cut / true .code:n = {},
         cut / false .code:n =
@@ -2443,31 +2609,37 @@
           },
         cut .default:n = true,
         nocut .meta:n = { cut=false },
+        nocut .value_forbidden:n = true,
         thickness .code:n =
           { % could also add keys to clist with changed dimens; which is better?
             \tl_gput_right:cn { g__keythms_thm_preheadfromkeys_ \l__keythms_thm_envname_tl _tl }
               { \dim_set:Nn \l_keythms_tcbthmbox_thickness_dim { ##1 } }
           },
+        thickness .value_required:n = true,
         leftmargin .code:n =
           {
             \tl_gput_right:cn { g__keythms_thm_preheadfromkeys_ \l__keythms_thm_envname_tl _tl }
               { \dim_set:Nn \l_keythms_tcbthmbox_leftmargin_dim { ##1 } }
           },
+        leftmargin .value_required:n = true,
         rightmargin .code:n =
           {
             \tl_gput_right:cn { g__keythms_thm_preheadfromkeys_ \l__keythms_thm_envname_tl _tl }
               { \dim_set:Nn \l_keythms_tcbthmbox_rightmargin_dim { ##1 } }
           },
+        rightmargin .value_required:n = true,
         hskip .code:n =
           {
             \tl_gput_right:cn { g__keythms_thm_preheadfromkeys_ \l__keythms_thm_envname_tl _tl }
               { \dim_set:Nn \l_keythms_tcbthmbox_hskip_dim { ##1 } }
           },
+        hskip .value_required:n = true,
         vskip .code:n =
           {
             \tl_gput_right:cn { g__keythms_thm_preheadfromkeys_ \l__keythms_thm_envname_tl _tl }
               { \dim_set:Nn \l_keythms_tcbthmbox_vskip_dim { ##1 } }
           },
+        vskip .value_required:n = true,
       }
     \dim_new:N \l_keythms_tcbthmbox_thickness_dim
     \dim_set:Nn \l_keythms_tcbthmbox_thickness_dim { 0.6pt }



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