summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2025-02-15 21:24:56 +0000
committerKarl Berry <karl@freefriends.org>2025-02-15 21:24:56 +0000
commit4969b03997b1b4c5690bd179fe5576ec24729bdc (patch)
treece1dad42901d64032c3b73a5f6f4c460e51c261f
parent9659c1d10fbf758af06d0df02bfe312e9354f6f2 (diff)
keytheorems (15feb25)
git-svn-id: svn://tug.org/texlive/trunk@74002 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Master/texmf-dist/doc/latex/keytheorems/CHANGELOG.md8
-rw-r--r--Master/texmf-dist/doc/latex/keytheorems/keytheorems-doc.pdfbin175459 -> 181198 bytes
-rw-r--r--Master/texmf-dist/doc/latex/keytheorems/keytheorems-doc.tex67
-rw-r--r--Master/texmf-dist/tex/latex/keytheorems/keytheorems.sty484
4 files changed, 368 insertions, 191 deletions
diff --git a/Master/texmf-dist/doc/latex/keytheorems/CHANGELOG.md b/Master/texmf-dist/doc/latex/keytheorems/CHANGELOG.md
index 079b2bf542b..ba9b7030d4e 100644
--- a/Master/texmf-dist/doc/latex/keytheorems/CHANGELOG.md
+++ b/Master/texmf-dist/doc/latex/keytheorems/CHANGELOG.md
@@ -1,5 +1,12 @@
# Changelog for keytheorems package
+## [v0.2.5]
+- disable `\index` and `\glossary` in restated theorems
+- fix [\#11](https://github.com/mbertucci47/keytheorems/issues/11)
+- fix [\#13](https://github.com/mbertucci47/keytheorems/issues/13)
+- avoid printing `note={}` to thlist file for theorems without a note
+- add `counter-format` key
+
## [v0.2.4]
- fixed issue with too much expansion in `manual-num`
- fix [\#14](https://github.com/mbertucci47/keytheorems/issues/14)
@@ -62,6 +69,7 @@
## 0.1.0 - 2024-09-04
- First release
+[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
[v0.2.2]: https://github.com/mbertucci47/keytheorems/compare/v0.2.1...v0.2.2
diff --git a/Master/texmf-dist/doc/latex/keytheorems/keytheorems-doc.pdf b/Master/texmf-dist/doc/latex/keytheorems/keytheorems-doc.pdf
index 3b107f6a1e6..8977fee015d 100644
--- a/Master/texmf-dist/doc/latex/keytheorems/keytheorems-doc.pdf
+++ b/Master/texmf-dist/doc/latex/keytheorems/keytheorems-doc.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/keytheorems/keytheorems-doc.tex b/Master/texmf-dist/doc/latex/keytheorems/keytheorems-doc.tex
index 8edfc37667a..e2fd76c3cff 100644
--- a/Master/texmf-dist/doc/latex/keytheorems/keytheorems-doc.tex
+++ b/Master/texmf-dist/doc/latex/keytheorems/keytheorems-doc.tex
@@ -66,7 +66,7 @@
notefont=\bfseries,
bodyfont=\normalfont,
}
-\newkeytheorem{mytheo}[name=My Theorem,style=tcb-standard]
+\newkeytheorem{mytheo}[name=Theorem,style=tcb-standard]
\newkeytheorem{corollary}[tcolorbox]
\newkeytheorem{definition}[
style=definition,
@@ -80,6 +80,10 @@
\newkeytheorem{observation}[style=breaksty]
\newkeytheorem{quotethm}[name=Quote Theorem,leftmargin=1cm,rightmargin=1cm]
\newkeytheorem{indentedthm}[name=Indented Theorem,leftmargin=1cm]
+\newkeytheorem{mainthm}[
+ name=Theorem,
+ counter-format=\Alph{mainthm},
+ ]
\MakeShortVerb{\|}
\newcommand{\env}{\texttt}
@@ -365,7 +369,7 @@ This replaces the value of \refKey{note} when displayed in the list of theorems
This is the key-value equivalent of |\begin{theorem}| \cs{label}\marg{label name}.
\begin{keythmscode}[]
-\begin{theorem}[label=bezout]
+\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}
See \zcref{bezout}.
@@ -395,12 +399,15 @@ Don't confuse your readers by changing the numbering without good reason.
Pick up a theorem where you left off.
The theorem number remains the same.
The printed text can be customized with the \refKey{continues-code} option.
-The starred version also copies the theorem note, if it exists.
+The starred version also copies the theorem \refKey{note} and \refKey{short-note} if they are nonempty.
\begin{keythmscode}[]
\begin{theorem}[continues=bezout]
Moreover, the integers of the form $az+bt$ are exactly the multiples of $\gcd(a,b)$.
\end{theorem}
+\begin{theorem}[continues*=bezout]
+Moreover, the integers of the form $az+bt$ are exactly the multiples of $\gcd(a,b)$.
+\end{theorem}
\end{keythmscode}
\end{docKey}
@@ -454,8 +461,8 @@ At the moment this is only useful with the \refKey{note} key.
\begin{keythmscode}[]
\begin{theorem}[
store=rktest,
- note=ORIGINAL,
- restate-keys={note=RESTATED}
+ note=Original,
+ restate-keys={note=Restated}
]
Wow, yet another theorem.
\end{theorem}
@@ -684,6 +691,34 @@ It offers all the same features as \pkg{cleveref} and is actively maintained.
\subsection{Keys added by \pkg{keytheorems}} \label{thm-added-keys}
+\begin{docKey}{counter-format}
+ {=\meta{code}}
+ {initially unset}
+Syntactic sugar that essentially does \cs{renewcommand}\ttbraces{\cs{the}\meta{counter}}\marg{code}.
+The \meta{code} should not contain any unexpandable tokens such as formatting commands.
+Formatting should be taken care of in the style keys \refKey{headfont} and \refKey{numberfont}.
+If used with an unnumbered theorem, a warning is issued.
+
+\begin{codepreamble}
+\newkeytheorem{mainthm}[
+ name=Theorem,
+ counter-format=\Alph{mainthm},
+ ]
+\end{codepreamble}
+
+\begin{keythmscode}[withpreamble]
+\begin{mainthm}
+The first main result, distinguished by using letters.
+\end{mainthm}
+\begin{mainthm}
+And here is the second main result.
+\end{mainthm}
+\end{keythmscode}
+
+Eventually \LaTeX{} will allow syntax of the form \cs{Alph*} similar to \pkg{enumitem}'s |label| key, where the |*| means ``use the current counter'' (see \href{https://github.com/latex3/latex2e/issues/1632}{\texttt{latex2e\#1632}}).
+Then the above example could be written as |counter-format=\Alph*|.
+\end{docKey}
+
\begin{docKeys}[doc parameter={=\meta{length}}]
{
{ doc name=leftmargin },
@@ -741,10 +776,10 @@ The theorem head is typeset as a tcolorbox title; to avoid this see \refKey{tcol
\begin{keythmscode}[withpreamble]
\begin{corollary}
-Some text.
+Products exist in the category of schemes over $S$.
\end{corollary}
-\begin{definition}[A nice definition]
-Some more text.
+\begin{definition}[Dedekind domains]
+A \emph{Dedekind domain} is an integrally closed, Noetherian domain of dimension one.
\end{definition}
\end{keythmscode}
@@ -763,8 +798,8 @@ Same usage as \refKey{tcolorbox} but the theorem head is typeset as usual, not a
\end{codepreamble}
\begin{keythmscode}[withpreamble]
-\begin{boxcor}
-Some text.
+\begin{boxcor}[Cauchy's theorem]
+Let $G$ be a finite group and $p$ a prime dividing the order of $G$. Then $G$ contains an element of order $p$.
\end{boxcor}
\end{keythmscode}
@@ -787,14 +822,14 @@ Some text.
bodyfont=\normalfont,
}
\newkeytheorem{mytheo}[
- name=My Theorem,
+ name=Theorem,
style=tcb-standard
]
\end{codepreamble}
\begin{keythmscode}[withpreamble]
-\begin{mytheo}[This is my title]
-Some theorem text.
+\begin{mytheo}[Quillen-Suslin]
+Every finitely generated projective module over a polynomial ring is free.
\end{mytheo}
\end{keythmscode}
@@ -1196,7 +1231,7 @@ This can be useful for disabling commands such as \cs{footnote} in the restated
\addtotheoremhook{restated}{\renewcommand\footnote[2][]{}}
\end{dispListing}
-By default, \pkg{keytheorems} disables the \cs{label} and \cs{RecordProperties} commands in restated theorems.
+By default, the \hook{restated} hook disables the \cs{glossary}, \cs{index}, \cs{label}, and \cs{RecordProperties} commands.
In \pkg{thmtools}, the \hook{prefoot} and \hook{postfoot} hooks always prepend code, i.e. the code
\begin{dispListing}
@@ -1212,7 +1247,7 @@ With \pkg{keytheorems}, code is added in the order declared, meaning
results in |AB| after the theorem.
This is the behavior of the \LaTeX{} kernel hooks that \pkg{keytheorems} uses under the hood.
-Code added using the hook keys \refKey{preheadhook}, etc. is outermost, meaning executed first in \hook{prehead} and \hook{posthead} and last in \hook{prefoot} and \hook{postfoot}.
+Code added using the hook keys \refKey{preheadhook}, etc. is outermost, meaning executed first in \hook{prehead} and \hook{posthead} and last in \hook{prefoot} and \hook{postfoot}. Furthermore, if present, the \refKey{qed} symbol is placed \emph{before} the \hook{prefoot} hook.
\end{docCommand}
\section{Miscellaneous notes}
@@ -1265,7 +1300,7 @@ An example invocation might look like
testphase={phase-III,math,table,title,firstaid}
}
\end{dispListing}
-
+With the current |dev| formats, the last key-value can be replaced with |testphase=latest|.
At a minimum, the |testphase| modules |phase-III| and |firstaid| are required.
\subsection{Public coding interfaces}
diff --git a/Master/texmf-dist/tex/latex/keytheorems/keytheorems.sty b/Master/texmf-dist/tex/latex/keytheorems/keytheorems.sty
index 4f1d145935a..3f689f68add 100644
--- a/Master/texmf-dist/tex/latex/keytheorems/keytheorems.sty
+++ b/Master/texmf-dist/tex/latex/keytheorems/keytheorems.sty
@@ -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@date{2025-01-21}
-\def\@keythms@version{0.2.4}
+\def\@keythms@date{2025-01-22}
+\def\@keythms@version{0.2.5}
\ProvidesExplPackage{keytheorems}{\@keythms@date}{\@keythms@version}
{l3keys interface to amsthm}
@@ -77,7 +77,11 @@
\msg_new:nnn { keytheorems } { undefined-thm-hook }
{
No~theorem~hook~'#1'.~Check~the~spelling.~
- Should~be~one~of~'prehead',~'posthead',~'prefoot',~'postfoot',~or'restated'.
+ 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.
}
\msg_new:nnn { keytheorems } { hyperref-Autoref }
{
@@ -89,6 +93,10 @@
No~Autoref~name~for~'#1'.~
Please~define~\c_backslash_str #1Autorefname.
}
+\msg_new:nnn { keytheorems } { ctrfmt-unnumbered }
+ {
+ Theorem~'#1'~is~not~numbered.~Using~'counter-format'~does~not~make~sense.
+ }
\msg_new:nnn { keytheorems } { thmstyle-undefined }
{
Theorem~style~'#1'~undefined.~
@@ -130,9 +138,12 @@
%%% Declare Variables %%%
%%%%%%%%%%%%%%%%%%%%%%%%%
+\clist_new:N \l__keythms_tmpa_clist
\dim_new:N \l__keythms_tmpa_dim
\iow_new:N \g__keythms_tmpa_iow
+\seq_new:N \l__keythms_tmpa_seq
\tl_new:N \l__keythms_tmpa_tl
+\tl_new:N \l__keythms_tmpb_tl
\bool_new:N \g__keythms_listof_writefile_bool
\bool_gset_false:N \g__keythms_listof_writefile_bool
@@ -262,6 +273,7 @@
spaceabove .tl_set:N = \l__keythms_thmstyle_spaceabove_tl,
spacebelow .tl_set:N = \l__keythms_thmstyle_spacebelow_tl,
% thm keys that are saved for later
+ counter-format .code:n = \__keythms_thmstyle_savethmkey_reqval:n { #1 },
leftmargin .code:n = \__keythms_thmstyle_savethmkey_reqval:n { #1 },
numbered .code:n = \__keythms_thmstyle_savethmkey_optval:n { #1 },
numberlike .code:n = \__keythms_thmstyle_savethmkey_reqval:n { #1 },
@@ -447,51 +459,101 @@
%%% Defining Theorems %%%
%%%%%%%%%%%%%%%%%%%%%%%%%
-% FIX: reimplement these without \NewDocumentCommand and \SplitArgument
-\NewDocumentCommand \keythms_thm_setrefnames:nn
- { m >{\SplitArgument{1}{,}} m } % #1 = envname, #2 = <refname> or <sing,plural>
- { \__keythms_thm_setrefnames_aux:nnn{#1}#2 }
-\cs_new_protected:Npn \__keythms_thm_setrefnames_aux:nnn #1#2#3
+\cs_new_protected:Npn \__keythms_thm_setrefnames:nn #1#2
+ { % use \seq_set_split instead of clist functions to preserve empty entries
+ \seq_set_split:Nnn \l__keythms_tmpa_seq { , } { #2 }
+ \int_compare:nNnTF { \seq_count:N \l__keythms_tmpa_seq } = { 2 }
+ {
+ \__keythms_thm_setrefnames_auxII:nee { #1 }
+ { \seq_item:Nn \l__keythms_tmpa_seq { 1 } }
+ { \seq_item:Nn \l__keythms_tmpa_seq { 2 } }
+ }
+ {
+ \int_compare:nNnTF { \seq_count:N \l__keythms_tmpa_seq } = { 1 }
+ {
+ \__keythms_thm_setrefnames_auxI:ne { #1 }
+ { \seq_item:Nn \l__keythms_tmpa_seq { 1 } }
+ }
+ { \msg_error:nnn { keytheorems } { refname-argcount } { refname } }
+ }
+ }
+\cs_generate_variant:Nn \__keythms_thm_setrefnames:nn { nV }
+\cs_new_protected:Npn \__keythms_thm_setrefnames_auxI:nn #1#2
+ {
+ \cs_set:cpn { #1 autorefname } { #2 }
+ \IfPackageLoadedT { cleveref }
+ {
+ \crefname{#1}{#2}{\textbf{??~(pl.~#2)}}
+ }
+ \IfPackageLoadedT { zref-clever }
+ {
+ \zcRefTypeSetup{#1}{ name-sg=#2 }
+ }
+ }
+\cs_new_protected:Npn \__keythms_thm_setrefnames_auxII:nnn #1#2#3
{
\cs_set:cpn { #1 autorefname } { #2 }
\IfPackageLoadedT { cleveref }
{
- \tl_if_novalue:nTF { #3 }
- { \crefname{#1}{#2}{\textbf{??~(pl.~#2)}} }
- { \crefname{#1}{#2}{#3} }
+ \crefname{#1}{#2}{#3}
}
\IfPackageLoadedT { zref-clever }
{
- \tl_if_novalue:nTF { #3 }
- { \zcRefTypeSetup{#1}{ name-sg=#2 } }
- { \zcRefTypeSetup{#1}{ name-sg=#2, name-pl=#3 } }
+ \zcRefTypeSetup{#1}{ name-sg=#2, name-pl=#3 }
}
}
-\cs_generate_variant:Nn \keythms_thm_setrefnames:nn { nV }
+\cs_generate_variant:Nn \__keythms_thm_setrefnames_auxI:nn { ne }
+\cs_generate_variant:Nn \__keythms_thm_setrefnames_auxII:nnn { nee }
-\NewDocumentCommand \keythms_thm_setRefnames:nn
- { m >{\SplitArgument{1}{,}} m } % #1 = envname, #2 = <refname> or <sing,plural>
- { \__keythms_thm_setRefnames_aux:nnn{#1}#2 }
-\cs_new_protected:Npn \__keythms_thm_setRefnames_aux:nnn #1#2#3
+\cs_new_protected:Npn \__keythms_thm_setRefnames:nn #1#2
+ { % use \seq_set_split instead of clist functions to preserve empty entries
+ \seq_set_split:Nnn \l__keythms_tmpa_seq { , } { #2 }
+ \int_compare:nNnTF { \seq_count:N \l__keythms_tmpa_seq } = { 2 }
+ {
+ \__keythms_thm_setRefnames_auxII:nee { #1 }
+ { \seq_item:Nn \l__keythms_tmpa_seq { 1 } }
+ { \seq_item:Nn \l__keythms_tmpa_seq { 2 } }
+ }
+ {
+ \int_compare:nNnTF { \seq_count:N \l__keythms_tmpa_seq } = { 1 }
+ {
+ \__keythms_thm_setRefnames_auxI:ne { #1 }
+ { \seq_item:Nn \l__keythms_tmpa_seq { 1 } }
+ }
+ { \msg_error:nnn { keytheorems } { refname-argcount } { Refname } }
+ }
+ }
+\cs_generate_variant:Nn \__keythms_thm_setRefnames:nn { nV }
+\cs_new_protected:Npn \__keythms_thm_setRefnames_auxI:nn #1#2
{
\cs_set:cpn { #1 Autorefname } { #2 }
\IfPackageLoadedT { cleveref }
{
- \tl_if_novalue:nTF { #3 }
- { \Crefname{#1}{#2}{\textbf{??~(pl.~#2)}} }
- { \Crefname{#1}{#2}{#3} }
+ \Crefname{#1}{#2}{\textbf{??~(pl.~#2)}}
}
\IfPackageLoadedT { zref-clever }
{
- \tl_if_novalue:nTF { #3 }
- { \zcRefTypeSetup{#1}{ Name-sg=#2 } }
- { \zcRefTypeSetup{#1}{ Name-sg=#2, Name-pl=#3 } }
+ \zcRefTypeSetup{#1}{ Name-sg=#2 }
}
}
-\cs_generate_variant:Nn \keythms_thm_setRefnames:nn { nV }
+\cs_new_protected:Npn \__keythms_thm_setRefnames_auxII:nnn #1#2#3
+ {
+ \cs_set:cpn { #1 Autorefname } { #2 }
+ \IfPackageLoadedT { cleveref }
+ {
+ \Crefname{#1}{#2}{#3}
+ }
+ \IfPackageLoadedT { zref-clever }
+ {
+ \zcRefTypeSetup{#1}{ Name-sg=#2, Name-pl=#3 }
+ }
+ }
+\cs_generate_variant:Nn \__keythms_thm_setRefnames_auxI:nn { ne }
+\cs_generate_variant:Nn \__keythms_thm_setRefnames_auxII:nnn { nee }
\keys_define:nn { keytheorems/thm }
{
+ counter-format .tl_set:N = \l__keythms_thm_ctrfmt_tl,
heading .meta:n = { name = {#1} },
leftmargin .dim_set:N = \l__keythms_thm_leftmargin_dim,
name .tl_set:N = \l__keythms_thm_name_tl,
@@ -541,20 +603,21 @@
\keys_precompile:nnN { keytheorems/thm }
{
- leftmargin = 0pt,
- name = \q_no_value,
- numbered = true,
- parent = {},
- postfoothook = {},
- postheadhook = {},
- prefoothook = {},
- preheadhook = {},
- qed = \q_no_value,
- refname = \q_no_value,
- Refname = \q_no_value,
- rightmargin = 0pt,
- sibling = {},
- style = {},
+ counter-format = \q_no_value,
+ leftmargin = 0pt,
+ name = \q_no_value,
+ numbered = true,
+ parent = {},
+ postfoothook = {},
+ postheadhook = {},
+ prefoothook = {},
+ preheadhook = {},
+ qed = \q_no_value,
+ refname = \q_no_value,
+ Refname = \q_no_value,
+ rightmargin = 0pt,
+ sibling = {},
+ style = {},
}
\l__keythms_thm_defaultkeys_tl
@@ -724,9 +787,9 @@
\exp_args:NnV \cs_set:cpn { #1 Autorefname } \l__keythms_thm_name_tl
% Set ref names
\quark_if_no_value:NF \l__keythms_thm_refname_tl
- { \keythms_thm_setrefnames:nV { #1 } \l__keythms_thm_refname_tl }
+ { \__keythms_thm_setrefnames:nV { #1 } \l__keythms_thm_refname_tl }
\quark_if_no_value:NF \l__keythms_thm_Refname_tl
- { \keythms_thm_setRefnames:nV { #1 } \l__keythms_thm_Refname_tl }
+ { \__keythms_thm_setRefnames:nV { #1 } \l__keythms_thm_Refname_tl }
% Set margins if needed
\bool_lazy_or:nnT
{ ! \dim_compare_p:nNn { \l__keythms_thm_leftmargin_dim } = { 0pt } }
@@ -753,6 +816,13 @@
{ \l__keythms_thm_tcbkeys_tl }
}
}
+ % Set counter format if needed
+ \quark_if_no_value:NF \l__keythms_thm_ctrfmt_tl
+ {
+ \bool_if:NTF \l__keythms_thm_numbered_bool
+ { \exp_args:NnV \cs_set:cpn { the #1 } \l__keythms_thm_ctrfmt_tl }
+ { \msg_warning:nnn { keytheorems } { ctrfmt-unnumbered } { #1 } }
+ }
% Set up list-of definition
\cs_set_eq:cN { l@ #1 } \keythms_listof_tocline:
% Set default list-of display command
@@ -852,11 +922,11 @@
\cs_new_protected:Npn \__keythms_thm_tcbnotitlebarcode:nn #1#2
{ % #1 = name, #2 = tcolorbox keys
\__keythms_thm_tcbshared:nn { #1 } { #2 }
- \tl_gclear_new:c { g__keythms_thm_#1_tcbprehead_tl }
- \tl_gset:cn { g__keythms_thm_#1_tcbprehead_tl }
+ \tl_gclear_new:c { g__keythms_thm_tcbprehead_#1_tl }
+ \tl_gset:cn { g__keythms_thm_tcbprehead_#1_tl }
{ \begin{tcolorbox}[keythms_tcb_#1] }
- \tl_gclear_new:c { g__keythms_thm_#1_tcbpostfoot_tl }
- \tl_gset:cn { g__keythms_thm_#1_tcbpostfoot_tl }
+ \tl_gclear_new:c { g__keythms_thm_tcbpostfoot_#1_tl }
+ \tl_gset:cn { g__keythms_thm_tcbpostfoot_#1_tl }
{ \end{tcolorbox} }
}
\cs_new_protected:Npn \__keythms_thm_tcbshared:nn #1#2
@@ -916,12 +986,13 @@
{ % #1 = name, #2 = symbol
\tl_gput_right:cn { g__keythms_thm_postheadfromkeys_#1_tl }
{
- \tl_if_novalue:nF { #2 } { \protected@edef\qedsymbol{#2} }
+ \tl_if_novalue:nF { #2 } { \protected@edef \qedsymbol { #2 } }
\pushQED{\qed}
}
- \tl_gput_left:cn { g__keythms_thm_prefootfromkeys_#1_tl }
+ \tl_gclear_new:c { g__keythms_thm_QEDprefoot_#1_tl }
+ \tl_gset:cn { g__keythms_thm_QEDprefoot_#1_tl }
{
- \tl_if_novalue:nF { #2 } { \protected@edef\qedsymbol{#2} }
+ \tl_if_novalue:nF { #2 } { \protected@edef \qedsymbol { #2 } }
\popQED
}
}
@@ -929,33 +1000,20 @@
\cs_new_protected:Npn \__keythms_nocheck_removefromreset:nn #1#2
{ % need to fake @ckpt counter
\group_begin:
- \cs_if_exist:cF { c@#2 } { \cs_set:cpn { c@#2 } { } }
- \@removefromreset{#1}{#2}
+ \cs_if_exist:cF { c@ #2 } { \cs_set:cpn { c@ #2 } { } }
+ \@removefromreset{ #1 }{ #2 }
\group_end:
}
\cs_new_protected:Npn \keythms_thm_renewkeythm:nn #1#2
{ % #1 = name, #2 = keys
\cs_if_exist:cTF { #1 }
- {
- \cs_undefine:c { #1 }
- \cs_undefine:c { c@ #1 }
- \cs_undefine:c { the #1 }
- \tl_if_exist:cT { g__keythms_thm_#1_parent_tl }
- { % remove parent counter binding
- \exp_args:Nnv \@removefromreset { #1 } { g__keythms_thm_#1_parent_tl }
- }
- \__keythms_nocheck_removefromreset:nn { #1 } { @ckpt }
- \keythms_thm_newkeythm:nn { #1 } { #2 }
- }
+ { \keythms_thm_declarekeythm:nn { #1 } { #2 } }
{ \msg_error:nnn { keytheorems } { thm-undefined} { #1 } }
}
\cs_new_protected:Npn \keythms_thm_providekeythm:nn #1#2
{ % #1 = name, #2 = keys
- \cs_if_free:cT { #1 }
- {
- \keythms_thm_newkeythm:nn { #1 } { #2 }
- }
+ \cs_if_free:cT { #1 } { \keythms_thm_newkeythm:nn { #1 } { #2 } }
}
\cs_new_protected:Npn \keythms_thm_declarekeythm:nn #1#2
{ % #1 = name, #2 = keys
@@ -967,6 +1025,10 @@
\exp_args:Nnv \@removefromreset { #1 } { g__keythms_thm_#1_parent_tl }
}
\__keythms_nocheck_removefromreset:nn { #1 } { @ckpt }
+ \cs_undefine:c { g__keythms_thm_QEDprefoot_#1_tl } % These are only
+ \cs_undefine:c { g__keythms_thm_tcbpatch_#1_tl } % conditionally defined
+ \cs_undefine:c { g__keythms_thm_tcbprehead_#1_tl } % Need to undefine
+ \cs_undefine:c { g__keythms_thm_tcbpostfoot_#1_tl } % so old defs not used
\keythms_thm_newkeythm:nn { #1 } { #2 }
}
@@ -1030,8 +1092,16 @@
\hook_gput_code:nnn { begindocument } { . }
{
\IfPackageLoadedTF { nameref }
- {
- \cs_new:Npn \__keythms_thmuse_recordnote: { } % nameref takes care of this
+ { % only need to record short-note if nameref loaded
+ \cs_new:Npn \__keythms_thmuse_recordnote:
+ {
+ \tl_if_empty:NF \l__keythms_thmuse_shortnote_tl
+ {
+ \RecordProperties
+ { keythms_recordednote_\l__keythms_thmuse_label_tl }
+ { keytheorems/recordedshortnote }
+ }
+ }
\cs_new:Npn \__keythms_getrecordednote:n #1
{
\getrefbykeydefault{ #1 }{ name }{ }
@@ -1042,11 +1112,22 @@
{ \l__keythms_thmuse_note_tl }
\cs_new:Npn \__keythms_thmuse_recordnote:
{
+ \clist_clear:N \l__keythms_tmpa_clist
\tl_if_empty:NF \l__keythms_thmuse_note_tl
{
+ \clist_put_right:Nn \l__keythms_tmpa_clist
+ { keytheorems/recordednote }
+ }
+ \tl_if_empty:NF \l__keythms_thmuse_shortnote_tl
+ {
+ \clist_put_right:Nn \l__keythms_tmpa_clist
+ { keytheorems/recordedshortnote }
+ }
+ \clist_if_empty:NF \l__keythms_tmpa_clist
+ {
\RecordProperties
{ keythms_recordednote_\l__keythms_thmuse_label_tl }
- { keytheorems/recordednote }
+ { \l__keythms_tmpa_clist }
}
}
\cs_new:Npn \__keythms_getrecordednote:n #1
@@ -1057,13 +1138,23 @@
}
}
+% 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,
continues* .code:n =
{
\keys_set:nn { keytheorems/thmuse } { continues = #1 }
- \protected@edef \l__keythms_tmpa_tl { \__keythms_getrecordednote:n{#1} }
+ \protected@edef \l__keythms_tmpa_tl
+ { \__keythms_getrecordednote:n { #1 } }
\tl_if_empty:NF \l__keythms_tmpa_tl
{
\keys_set:nn { keytheorems/thmuse }
@@ -1084,7 +1175,7 @@
restate* .meta:n = { store* = {#1} },
restate-keys .clist_set:N = \l__keythms_thmuse_restatekeys_clist,
seq .code:n = {},
- short-note .code:n = {}, % these do nothing at point of use
+ short-note .tl_set:N = \l__keythms_thmuse_shortnote_tl,
short-name .code:n = {},
store .tl_set:N = \l__keythms_thmuse_store_tl, % should this be .tl_set_e:N ?
store* .tl_set:N = \l__keythms_thmuse_storereversed_tl,
@@ -1114,7 +1205,7 @@
\end{keythms_orig_#1}
\__keythms_thm_postfoot_code:n { #1 }
}
- {}
+ { }
\DeclareDocumentEnvironment { keythms_grabreversed_#1 } { m m +b }
{ % ##1 = keys, ##2 = note, ##3 = theorem body
\tl_if_exist:cTF
@@ -1172,76 +1263,77 @@
}
}
{ }
- % NOTE: have to do a lot of shenanigans to make sure the begin/end of grabbed
- % theorem env captures only the body and no package code.
- % This is the price of on-the-fly redefining the env to grab body
- \RenewDocumentEnvironment { #1 } { ={note} O{} }
- {
- \tl_set:Nn \l_keythms_thmuse_envname_tl { #1 }
- \keys_set:nn { keytheorems/thmuse } { ##1 }
- \tl_if_empty:NTF \l__keythms_thmuse_store_tl
- {
- \tl_if_empty:NTF \l__keythms_thmuse_storereversed_tl
- { \__keythms_thm_prehead_code:n { #1 } }
- {
- \bool_gset_true:N \g__keythms_listof_writefile_bool
- \cs_set_eq:NN \__keythms_withhooks_begin:nnn \__keythms_grabreversed_begin:nnn
- \cs_set_eq:NN \__keythms_withhooks_end:n \__keythms_grabreversed_end:n
- }
- }
- {
- \bool_gset_true:N \g__keythms_listof_writefile_bool
- \cs_set_eq:NN \__keythms_withhooks_begin:nnn \__keythms_grab_begin:nnn
- \cs_set_eq:NN \__keythms_withhooks_end:n \__keythms_grab_end:n
- }
- \__keythms_withhooks_begin:nnV { #1 } { ##1 } \l__keythms_thmuse_note_tl
- }
- {
- \__keythms_withhooks_end:n { #1 }
- \tl_if_empty:NF \l__keythms_thmuse_store_tl
- {
- \cs_if_exist:cF
- { __keythms_getthm_ \l__keythms_thmuse_store_tl _theorem }
- {
- \cs_new:cpe
- { __keythms_getthm_ \l__keythms_thmuse_store_tl _theorem }
- {
- \exp_not:N \__keythms_getthm_theorem:nnnnn
- \exp_not:o { \g__keythms_thmuse_temprestatedata_tl }
- }
- \cs_new:cpe
- { __keythms_getthm_ \l__keythms_thmuse_store_tl _body }
- {
- \exp_not:N \__keythms_getthm_body:nnn
- \exp_args:No \exp_not:o
- {
- \exp_after:wN \__keythms_use_i_iii_v_braced:nnnnn
- \g__keythms_thmuse_temprestatedata_tl
- }
- }
- }
- }
- \tl_if_empty:NF \l__keythms_thmuse_storereversed_tl
- {
- \cs_if_exist:cF
- { __keythms_getthm_ \l__keythms_thmuse_storereversed_tl _theorem }
- {
- \cs_new:cpe
- { __keythms_getthm_ \l__keythms_thmuse_storereversed_tl _theorem }
- {
- \exp_not:N \__keythms_getthmreversed_theorem:nnn
- \exp_not:o { \g__keythms_thmuse_temprestatedatareversed_tl }
- }
- \cs_new:cpn
- { __keythms_getthm_ \l__keythms_thmuse_storereversed_tl _body }
- {
- \textbf{??}
- \msg_warning:nnn { keytheorems } { restate-body-never-got }
- { #1 }
- }
- }
- }
- }
+ % NOTE: have to do a lot of shenanigans to make sure the begin/end of grabbed
+ % theorem env captures only the body and no package code.
+ % This is the price of on-the-fly redefining the env to grab body
+ \RenewDocumentEnvironment { #1 } { ={note} o }
+ {
+ \tl_set:Nn \l_keythms_thmuse_envname_tl { #1 }
+ \tl_if_novalue:nF { ##1 }
+ { \keys_set:nn { keytheorems/thmuse } { ##1 } }
+ \tl_if_empty:NTF \l__keythms_thmuse_store_tl
+ {
+ \tl_if_empty:NTF \l__keythms_thmuse_storereversed_tl
+ { \__keythms_thm_prehead_code:n { #1 } }
+ {
+ \bool_gset_true:N \g__keythms_listof_writefile_bool
+ \cs_set_eq:NN \__keythms_withhooks_begin:nnn \__keythms_grabreversed_begin:nnn
+ \cs_set_eq:NN \__keythms_withhooks_end:n \__keythms_grabreversed_end:n
+ }
+ }
+ {
+ \bool_gset_true:N \g__keythms_listof_writefile_bool
+ \cs_set_eq:NN \__keythms_withhooks_begin:nnn \__keythms_grab_begin:nnn
+ \cs_set_eq:NN \__keythms_withhooks_end:n \__keythms_grab_end:n
+ }
+ \__keythms_withhooks_begin:nnV { #1 } { ##1 } \l__keythms_thmuse_note_tl
+ }
+ {
+ \__keythms_withhooks_end:n { #1 }
+ \tl_if_empty:NF \l__keythms_thmuse_store_tl
+ {
+ \cs_if_exist:cF
+ { __keythms_getthm_ \l__keythms_thmuse_store_tl _theorem }
+ {
+ \cs_new:cpe
+ { __keythms_getthm_ \l__keythms_thmuse_store_tl _theorem }
+ {
+ \exp_not:N \__keythms_getthm_theorem:nnnnn
+ \exp_not:o { \g__keythms_thmuse_temprestatedata_tl }
+ }
+ \cs_new:cpe
+ { __keythms_getthm_ \l__keythms_thmuse_store_tl _body }
+ {
+ \exp_not:N \__keythms_getthm_body:nnn
+ \exp_args:No \exp_not:o
+ {
+ \exp_after:wN \__keythms_use_i_iii_v_braced:nnnnn
+ \g__keythms_thmuse_temprestatedata_tl
+ }
+ }
+ }
+ }
+ \tl_if_empty:NF \l__keythms_thmuse_storereversed_tl
+ {
+ \cs_if_exist:cF
+ { __keythms_getthm_ \l__keythms_thmuse_storereversed_tl _theorem }
+ {
+ \cs_new:cpe
+ { __keythms_getthm_ \l__keythms_thmuse_storereversed_tl _theorem }
+ {
+ \exp_not:N \__keythms_getthmreversed_theorem:nnn
+ \exp_not:o { \g__keythms_thmuse_temprestatedatareversed_tl }
+ }
+ \cs_new:cpn
+ { __keythms_getthm_ \l__keythms_thmuse_storereversed_tl _body }
+ {
+ \textbf{??}
+ \msg_warning:nnn { keytheorems } { restate-body-never-got }
+ { #1 }
+ }
+ }
+ }
+ }
}
\cs_new:Npn \__keythms_use_i_iii_v_braced:nnnnn #1#2#3#4#5 { {#1}{#3}{#5} }
@@ -1310,7 +1402,7 @@
\hook_use:n { keytheorems/#1/prehead }
\hook_use:n { keytheorems/allthms/prehead }
% \use:c instead of \tl_use:c so doesn't error if tl doesn't exist
- \use:c { g__keythms_thm_#1_tcbprehead_tl }
+ \use:c { g__keythms_thm_tcbprehead_#1_tl }
}
\cs_new_protected:Npn \__keythms_thm_posthead_code:n #1
{ % #1 = theorem name
@@ -1331,12 +1423,13 @@
}
\cs_new_protected:Npn \__keythms_thm_prefoot_code:n #1
{ % #1 = theorem name
+ \use:c { g__keythms_thm_QEDprefoot_#1_tl }
\hook_use:n { keytheorems/allthms/prefoot }
\hook_use:n { keytheorems/#1/prefoot }
}
\cs_new_protected:Npn \__keythms_thm_postfoot_code:n #1
{ % #1 = theorem name
- \use:c { g__keythms_thm_#1_tcbpostfoot_tl }
+ \use:c { g__keythms_thm_tcbpostfoot_#1_tl }
\hook_use:n { keytheorems/allthms/postfoot }
\hook_use:n { keytheorems/#1/postfoot }
}
@@ -1352,8 +1445,8 @@
{ \@currentHref }
{ \thepage }
{ #2 }
- { \exp_not:n { #3 } } % do we want any expansion here, perhaps
- { \exp_not:n { #4 } } % with \text_expand:n ?
+ { \tl_if_novalue:nF { #3 } { \exp_not:n { #3 } } }
+ { \exp_not:n { #4 } }
}
}
}
@@ -1377,8 +1470,8 @@
{ #1 }
{ \@currentlabel }
{ \prop_to_keyval:N \g__keythms_thmuse_othercounters_prop }
- { \exp_not:n { #2 } } % do we want any expansion here, perhaps
- { \exp_not:n { #3 } } % with \text_expand:n ?
+ { \exp_not:n { #2 } }
+ { \exp_not:n { #3 } }
}
}
\cs_new_protected:Npn \__keythms_thm_tempstorerestatedatareversed:nnn #1#2#3
@@ -1405,7 +1498,7 @@
restate* .meta:n = { store* = {#1} },
store .tl_set:N = \l__keythms_storeatbegin_store_tl,
store* .tl_set:N = \l__keythms_storeatbegin_storereversed_tl,
- unknown .code:n = { } % do nothing with unknown keys
+ unknown .code:n = {} % do nothing with unknown keys
}
\cs_new_protected:Npn \KeyThmsContentsLine #1 { }
@@ -1497,12 +1590,19 @@
\NewDocumentCommand \IfRestatingT { } { \keythms_if_restating:T }
\NewDocumentCommand \IfRestatingF { } { \keythms_if_restating:F }
+\cs_if_exist:NF \@gobble@som
+ { % defined in ltsect.dtx 1.1g
+ \DeclareExpandableDocumentCommand\@gobble@om{+o+m}{}
+ \DeclareExpandableDocumentCommand\@gobble@som{s+o+m}{}
+ }
\hook_gput_code:nnn { keytheorems/allthms/restated } { . }
{ % code to disable things in restated theorems
- \renewcommand\label[2][]{} % opt arg in case cleveref loaded
+ \cs_set_eq:NN \label \@gobble@om % opt arg in case cleveref loaded
\cs_set_eq:NN \ltx@label \use_none:n % thmtools does this; why?
\cs_set_eq:NN \property_record:nn \use_none:nn
\cs_set_eq:NN \setuniqmark \use_none:n % work with numbered=unless-unique
+ \cs_set_eq:NN \index \@gobble@som % see ltsect.dtx
+ \cs_set_eq:NN \glossary \@gobble@om % see ltsect.dtx
% QUESTION: also disable \hyper@@anchor? \MakeLinkTarget?
}
@@ -1694,6 +1794,7 @@
{ \__keythms_listof_ignore_aux:n { ##1 } }
}
},
+ ignoreall .value_forbidden:n = true,
indent .dim_set:N = \l__keythms_listof_indent_dim,
indent .initial:n = 1.5em,
no-chapter-skip .bool_set:N = \l__keythms_listof_nochapskip_bool,
@@ -1728,6 +1829,7 @@
{ \__keythms_getthm_theorem:nnnnn {##1}{##2}{##5}{##6}{##7} }
}
},
+ print-body .value_forbidden:n = true,
seq .code:n =
{
\hook_gput_code:nnn { begindocument/before } { keytheorems }
@@ -1746,6 +1848,7 @@
{ \__keythms_listof_show_aux:n { ##1 } }
}
},
+ showall .value_forbidden:n = true,
swapnumber .bool_set:N = \l__keythms_listof_swapnumber_bool,
swapnumber .initial:n = false,
title .tl_set:N = \l__keythms_listof_title_tl,
@@ -1788,8 +1891,7 @@
}
\cs_new_protected:Npn \__keythms_listof_ignore_aux:n #1
{
- \cs_set_protected:cpn { __keythms_thmitem_#1:nnnnnn } ##1##2##3##4##5##6
- { }
+ \cs_set_protected:cpn { __keythms_thmitem_#1:nnnnnn } ##1##2##3##4##5##6 { }
}
\cs_new_protected:Npn \keythms_listof_show:n #1
@@ -1892,12 +1994,18 @@
continues* .code:n =
{
\keys_set:nn { keytheorems/listofheading } { continues = #1 }
- \protected@edef \l__keythms_tmpa_tl { \__keythms_getrecordednote:n{#1} }
+ \protected@edef \l__keythms_tmpa_tl { \__keythms_getrecordednote:n {#1} }
\tl_if_empty:NF \l__keythms_tmpa_tl
{
\keys_set:nn { keytheorems/listofheading }
{ note = \l__keythms_tmpa_tl }
}
+ \protected@edef \l__keythms_tmpb_tl { \__keythms_getrecordedshortnote:n {#1} }
+ \tl_if_empty:NF \l__keythms_tmpb_tl
+ {
+ \keys_set:nn { keytheorems/listofheading }
+ { short-note = \l__keythms_tmpb_tl }
+ }
},
name .meta:n = { note = {#1} },
note .tl_set:N = \l__keythms_listofheading_note_tl,
@@ -1910,7 +2018,7 @@
{
\bool_set_true:N \l__keythms_listofheading_storereversed_bool
},
- unknown .code:n = { } % do nothing with unknown keys
+ unknown .code:n = {} % do nothing with unknown keys
}
\cs_new:Npn \__keythms_listof_printnote:
@@ -1955,13 +2063,25 @@
{
\bool_if:NF \l__keythms_listof_nocont_bool
{
- \tl_if_empty:NF \l__keythms_listofheading_note_tl
+ \tl_if_empty:NTF \l__keythms_listofheading_shortnote_tl
{
- \tl_put_right:Nn \l__keythms_listofheading_note_tl { , ~ }
+ \tl_if_empty:NF \l__keythms_listofheading_note_tl
+ {
+ \tl_put_right:Nn \l__keythms_listofheading_note_tl { , ~ }
+ }
+ \tl_put_right:Nn \l__keythms_listofheading_note_tl
+ {
+ \__keythms_thmuse_continues:V
+ \l__keythms_listofheading_contlabel_tl
+ }
}
- \tl_put_right:Nn \l__keythms_listofheading_note_tl
{
- \__keythms_thmuse_continues:V \l__keythms_listofheading_contlabel_tl
+ \tl_put_right:Nn \l__keythms_listofheading_shortnote_tl
+ {
+ , ~
+ \__keythms_thmuse_continues:V
+ \l__keythms_listofheading_contlabel_tl
+ }
}
\cs_set_eq:NN \pageref \__keythms_listof_pagerefnolink:w % always no link
#2
@@ -2171,7 +2291,7 @@
{
\newkeytheorem { ##2 } [ ##1 ]
}
- \ProvideDocumentEnvironment { restatable } { O{} m m }
+ \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_addcontentsdata:nnnn ####1####2####3####4
{ % ####1 = theorem name, ####2 = stored counters, ####3 = keys, ####4 = body
@@ -2185,7 +2305,10 @@
{ \@currentHref }
{ \thepage }
{ ####2 }
- { store=\l__keythms_thmuse_store_tl,\exp_not:n { ####3 } } % this line is changed
+ { % this argument is changed
+ store=\l__keythms_thmuse_store_tl
+ \tl_if_novalue:nF { ####3 } { ,\exp_not:n { ####3 } }
+ }
{ \exp_not:n { ####4 } }
}
}
@@ -2203,7 +2326,7 @@
{ \getkeytheorem{ ##3 } }
}
}
- \ProvideDocumentEnvironment { restatable* } { O{} m m }
+ \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
{ % ####1 = theorem name, ####2 = keys, ####3 = body
@@ -2213,7 +2336,10 @@
{
\token_to_str:N \KeyThmsSavedTheoremReversed { \l__keythms_thmuse_storereversed_tl }
{ ####1 }
- { store*=\l__keythms_thmuse_storereversed_tl,\exp_not:n { ####2 } } % this line is changed
+ { % this argument is changed
+ store*=\l__keythms_thmuse_storereversed_tl
+ \tl_if_novalue:nF { ####2 } { ,\exp_not:n { ####2 } }
+ }
{ \exp_not:n { ####3 } }
}
}
@@ -2367,7 +2493,7 @@
% FIX: surely a better way to do this
\RequirePackage{tcolorbox}
\pgfkeysifdefined{/tcb/keythms_tcbshaded_default/.@cmd} % even worth it?
- {}
+ { }
{
\tcbset % wish I could do this outside of key but can't assume tcb loaded
{
@@ -2398,7 +2524,7 @@
\RequirePackage{tcolorbox}
\tcbuselibrary{skins,breakable}
\pgfkeysifdefined{/tcb/keythms_tcbthmbox_default/.@cmd} % even worth it?
- {}
+ { }
{
\tcbset{
keythms_tcbthmbox_default/.style={
@@ -2752,22 +2878,30 @@
{ tcolorbox-no-titlebar }
},
}
- \keys_define:nn { keytheorems/listof }
+ \bool_lazy_any:nF
{
- print-body .code:n =
+ { \__keythms_if_classloaded_p:n { amsart } }
+ { \__keythms_if_classloaded_p:n { amsbook } }
+ { \__keythms_if_classloaded_p:n { amsproc } }
+ }
+ { % only redefine \@starttoc with print-body when AMS class not loaded
+ \keys_define:nn { keytheorems/listof }
{
- \cs_set_protected:Nn \keythms_listof_listcmd:nnnnnnn
+ print-body .code:n =
{
- \tl_if_empty:nF { ##7 }
+ \cs_set_protected:Nn \keythms_listof_listcmd:nnnnnnn
{
- \__keythms_getthm_theorem:nnnnn
- {##1}{##2}{##5}{##6}{##7}
+ \tl_if_empty:nF { ##7 }
+ {
+ \__keythms_getthm_theorem:nnnnn
+ {##1}{##2}{##5}{##6}{##7}
+ }
}
- }
- % with tagging, make \@starttoc same as input
- \cs_set_protected:Npn \@starttoc ##1
- { \makeatletter \@input { \jobname.##1 } }
- },
+ % with tagging, make \@starttoc same as input
+ \cs_set_protected:Npn \@starttoc ##1
+ { \makeatletter \@input { \jobname.##1 } }
+ },
+ }
}
\IfFormatAtLeastTF { 2025-06-01 }
{ % dev formats use theoremblock instance