summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/keytheorems/keytheorems.sty
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2024-10-01 19:51:14 +0000
committerKarl Berry <karl@freefriends.org>2024-10-01 19:51:14 +0000
commit12ee80fc9f233df74671ea25a742a604019a56b9 (patch)
treee32f765d6f29cff38210a77254e183c679332b14 /Master/texmf-dist/tex/latex/keytheorems/keytheorems.sty
parentf36cf8b9cb56d24e6980acdb3420981dd1a38e62 (diff)
keytheorems (1oct24)
git-svn-id: svn://tug.org/texlive/trunk@72443 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/keytheorems/keytheorems.sty')
-rw-r--r--Master/texmf-dist/tex/latex/keytheorems/keytheorems.sty539
1 files changed, 269 insertions, 270 deletions
diff --git a/Master/texmf-dist/tex/latex/keytheorems/keytheorems.sty b/Master/texmf-dist/tex/latex/keytheorems/keytheorems.sty
index efea2364277..7059d951a0a 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-22}{0.1.4}{l3keys interface to amsthm}
+\ProvidesExplPackage{keytheorems}{2024-09-30}{0.1.5}{l3keys interface to amsthm}
\IfFormatAtLeastTF { 2024-06-01 } { }
{
@@ -19,11 +19,10 @@
\ProvideDocumentCommand \IfClassLoadedT { m m }
{ \IfClassLoadedTF{#1}{#2}{ } }
}
-\RequirePackage{aliascnt} % for sibling theorems
-\RequirePackage{amsthm}
-% ^ ams classes have way of ignoring this so don't need to check if they're loaded
-\RequirePackage{refcount} % for \getrefnumber
-\RequirePackage{translations} % for translating "List of Theorems"
+\RequirePackage{aliascnt}
+\RequirePackage{amsthm} % ams classes have way of ignoring this
+\RequirePackage{refcount}
+\RequirePackage{translations}
%%%%%%%%%%%%%%%%%%%%%%
%%% Error Messages %%%
@@ -129,6 +128,7 @@
\clist_new:N \l__keythms_thmstyle_savedkeys_clist
\iow_new:N \g__keythms_listof_stream
\prop_new:N \g__keythms_thmnames_prop
+\prop_new:N \g__keythms_thmstyle_defaultkeys_prop
\prop_new:N \g__keythms_thmuse_othercounters_prop
\prop_new:N \l__keythms_restate_counters_prop
\tl_new:N \l__keythms_thm_currentthmstyle_tl
@@ -155,25 +155,24 @@
\cs_gset:Npn \thekeythms_unnumbered_dummyctr { }
\cs_generate_variant:Nn \hook_gput_code:nnn { nnV }
-\cs_generate_variant:Nn \keys_precompile:nnN { nv, nVc }
+\cs_generate_variant:Nn \keys_precompile:nnN { nv, nVc, nnc, ne }
%%%%%%%%%%%%%%
%%% Styles %%%
%%%%%%%%%%%%%%
-% \__keythms_thmstyle_setbraces:nn { <left brace> } { <right brace> }
\cs_new_protected:Npn \__keythms_thmstyle_setbraces:nn #1#2
- {
+ { % #1 = left brace, #2 = right brace
\tl_set:Nn \l__keythms_thmstyle_lnotebrace_tl { #1 }
\tl_set:Nn \l__keythms_thmstyle_rnotebrace_tl { #2 }
}
\cs_new_protected:Npn \keythms_thmstyle_savethmkey_reqval:n #1
- {
+ { % #1 = key value
\clist_put_right:No \l__keythms_thmstyle_savedkeys_clist
{ \l_keys_key_str = { #1 } }
}
\cs_new_protected:Npn \keythms_thmstyle_savethmkey_optval:n #1
- {
+ { % #1 = key value
\tl_if_empty:NTF \l_keys_value_tl
{
\clist_put_right:No \l__keythms_thmstyle_savedkeys_clist
@@ -187,19 +186,13 @@
\keys_define:nn { keytheorems/thmstyle }
{
- spaceabove .tl_set:N = \l__keythms_thmstyle_spaceabove_tl,
- spacebelow .tl_set:N = \l__keythms_thmstyle_spacebelow_tl,
bodyfont .tl_set:N = \l__keythms_thmstyle_bodyfont_tl,
- headindent .tl_set:N = \l__keythms_thmstyle_headindent_tl,
- headfont .tl_set:N = \l__keythms_thmstyle_headfont_tl,
- headpunct .tl_set:N = \l__keythms_thmstyle_headpunct_tl,
- postheadspace .tl_set:N = \l__keythms_thmstyle_postheadspace_tl,
break .meta:n = { postheadspace = \newline }, % add error if postheadspace set
break .value_forbidden:n = true,
- numberfont .tl_set:N = \l__keythms_thmstyle_numberfont_tl,
- notefont .tl_set:N = \l__keythms_thmstyle_notefont_tl,
- notebraces .code:n = \exp_after:wN \__keythms_thmstyle_setbraces:nn #1,
- noteseparator .tl_set:N = \l__keythms_thmstyle_noteseparator_tl,
+ headfont .tl_set:N = \l__keythms_thmstyle_headfont_tl,
+ headformat .meta:n = { headstyle = #1 },
+ headindent .tl_set:N = \l__keythms_thmstyle_headindent_tl,
+ headpunct .tl_set:N = \l__keythms_thmstyle_headpunct_tl,
headstyle .choice:,
headstyle / margin .code:n =
{
@@ -211,62 +204,44 @@
\cs_set:Nn \keythms_thmstyle_headcmd:nnn { \NUMBER\ \NAME\NOTE }
},
headstyle / unknown .cs_set:Np = \keythms_thmstyle_headcmd:nnn #1#2#3,
- headformat .meta:n = { headstyle = #1 },
inherit-style .choice:,
inherit-style / plain .meta:n = {},
inherit-style / definition .meta:n = { bodyfont = \normalfont },
inherit-style / remark .meta:n =
{
- headfont = \itshape,
- bodyfont = \normalfont,
+ bodyfont = \normalfont,
+ headfont = \itshape,
spaceabove = 0.5\topsep,
spacebelow = 0.5\topsep,
},
+ notebraces .code:n = \exp_after:wN \__keythms_thmstyle_setbraces:nn #1,
+ notefont .tl_set:N = \l__keythms_thmstyle_notefont_tl,
+ noteseparator .tl_set:N = \l__keythms_thmstyle_noteseparator_tl,
+ numberfont .tl_set:N = \l__keythms_thmstyle_numberfont_tl,
+ postheadspace .tl_set:N = \l__keythms_thmstyle_postheadspace_tl,
+ 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
numbered .code:n = \keythms_thmstyle_savethmkey_optval:n { #1 },
- parent .code:n = \keythms_thmstyle_savethmkey_reqval:n { #1 },
- numberwithin .code:n = \keythms_thmstyle_savethmkey_reqval:n { #1 },
- within .code:n = \keythms_thmstyle_savethmkey_reqval:n { #1 },
- sibling .code:n = \keythms_thmstyle_savethmkey_reqval:n { #1 },
numberlike .code:n = \keythms_thmstyle_savethmkey_reqval:n { #1 },
- sharenumber .code:n = \keythms_thmstyle_savethmkey_reqval:n { #1 },
- preheadhook .code:n = \keythms_thmstyle_savethmkey_reqval:n { #1 },
+ numberwithin .code:n = \keythms_thmstyle_savethmkey_reqval:n { #1 },
+ parent .code:n = \keythms_thmstyle_savethmkey_reqval:n { #1 },
+ postfoothook .code:n = \keythms_thmstyle_savethmkey_reqval:n { #1 },
postheadhook .code:n = \keythms_thmstyle_savethmkey_reqval:n { #1 },
prefoothook .code:n = \keythms_thmstyle_savethmkey_reqval:n { #1 },
- postfoothook .code:n = \keythms_thmstyle_savethmkey_reqval:n { #1 },
+ preheadhook .code:n = \keythms_thmstyle_savethmkey_reqval:n { #1 },
qed .code:n = \keythms_thmstyle_savethmkey_optval:n { #1 },
+ sharenumber .code:n = \keythms_thmstyle_savethmkey_reqval:n { #1 },
+ sibling .code:n = \keythms_thmstyle_savethmkey_reqval:n { #1 },
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 },
}
\cs_new_protected:Nn \keythms_thmstyle_thmname:n { \thmname{#1} }
\cs_new_protected:Nn \keythms_thmstyle_thmnumber:n { \thmnumber{#1} }
\cs_new_protected:Nn \keythms_thmstyle_thmnote:n { \thmnote{#1} }
-%% NOTE: if these are used, user is in charge of spacing with \NAME and \NUMBER
-%% QUESTION: should these be moved into def of \newkeytheoremstyle?
-\cs_new:Npn \NAME { \keythms_thmstyle_thmname:n { ##1 } }
-\cs_new:Npn \NUMBER
- {
- \keythms_thmstyle_thmnumber:n
- {
- \group_begin:
- \exp_not:V \l__keythms_thmstyle_numberfont_tl
- ##2
- \group_end:
- }
- }
-\cs_new:Npn \NOTE
- {
- \keythms_thmstyle_thmnote:n
- { \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:
- }
- }
-
\cs_new:Npn \keythms_thmstyle_headcmd_default:nnn #1#2#3
{
\keythms_thmstyle_thmname:n { #1 }
@@ -286,26 +261,26 @@
}
}
-\cs_new_protected:Npn \keythms_thmstyle_setdefaultkeys:n #1
- {
- \keys_precompile:nnN { keytheorems/thmstyle }
- { #1 }
- \l__keythms_thmstyle_defaultkeys_tl
- }
-\keythms_thmstyle_setdefaultkeys:n
+\prop_gset_from_keyval:Nn \g__keythms_thmstyle_defaultkeys_prop
{ % support files may overwrite these defaults
- spaceabove = \topsep,
- spacebelow = \topsep,
bodyfont = \itshape,
- headindent = 0pt,
headfont = \bfseries,
+ headindent = 0pt,
headpunct = {.},
- postheadspace = 5pt plus 1pt minus 1pt,
- numberfont = \upshape,
- notefont = \fontseries\mddefault\upshape,
+ headstyle = \keythms_thmstyle_headcmd_default:nnn{#1}{#2}{#3},
notebraces = {(}{)},
+ notefont = \fontseries\mddefault\upshape,
noteseparator = {~},
- headstyle = \keythms_thmstyle_headcmd_default:nnn{#1}{#2}{#3},
+ numberfont = \upshape,
+ postheadspace = 5pt plus 1pt minus 1pt,
+ spaceabove = \topsep,
+ spacebelow = \topsep,
+ }
+\hook_gput_code:nnn { package/keytheorems/after } { . }
+ { % need to defer to wait for support files
+ \keys_precompile:neN { keytheorems/thmstyle }
+ { \prop_to_keyval:N \g__keythms_thmstyle_defaultkeys_prop }
+ \l__keythms_thmstyle_defaultkeys_tl
}
\NewDocumentCommand \newkeytheoremstyle { m m }
@@ -338,8 +313,31 @@
\cs_new_eq:NN \keythms_thmstyle_new:nnnnnnnnn \newtheoremstyle
\cs_generate_variant:Nn \keythms_thmstyle_new:nnnnnnnnn { nVVVVVVVe }
+\tl_put_right:Nn \l_text_expand_exclude_tl { \thmnote \thmnumber \thmname }
+% ^ allows \thmnote, etc. to work in headstyle; hope no bad side effects!
\cs_new_protected:Npn \keythms_thmstyle_declarestyle:nn #1#2
- {
+ { % user is in charge of spacing with \NAME and \NUMBER (thmtools compat...)
+ \cs_set:Npn \NAME { \keythms_thmstyle_thmname:n { ####1 } }
+ \cs_set:Npn \NUMBER
+ {
+ \keythms_thmstyle_thmnumber:n
+ {
+ \group_begin:
+ \exp_not:V \l__keythms_thmstyle_numberfont_tl
+ ####2
+ \group_end:
+ }
+ }
+ \cs_set:Npn \NOTE
+ {
+ \keythms_thmstyle_thmnote:n
+ { \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:
+ }
+ }
\clist_clear:N \l__keythms_thmstyle_savedkeys_clist
\tl_use:N \l__keythms_thmstyle_defaultkeys_tl
\keys_set:nn { keytheorems/thmstyle } { #2 }
@@ -352,14 +350,21 @@
\l__keythms_thmstyle_headpunct_tl
\l__keythms_thmstyle_postheadspace_tl
{ \text_expand:n { \keythms_thmstyle_headcmd:nnn{##1}{##2}{##3} } }
- % Define new inherit-style key
- \keys_define:nn { keytheorems/thmstyle }
- { inherit-style / #1 .meta:n = { #2 } }
- \tl_if_exist:cF { l__keythms_thmstyle_ #1 _savedkeys_tl }
- { \tl_new:c { l__keythms_thmstyle_ #1 _savedkeys_tl } }
+ % Define inherit-style key
+ \tl_if_exist:cF { l__keythms_thmstyle_ #1 _metakeys_tl }
+ { \tl_new:c { l__keythms_thmstyle_ #1 _metakeys_tl } }
+ \keys_precompile:nnc { keytheorems/thmstyle } { #2 } % use precompile instead of meta key
+ { l__keythms_thmstyle_ #1 _metakeys_tl } % because that's sensitive to hashes
+ \keys_define:nn { keytheorems/thmstyle } % and we want to allow both # and ##
+ { inherit-style / #1 .code:n = \tl_use:c { l__keythms_thmstyle_ #1 _metakeys_tl } }
+ \tl_if_exist:cF { l__keythms_thmstyle_ #1 _savedthmkeys_tl }
+ { \tl_new:c { l__keythms_thmstyle_ #1 _savedthmkeys_tl } }
\keys_precompile:nVc { keytheorems/thm }
\l__keythms_thmstyle_savedkeys_clist
- { l__keythms_thmstyle_ #1 _savedkeys_tl }
+ { l__keythms_thmstyle_ #1 _savedthmkeys_tl }
+ \cs_undefine:N \NAME % undefine to prevent conflicts
+ \cs_undefine:N \NUMBER
+ \cs_undefine:N \NOTE
}
%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -367,10 +372,8 @@
%%%%%%%%%%%%%%%%%%%%%%%%%
% FIX: reimplement these without \NewDocumentCommand and \SplitArgument
-
-% \keythms_thm_setrefnames:n { <envname> } { <refname> or <sing,plural> }
\NewDocumentCommand \keythms_thm_setrefnames:nn
- { m >{\SplitArgument{1}{,}} m }
+ { 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
{
@@ -384,9 +387,8 @@
}
\cs_generate_variant:Nn \keythms_thm_setrefnames:nn { nV }
-% \keythms_thm_setRefnames:n { <envname> } { <refname> or <sing,plural> }
\NewDocumentCommand \keythms_thm_setRefnames:nn
- { m >{\SplitArgument{1}{,}} m }
+ { 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
{
@@ -402,37 +404,35 @@
\keys_define:nn { keytheorems/thm }
{
- name .tl_set:N = \l__keythms_thm_name_tl,
- title .meta:n = { name = #1 },
heading .meta:n = { name = #1 },
- refname .tl_set:N = \l__keythms_thm_refname_tl,
- Refname .tl_set:N = \l__keythms_thm_Refname_tl,
+ name .tl_set:N = \l__keythms_thm_name_tl,
numbered .choice:,
- numbered / true .code:n = \bool_set_true:N \l__keythms_thm_numbered_bool,
+ numbered .default:n = true,
numbered / false .code:n = \bool_set_false:N \l__keythms_thm_numbered_bool,
- numbered / yes .meta:n = { numbered = true },
- numbered / no .meta:n = { numbered = false },
+ numbered / no .meta:n = { numbered = false },
+ numbered / true .code:n = \bool_set_true:N \l__keythms_thm_numbered_bool,
numbered / unless-unique .code:n =
{
\bool_set_true:N \l__keythms_thm_unlessunique_bool
},
numbered / unless~unique .meta:n = { numbered = unless-unique },
- numbered .default:n = true,
- parent .tl_set:N = \l__keythms_thm_parent_tl,
- numberwithin .meta:n = { parent = #1 },
- within .meta:n = { parent = #1 },
- sibling .tl_set:N = \l__keythms_thm_sibling_tl,
+ numbered / yes .meta:n = { numbered = true },
numberlike .meta:n = { sibling = #1 },
- sharenumber .meta:n = { sibling = #1 },
- style .tl_set:N = \l__keythms_thm_style_tl,
- style .groups:n = { style-comes-first },
- preheadhook .tl_set:N = \l__keythms_thm_preheadhook_tl,
+ numberwithin .meta:n = { parent = #1 },
+ parent .tl_set:N = \l__keythms_thm_parent_tl,
+ postfoothook .tl_set:N = \l__keythms_thm_postfoothook_tl,
postheadhook .tl_set:N = \l__keythms_thm_postheadhook_tl,
prefoothook .tl_set:N = \l__keythms_thm_prefoothook_tl,
- postfoothook .tl_set:N = \l__keythms_thm_postfoothook_tl,
+ preheadhook .tl_set:N = \l__keythms_thm_preheadhook_tl,
qed .tl_set:N = \l__keythms_thm_qed_tl,
qed .default:n = \c_novalue_tl,
% ^ distinguish between 'qed' and 'qed={}'
+ refname .tl_set:N = \l__keythms_thm_refname_tl,
+ Refname .tl_set:N = \l__keythms_thm_Refname_tl,
+ sharenumber .meta:n = { sibling = #1 },
+ sibling .tl_set:N = \l__keythms_thm_sibling_tl,
+ style .tl_set:N = \l__keythms_thm_style_tl,
+ style .groups:n = { style-comes-first },
tcolorbox .tl_set:N = \l__keythms_thm_tcbkeys_tl,
tcolorbox .default:n = {},
tcolorbox-no-titlebar .meta:n =
@@ -448,6 +448,8 @@
}
},
tcolorbox-no-titlebar .default:n = {},
+ title .meta:n = { name = #1 },
+ within .meta:n = { parent = #1 },
}
% what below is unnecessary? I really don't understand this code.
@@ -470,17 +472,17 @@
\keys_precompile:nnN { keytheorems/thm }
{
name = \q_no_value,
- refname = \q_no_value,
- Refname = \q_no_value,
numbered = true,
parent = {},
- sibling = {},
- style = {},
- preheadhook = {},
+ postfoothook = {},
postheadhook = {},
prefoothook = {},
- postfoothook = {},
+ preheadhook = {},
qed = \q_no_value,
+ refname = \q_no_value,
+ Refname = \q_no_value,
+ sibling = {},
+ style = {},
tcolorbox = \q_no_value,
}
\l__keythms_thm_defaultkeys_tl
@@ -497,23 +499,20 @@
% Make generic theorem hooks
\__keythms_thm_makethmhooks:n { allthms }
-% \newkeytheorem{<name>}{<keys>}
\NewDocumentCommand \newkeytheorem { m O{} }
- {
+ { % #1 = name, #2 = keys
\clist_map_inline:nn { #1 } % define multiple theorems at once
{ \keythms_thm_newkeythm:nn { ##1 } { #2 } }
}
-
\@onlypreamble \newkeytheorem
% to prevent error when plain, remark, or definition style used
-\tl_new:N \l__keythms_thmstyle_plain_savedkeys_tl
-\tl_new:N \l__keythms_thmstyle_remark_savedkeys_tl
-\tl_new:N \l__keythms_thmstyle_definition_savedkeys_tl
+\tl_new:N \l__keythms_thmstyle_plain_savedthmkeys_tl
+\tl_new:N \l__keythms_thmstyle_remark_savedthmkeys_tl
+\tl_new:N \l__keythms_thmstyle_definition_savedthmkeys_tl
-% \keythms_thm_newkeythm:nn { <envname> } { <keys> }
\cs_new_protected:Npn \keythms_thm_newkeythm:nn #1#2
- {
+ { % #1 = name, #2 = keys
% Store envname
\tl_set:Nn \l__keythms_thm_envname_tl { #1 }
% Make unless-unique false by default (can't precompile this)
@@ -526,16 +525,16 @@
\tl_set:Ne \l__keythms_thm_currentthmstyle_tl { \the\thm@style }
\tl_if_empty:NTF \l__keythms_thm_style_tl
{ % if \theoremstyle set, also use saved thm keys
- \tl_if_exist:cT {l__keythms_thmstyle_ \l__keythms_thm_currentthmstyle_tl _savedkeys_tl}
- { \tl_use:c {l__keythms_thmstyle_ \l__keythms_thm_currentthmstyle_tl _savedkeys_tl} }
+ \tl_if_exist:cT {l__keythms_thmstyle_ \l__keythms_thm_currentthmstyle_tl _savedthmkeys_tl}
+ { \tl_use:c {l__keythms_thmstyle_ \l__keythms_thm_currentthmstyle_tl _savedthmkeys_tl} }
}
{
% Temporarily set theorem style
\__keythms_theoremstyle:n { \l__keythms_thm_style_tl }
% If thm keys given in style, call now (possibly overwritten in next step)
% but don't error if user uses a style defined with just \newtheoremstyle
- \tl_if_exist:cT { l__keythms_thmstyle_ \l__keythms_thm_style_tl _savedkeys_tl }
- { \tl_use:c { l__keythms_thmstyle_ \l__keythms_thm_style_tl _savedkeys_tl } }
+ \tl_if_exist:cT { l__keythms_thmstyle_ \l__keythms_thm_style_tl _savedthmkeys_tl }
+ { \tl_use:c { l__keythms_thmstyle_ \l__keythms_thm_style_tl _savedthmkeys_tl } }
}
% Set env-specific keys
\keys_set:nn { keytheorems/thm } { #2 }
@@ -567,7 +566,7 @@
\quark_if_no_value:NT \l__keythms_thm_name_tl % use quark so name={} is valid
{
% use e so \text_titlecase called only once per theorem definition,
- % not each time the theorem is used
+ % not each time the theorem is used
\tl_set:Ne \l__keythms_thm_name_tl
{ \text_titlecase_first:n { #1 } }
}
@@ -670,9 +669,7 @@
\__keythms_listof_show_aux:n { #1 }
% Set theorem style back to original state if needed
\tl_if_empty:NF \l__keythms_thm_style_tl
- {
- \__keythms_theoremstyle:V \l__keythms_thm_currentthmstyle_tl
- }
+ { \__keythms_theoremstyle:V \l__keythms_thm_currentthmstyle_tl }
}
\cs_new_protected:Npn \__keythms_thm_tcboxcode:nn #1#2
@@ -741,7 +738,6 @@
\cs_new_eq:NN \__keythms_theoremstyle:n \theoremstyle
\cs_generate_variant:Nn \__keythms_theoremstyle:n { V }
-% \newtheorem variants
\cs_new_eq:NN \__keythms_thm_new:w \newtheorem
\cs_new_protected:Npn \__keythms_thm_new_numbered:nn #1#2
@@ -820,13 +816,6 @@
\keys_define:nn { keytheorems/thmuse }
{
- label .tl_set:N = \l__keythms_thmuse_label_tl,
- note .tl_set:N = \l__keythms_thmuse_note_tl,
- note .initial:n = {},
- name .meta:n = { note = #1 },
- % ^ for compatibility. "name" is ambiguous and doesn't match amsthm language
- short-note .code:n = {}, % these do nothing at point of use
- short-name .code:n = {},
continues .tl_set:N = \l__keythms_thmuse_contlabel_tl,
continues* .code:n =
{
@@ -838,17 +827,23 @@
{ note = \l__keythms_tmpa_tl }
}
},
- store .tl_set:N = \l__keythms_thmuse_store_tl, % should this be .tl_set_e:N ?
- %store .default:n = \q_no_value, % ={name} causes issues
- restate .meta:n = { store = #1 }, % thmtools compatibility
- store* .tl_set:N = \l__keythms_thmuse_storereversed_tl,
- restate* .meta:n = { store* = #1 },
- restate-keys .clist_set:N = \l__keythms_thmuse_restatekeys_clist,
- listhack .choice:, % need equals sign
+ label .tl_set:N = \l__keythms_thmuse_label_tl,
+ listhack .choice:, % needs 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,
listhack .initial:n = false,
+ name .meta:n = { note = #1 },
+ % ^ for compatibility. "name" is ambiguous and doesn't match amsthm language
+ note .tl_set:N = \l__keythms_thmuse_note_tl,
+ note .initial:n = {},
+ restate .meta:n = { store = #1 }, % thmtools compatibility
+ 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-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,
}
\cs_new_protected:Npn \keythms_keyify_theorem:n #1
@@ -1147,6 +1142,7 @@
{ \exp_not:n { #3 } }
}
}
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Retrieving Theorem Data %%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -1157,14 +1153,15 @@
\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 },
+ 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
}
-\cs_new_protected:Npn \KeyThmsContentsLine #1 { #1 }
+\cs_new_protected:Npn \KeyThmsContentsLine #1 { }
+% ^ initially a no-op, redefined where needed; important it's protected!
\NewDocumentCommand \addtheoremcontentsline { m m }
{
\addtocontents { thlist }
@@ -1187,8 +1184,6 @@
\hook_gput_code:nnn { begindocument } { . }
{
\group_begin:
- \cs_set_eq:NN \KeyThmsContentsLine \use_none:n
- \cs_set_eq:NN \KeyThmsAddvspace \use_none:n
\cs_set_protected:Npn \KeyThmsSavedTheorem #1#2#3#4#5#6#7
{
\group_begin:
@@ -1378,9 +1373,8 @@
\group_end:
}
-% \getkeytheorem[<property>]{<tag>}
\NewDocumentCommand \getkeytheorem { O{theorem} m }
- {
+ { % #1 = property, #2 = tag
\cs_if_exist:cTF { __keythms_getthm_#2_#1 }
{
\bool_if_exist:cTF { g__keythms_restate_#2_called_bool }
@@ -1414,9 +1408,8 @@
%%% Theorem Hooks %%%
%%%%%%%%%%%%%%%%%%%%%
-%%% \addtotheoremhook[<envname>]{<hook>}{<code>}
\NewDocumentCommand \addtotheoremhook { O{allthms} m +m }
- {
+ { % #1 = envname, #2 = hook, #3 = code
\__hook_if_declared:nTF { keytheorems/allthms/#2 }
{
\hook_gput_code:nnn { keytheorems/#1/#2 } { . } { #3 }
@@ -1425,7 +1418,6 @@
\msg_error:nnn { keytheorems } { undefined-thm-hook } { #2 }
}
}
-
% NOTE: I think it's OK we use the internal \__hook_if_declared:nTF above
% since we don't need to worry about the user creating new theorem hooks
% so, as we're only checking the existence of hooks created by us, it's OK.
@@ -1436,56 +1428,50 @@
\keys_define:nn { keytheorems/listof }
{
- numwidth .dim_set:N = \l__keythms_listof_numwidth_dim,
- numwidth .initial:n = 2.3em,
- indent .dim_set:N = \l__keythms_listof_indent_dim,
- indent .initial:n = 1.5em,
- ignore .code:n =
+ chapter-skip-length .dim_set:N = \keythms@listof@chaptervspace@dim,
+ chapter-skip-length .initial:n = 10pt,
+ format-code .cs_set:Np = \__keythms_listof_misdirect:nnn #1#2#3,
+ format-code .initial:n = \numberline{#2}#1#3,
+ ignore .code:n =
{
\hook_gput_code:nnn { begindocument/before } { keytheorems }
{ \keythms_listof_ignore:n { #1 } }
},
- show .code:n =
- {
+ ignoreall .code:n =
+ { % in case called before theorem defined
\hook_gput_code:nnn { begindocument/before } { keytheorems }
- { \keythms_listof_show:n { #1 } }
+ {
+ \prop_map_inline:Nn \g__keythms_thmnames_prop
+ { \__keythms_listof_ignore_aux:n { ##1 } }
+ }
},
- onlynamed .code:n =
+ 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,
+ no-chapter-skip .initial:n = false,
+ no-continues .bool_set:N = \l__keythms_listof_nocont_bool,
+ no-continues .initial:n = false,
+ no-title .bool_set:N = \l__keythms_listof_notitle_bool,
+ no-title .initial:n = false,
+ no-toc .bool_set:N = \l__keythms_listof_notoc_bool,
+ 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) },
+ numwidth .dim_set:N = \l__keythms_listof_numwidth_dim,
+ numwidth .initial:n = 2.3em,
+ onlynamed .code:n =
{
\hook_gput_code:nnn { begindocument/before } { keytheorems }
{ \keythms_listof_onlynamed:n { #1 } }
},
- onlynamed .default:n = \q_no_value,
- onlynumbered .code:n =
+ onlynamed .default:n = \q_no_value,
+ onlynumbered .code:n =
{
\hook_gput_code:nnn { begindocument/before } { keytheorems }
{ \keythms_listof_onlynumbered:n { #1 } }
},
- onlynumbered .default:n = \q_no_value,
- ignoreall .code:n =
- {
- \hook_gput_code:nnn { begindocument/before } { keytheorems } % in case called before theorem defined
- {
- \prop_map_inline:Nn \g__keythms_thmnames_prop
- { \__keythms_listof_ignore_aux:n { ##1 } }
- }
- },
- showall .code:n =
- {
- \hook_gput_code:nnn { begindocument/before } { keytheorems } % in case called before theorem defined
- {
- \prop_map_inline:Nn \g__keythms_thmnames_prop
- { \__keythms_listof_show_aux:n { ##1 } }
- }
- },
- title .tl_set:N = \l__keythms_listof_title_tl,
- title .initial:n = \GetTranslation{keythms_listof_title},
- swapnumber .bool_set:N = \l__keythms_listof_swapnumber_bool,
- swapnumber .initial:n = false,
- title-code .cs_set:Np = \__keythms_listof_titlecmd:n #1,
- no-title .bool_set:N = \l__keythms_listof_notitle_bool,
- no-title .initial:n = false,
- print-body .code:n =
+ onlynumbered .default:n = \q_no_value,
+ print-body .code:n =
{
\cs_set_protected:Nn \keythms_listof_listcmd:nnnnnnn
{
@@ -1495,43 +1481,53 @@
{##1}{##2}{##5}{##6}{##7}
}
}
- \cs_set_eq:NN \KeyThmsContentsLine \use_none:n
- % ^ I assume we want this?
- \cs_set_eq:NN \KeyThmsAddvspace \use_none:n
},
- note-code .cs_set:Np = \__keythms_listof_notecmd:n #1,
- note-code .initial:n = { ~ (#1) },
- no-continues .bool_set:N = \l__keythms_listof_nocont_bool,
- no-continues .initial:n = false,
- no-chapter-skip .bool_set:N = \l__keythms_listof_nochapskip_bool,
- no-chapter-skip .initial:n = false,
- chapter-skip-length .dim_set:N = \keythms@listof@chaptervspace@dim,
- chapter-skip-length .initial:n = 10pt,
- no-toc .bool_set:N = \l__keythms_listof_notoc_bool,
- no-toc .initial:n = false, % false does not mean "to-toc" for standard classes
+ seq .code:n =
+ {
+ \hook_gput_code:nnn { begindocument/before } { keytheorems }
+ { \keythms_listof_showseq:n { #1 } }
+ },
+ show .code:n =
+ {
+ \hook_gput_code:nnn { begindocument/before } { keytheorems }
+ { \keythms_listof_show:n { #1 } }
+ },
+ showall .code:n =
+ { % in case called before theorem defined
+ \hook_gput_code:nnn { begindocument/before } { keytheorems }
+ {
+ \prop_map_inline:Nn \g__keythms_thmnames_prop
+ { \__keythms_listof_show_aux:n { ##1 } }
+ }
+ },
+ swapnumber .bool_set:N = \l__keythms_listof_swapnumber_bool,
+ swapnumber .initial:n = false,
+ title .tl_set:N = \l__keythms_listof_title_tl,
+ title .initial:n = \GetTranslation{keythms_listof_title},
+ title-code .cs_set:Np = \__keythms_listof_titlecmd:n #1,
}
-\hook_gput_code:nnn { begindocument } { . } % redefine these keys at begindocument
- {
+\hook_gput_code:nnn { begindocument } { . }
+ { % redefine these keys at begindocument
\keys_define:nn { keytheorems/listof }
{
- ignore .code:n = \keythms_listof_ignore:n { #1 },
- show .code:n = \keythms_listof_show:n { #1 },
- onlynamed .code:n = \keythms_listof_onlynamed:n { #1 },
- onlynamed .default:n = \q_no_value,
- onlynumbered .code:n = \keythms_listof_onlynumbered:n { #1 },
- onlynumbered .default:n = \q_no_value,
- ignoreall .code:n =
+ ignore .code:n = \keythms_listof_ignore:n { #1 },
+ ignoreall .code:n =
{
\prop_map_inline:Nn \g__keythms_thmnames_prop
{ \__keythms_listof_ignore_aux:n { ##1 } }
},
- showall .code:n =
+ onlynamed .code:n = \keythms_listof_onlynamed:n { #1 },
+ onlynamed .default:n = \q_no_value,
+ onlynumbered .code:n = \keythms_listof_onlynumbered:n { #1 },
+ onlynumbered .default:n = \q_no_value,
+ seq .code:n = \keythms_listof_showseq:n { #1 },
+ show .code:n = \keythms_listof_show:n { #1 },
+ showall .code:n =
{
\prop_map_inline:Nn \g__keythms_thmnames_prop
{ \__keythms_listof_show_aux:n { ##1 } }
},
- seq .code:n = \keythms_listof_showseq:n { #1 },
}
}
@@ -1640,18 +1636,14 @@
}
}
-% Seems unnecessary to repeat all this for reading the keyvals from seq.
+% Seems unnecessary to repeat all this for reading the keyvals from file.
% In thmtools they just hook the "thmitem" definition into the theorem declaration.
%% NOTE ON ABOVE: this gives more flexibility to define different kinds of lists.
%% See acro.sty for template idea.
\keys_define:nn { keytheorems/listofheading }
{
- note .tl_set:N = \l__keythms_listofheading_note_tl,
- name .meta:n = { note = #1 },
- short-note .tl_set:N = \l__keythms_listofheading_shortnote_tl,
- short-name .meta:n = { short-note = #1 },
- continues .tl_set:N = \l__keythms_listofheading_contlabel_tl,
- continues* .code:n =
+ continues .tl_set:N = \l__keythms_listofheading_contlabel_tl,
+ continues* .code:n =
{
\keys_set:nn { keytheorems/listofheading } { continues = #1 }
\protected@edef \l__keythms_tmpa_tl { \__keythms_getrecordednote:n{#1} }
@@ -1661,16 +1653,21 @@
{ note = \l__keythms_tmpa_tl }
}
},
- seq .tl_set:N = \l__keythms_listofheading_seq_tl,
- store* .code:n = \bool_set_true:N \l__keythms_listofheading_storereversed_bool,
- restate* .meta:n = { store*=#1 },
+ name .meta:n = { note = #1 },
+ note .tl_set:N = \l__keythms_listofheading_note_tl,
+ restate* .meta:n = { store*=#1 },
restate-keys .clist_set:N = \l__keythms_listofheading_restatekeys_clist,
- unknown .code:n = { } % do nothing with unknown keys
- % ^ this is OK because we have total control over possible keys; if invalid
- % key is given to theorem then an error will be raised there
+ seq .tl_set:N = \l__keythms_listofheading_seq_tl,
+ short-note .tl_set:N = \l__keythms_listofheading_shortnote_tl,
+ short-name .meta:n = { short-note = #1 },
+ store* .code:n =
+ {
+ \bool_set_true:N \l__keythms_listofheading_storereversed_bool
+ },
+ unknown .code:n = { } % do nothing with unknown keys
}
-\cs_new:Npn \__keythms_listof_printheading:
+\cs_new:Npn \__keythms_listof_printnote:
{
\tl_if_empty:NTF \l__keythms_listofheading_shortnote_tl
{
@@ -1682,19 +1679,14 @@
}
}
-\cs_new:Npn \__keythms_listof_default_listcmd:nnnnnnn #1#2#3#4#5#6#7
- {
+\cs_new:Npn \keythms_listof_listcmd:nnnnnnn #1#2#3#4#5#6#7
+ { % #1=name, #2=number, #3=Href, #4=page, #5=restate counters, #6=keys, #7=body
\contentsline{ #1 }
{
- \bool_if:NTF \l__keythms_listof_swapnumber_bool
- {
- \prop_item:Nn \g__keythms_thmnames_prop { #1 } ~ #2
- }
- {
- \numberline{ #2 }
- \prop_item:Nn \g__keythms_thmnames_prop { #1 }
- }
- \__keythms_listof_printheading:
+ \__keythms_listof_misdirect:nnn
+ { \prop_item:Nn \g__keythms_thmnames_prop { #1 } }
+ { #2 }
+ { \__keythms_listof_printnote: }
}
{ #4 }{ #3 }
}
@@ -1728,10 +1720,6 @@
\group_end:
}
-% set default listcmd
-\cs_new_eq:NN \keythms_listof_listcmd:nnnnnnn
- \__keythms_listof_default_listcmd:nnnnnnn
-
\cs_if_exist:NTF \chapter
{ \cs_set_protected:Npn \__keythms_listof_titlecmd:n #1 { \chapter*{#1} } }
{ \cs_set_protected:Npn \__keythms_listof_titlecmd:n #1 { \section*{#1} } }
@@ -1748,9 +1736,10 @@
\bool_gset_true:N \g__keythms_listof_writefile_bool
\group_begin:
\keys_set:nn { keytheorems/listof } { #1 }
- \bool_if:NT \l__keythms_listof_nochapskip_bool
+ \cs_set_protected:Npn \KeyThmsContentsLine ##1 { ##1 }
+ \bool_if:NF \l__keythms_listof_nochapskip_bool
{
- \cs_set_eq:NN \KeyThmsAddvspace \use_none:n
+ \cs_set_eq:NN \KeyThmsAddvspace \addvspace
}
\bool_if:NF \l__keythms_listof_notitle_bool
{
@@ -1759,6 +1748,10 @@
{ \MakeUppercase \l__keythms_listof_title_tl }
{ \MakeUppercase \l__keythms_listof_title_tl }
}
+ \bool_if:NT \l__keythms_listof_swapnumber_bool
+ {
+ \cs_set:Npn \__keythms_listof_misdirect:nnn ##1##2##3 { ##1 ~ ##2##3 }
+ }
\legacy_if_set_false:n { @filesw }
\@starttoc{ thlist }
\group_end:
@@ -1787,7 +1780,7 @@
}
% chaptervspacehack (code translated from thmtools)
-\cs_new_eq:NN \KeyThmsAddvspace \addvspace
+\cs_new_protected:Npn \KeyThmsAddvspace #1 { } % initially no-op, redefined where needed
\int_new:N \g_keythms_listof_prevchapter_int
\int_gset:Nn \g_keythms_listof_prevchapter_int { 1 }
% ^ if this is zero, bad things happen if title-code is changed; anyways don't
@@ -1804,7 +1797,7 @@
{
\addtocontents{ thlist }
{
- \protect\KeyThmsAddvspace
+ \KeyThmsAddvspace
{ \keythms@listof@chaptervspace@dim }
}
\int_gset:Nn \g_keythms_listof_prevchapter_int { \value{chapter} }
@@ -1848,39 +1841,32 @@
\keys_define:nn { keytheorems }
{
- restate-counters .code:n =
- {
- \clist_map_inline:nn { #1 }
- { \tl_new:c { l_keythms_restate_current_##1_tl } }
- \clist_gput_right:Nn \g__keythms_restatecounters_clist { #1 }
- },
- restate-counters .initial:n = equation,
- continues-code .cs_set:Np = \__keythms_thmuse_continues:n #1,
- continues-code .initial:n =
+ auto-translate .bool_gset:N = \g__keythms_autotranslate_bool,
+ auto-translate .initial:n = true,
+ continues-code .cs_set:Np = \__keythms_thmuse_continues:n #1,
+ continues-code .initial:n =
{ % not sure how best to handle this translation
\GetTranslation{keythms_continues}\pageref{#1}
},
+ overload .code:n = \__keythms_overload_code:,
+ overload .value_forbidden:n = true,
+ overload .usage:n = preamble,
qed-symbol .cs_set_protected:Np = \qedsymbol,
- overload .code:n = \__keythms_overload_code:,
- overload .value_forbidden:n = true,
- overload .usage:n = preamble,
- thmtools-compat .code:n =
- { % prevent loading the code again if key called twice
- \bool_if:NF \g__keythms_thmtoolscompat_bool
- { \__keythms_thmtoolscompat_code: }
+ restate-counters .code:n =
+ {
+ \clist_map_inline:nn { #1 }
+ { \tl_new:c { l_keythms_restate_current_##1_tl } }
+ \clist_gput_right:Nn \g__keythms_restatecounters_clist { #1 }
},
- thmtools-compat .value_forbidden:n = true,
- thmtools-compat .usage:n = preamble,
- store-all .code:n = \__keythms_storeall_code:,
- store-all .value_forbidden:n = true,
- store-all .usage:n = preamble,
- auto-translate .bool_gset:N = \g__keythms_autotranslate_bool,
- auto-translate .initial:n = true,
- store-sets-label .code:n =
+ restate-counters .initial:n = equation,
+ store-all .code:n = \__keythms_storeall_code:,
+ store-all .value_forbidden:n = true,
+ store-all .usage:n = preamble,
+ store-sets-label .code:n =
{
\keys_define:nn { keytheorems/thmuse }
{
- store .code:n =
+ store .code:n =
{
\tl_set:Nn \l__keythms_thmuse_label_tl { ##1 }
\tl_set:Nn \l__keythms_thmuse_store_tl { ##1 }
@@ -1892,13 +1878,19 @@
},
}
},
+ thmtools-compat .code:n =
+ { % prevent loading the code again if key called twice
+ \bool_if:NF \g__keythms_thmtoolscompat_bool
+ { \__keythms_thmtoolscompat_code: }
+ },
+ thmtools-compat .value_forbidden:n = true,
+ thmtools-compat .usage:n = preamble,
}
\cs_generate_variant:Nn \__keythms_thmuse_continues:n { V }
-% \keytheoremset{<options>}
\NewDocumentCommand \keytheoremset { m }
- {
+ { % #1 = keys
\keys_set:nn { keytheorems } { #1 }
}
@@ -1993,6 +1985,12 @@
}
}
\ProvideDocumentCommand { \listoftheorems } { } { \listofkeytheorems }
+ \ProvideDocumentCommand { \listtheoremname } { }
+ { \GetTranslation{keythms_listof_title} }
+ \keys_define:nn { keytheorems/listof }
+ { % redefine since thmtools way is \renewcommand\listtheoremname{...}
+ title .initial:n = \listtheoremname
+ }
\ProvideDocumentCommand { \addtotheorempreheadhook } { O{allthms} m }
{
\addtotheoremhook [ ##1 ] { prehead } { ##2 }
@@ -2063,8 +2061,8 @@
},
cut .default:n = true,
nocut .meta:n = { cut=false },
- thickness .code:n = % could also add keys to clist with changed dimens; which is better?
- {
+ thickness .code:n =
+ { % could also add keys to clist with changed dimens; which is better?
\hook_gput_code:nnn { keytheorems/\l__keythms_thm_envname_tl/prehead }
{ keythms_tcbox }
{ \dim_set:Nn \l_keythms_tcbthmbox_thickness_dim { ##1 } }
@@ -2343,8 +2341,8 @@
{
\keys_define:nn { keytheorems/listof } % adjust to AMS classes
{
- numwidth .initial:n = 1.5pc,
indent .initial:n = 0pt,
+ numwidth .initial:n = 1.5pc,
title-code .code:n =
{ % warn but set titlecmd just in case
\msg_warning:nn { keytheorems } { title-code-with-AMS }
@@ -2356,9 +2354,10 @@
\bool_gset_true:N \g__keythms_listof_writefile_bool
\group_begin:
\keys_set:nn { keytheorems/listof } { ##1 }
- \bool_if:NT \l__keythms_listof_nochapskip_bool
+ \cs_set_protected:Npn \KeyThmsContentsLine ####1 { ####1 }
+ \bool_if:NF \l__keythms_listof_nochapskip_bool
{
- \cs_set_eq:NN \KeyThmsAddvspace \use_none:n
+ \cs_set_eq:NN \KeyThmsAddvspace \addvspace
}
\legacy_if_set_false:n { @filesw }
\bool_if:NTF \l__keythms_listof_notitle_bool