summaryrefslogtreecommitdiff
path: root/Master
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2024-09-20 21:23:01 +0000
committerKarl Berry <karl@freefriends.org>2024-09-20 21:23:01 +0000
commita9cc08e03bd58b2de3a9f76514352321ada2b40d (patch)
treebdb524fe005ba7474ddba7e3efad20b71fd7f550 /Master
parent4b90f274480dd8c7f17554c1c892715373d9abfd (diff)
keytheorems (20sep24)
git-svn-id: svn://tug.org/texlive/trunk@72331 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r--Master/texmf-dist/doc/latex/keytheorems/CHANGELOG.md7
-rw-r--r--Master/texmf-dist/doc/latex/keytheorems/README.md13
-rw-r--r--Master/texmf-dist/doc/latex/keytheorems/keytheorems-doc.pdfbin525658 -> 529999 bytes
-rw-r--r--Master/texmf-dist/doc/latex/keytheorems/keytheorems-doc.tex80
-rw-r--r--Master/texmf-dist/tex/latex/keytheorems/class-support/keythms-amsart-support.tex4
-rw-r--r--Master/texmf-dist/tex/latex/keytheorems/class-support/keythms-amsbook-support.tex3
-rw-r--r--Master/texmf-dist/tex/latex/keytheorems/class-support/keythms-amsproc-support.tex3
-rw-r--r--Master/texmf-dist/tex/latex/keytheorems/class-support/keythms-memoir-support.tex2
-rw-r--r--Master/texmf-dist/tex/latex/keytheorems/keytheorems.sty351
9 files changed, 382 insertions, 81 deletions
diff --git a/Master/texmf-dist/doc/latex/keytheorems/CHANGELOG.md b/Master/texmf-dist/doc/latex/keytheorems/CHANGELOG.md
index 053436ddb74..49285822408 100644
--- a/Master/texmf-dist/doc/latex/keytheorems/CHANGELOG.md
+++ b/Master/texmf-dist/doc/latex/keytheorems/CHANGELOG.md
@@ -1,5 +1,11 @@
# Changelog for keytheorems package
+## [v0.1.3]
+- add `noteseparator` key
+- add `\IfRestatingT`, `\IfRestatingF`
+- add `store*` key
+- add Portuguese translations
+
## [v0.1.2]
- Move support for memoir and AMS classes to dedicated files
- document `headformat` key
@@ -14,5 +20,6 @@
## 0.1.0 - 2024-09-04
- First release
+[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
diff --git a/Master/texmf-dist/doc/latex/keytheorems/README.md b/Master/texmf-dist/doc/latex/keytheorems/README.md
index baf8506c2df..bf344a5b240 100644
--- a/Master/texmf-dist/doc/latex/keytheorems/README.md
+++ b/Master/texmf-dist/doc/latex/keytheorems/README.md
@@ -94,7 +94,8 @@ Some of the code is a direct translation from thmtools but a few things are chan
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
- `store` (alias `restate`) key.
+ `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}`.
For just the theorem body, use `\getkeytheorem[body]{foo}`. Also, this retrieval
can happen even before the theorem is stated since keytheorems writes the contents
@@ -107,12 +108,7 @@ Some of the code is a direct translation from thmtools but a few things are chan
- With thmtools, the command `\newtheorem{<envname>}{<heading>}` is changed to behave like
`\declaretheorem[name=<heading>]{<envname>}`. This is not the default here. Instead either
only use the new interface or load the package with option `overload`.
-- All new keys (see doc for descriptions):
- - global (load-time or in `\keytheoremset`): `overload`, `thmtools-compat`, `store-all`, `restate-counters`, `continues-code`, `qed-symbol`, `auto-translate`
- - keys for theorem envs: `note` (alias `name`), `short-note`, `continues*`, `store` (alias `restate`), `seq`
- - declaring theorems (in `\newkeytheorem`): `tcolorbox`, `tcolorbox-no-titlebar`
- - declaring styles (in `\newkeytheoremstyle`): `inherit-style`
- - list of theorems (in `\keytheoremlistset` and `\listofkeytheorems`): `onlynumbered`, `seq`, `title-code`, `no-title`, `note-code`, `print-body`, `no-continues`, `no-chapter-skip`, `chapter-skip-length`
+- Adds several new keys (see doc for details).
## thmtools issues resolved by keytheorems
Issues from the thmtools [github page](https://github.com/muzimuzhi/thmtools),
@@ -464,10 +460,9 @@ text
- Clean up the code. Things are out of order, poorly named, etc.
- Add more error messages.
- thmtools features not yet implemented
- - labels pointing to restated theorem, not original
- real [`beamer`](https://ctan.org/pkg/beamer) support
- certainly more
-- For a complete list, see [`keytheorems-ideas.txt`](https://github.com/mbertucci47/keytheorems/blob/main/keytheorems-ideas.txt)
+- For a complete list, see [`keytheorems-ideas.md`](https://github.com/mbertucci47/keytheorems/blob/main/keytheorems-ideas.md)
## Notes/issues on thmtools, not on Github
diff --git a/Master/texmf-dist/doc/latex/keytheorems/keytheorems-doc.pdf b/Master/texmf-dist/doc/latex/keytheorems/keytheorems-doc.pdf
index 79acb6371a3..bbcd528596e 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 b285f5f8401..78b149fbac4 100644
--- a/Master/texmf-dist/doc/latex/keytheorems/keytheorems-doc.tex
+++ b/Master/texmf-dist/doc/latex/keytheorems/keytheorems-doc.tex
@@ -20,7 +20,7 @@
\usepackage{cleveref}
\usepackage{amssymb}
-\def\version{0.1.2}
+\def\version{0.1.3}
\title{%
\pkg{keytheorems} package \\[1ex]
@@ -53,7 +53,17 @@
\newkeytheorem{remark}[style=remark]
\tcbset{
defstyle/.style={arc=0mm,colback=blue!5!white,colframe=blue!75!black},
+ thmstyle/.style={colback=green!5,colframe=green!35!black},
}
+\newkeytheoremstyle{tcb-standard}{
+ tcolorbox=thmstyle,
+ headpunct={},
+ notebraces={}{},
+ noteseparator={: },
+ notefont=\bfseries,
+ bodyfont=\normalfont,
+ }
+\newkeytheorem{mytheo}[name=My Theorem,style=tcb-standard]
\newkeytheorem{corollary}[tcolorbox]
\newkeytheorem{definition}[
style=definition,
@@ -137,7 +147,7 @@ Several issues encountered with \pkg{thmtools} are avoided (see the README for a
\section{Dependencies}
-Without using the \refKey{tcolorbox} or \refKey{tcolorbox-no-titlebar} options, the package loads the \pkg{aliascnt}, \pkg{amsthm}, \pkg{refcount}, and \pkg{translations} packages.
+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}
@@ -198,7 +208,7 @@ This key does not reset the list, so you don't need to include |equation| in \me
{initially \cs{GetTranslation}\ttbraces{keythms\string_continues}\cs{pageref}\ttbraces{\#1}}
The code used to typeset the note produced by the \refKey{continues} key.
If English or an unknown language is used, defaults to \texttt{continuing from p.}\cs{,}\cs{pageref}\ttbraces{\#1}.
-Currently (likely inaccurate!) translations exist for French, German, Italian, and Spanish.
+Currently (likely inaccurate!) translations exist for French, German, Italian, Portuguese, and Spanish.
\end{docKey}
\begin{docKey}{qed-symbol}
@@ -304,10 +314,10 @@ The starred version also copies the theorem note, if it exists.
\end{docKey}
\begin{docKey}{store}
- {=\meta{tag}}
+ {\sarg=\meta{tag}}
{initially unset}
-Alias \docAuxKey{restate}.
-Stores the the theorem to be restated at any point in the document with \refCom{getkeytheorem}.
+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.
\begin{keythmscode}[]
\begin{theorem}[store=blub]
@@ -610,6 +620,33 @@ Some text
\end{docKey}
+\pkg{tcolorbox} offers its own comprehensive \texttt{theorems} library. If all of your theorems are to be tcolorboxes, I highly recommend using it instead of this package! However, if only some of your theorems will use a tcolorbox, you may want to replicate the styles of \cs{NewTcbTheorem}. Here is an example that emulates \pkg{tcolorbox}'s \texttt{standard} theorem style.
+
+\begin{tcbwritetemp}
+\tcbset{
+ thmstyle/.style={
+ colback=green!5,
+ colframe=green!35!black},
+ }
+\newkeytheoremstyle{tcb-standard}{
+ tcolorbox=thmstyle,
+ headpunct={},
+ notebraces={}{},
+ noteseparator={: },
+ notefont=\bfseries,
+ bodyfont=\normalfont,
+ }
+\newkeytheorem{mytheo}[
+ name=My Theorem,
+ style=tcb-standard]
+\end{tcbwritetemp}
+
+\begin{keythmscode}[withpreamble]
+\begin{mytheo}[This is my title]
+Some theorem text
+\end{mytheo}
+\end{keythmscode}
+
\section{Theorem Styles}
\begin{docCommand}{newkeytheoremstyle}
@@ -698,6 +735,12 @@ Alias \docAuxKey{headstyle}. Within \meta{code}, the commands \docAuxCommand{NAM
\subsection{Keys added by \pkg{keytheorems}}
+\begin{docKey}{noteseparator}
+ {=\meta{code}}
+ {initially \textvisiblespace}
+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}{inherit-style}
{=\meta{style name}}
{initially unset}
@@ -712,7 +755,7 @@ At the start of the next run, this file is input at the beginning of the documen
\begin{docCommand}{getkeytheorem}
{\oarg{property}\marg{tag}}
-Retrieves the theorem given the key |store=|\meta{tag}.
+Retrieves the theorem given the key |store=|\meta{tag} or |store*=|\meta{tag}.
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.
@@ -728,9 +771,22 @@ Fascinating example.
\end{docCommand}
-\begin{docCommand}{IfRestatingTF}
- {\marg{true code}\marg{false code}}
-Executes \meta{true code} if being retrieved with \refCom{getkeytheorem} and \meta{false code} if in the original theorem.
+\begin{docCommands}
+ {
+ {
+ doc name = IfRestatingTF,
+ doc parameter=\marg{true code}\marg{false code}
+ },
+ {
+ doc name = IfRestatingT,
+ doc parameter=\marg{true code}
+ },
+ {
+ doc name = IfRestatingF,
+ doc parameter=\marg{false code}
+ }
+ }
+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{example}[store=hmm]
@@ -742,7 +798,7 @@ example!
\getkeytheorem{hmm}
\end{keythmscode}
-\end{docCommand}
+\end{docCommands}
\section{Listing Theorems}
@@ -812,7 +868,7 @@ For the AMS classes, this is initially |1.5pc|.
{=\meta{text}}
{initially \cs{GetTranslation}\ttbraces{keythms\string_listof\string_title}}
Defaults to ``List of Theorems'' if English or an unknown language is used.
-Currently French, German, Italian, and Spanish have (likely inaccurate!) translations.
+Currently French, German, Italian, Portuguese, and Spanish have (likely inaccurate!) translations.
A translation can be added with a GitHub pull request or manually with \cs{DeclareTranslation}\marg{lang}\ttbraces{keythms\string_listof\string_title}\marg{text}.
\end{docKey}
diff --git a/Master/texmf-dist/tex/latex/keytheorems/class-support/keythms-amsart-support.tex b/Master/texmf-dist/tex/latex/keytheorems/class-support/keythms-amsart-support.tex
index 36f89461d22..43b1813384a 100644
--- a/Master/texmf-dist/tex/latex/keytheorems/class-support/keythms-amsart-support.tex
+++ b/Master/texmf-dist/tex/latex/keytheorems/class-support/keythms-amsart-support.tex
@@ -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-16}{0.1.2}
+\ProvidesExplFile{keythms-amsart-support}{2024-09-19}{0.1.3}
{keytheorems~support~for~the~amsart~class}
\__keythms_support_AMSshared_code:
@@ -20,6 +20,7 @@
postheadspace = .5em,
notefont = \@acmplainnotefont,
notebraces = {(}{)},
+ noteseparator = {~},
headstyle = \keythms_thmstyle_headcmd_default:nnn{#1}{#2}{#3},
}
\keys_define:nn { keytheorems/thmstyle }
@@ -47,6 +48,7 @@
postheadspace = 5pt plus 1pt minus 1pt,
notefont = \fontseries\mddefault\upshape,
notebraces = {(}{)},
+ noteseparator = {~},
headstyle = \keythms_thmstyle_headcmd_default:nnn{#1}{#2}{#3},
}
}
diff --git a/Master/texmf-dist/tex/latex/keytheorems/class-support/keythms-amsbook-support.tex b/Master/texmf-dist/tex/latex/keytheorems/class-support/keythms-amsbook-support.tex
index e7e83ea1cbe..f5d8fc9cb95 100644
--- a/Master/texmf-dist/tex/latex/keytheorems/class-support/keythms-amsbook-support.tex
+++ b/Master/texmf-dist/tex/latex/keytheorems/class-support/keythms-amsbook-support.tex
@@ -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-16}{0.1.2}
+\ProvidesExplFile{keythms-amsbook-support}{2024-09-19}{0.1.3}
{keytheorems~support~for~the~amsbook~class}
\__keythms_support_AMSshared_code:
@@ -17,6 +17,7 @@
postheadspace = 5pt plus 1pt minus 1pt,
notefont = \fontseries\mddefault\upshape,
notebraces = {(}{)},
+ noteseparator = {~},
headstyle = \keythms_thmstyle_headcmd_default:nnn{#1}{#2}{#3},
}
diff --git a/Master/texmf-dist/tex/latex/keytheorems/class-support/keythms-amsproc-support.tex b/Master/texmf-dist/tex/latex/keytheorems/class-support/keythms-amsproc-support.tex
index a3bb1d65b96..62306f0b290 100644
--- a/Master/texmf-dist/tex/latex/keytheorems/class-support/keythms-amsproc-support.tex
+++ b/Master/texmf-dist/tex/latex/keytheorems/class-support/keythms-amsproc-support.tex
@@ -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-16}{0.1.2}
+\ProvidesExplFile{keythms-amsproc-support}{2024-09-19}{0.1.3}
{keytheorems~support~for~the~amsproc~class}
\__keythms_support_AMSshared_code:
@@ -17,6 +17,7 @@
postheadspace = 5pt plus 1pt minus 1pt,
notefont = \fontseries\mddefault\upshape,
notebraces = {(}{)},
+ noteseparator = {~},
headstyle = \keythms_thmstyle_headcmd_default:nnn{#1}{#2}{#3},
}
diff --git a/Master/texmf-dist/tex/latex/keytheorems/class-support/keythms-memoir-support.tex b/Master/texmf-dist/tex/latex/keytheorems/class-support/keythms-memoir-support.tex
index 4fa28040426..c2ac32a40ba 100644
--- a/Master/texmf-dist/tex/latex/keytheorems/class-support/keythms-memoir-support.tex
+++ b/Master/texmf-dist/tex/latex/keytheorems/class-support/keythms-memoir-support.tex
@@ -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-16}{0.1.2}
+\ProvidesExplFile{keythms-memoir-support}{2024-09-19}{0.1.3}
{keytheorems~support~for~the~memoir~class}
\bool_new:N \l__keythms_support_titlecode_bool
diff --git a/Master/texmf-dist/tex/latex/keytheorems/keytheorems.sty b/Master/texmf-dist/tex/latex/keytheorems/keytheorems.sty
index 28c485083e9..2dc91cf86cc 100644
--- a/Master/texmf-dist/tex/latex/keytheorems/keytheorems.sty
+++ b/Master/texmf-dist/tex/latex/keytheorems/keytheorems.sty
@@ -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-16}{0.1.2}{l3keys interface to amsthm}
+\ProvidesExplPackage{keytheorems}{2024-09-19}{0.1.3}{l3keys interface to amsthm}
\IfFormatAtLeastTF { 2024-06-01 } { }
{
@@ -10,6 +10,7 @@
\cs_generate_variant:Nn \cs_set:Npn { Npe }
\cs_generate_variant:Nn \iow_shipout:Nn { Ne }
\cs_generate_variant:Nn \keys_set:nn { ne }
+ \cs_generate_variant:Nn \msg_warning:nnn { nne }
\cs_generate_variant:Nn \tl_put_right:Nn { Ne }
\ProvideDocumentCommand \IfPackageLoadedT { m m }
{ \IfPackageLoadedTF{#1}{#2}{ } }
@@ -45,6 +46,25 @@
Try~compiling~again.~If~that~doesn't~work,~
check~the~spelling~of~'#1'.
}
+\msg_new:nnn { keytheorems } { no-prop-for-stored-theorem }
+ {
+ No~property~'#1'~found~for~stored~theorem~'#2'.
+ }
+\msg_new:nnn { keytheorems } { store-reversed-not-got }
+ {
+ 'store*=#1'~only~makes~sense~if~you've~called~\protect\getkeytheorem{#1}.~
+ Check~that~\protect\getkeytheorem{#1}~is~called~and~compile~again.
+ }
+\msg_new:nnn { keytheorems } { restate-body-never-got }
+ {
+ With~'store*=#1',~\protect\getkeytheorem[body]{#1}~only~makes~sense~if~
+ \protect\getkeytheorem{#1}~has~been~called.~
+ Check~that~\protect\getkeytheorem{#1}~is~called~and~compile~again.
+ }
+\msg_new:nnn { keytheorems } { store-reversed-called-twice }
+ {
+ With~'store*=#1',~\protect\getkeytheorem{#1}~can~be~called~only~once.
+ }
\msg_new:nnn { keytheorems } { undefined-thm-hook }
{
No~theorem~hook~'#1'.~Check~the~spelling.~
@@ -116,6 +136,7 @@
\tl_new:N \l__keythms_thmstyle_rnotebrace_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
\newcounter{keythms_restate_dummyctr}
\cs_gset:Npn \theHkeythms_restate_dummyctr
@@ -133,19 +154,6 @@
\cs_generate_variant:Nn \hook_gput_code:nnn { nnV }
\cs_generate_variant:Nn \keys_precompile:nnN { nv, nVc }
-% for detecting AMS classes
-\prg_new_conditional:Npnn \keythms_if_amsclass: { T, TF }
- {
- \IfClassLoadedTF { amsart } { \prg_return_true: }
- {
- \IfClassLoadedTF { amsbook } { \prg_return_true: }
- {
- \IfClassLoadedTF { amsproc } { \prg_return_true: }
- { \prg_return_false: }
- }
- }
- }
-
%%%%%%%%%%%%%%
%%% Styles %%%
%%%%%%%%%%%%%%
@@ -187,6 +195,7 @@
break .value_forbidden:n = true,
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,
headstyle .choice:,
headstyle / margin .code:n =
{
@@ -240,7 +249,8 @@
\cs_new:Npn \NOTE
{
\keythms_thmstyle_thmnote:n
- { ~ \group_begin: % group so notefont doesn't affect headpunct
+ { \exp_not:V \l__keythms_thmstyle_noteseparator_tl
+ \group_begin: % group so notefont doesn't affect headpunct
\exp_not:V \l__keythms_thmstyle_notefont_tl
\l__keythms_thmstyle_lnotebrace_tl ##3 \l__keythms_thmstyle_rnotebrace_tl
\group_end:
@@ -250,11 +260,10 @@
\cs_new:Npn \keythms_thmstyle_headcmd_default:nnn #1#2#3
{
\keythms_thmstyle_thmname:n { #1 }
- \keythms_thmstyle_thmnumber:n
- { \tl_if_empty:nF { #1 } { ~ } \exp_not:N \textup { #2 } }
- % ^ this \tl_if_empty has no effect...
+ \keythms_thmstyle_thmnumber:n { ~ \textup { #2 } }
\keythms_thmstyle_thmnote:n
- { ~ \group_begin: % group so notefont doesn't affect headpunct
+ { \exp_not:V \l__keythms_thmstyle_noteseparator_tl
+ \group_begin: % group so notefont doesn't affect headpunct
\exp_not:V \l__keythms_thmstyle_notefont_tl
\l__keythms_thmstyle_lnotebrace_tl #3 \l__keythms_thmstyle_rnotebrace_tl
\group_end:
@@ -278,6 +287,7 @@
postheadspace = 5pt plus 1pt minus 1pt,
notefont = \fontseries\mddefault\upshape,
notebraces = {(}{)},
+ noteseparator = {~},
headstyle = \keythms_thmstyle_headcmd_default:nnn{#1}{#2}{#3},
}
@@ -824,6 +834,8 @@
%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 },
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,
@@ -856,6 +868,68 @@
\__keythms_thm_postfoot_code:n { #1 }
}
{}
+ \DeclareDocumentEnvironment { keythms_grabreversed_#1 } { m O{} +b }
+ { % ##1 = keys, ##2 = note, ##3 = theorem body
+ \tl_if_exist:cTF
+ { c__keythms_storeatbegin_ \l__keythms_thmuse_storereversed_tl _restatecounters_tl }
+ {
+ \bool_set_true:N \l__keythms_thmuse_restating_bool
+ \exp_args:NNe \prop_set_from_keyval:Nn \l__keythms_restate_counters_prop
+ { \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 }
+ { \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
+ % user to say "restate-counters={section,chapter,...}".
+ \cs_set:cpn { theH ####1 }
+ { \use:c { the ####1 } . \theHkeythms_restate_dummyctr }
+ }
+ \tl_if_empty:cTF
+ { c__keythms_storeatbegin_ \l__keythms_thmuse_storereversed_tl _label_tl }
+ { \refstepcounter{keythms_restate_dummyctr} } % for unnumbered theorems
+ {
+ \cs_set:cpn { the #1 }
+ { \tl_use:c { c__keythms_storeatbegin_ \l__keythms_thmuse_storereversed_tl _label_tl } }
+ \cs_set_eq:cN { c@ #1 } \c@keythms_restate_dummyctr
+ \cs_set_eq:cN { theH #1 } \theHkeythms_restate_dummyctr
+ % ^ why are the last two lines here? We shouldn't be referencing
+ % restated theorems. Think it's a remnant of thmtools
+ % WRONG: needed to make numbering correct after restated theorem.
+ % not sure about theH. <- this is needed to prevent duplicate anchors
+ }
+ }
+ {
+ \msg_warning:nne { keytheorems } { store-reversed-not-got }
+ { \l__keythms_thmuse_storereversed_tl }
+ }
+ \renewcommand\label[2][]{} % disable \label (opt arg in case cleveref loaded)
+ \cs_set_eq:NN \ltx@label \use_none:n % disable \ltx@label
+ \cs_set_eq:NN \property_record:nn \use_none:nn % disable \RecordProperties
+ \cs_set_eq:NN \setuniqmark \use_none:n % work with numbered=unless-unique
+ % QUESTION: also disable \hyper@@anchor? \MakeLinkTarget?
+ \hook_use:n { keytheorems/#1/restated }
+ \hook_use:n { keytheorems/allthms/restated }
+ \__keythms_thm_prehead_code:n { #1 }
+ \begin{keythms_orig_#1}[{##2}]
+ \__keythms_thm_posthead_code:n { #1 }
+ % below needs to come after posthead so that correct \@currentHref
+ % is stored for tcolorbox theorems
+ \__keythms_thm_addstoredreverseddata:nnn { #1 } { ##1 } { ##3 }
+ \__keythms_thm_tempstorerestatedatareversed:nnn { #1 } { ##1 } { ##3 }
+ ##3
+ \__keythms_thm_prefoot_code:n { #1 }
+ \end{keythms_orig_#1}
+ \__keythms_thm_postfoot_code:n { #1 }
+ \prop_map_inline:Nn \l__keythms_restate_counters_prop
+ {
+ \exp_args:Nnc \setcounter { ####1 }
+ { l_keythms_restate_current_####1_tl }
+ }
+ }
+ { }
% 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
@@ -870,6 +944,14 @@
\cs_set_eq:NN \__keythms_withhooks_begin:nnV \__keythms_grab_begin:nnV
\cs_set_eq:NN \__keythms_withhooks_end:n \__keythms_grab_end:n
}
+ \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 } }
@@ -903,6 +985,26 @@
}
}
}
+ \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_iii_v_braced:nnnnn #1#2#3#4#5 { {#3}{#5} }
@@ -941,6 +1043,18 @@
\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}]
+ }
+\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}] }
@@ -1016,6 +1130,19 @@
}
}
}
+\cs_new_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 }
+ { \exp_not:n { #2 } }
+ { \exp_not:n { #3 } }
+ }
+ }
+ }
\cs_new_protected:Npn \__keythms_thm_tempstorerestatedata:nnn #1#2#3
{ % #1 = theorem name, #2 = keys, #3 = body
\tl_gset:Ne \g__keythms_thmuse_temprestatedata_tl % needs to be global to get out of env
@@ -1027,18 +1154,29 @@
{ \exp_not:n { #3 } } % with \text_expand:n ?
}
}
-
+\cs_new_protected:Npn \__keythms_thm_tempstorerestatedatareversed:nnn #1#2#3
+ {
+ \tl_gset:Ne \g__keythms_thmuse_temprestatedatareversed_tl % needs to be global to get out of env
+ {
+ { #1 }
+ { \exp_not:n { #2 } }
+ { \exp_not:n { #3 } }
+ }
+ }
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Retrieving Theorem Data %%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\cs_new_protected:Npn \KeyThmsSavedTheorem #1#2#3#4#5#6#7 % 7th arg is body
{ \use:c { __keythms_thmitem_#1:nnnnnn } {#2}{#3}{#4}{#5}{#6}{#7} }
+\cs_new_protected:Npn \KeyThmsSavedTheoremReversed #1#2#3#4 { } % gobble by default
\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
}
@@ -1085,8 +1223,39 @@
\__keythms_getthm_body:nn {#5}{#7}
}
}
+ \tl_if_empty:NF \l__keythms_storeatbegin_storereversed_tl
+ {
+ \tl_const:cn
+ { c__keythms_storeatbegin_ \l__keythms_storeatbegin_storereversed_tl _label_tl }
+ { #2 }
+ \tl_const:cn
+ { c__keythms_storeatbegin_ \l__keythms_storeatbegin_storereversed_tl _restatecounters_tl }
+ { #5 }
+ \cs_new_protected:cpn
+ { __keythms_getthm_ \l__keythms_storeatbegin_storereversed_tl _body }
+ {
+ \__keythms_getthm_body:nn {#5}{#7}
+ }
+ }
\group_end:
}
+ \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 } }
+ \hook_gput_code:nnn { begindocument/end } { . }
+ {
+ \cs_if_exist:cF { __keythms_getthm_ #1 _body }
+ {
+ \cs_new_protected:cpn { __keythms_getthm_ #1 _body }
+ {
+ \textbf{??}
+ \msg_warning:nnn { keytheorems } { restate-body-never-got } { #1 }
+ }
+ }
+ }
+ }
\file_if_exist_input:n { \c_sys_jobname_str.thlist }
\group_end:
}
@@ -1098,6 +1267,8 @@
{ \prg_return_false: }
}
\NewDocumentCommand \IfRestatingTF { } { \keythms_if_restating:TF }
+\NewDocumentCommand \IfRestatingT { } { \keythms_if_restating:T }
+\NewDocumentCommand \IfRestatingF { } { \keythms_if_restating:F }
\cs_new_protected:Npn \__keythms_getthm_theorem:nnnnn #1#2#3#4#5
{ % #1 = name, #2 = number, #3 = restate counters, #4 = keys, #5 = theorem body
@@ -1111,7 +1282,8 @@
% ^ FIX: what if eq's numbered by section, theorem, etc.? The
% thmtools code is opaque.... Or maybe should be up to the
% user to say "restate-counters={section,chapter,...}".
- \cs_set:cpn { theH ##1 } { \use:c { the ##1 } . \theHkeythms_restate_dummyctr }
+ \cs_set:cpn { theH ##1 }
+ { \use:c { the ##1 } . \theHkeythms_restate_dummyctr }
}
\tl_if_empty:nTF { #2 }
{ \refstepcounter{keythms_restate_dummyctr} } % for unnumbered theorems
@@ -1162,7 +1334,8 @@
% ^ FIX: what if eq's numbered by section, theorem, etc.? The
% thmtools code is opaque.... Or maybe should be up to the
% user to say "restate-counters={section,chapter,...}".
- \cs_set:cpn { theH ##1 } { \use:c { the ##1 } . \theHkeythms_restate_dummyctr }
+ \cs_set:cpn { theH ##1 }
+ { \use:c { the ##1 } . \theHkeythms_restate_dummyctr }
}
\refstepcounter{keythms_restate_dummyctr}
\renewcommand\label[2][]{} % disable \label (opt arg in case cleveref loaded)
@@ -1179,18 +1352,79 @@
\group_end:
}
+\cs_new_protected:Npn \__keythms_getthmreversed_theorem:nnn #1#2#3
+ { % #1 = envname, #2 = keys, #3 = theorem body
+ \group_begin:
+ \bool_set_false:N \l__keythms_thmuse_restating_bool
+ \keys_set:nn { keytheorems/thmuse } { #2 }
+ \__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 }
+ \clist_map_inline:Nn \g__keythms_restatecounters_clist
+ {
+ \prop_gput:Nne \g__keythms_thmuse_othercounters_prop { ##1 }
+ { \the\value{##1} }
+ }
+ \__keythms_thm_posthead_code:n { #1 }
+ \__keythms_thm_addcontentsdata:nnnn { #1 }
+ { \prop_to_keyval:N \g__keythms_thmuse_othercounters_prop }
+ { #2 } { #3 }
+ \__keythms_thm_tempstorerestatedata:nnn { #1 } { #2 } { #3 } % for defining getthm_body
+ #3
+ \__keythms_thm_prefoot_code:n { #1 }
+ \__keythms_orig_end:n { #1 }
+ \__keythms_thm_postfoot_code:n { #1 }
+ % While we're here, define getthm_body
+ \cs_if_exist:cF
+ { __keythms_getthm_ \l__keythms_thmuse_storereversed_tl _body }
+ {
+ \cs_new:cpe
+ { __keythms_getthm_ \l__keythms_thmuse_storereversed_tl _body }
+ {
+ \exp_not:N \__keythms_getthm_body:nn
+ \exp_args:No \exp_not:o
+ {
+ \exp_after:wN \__keythms_use_iii_v_braced:nnnnn
+ \g__keythms_thmuse_temprestatedata_tl
+ }
+ }
+ }
+ \bool_gset_true:c
+ { g__keythms_restate_ \l__keythms_thmuse_storereversed_tl _called_bool }
+ \group_end:
+ }
+
% \getkeytheorem[<property>]{<tag>}
-\NewDocumentCommand \getkeytheorem { o m }
+\NewDocumentCommand \getkeytheorem { O{theorem} m }
{
- \cs_if_exist:cTF { __keythms_getthm_#2_theorem }
+ \cs_if_exist:cTF { __keythms_getthm_#2_#1 }
{
- \IfNoValueTF { #1 }
- { \use:c { __keythms_getthm_#2_theorem } }
+ \bool_if_exist:cTF { g__keythms_restate_#2_called_bool }
+ {
+ \str_if_eq:nnTF { #1 } { theorem }
+ {
+ \bool_if:cTF
+ { g__keythms_restate_#2_called_bool }
+ {
+ \msg_error:nnn { keytheorems }
+ { store-reversed-called-twice } { #2 }
+ }
+ { \use:c { __keythms_getthm_#2_#1 } }
+ }
+ { \use:c { __keythms_getthm_#2_#1 } }
+ }
{ \use:c { __keythms_getthm_#2_#1 } }
}
{
\textbf{??}
- \msg_warning:nnn { keytheorems } { no-stored-theorem } { #2 }
+ \cs_if_exist:cTF { __keythms_getthm_#2_theorem }
+ {
+ \msg_warning:nnnn { keytheorems } { no-prop-for-stored-theorem }
+ { #1 } { #2 } % should this be an error?
+ }
+ { \msg_warning:nnn { keytheorems } { no-stored-theorem } { #2 } }
}
}
@@ -1199,13 +1433,11 @@
%%%%%%%%%%%%%%%%%%%%%
%%% \addtotheoremhook[<envname>]{<hook>}{<code>}
-\NewDocumentCommand \addtotheoremhook { o m +m }
+\NewDocumentCommand \addtotheoremhook { O{allthms} m +m }
{
\__hook_if_declared:nTF { keytheorems/allthms/#2 }
{
- \IfNoValueTF { #1 }
- { \hook_gput_code:nnn { keytheorems/allthms/#2 } { . } { #3 } }
- { \hook_gput_code:nnn { keytheorems/#1/#2 } { . } { #3 } }
+ \hook_gput_code:nnn { keytheorems/#1/#2 } { . } { #3 }
}
{
\msg_error:nnn { keytheorems } { undefined-thm-hook } { #2 }
@@ -1577,7 +1809,8 @@
{
\cs_set_protected:Npn \keythms_listof_chaptervspacehack:
{
- \int_compare:nNnF { \value{chapter} } = { \g_keythms_listof_prevchapter_int }
+ \int_compare:nNnF
+ { \value{chapter} } = { \g_keythms_listof_prevchapter_int }
{
\addtocontents{ thlist }
{
@@ -1665,7 +1898,7 @@
\cs_new_protected:Npn \__keythms_overload_code:
{
- \RenewDocumentCommand { \newtheorem } { smomo }
+ \RenewDocumentCommand { \newtheorem } { s m o m o }
{
\IfBooleanTF { ##1 }
{ \keythms_thm_newkeythm:nn { ##2 } { name=##4, numbered=no } }
@@ -1708,42 +1941,41 @@
}
}
\ProvideDocumentCommand { \listoftheorems } { } { \listofkeytheorems }
- \ProvideDocumentCommand { \addtotheorempreheadhook } { o m }
+ \ProvideDocumentCommand { \addtotheorempreheadhook } { O{allthms} m }
{
- \IfNoValueTF { ##1 }
- { \addtotheoremhook { prehead } { ##2 } }
- { \addtotheoremhook [ ##1 ] { prehead } { ##2 } }
+ \addtotheoremhook [ ##1 ] { prehead } { ##2 }
}
- \ProvideDocumentCommand { \addtotheorempostheadhook } { o m }
+ \ProvideDocumentCommand { \addtotheorempostheadhook } { O{allthms} m }
{
- \IfNoValueTF { ##1 }
- { \addtotheoremhook { posthead } { ##2 } }
- { \addtotheoremhook [ ##1 ] { posthead } { ##2 } }
+ \addtotheoremhook [ ##1 ] { posthead } { ##2 }
}
- \ProvideDocumentCommand { \addtotheoremprefoothook } { o m }
+ \ProvideDocumentCommand { \addtotheoremprefoothook } { O{allthms} m }
{
- \IfNoValueTF { ##1 }
- { \addtotheoremhook { prefoot } { ##2 } }
- { \addtotheoremhook [ ##1 ] { prefoot } { ##2 } }
+ \addtotheoremhook [ ##1 ] { prefoot } { ##2 }
}
- \ProvideDocumentCommand { \addtotheorempostfoothook } { o m }
+ \ProvideDocumentCommand { \addtotheorempostfoothook } { O{allthms} m }
{
- \IfNoValueTF { ##1 }
- { \addtotheoremhook { postfoot } { ##2 } }
- { \addtotheoremhook [ ##1 ] { postfoot } { ##2 } }
+ \addtotheoremhook [ ##1 ] { postfoot } { ##2 }
}
\clist_new:N \l__keythms_tcbshaded_keys_clist
\clist_new:N \l__keythms_tcbthmbox_keys_clist
\keys_define:nn { keytheorems/thm/shaded }
{
- textwidth .code:n = \clist_put_right:Nn \l__keythms_tcbshaded_keys_clist { width=##1 },
- bgcolor .code:n = \clist_put_right:Nn \l__keythms_tcbshaded_keys_clist { colback=##1 },
- rulewidth .code:n = \clist_put_right:Nn \l__keythms_tcbshaded_keys_clist { boxrule=##1 },
- rulecolor .code:n = \clist_put_right:Nn \l__keythms_tcbshaded_keys_clist { colframe=##1 },
- margin .code:n = \clist_put_right:Nn \l__keythms_tcbshaded_keys_clist { boxsep=##1 },
+ textwidth .code:n =
+ \clist_put_right:Nn \l__keythms_tcbshaded_keys_clist { width=##1 },
+ bgcolor .code:n =
+ \clist_put_right:Nn \l__keythms_tcbshaded_keys_clist { colback=##1 },
+ rulewidth .code:n =
+ \clist_put_right:Nn \l__keythms_tcbshaded_keys_clist { boxrule=##1 },
+ rulecolor .code:n =
+ \clist_put_right:Nn \l__keythms_tcbshaded_keys_clist { colframe=##1 },
+ margin .code:n =
+ \clist_put_right:Nn \l__keythms_tcbshaded_keys_clist { boxsep=##1 },
padding .meta:n = { margin=##1 },
- leftmargin .code:n = \clist_put_right:Nn \l__keythms_tcbshaded_keys_clist { left~skip=##1 },
- rightmargin .code:n = \clist_put_right:Nn \l__keythms_tcbshaded_keys_clist { right~skip=##1 },
+ leftmargin .code:n =
+ \clist_put_right:Nn \l__keythms_tcbshaded_keys_clist { left~skip=##1 },
+ rightmargin .code:n =
+ \clist_put_right:Nn \l__keythms_tcbshaded_keys_clist { right~skip=##1 },
}
\keys_define:nn { keytheorems/thm/thmbox }
{
@@ -2013,6 +2245,11 @@
thmbox .default:n = M,
mdframed .code:n = \msg_error:nn { keytheorems } { mdframed-undefined },
}
+ \keys_define:nn { keytheorems/thmstyle }
+ {
+ shaded .code:n = \keythms_thmstyle_savethmkey_optval:n { ##1 },
+ thmbox .code:n = \keythms_thmstyle_savethmkey_optval:n { ##1 },
+ }
}
\cs_new_protected:Npn \__keythms_storeall_code:
@@ -2040,6 +2277,8 @@
\ProvideTranslation { Italian } { keythms_continues } { continua~da~p.\, }
\ProvideTranslation { Spanish } { keythms_listof_title } { Lista~de~teoremas }
\ProvideTranslation { Spanish } { keythms_continues } { continĂșa~de~la~p.\, }
+ \ProvideTranslation { Portuguese } { keythms_listof_title } { Lista~de~teoremas }
+ \ProvideTranslation { Portuguese } { keythms_continues } { continua~da~p.\, }
}
}