diff --git a/README.md b/README.md index 4c9c80f..9180685 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # keytheorems -An experimental LaTeX package to use [`amsthm`](https://www.ctan.org/pkg/amsthm) +A LaTeX package to use [`amsthm`](https://www.ctan.org/pkg/amsthm) with a key-value interface. Meant to emulate most of the functionality of [`thmtools`](https://www.ctan.org/pkg/thmtools) but written in expl3. The goal was just an exercise in using expl3, but if you find a bug feel free to open an issue or PR. @@ -65,8 +65,7 @@ More of a reference document than documentation. ## Differences with thmtools -Most of the code is a direct translation from thmtools -but a few things are changed: +Some of the code is a direct translation from thmtools but a few things are changed: - The only backend supported is amsthm, and it is loaded by the package. As I understand it, [`ntheorem`](https://www.ctan.org/pkg/ntheorem) has quite a few bugs and no active development, and if you're just using the kernel `\newtheorem` then you don't need a package like this. diff --git a/doc/keytheorems-doc.pdf b/doc/keytheorems-doc.pdf index 6871b07..d40d9b5 100644 Binary files a/doc/keytheorems-doc.pdf and b/doc/keytheorems-doc.pdf differ diff --git a/doc/keytheorems-doc.tex b/doc/keytheorems-doc.tex index 0e75424..349cd6c 100644 --- a/doc/keytheorems-doc.tex +++ b/doc/keytheorems-doc.tex @@ -18,7 +18,7 @@ \usepackage{cleveref} \usepackage{amssymb} -\def\version{0.0.8$\delta$} +\def\version{0.1.0} \title{% \pkg{keytheorems} package \\[1ex] @@ -128,7 +128,7 @@ \maketitle \begin{abstract} -An experimental \pkg{expl3}-implementation of a key-value interface to \pkg{amsthm}, implementing most of the functionality provided by \pkg{thmtools}. Likely contains many bugs; use at your own risk! +An \pkg{expl3}-implementation of a key-value interface to \pkg{amsthm}, implementing most of the functionality provided by \pkg{thmtools}. Several issues encountered with \pkg{thmtools} are avoided and a few new features are added (see the README). \end{abstract} \tableofcontents diff --git a/keytheorems.sty b/keytheorems.sty index de898bf..2a7240a 100644 --- a/keytheorems.sty +++ b/keytheorems.sty @@ -1,5 +1,5 @@ \NeedsTeXFormat{LaTeX2e}[2024/06/01] -\ProvidesExplPackage{keytheorems}{2024-07-17}{0.0.9beta}{l3keys interface to amsthm} +\ProvidesExplPackage{keytheorems}{2024-09-04}{0.1.0}{l3keys interface to amsthm} %%% TESTING % \debug_on:n { all } @@ -133,12 +133,12 @@ \tl_set:Nn \l__keythms_thmstyle_lnotebrace_tl { #1 } \tl_set:Nn \l__keythms_thmstyle_rnotebrace_tl { #2 } } -\cs_new:Npn \keythms_thmstyle_savethmkey_reqval:n #1 +\cs_new_protected:Npn \keythms_thmstyle_savethmkey_reqval:n #1 { \clist_put_right:No \l__keythms_thmstyle_savedkeys_clist { \l_keys_key_str = { #1 } } } -\cs_new:Npn \keythms_thmstyle_savethmkey_optval:n #1 +\cs_new_protected:Npn \keythms_thmstyle_savethmkey_optval:n #1 { \tl_if_empty:NTF \l_keys_value_tl { @@ -507,7 +507,7 @@ } % what below is unnecessary? I really don't understand this code. -\cs_new:Npn \__keythms_thm_storedeferredthmhead:n #1 +\cs_new_protected:Npn \__keythms_thm_storedeferredthmhead:n #1 { \if@inlabel \indent \par \fi % eject a section head if one is pending \if@nobreak @@ -736,7 +736,7 @@ % ^ don't like playing with hyperref internals... but don't see around % it because hyperref tries to add to para hook which doesn't work % when title set up the way we do it - \cs_set:Npn \thm@space@setup { \thm@preskip=0pt \thm@postskip=0pt } + \cs_set_protected:Npn \thm@space@setup { \thm@preskip=0pt \thm@postskip=0pt } % ^ to match tcolorbox defaults; shouldn't interfere with user styles } \hook_gset_rule:nnnn { keytheorems/#1/posthead } @@ -1028,7 +1028,7 @@ \cs_generate_variant:Nn \__keythms_orig_begin:nn { nV } \cs_new_protected:Npn \__keythms_orig_end:n #1 { \end{keythms_orig_#1} } -\cs_new:Npn \__keythms_thm_prehead_code:n #1 +\cs_new_protected:Npn \__keythms_thm_prehead_code:n #1 { % #1 = theorem name \tl_set:Nn \l__keythms_thmuse_envname_tl { #1 } \hook_use:n { keytheorems/#1/prehead } @@ -1036,7 +1036,7 @@ } %% this below has to be separate from prehead_code above since we need to add %% continues-code to note before retrieving it in \__keythms_withhooks_begin:nnV -\cs_new:Npn \__keythms_thm_prehead_continues_code:n #1 +\cs_new_protected:Npn \__keythms_thm_prehead_continues_code:n #1 { % #1 = theorem name \tl_if_empty:NF \l__keythms_thmuse_contlabel_tl { @@ -1053,7 +1053,7 @@ %\cs_set_eq:NN \setuniqmark \use_none:n % not the right fix } } -\cs_new:Npn \__keythms_thm_posthead_code:n #1 +\cs_new_protected:Npn \__keythms_thm_posthead_code:n #1 { % #1 = theorem name \hook_use:n { keytheorems/#1/posthead } \hook_use:n { keytheorems/allthms/posthead } @@ -1070,17 +1070,17 @@ \everypar{\setbox\z@\lastbox\everypar{}}% } } -\cs_new:Npn \__keythms_thm_prefoot_code:n #1 +\cs_new_protected:Npn \__keythms_thm_prefoot_code:n #1 { % #1 = theorem name \hook_use:n { keytheorems/allthms/prefoot } \hook_use:n { keytheorems/#1/prefoot } } -\cs_new:Npn \__keythms_thm_postfoot_code:n #1 +\cs_new_protected:Npn \__keythms_thm_postfoot_code:n #1 { % #1 = theorem name \hook_use:n { keytheorems/allthms/postfoot } \hook_use:n { keytheorems/#1/postfoot } } -\cs_new:Npn \__keythms_thm_addcontentsdata:nnnn #1#2#3#4 +\cs_new_protected:Npn \__keythms_thm_addcontentsdata:nnnn #1#2#3#4 { % #1 = theorem name, #2 = stored counters, #3 = keys, #4 = body \keythms_listof_chaptervspacehack: \iow_shipout:Ne \@auxout @@ -1097,7 +1097,7 @@ } } } -\cs_new:Npn \__keythms_thm_tempstorerestatedata:nnn #1#2#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 { @@ -1154,13 +1154,13 @@ \keys_set:nn { keytheorems/storeatbegin } { #6 } \tl_if_empty:NF \l__keythms_storeatbegin_store_tl { - \cs_new:cpn + \cs_new_protected:cpn { __keythms_getthm_ \l__keythms_storeatbegin_store_tl _theorem } { \__keythms_getthm_theorem:nnnnn {#1}{#2}{#5}{#6}{#7} } - \cs_new:cpn + \cs_new_protected:cpn { __keythms_getthm_ \l__keythms_storeatbegin_store_tl _body } { \__keythms_getthm_body:nn {#5}{#7} @@ -1352,7 +1352,7 @@ no-title .initial:n = false, print-body .code:n = { - \cs_set:Nn \keythms_listof_listcmd:nnnnnnn + \cs_set_protected:Nn \keythms_listof_listcmd:nnnnnnn { \tl_if_empty:nF { ##7 } { @@ -1560,7 +1560,7 @@ } % NOTE: We still need to do this setup for [print-body] so that onlynamed works -\cs_new:Npn \__keythms_listof_listcmd_setup:nn #1#2 +\cs_new_protected:Npn \__keythms_listof_listcmd_setup:nn #1#2 { % #1 = keys, #2 = list command \group_begin: \keys_set:nn { keytheorems/listofheading } { #1 } @@ -1588,8 +1588,8 @@ \__keythms_listof_default_listcmd:nnnnnnn \cs_if_exist:NTF \chapter - { \cs_set:Npn \__keythms_listof_titlecmd:n #1 { \chapter*{#1} } } - { \cs_set:Npn \__keythms_listof_titlecmd:n #1 { \section*{#1} } } + { \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 @@ -1694,12 +1694,12 @@ \int_gset:Nn \g_keythms_listof_prevchapter_int { 1 } % ^ if this is zero, bad things happen if title-code is changed; anyways don't % need addvspace at top -\cs_new:Npn \keythms_listof_chaptervspacehack: { } +\cs_new_protected:Npn \keythms_listof_chaptervspacehack: { } \cs_if_exist:cT { c@chapter } { \cs_if_eq:NNF \c@chapter \relax { - \cs_set:Npn \keythms_listof_chaptervspacehack: + \cs_set_protected:Npn \keythms_listof_chaptervspacehack: { \int_compare:nNnF { \value{chapter} } = { \g_keythms_listof_prevchapter_int } { @@ -1726,7 +1726,7 @@ \group_end: } -\cs_new:Npn \__keythms_Autoref_testreftype:w #1.#2\\ +\cs_new_protected:Npn \__keythms_Autoref_testreftype:w #1.#2\\ { \cs_if_exist:cTF { #1 Autorefname } { @@ -1814,7 +1814,7 @@ } { \end{##2} - \cs_new:cpn { ##3 } + \cs_new_protected:cpn { ##3 } { % make \foo and \foo* identical \peek_meaning_remove:NTF * { \use:c { __keythms_getthm_ ##3 _theorem } } diff --git a/tests/keytheorems-amsthmtest.pdf b/tests/keytheorems-amsthmtest.pdf index 47031bf..8d2af5c 100644 Binary files a/tests/keytheorems-amsthmtest.pdf and b/tests/keytheorems-amsthmtest.pdf differ diff --git a/tests/keytheorems-comptest.pdf b/tests/keytheorems-comptest.pdf index 463af04..797a112 100644 Binary files a/tests/keytheorems-comptest.pdf and b/tests/keytheorems-comptest.pdf differ diff --git a/tests/thmtools-comptest.pdf b/tests/thmtools-comptest.pdf index b48f8fe..e06f916 100644 Binary files a/tests/thmtools-comptest.pdf and b/tests/thmtools-comptest.pdf differ