summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/keytheorems/keytheorems.sty
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2024-09-17 19:55:16 +0000
committerKarl Berry <karl@freefriends.org>2024-09-17 19:55:16 +0000
commit20121128c321ffa90b9eec1e202acda01550a716 (patch)
tree29c72d3f7f890c9311ba6ab2640a593a94dcbd91 /Master/texmf-dist/tex/latex/keytheorems/keytheorems.sty
parent3ac84ad79b7efd8cc2384769d19890215ab07228 (diff)
keytheorems (17sep24)
git-svn-id: svn://tug.org/texlive/trunk@72310 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.sty306
1 files changed, 114 insertions, 192 deletions
diff --git a/Master/texmf-dist/tex/latex/keytheorems/keytheorems.sty b/Master/texmf-dist/tex/latex/keytheorems/keytheorems.sty
index 540a2ca800b..28c485083e9 100644
--- a/Master/texmf-dist/tex/latex/keytheorems/keytheorems.sty
+++ b/Master/texmf-dist/tex/latex/keytheorems/keytheorems.sty
@@ -1,5 +1,8 @@
+% 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
\NeedsTeXFormat{LaTeX2e}[2023-06-01]
-\ProvidesExplPackage{keytheorems}{2024-09-09}{0.1.1}{l3keys interface to amsthm}
+\ProvidesExplPackage{keytheorems}{2024-09-16}{0.1.2}{l3keys interface to amsthm}
\IfFormatAtLeastTF { 2024-06-01 } { }
{
@@ -10,6 +13,8 @@
\cs_generate_variant:Nn \tl_put_right:Nn { Ne }
\ProvideDocumentCommand \IfPackageLoadedT { m m }
{ \IfPackageLoadedTF{#1}{#2}{ } }
+ \ProvideDocumentCommand \IfClassLoadedT { m m }
+ { \IfClassLoadedTF{#1}{#2}{ } }
}
\RequirePackage{aliascnt} % for sibling theorems
\RequirePackage{amsthm}
@@ -65,6 +70,10 @@
Theorem~style~'#1'~already~defined.~
Use~\protect\renewkeytheoremstyle\space instead.
}
+\msg_new:nnn { keytheorems } { title-code-with-AMS }
+ {
+ The~'title-code'~key~has~no~effect~with~an~AMS~class.
+ }
% Error if thmtools loaded since compilation hangs.
% If thmtools loaded after, produce warning.
@@ -201,19 +210,19 @@
spacebelow = 0.5\topsep,
},
% 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 },
- 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 },
- qed .code:n = \keythms_thmstyle_savethmkey_optval:n { #1 },
- tcolorbox .code:n = \keythms_thmstyle_savethmkey_optval:n { #1 },
+ 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 },
+ 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 },
+ qed .code:n = \keythms_thmstyle_savethmkey_optval:n { #1 },
+ tcolorbox .code:n = \keythms_thmstyle_savethmkey_optval:n { #1 },
tcolorbox-no-titlebar .code:n = \keythms_thmstyle_savethmkey_optval:n { #1 },
}
@@ -252,21 +261,14 @@
}
}
-%%% <SURELY A BETTER WAY>
-\cs_new_protected:Npn \__keythms_thmstyle_definekeylist:nn #1#2
- {
- \clist_const:cn { c__keythms_thmstyle_defaultkeys_ #1 _clist } { #2 }
- }
-
-\cs_new_protected:Npn \__keythms_thmstyle_setdefaultkeys:n #1
+\cs_new_protected:Npn \keythms_thmstyle_setdefaultkeys:n #1
{
- \keys_precompile:nvN { keytheorems/thmstyle }
- { c__keythms_thmstyle_defaultkeys_ #1 _clist }
+ \keys_precompile:nnN { keytheorems/thmstyle }
+ { #1 }
\l__keythms_thmstyle_defaultkeys_tl
}
-
-\__keythms_thmstyle_definekeylist:nn { default }
- {
+\keythms_thmstyle_setdefaultkeys:n
+ { % support files may overwrite these defaults
spaceabove = \topsep,
spacebelow = \topsep,
bodyfont = \itshape,
@@ -278,105 +280,6 @@
notebraces = {(}{)},
headstyle = \keythms_thmstyle_headcmd_default:nnn{#1}{#2}{#3},
}
-\__keythms_thmstyle_definekeylist:nn { amsart }
- {
- spaceabove = .5\baselineskip plus .2\baselineskip minus .2\baselineskip,
- spacebelow = .5\baselineskip plus .2\baselineskip minus .2\baselineskip,
- bodyfont = \itshape,
- headindent = 0pt,
- headfont = \bfseries,
- headpunct = {.},
- postheadspace = 5pt plus 1pt minus 1pt,
- notefont = \fontseries\mddefault\upshape,
- notebraces = {(}{)},
- headstyle = \keythms_thmstyle_headcmd_default:nnn{#1}{#2}{#3},
- }
-\__keythms_thmstyle_definekeylist:nn { amsproc }
- {
- spaceabove = .5\baselineskip plus .2\baselineskip minus .2\baselineskip,
- spacebelow = .5\baselineskip plus .2\baselineskip minus .2\baselineskip,
- bodyfont = \itshape,
- headindent = \parindent,
- headfont = \scshape,
- headpunct = {.},
- postheadspace = 5pt plus 1pt minus 1pt,
- notefont = \fontseries\mddefault\upshape,
- notebraces = {(}{)},
- headstyle = \keythms_thmstyle_headcmd_default:nnn{#1}{#2}{#3},
- }
-\__keythms_thmstyle_definekeylist:nn { amsbook }
- {
- spaceabove = .5\baselineskip plus .2\baselineskip minus .2\baselineskip,
- spacebelow = .5\baselineskip plus .2\baselineskip minus .2\baselineskip,
- bodyfont = \itshape,
- headindent = \parindent,
- headfont = \scshape,
- headpunct = {.},
- postheadspace = 5pt plus 1pt minus 1pt,
- notefont = \fontseries\mddefault\upshape,
- notebraces = {(}{)},
- headstyle = \keythms_thmstyle_headcmd_default:nnn{#1}{#2}{#3},
- }
-\__keythms_thmstyle_definekeylist:nn { acmart }
- {
- spaceabove = .5\baselineskip plus .2\baselineskip minus .2\baselineskip,
- spacebelow = .5\baselineskip plus .2\baselineskip minus .2\baselineskip,
- bodyfont = \@acmplainbodyfont,
- headindent = \@acmplainindent,
- headfont = \@acmplainheadfont,
- headpunct = {.},
- postheadspace = .5em,
- notefont = \@acmplainnotefont,
- notebraces = {(}{)},
- headstyle = \keythms_thmstyle_headcmd_default:nnn{#1}{#2}{#3},
- }
-
-\IfClassLoadedTF { amsart }
- {
- \IfClassLoadedTF { acmart } % acmart loads amsart
- {
- \__keythms_thmstyle_setdefaultkeys:n { acmart }
- }
- {
- \__keythms_thmstyle_setdefaultkeys:n { amsart }
- \keys_define:nn { keytheorems/thmstyle }
- {
- inherit-style / remark .meta:n =
- {
- headfont = \itshape,
- bodyfont = \normalfont,
- }
- }
- }
- }
- {
- \IfClassLoadedTF { amsbook }
- {
- \__keythms_thmstyle_setdefaultkeys:n { amsbook }
- \keys_define:nn { keytheorems/thmstyle }
- {
- inherit-style / remark .meta:n =
- {
- bodyfont = \normalfont,
- },
- }
- }
- {
- \IfClassLoadedTF { amsproc }
- {
- \__keythms_thmstyle_setdefaultkeys:n { amsproc }
- \keys_define:nn { keytheorems/thmstyle }
- {
- inherit-style / remark .meta:n =
- {
- bodyfont = \normalfont,
- },
- }
- }
- { \__keythms_thmstyle_setdefaultkeys:n { default } }
- }
- }
-%%% </SURELY A BETTER WAY>
\NewDocumentCommand \newkeytheoremstyle { m m }
{
@@ -730,6 +633,8 @@
\exp_args:Nno \__keythms_thm_tcboxcode:nn { #1 }
{ \l__keythms_thm_tcbkeys_tl }
}
+ % Set up list-of definition
+ \cs_set_eq:cN { l@ #1 } \keythms_listof_tocline:
% Set default list-of display command
\__keythms_listof_show_aux:n { #1 }
% Set theorem style back to original state if needed
@@ -1319,6 +1224,8 @@
{
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 =
{
\hook_gput_code:nnn { begindocument/before } { keytheorems }
@@ -1386,6 +1293,8 @@
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
}
\hook_gput_code:nnn { begindocument } { . } % redefine these keys at begindocument
@@ -1605,79 +1514,32 @@
{ \cs_set_protected:Npn \__keythms_listof_titlecmd:n #1 { \chapter*{#1} } }
{ \cs_set_protected:Npn \__keythms_listof_titlecmd:n #1 { \section*{#1} } }
-\hook_gput_code:nnn { begindocument } { . }
- { % try to detect ams classes
- \keythms_if_amsclass:TF
- {
- \prop_map_inline:Nn \g__keythms_thmnames_prop
- {
- \cs_set:cpn { l@ #1 }
- {
- \@tocline{ 0 }{ 3pt plus 2pt }{ 0pt }
- { \l__keythms_listof_numwidth_dim }{ }
- }
- }
- }
- {
- \prop_map_inline:Nn \g__keythms_thmnames_prop
- {
- \cs_set:cpn { l@ #1 }
- {
- \@dottedtocline{ 1 }{ 1.5em }
- { \l__keythms_listof_numwidth_dim }
- }
- }
- }
- }
+\cs_new_protected:Npn \__keythms_listof_default_tocline:
+ {
+ \@dottedtocline{ 1 }{ \l__keythms_listof_indent_dim }
+ { \l__keythms_listof_numwidth_dim }
+ }
+\cs_new_eq:NN \keythms_listof_tocline: \__keythms_listof_default_tocline:
-\keythms_if_amsclass:TF
+\NewDocumentCommand \listofkeytheorems { O{} }
{
- \keys_define:nn { keytheorems/listof } % adjust to class
+ \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
{
- numwidth .initial:n = 1.5pc,
- }
- \NewDocumentCommand \listofkeytheorems { O{} }
- { % title command not customizable here
- \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_eq:NN \KeyThmsAddvspace \use_none:n
- }
- \legacy_if_set_false:n { @filesw }
- \bool_if:NTF \l__keythms_listof_notitle_bool
- {
- \@starttoc{ thlist }{ }
- }
- { % ams classes don't expand title enough
- \protected@edef \l__keythms_tmpa_tl { \l__keythms_listof_title_tl }
- \@starttoc{ thlist }{ \l__keythms_tmpa_tl }
- }
- \group_end:
+ \cs_set_eq:NN \KeyThmsAddvspace \use_none:n
}
- }
- {
- \NewDocumentCommand \listofkeytheorems { O{} }
+ \bool_if:NF \l__keythms_listof_notitle_bool
{
- \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_eq:NN \KeyThmsAddvspace \use_none:n
- }
- \bool_if:NF \l__keythms_listof_notitle_bool
- {
- \__keythms_listof_titlecmd:n { \l__keythms_listof_title_tl }
- \@mkboth % QUESTION: should this go in titlecmd ?
- { \MakeUppercase \l__keythms_listof_title_tl }
- { \MakeUppercase \l__keythms_listof_title_tl }
- }
- \legacy_if_set_false:n { @filesw }
- \@starttoc{ thlist }
- \group_end:
+ \__keythms_listof_titlecmd:n { \l__keythms_listof_title_tl }
+ \@mkboth % QUESTION: should this go in titlecmd ?
+ { \MakeUppercase \l__keythms_listof_title_tl }
+ { \MakeUppercase \l__keythms_listof_title_tl }
}
+ \legacy_if_set_false:n { @filesw }
+ \@starttoc{ thlist }
+ \group_end:
}
% ^ unlike thmtools we don't use the class's style of \listoffigures because
% we want control over title-code, no-title, etc. But this means we have to guess
@@ -2174,6 +2036,8 @@
\ProvideTranslation { French } { keythms_continues } { suite~de~la~p.\, }
\ProvideTranslation { German } { keythms_listof_title } { Liste~der~Theoreme }
\ProvideTranslation { German } { keythms_continues } { weiter~von~Seite~ }
+ \ProvideTranslation { Italian } { keythms_listof_title } { Elenco~dei~teoremi }
+ \ProvideTranslation { Italian } { keythms_continues } { continua~da~p.\, }
\ProvideTranslation { Spanish } { keythms_listof_title } { Lista~de~teoremas }
\ProvideTranslation { Spanish } { keythms_continues } { continĂșa~de~la~p.\, }
}
@@ -2181,4 +2045,62 @@
\ProcessKeyOptions[keytheorems]
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%% Support for non-default classes %%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\cs_new_protected:Npn \__keythms_support_AMSshared_code:
+ {
+ \keys_define:nn { keytheorems/listof } % adjust to AMS classes
+ {
+ numwidth .initial:n = 1.5pc,
+ indent .initial:n = 0pt,
+ title-code .code:n =
+ { % warn but set titlecmd just in case
+ \msg_warning:nn { keytheorems } { title-code-with-AMS }
+ \cs_set_protected:Npn \__keythms_listof_titlecmd:n ####1 { ##1 }
+ },
+ }
+ \RenewDocumentCommand \listofkeytheorems { O{} }
+ { % title command not customizable here
+ \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_eq:NN \KeyThmsAddvspace \use_none:n
+ }
+ \legacy_if_set_false:n { @filesw }
+ \bool_if:NTF \l__keythms_listof_notitle_bool
+ { % hacky!
+ \cs_set_eq:NN \@startsection \use_none:nnnnnnn
+ \@starttoc{ thlist }{ }
+ }
+ { % ams classes don't expand title enough
+ \protected@edef \l__keythms_tmpa_tl { \l__keythms_listof_title_tl }
+ \bool_if:NT \l__keythms_listof_notoc_bool
+ { \cs_set_eq:NN \addcontentsline \use_none:nnn } % hacky!
+ \@starttoc{ thlist }{ \l__keythms_tmpa_tl }
+ }
+ \group_end:
+ }
+ \cs_new:Npn \__keythms_listof_ams_tocline:
+ {
+ \@tocline{ 0 }{ 3pt plus 2pt }{ \l__keythms_listof_indent_dim }
+ { \l__keythms_listof_numwidth_dim }{ }
+ }
+ \cs_set_eq:NN \keythms_listof_tocline: \__keythms_listof_ams_tocline:
+ }
+
+\cs_new_protected:Npn \keythms_support_check:n #1
+ {
+ \IfClassLoadedT { #1 } { \file_input:n { class-support/keythms-#1-support } }
+ }
+
+% acmart defaults also handled in amsart support file
+\keythms_support_check:n { amsart }
+\keythms_support_check:n { amsbook }
+\keythms_support_check:n { amsproc }
+\keythms_support_check:n { memoir }
+
\file_input_stop: \ No newline at end of file