muzimuzhi / thmtools

New home for LaTeX package bundle thmtools
LaTeX Project Public License v1.3c
16 stars 3 forks source link

`\thmt@autoreffix` should do restoration globally #27

Closed muzimuzhi closed 2 years ago

muzimuzhi commented 2 years ago

Description

Since both \@counteralias and cleveref's \@ynthm (when amsthm is loaded, see lines 2986--3024, especially line 3013) set \the<envname> globally, \thmt@autoreffix should also restore \the<envname> globally as well.

The difference is not sensible until package create-theorem uses \newtheorem in a group. Then the restoration in \thmt@autoreffix is cancelled after group.

Example and analysis

In example taken from https://tex.stackexchange.com/q/646129,

\documentclass{article}
\usepackage{amsthm}
\usepackage{thmtools}
\usepackage{create-theorem}

\CreateTheorem { theorem } {}

\begin{document}
\begin{theorem}
    Text.
\end{theorem}
\end{document}

Proposal

diff --git a/source/thm-autoref.dtx b/source/thm-autoref.dtx
index cf84463..850d171 100644
--- a/source/thm-autoref.dtx
+++ b/source/thm-autoref.dtx
@@ -33,7 +33,7 @@
   \ifthmt@hassibling
     \@counteralias{\thmt@envname}{\thmt@sibling}%
     \@xa\def\@xa\thmt@autoreffix\@xa{%
-      \@xa\let\csname the\thmt@envname\@xa\endcsname
+      \@xa\global\@xa\let\csname the\thmt@envname\@xa\endcsname
         \csname the\thmt@sibling\endcsname
       \def\thmt@autoreffix{}%
     }%