From d59ef01933b3ea15ff69a9202d98788a3e3841bf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Maximilian=20Ke=C3=9Fler?= <git@maximilian-kessler.de>
Date: Mon, 31 Jan 2022 20:11:37 +0100
Subject: [PATCH] write groupthm version of theorem declaration to aux file

---
 src/environments/groupthm/groupthm.dtx | 25 +++++--------------------
 1 file changed, 5 insertions(+), 20 deletions(-)

diff --git a/src/environments/groupthm/groupthm.dtx b/src/environments/groupthm/groupthm.dtx
index 14b8f09..daf2f59 100644
--- a/src/environments/groupthm/groupthm.dtx
+++ b/src/environments/groupthm/groupthm.dtx
@@ -855,9 +855,11 @@
       {
         \hook_gput_code:nnn { enddocument / afterlastpage } { groupthm }
           {
-           \iow_now:cn { @auxout }
+           \iow_now:cx { @auxout }
              {
-               \declaretheorem [ #1 ] { #2 }
+               \token_to_str:N \ExplSyntaxOn
+               \exp_not:N \@@_thmtools_declare_theorem:nn { #1 } { #2 }
+               \token_to_str:N \ExplSyntaxOff
              }
            }
       }
@@ -2681,34 +2683,17 @@
         {
           \hook_use_once:n { @@ / define lazy }
         }
-        {
-        }
     }
 %    \end{macrocode}  
 % 
 %
-% \begin{macro}{\@@_fake_declare_theorem:w}
-%    \begin{syntax}
-%       
-%    \end{syntax}
-%		 
-%     This is a fake version of the \cs{declaretheorem} macro
-%     that accepts the arguments but does nothing.
-%
-%    \begin{macrocode}
-\NewDocumentCommand { \@@_fake_declare_theorem:w }{ o m }
-  {
-    \relax
-  }
-%    \end{macrocode}
-% \end{macro}
 % 
 % 
 % 
 %    \begin{macrocode}
 \hook_gput_code:nnn { enddocument / afterlastpage } { groupthm }
   {
-    \let \declaretheorem \@@_fake_declare_theorem:w
+    \cs_set_eq:NN \@@_thmtools_declare_theorem:nn \use_none:nn
     \iow_now:cx { @auxout }
       {
         \token_to_str:N \ExplSyntaxOn