Skip to content

Commit

Permalink
v0.1.0
Browse files Browse the repository at this point in the history
- add `_protected` in a few places; probably more needed
- remove "experimental"
  • Loading branch information
mbertucci47 committed Sep 5, 2024
1 parent 2429117 commit d43a653
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 27 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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.
Expand Down
Binary file modified doc/keytheorems-doc.pdf
Binary file not shown.
4 changes: 2 additions & 2 deletions doc/keytheorems-doc.tex
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
\usepackage{cleveref}
\usepackage{amssymb}

\def\version{0.0.8$\delta$}
\def\version{0.1.0}

\title{%
\pkg{keytheorems} package \\[1ex]
Expand Down Expand Up @@ -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
Expand Down
44 changes: 22 additions & 22 deletions keytheorems.sty
Original file line number Diff line number Diff line change
@@ -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 }
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 }
Expand Down Expand Up @@ -1028,15 +1028,15 @@
\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 }
\hook_use:n { keytheorems/allthms/prehead }
}
%% 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
{
Expand All @@ -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 }
Expand All @@ -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
Expand All @@ -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
{
Expand Down Expand Up @@ -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}
Expand Down Expand Up @@ -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 }
{
Expand Down Expand Up @@ -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 }
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 }
{
Expand All @@ -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 }
{
Expand Down Expand Up @@ -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 } }
Expand Down
Binary file modified tests/keytheorems-amsthmtest.pdf
Binary file not shown.
Binary file modified tests/keytheorems-comptest.pdf
Binary file not shown.
Binary file modified tests/thmtools-comptest.pdf
Binary file not shown.

0 comments on commit d43a653

Please sign in to comment.